Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gdtel-gztel-school-center
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴学德
gdtel-gztel-school-center
Commits
8548bcb6
Commit
8548bcb6
authored
Jan 28, 2021
by
陈浩建
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
宽带
parent
bc0de1ae
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
415 additions
and
17 deletions
+415
-17
apply-net/src/main/java/com/winsun/controller/DankuanController.java
+0
-0
apply-net/src/main/java/com/winsun/controller/RongHeController.java
+0
-0
apply-net/src/main/java/com/winsun/controller/codeManagerController.java
+25
-12
apply-net/src/main/resources/txtfiledetail.properties
+15
-0
common/src/main/java/com/winsun/bean/OrderView.java
+14
-2
common/src/main/java/com/winsun/bean/Product.java
+30
-1
common/src/main/java/com/winsun/bean/UniversityInfo.java
+28
-2
common/src/main/java/com/winsun/constant/Constant.java
+40
-0
common/src/main/java/com/winsun/mapper/HhrUserMapper.java
+16
-0
common/src/main/java/com/winsun/mapper/OrderViewMapper.java
+9
-0
common/src/main/java/com/winsun/mapper/ProductMapper.java
+15
-0
common/src/main/java/com/winsun/mapper/SchoolMapper.java
+6
-0
common/src/main/java/com/winsun/mapper/UniversityInfoMapper.java
+2
-0
common/src/main/java/com/winsun/utils/Base64ToImgUtils.java
+61
-0
common/src/main/java/com/winsun/utils/RandomUtil.java
+16
-0
common/src/main/java/com/winsun/utils/SignUtil.java
+138
-0
No files found.
apply-net/src/main/java/com/winsun/controller/DankuanController.java
View file @
8548bcb6
This diff is collapsed.
Click to expand it.
apply-net/src/main/java/com/winsun/controller/RongHeController.java
View file @
8548bcb6
This diff is collapsed.
Click to expand it.
apply-net/src/main/java/com/winsun/controller/codeManagerController.java
View file @
8548bcb6
...
...
@@ -3,15 +3,11 @@ package com.winsun.controller;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
import
com.winsun.auth.core.common.model.ResponseData
;
import
com.winsun.bean.KdPhone
;
import
com.winsun.bean.Order
;
import
com.winsun.bean.Regular
;
import
com.winsun.bean.XshInventory
;
import
com.winsun.mapper.KdPhoneMapper
;
import
com.winsun.mapper.OrderMapper
;
import
com.winsun.mapper.RegularMapper
;
import
com.winsun.mapper.XshInventoryMapper
;
import
com.winsun.bean.*
;
import
com.winsun.mapper.*
;
import
com.winsun.smsUtils.SendSmsAndMail
;
import
com.winsun.utils.MessageUtil
;
import
com.winsun.utils.MyBatisPlusUpdateUtils
;
import
com.winsun.utils.RandomUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -46,6 +42,8 @@ public class codeManagerController {
@Autowired
private
XshInventoryMapper
xshInventoryMapper
;
@Autowired
private
AuthCodeMapper
authCodeMapper
;
@Autowired
@Qualifier
(
"redisStringTemplate"
)
private
RedisTemplate
redisTemplate
;
...
...
@@ -65,10 +63,25 @@ public class codeManagerController {
wrapper2
.
eq
(
"business_number"
,
phone
);
List
<
Order
>
list1
=
orderMapper
.
selectList
(
wrapper2
);
if
(
list
.
size
()>
0
||
list1
.
size
()>
0
){
// 生成6位随机数
String
veCode
=
String
.
valueOf
((
int
)
((
RandomUtil
.
getSecrityRandom
()
*
9
+
1
)
*
100000
));
//MessageUtil.sent(packageUpgrade.getAccNbr(),"4","您获取的验证码为:"+s+",半小时内有效。");
redisTemplate
.
opsForValue
().
set
(
phone
,
veCode
,
240
,
TimeUnit
.
MINUTES
);
// 生成6位随机数
int
veCode
=
(
int
)
((
RandomUtil
.
getSecrityRandom
()
*
9
+
1
)
*
100000
);
// MessageUtil.sent(packageUpgrade.getAccNbr(),"4","您获取的验证码为:"+s+",半小时内有效。");
// 新框架短信验证码保存在Redis,但由于业务需要使用原来方式,存在数据库里
redisTemplate
.
opsForValue
().
set
(
phone
,
String
.
valueOf
(
veCode
),
240
,
TimeUnit
.
MINUTES
);
AuthCode
authCode
=
new
AuthCode
();
authCode
.
setId
(
phone
);
authCode
.
setUserAuthCode
(
veCode
);
Wrapper
<
AuthCode
>
authCodeWrapper
=
new
EntityWrapper
<>();
authCodeWrapper
.
eq
(
"id"
,
phone
);
Map
<
String
,
Object
>
map2
=
new
HashMap
<>();
map2
.
put
(
"user_authcode"
,
veCode
);
List
<
AuthCode
>
auth
=
authCodeMapper
.
queryAuthCode
(
phone
);
if
(
auth
.
size
()>
0
){
authCodeMapper
.
updateForSet
(
MyBatisPlusUpdateUtils
.
toUpdateSet
(
map2
),
authCodeWrapper
);
}
else
{
authCodeMapper
.
insert
(
authCode
);
}
SendSmsAndMail
.
sendSms
(
phone
,
veCode
+
""
,
"7"
);
log
.
info
(
"验证码:"
+
veCode
);
map
.
put
(
"code"
,
1
);
...
...
apply-net/src/main/resources/txtfiledetail.properties
0 → 100644
View file @
8548bcb6
#############################################################################
#ػFTP
#
ftp_host
=
127.0.0.1
ftp_port
=
21
ftp_username
=
root
ftp_password
=
qUDZj/w2Rus=
ftp_sys
=
E:/FTP
hhr_img
=
/datas/apps/web/tomcats/apache-tomcat-7.0.100-hhr/hhrphoto
#hhr_img=D:/a
sign_img
=
/datas/apps/web/tomcats/apache-tomcat-7.0.100-hhr/hhr-sign-img
#sign_img=D:/a
yrym_sign
=
rQXPSHvWvHasj17#5L70ux3KvlWNqoVQ
common/src/main/java/com/winsun/bean/OrderView.java
View file @
8548bcb6
...
...
@@ -55,11 +55,16 @@ public class OrderView implements Serializable {
@TableField
(
value
=
"orderDate"
)
private
Date
orderDate
;
/**
* 订单状态
*/
* 订单状态
*/
@TableField
(
value
=
"status"
)
private
String
status
;
/**
* 合伙人id
*/
@TableField
(
value
=
"hehuoren_id"
)
private
String
hehuorenId
;
/**
* 区域
*/
@TableField
(
value
=
"order_region"
)
...
...
@@ -149,5 +154,11 @@ public class OrderView implements Serializable {
*/
@TableField
(
value
=
"orderSeqTHD"
)
private
String
orderseqThd
;
/**
* 套餐下标
*/
@TableField
(
value
=
"set_meal_index"
)
private
String
setMealIndex
;
}
\ No newline at end of file
common/src/main/java/com/winsun/bean/Product.java
View file @
8548bcb6
package
com
.
winsun
.
bean
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableId
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.enums.IdType
;
...
...
@@ -25,110 +26,138 @@ public class Product implements Serializable {
/**
* 宽带标题
*/
@TableField
(
"product_title"
)
private
String
productTitle
;
/**
* 创建人
*/
@TableField
(
"product_creater"
)
private
String
productCreater
;
/**
* 最后更新时间
*/
@TableField
(
"product_last_update_time"
)
private
Date
productLastUpdateTime
;
/**
* 创建时间
*/
@TableField
(
"product_create_time"
)
private
Date
productCreateTime
;
/**
* 区域
*/
@TableField
(
"product_region"
)
private
String
productRegion
;
/**
*
*/
@TableField
(
"product_introduction_pic1"
)
private
String
productIntroductionPic1
;
/**
* 套餐及资费
*/
@TableField
(
"product_meal_price"
)
private
String
productMealPrice
;
/**
* 资费介绍
*/
@TableField
(
"product_set_meal_introduction"
)
private
String
productSetMealIntroduction
;
/**
* 了解产品
*/
@TableField
(
"product_introduction"
)
private
String
productIntroduction
;
/**
* 状态0正常,1下架
*/
private
String
productState
=
"0"
;
@TableField
(
"product_state"
)
private
String
productState
;
/**
* 适用学校
*/
@TableField
(
"product_university"
)
private
String
productUniversity
;
/**
* 标识
*/
@TableField
(
"identifying"
)
private
String
identifying
;
/**
* 融合资费介绍
*/
@TableField
(
"product_rf2"
)
private
String
productRf2
;
/**
* 小白卡套餐id
*/
@TableField
(
"product_school_abbreviated"
)
private
String
productSchoolAbbreviated
;
/**
* 资费
*/
@TableField
(
"product_price"
)
private
String
productPrice
;
/**
* 融合资费
*/
@TableField
(
"product_rh_Price"
)
private
String
productRhPrice
;
/**
* 宽带速率
*/
@TableField
(
"product_meal"
)
private
String
productMeal
;
/**
* 包年包月情况
*/
@TableField
(
"product_rate"
)
private
String
productRate
;
/**
* 融合包年包月情况
*/
@TableField
(
"product_rh_rate"
)
private
String
productRhRate
;
/**
* 资费正则Id
*/
@TableField
(
"product_introduction_pic2"
)
private
String
productIntroductionPic2
;
@TableField
(
"product_introduction_pic3"
)
private
String
productIntroductionPic3
;
@TableField
(
"product_introduction_pic4"
)
private
String
productIntroductionPic4
;
@TableField
(
"product_introduction_pic5"
)
private
String
productIntroductionPic5
;
@TableField
(
"university_id"
)
private
int
universityId
;
/**
* 是否显示融合时间
*/
@TableField
(
"show_rh_time"
)
private
String
showRhTime
;
}
common/src/main/java/com/winsun/bean/UniversityInfo.java
View file @
8548bcb6
package
com
.
winsun
.
bean
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableId
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.enums.IdType
;
...
...
@@ -22,108 +23,133 @@ public class UniversityInfo implements Serializable {
private
int
universityId
;
/**
* 学校名称
*/
@TableField
(
"university_name"
)
private
String
universityName
;
/**
*所在区域
*/
@TableField
(
"university_region"
)
private
String
universityRegion
;
/**
*外线方式
*/
@TableField
(
"university_exterior_lines"
)
private
String
universityExteriorLines
;
/**
*揽装工号
*/
@TableField
(
"university_package_number"
)
private
String
universityPackageNumber
;
/**
*创建人
*/
@TableField
(
"university_creater"
)
private
String
universityCreater
;
/**
*创建时间
*/
@TableField
(
"university_create_time"
)
private
Date
universityCreateTime
;
/**
*最后更新时间
*/
@TableField
(
"university_last_update_time"
)
private
Date
universityLastUpdateTime
;
/**
*装机地址
*/
@TableField
(
"university_installed_address"
)
private
String
universityInstalledAddress
;
/**
*允许上网终端类型
*/
@TableField
(
"university_terminal_type"
)
private
String
universityTerminalType
;
/**
*用户类别
*/
@TableField
(
"university_user_category"
)
private
String
universityUserCategory
;
/**
*用户类型
*/
@TableField
(
"university_user_type"
)
private
String
universityUserType
;
/**
*月租类型
*/
@TableField
(
"university_monthly_rent_type"
)
private
String
universityMonthlyRentType
;
/**
*'计费属性'
*/
@TableField
(
"university_charging_attribute"
)
private
String
universityChargingAttribute
;
/**
*最大在线数
*/
@TableField
(
"university_online_number"
)
private
String
universityOnlineNumber
;
/**
*一人一号多终端:0否 1是
*/
@TableField
(
"university_one_man_terminal"
)
private
String
universityOneManTerminal
;
/**
*是否FTTH+HUB:0否 1是
*/
@TableField
(
"university_is_ftth_hub"
)
private
String
universityIsFtthHub
;
/**
*地址
*/
@TableField
(
"university_installed_address_ID"
)
private
String
universityInstalledAddressId
;
/**
*学校联系号码
*/
@TableField
(
"university_contact_phone"
)
private
String
universityContactPhone
;
/**
*收费模式
*/
@TableField
(
"university_charge_mode"
)
private
String
universityChargeMode
;
/**
*
*/
@TableField
(
"university_domain_name"
)
private
String
universityDomainName
;
/**
*对用户显示的融合套餐
*/
@TableField
(
"rh_package"
)
private
String
rhPackage
;
/**
*融合资费
*/
@TableField
(
"expenses"
)
private
String
expenses
;
/**
*标识
*/
@TableField
(
"identifying"
)
private
String
identifying
;
/**
*融合办理,短信通知的提速的速率
*/
@TableField
(
"speed"
)
private
String
speed
;
/**
*公众号的名字
*/
@TableField
(
"public_number"
)
private
String
publicNumber
;
}
common/src/main/java/com/winsun/constant/Constant.java
View file @
8548bcb6
package
com
.
winsun
.
constant
;
import
javax.net.ssl.*
;
import
java.security.SecureRandom
;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
/**
* @author ljh
* @Description:常量类
...
...
@@ -21,6 +27,8 @@ public class Constant {
/*支付参数*/
public
final
static
String
CLIENTNUMBER
=
"xyzxyql"
;
//商户标识,由穗易付平台统一分配
public
final
static
String
APPK
=
"E805F0305C455BA7C5BAE3796C6500BD"
;
//KEY 商户标识,由穗易付平台统一分配
public
final
static
String
KEY
=
"E805F0305C455BA7C5BAE3796C6500BD"
;
//商户标识,由穗易付平台统一分配
public
final
static
String
USERNAME
=
"apitest"
;
//智能平台提供测试的账号
public
final
static
String
USERNAMEKEY
=
"46b97294d4dac3f62ee42f3ab2804f68"
;
//智能平台提供的测试key
public
final
static
String
ZHENGSHIAUCCON
=
"ruany"
;
//智能平台提供的正式账号
...
...
@@ -64,5 +72,37 @@ public class Constant {
public
final
static
String
ROLE2
=
"2"
;
// 用户权限:1管理员 2测试人员 3工作人员 4学校人员
public
final
static
String
ROLE3
=
"3"
;
// 用户权限:1管理员 2测试人员 3工作人员 4学校人员
public
final
static
String
ROLE4
=
"4"
;
// 用户权限:1管理员 2测试人员 3工作人员 4学校人员
/** 信任任何站点 */
public
static
void
trustEveryone
()
{
try
{
HttpsURLConnection
.
setDefaultHostnameVerifier
(
new
HostnameVerifier
()
{
@Override
public
boolean
verify
(
String
hostname
,
SSLSession
session
)
{
return
true
;
}
});
SSLContext
context
=
SSLContext
.
getInstance
(
"TLS"
);
context
.
init
(
null
,
new
X509TrustManager
[]
{
new
X509TrustManager
()
{
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
new
X509Certificate
[
0
];
}
}
},
new
SecureRandom
());
HttpsURLConnection
.
setDefaultSSLSocketFactory
(
context
.
getSocketFactory
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
common/src/main/java/com/winsun/mapper/HhrUserMapper.java
View file @
8548bcb6
...
...
@@ -2,6 +2,8 @@ package com.winsun.mapper;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Component
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
...
...
@@ -16,6 +18,20 @@ import java.util.Map;
@Mapper
@Component
public
interface
HhrUserMapper
extends
BaseMapper
<
HhrUser
>
{
@Select
(
"select u.area ,u.name ,u.school,u.phone_num "
+
"from hhr_user u "
+
"left join hhr_user_school us on u.id = us.user_id "
+
"where u.id=#{partner}"
)
List
<
Map
<
String
,
Object
>>
findPartnerById2
(
@Param
(
"partner"
)
String
partner
);
@Select
(
"select uuu.name ddname,sch.lzgh "
+
"from hhr_user u "
+
"left join hhr_user_school us on u.id = us.user_id "
+
"left join hhr_school sch on sch.id = us.school_id "
+
"left join hhr_supervisor_school ss on us.school_id = ss.school "
+
"left join hhr_user uuu on uuu.id = ss.user_id "
+
"where u.id=#{partner}"
)
List
<
Map
<
String
,
Object
>>
findSupervisorByPartnerId
(
@Param
(
"partner"
)
String
partner
);
/**
* 统计所有订单数
...
...
common/src/main/java/com/winsun/mapper/OrderViewMapper.java
View file @
8548bcb6
...
...
@@ -33,4 +33,13 @@ public interface OrderViewMapper extends BaseMapper<OrderView> {
@Insert
(
"insert into`hhr_order_history`(order_id, status, create_date) values(#{id}, #{status}, #{createTime})"
)
int
insertOrderHistory
(
@Param
(
"id"
)
String
id
,
@Param
(
"status"
)
String
status
,
@Param
(
"createTime"
)
Timestamp
createTime
);
@Select
(
"select * from order_view where orderSeq = #{orderSeq}"
)
Map
<
String
,
Object
>
queryorderSeq
(
@Param
(
"orderSeq"
)
String
orderSeq
);
@Update
(
"update hhr_order set rh_time = #{rhTime} where orderSeq=#{orderSeq}"
)
int
updatePayRhTime
(
@Param
(
"rhTime"
)
String
rhTime
,
@Param
(
"orderSeq"
)
String
orderSeq
);
@Select
(
"select * from order_view where orderNumber=#{orderNumber} and status !=#{status} "
)
List
<
Map
<
String
,
Object
>>
orderViewToStatusList
(
@Param
(
"orderNumber"
)
String
orderNumber
,
@Param
(
"status"
)
String
status
);
}
common/src/main/java/com/winsun/mapper/ProductMapper.java
View file @
8548bcb6
...
...
@@ -4,11 +4,26 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
import
com.winsun.bean.Package
;
import
com.winsun.bean.Product
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Map
;
@Mapper
@Component
public
interface
ProductMapper
extends
BaseMapper
<
Product
>
{
@Select
(
"SELECT * FROM `product_manage` WHERE product_id = (SELECT b.`bandproduct_id` FROM hhr_user_school a LEFT JOIN hhr_school b ON a.`school_id`=b.`id` WHERE a.user_id=#{partner})"
)
List
<
Map
<
String
,
Object
>>
findMoreUniversity
(
@Param
(
"partner"
)
String
partner
);
@Select
(
" SELECT pm.product_university as universityName,pm.product_region as productRegion,"
+
" pm.product_title productName "
+
" FROM hhr_user u "
+
" LEFT JOIN hhr_user_school us ON u.`id`=us.`user_id`"
+
" LEFT JOIN hhr_school s ON us.`school_id`=s.`id` "
+
" LEFT JOIN product_manage pm ON s.bandproduct_id=pm.product_id"
+
" WHERE u.`id`= #{id}"
)
List
<
Map
<
String
,
Object
>>
queryProductById
(
@Param
(
"id"
)
String
id
);
}
common/src/main/java/com/winsun/mapper/SchoolMapper.java
View file @
8548bcb6
...
...
@@ -50,4 +50,10 @@ public interface SchoolMapper extends BaseMapper<School> {
@Delete
(
"delete from hhr_supervisor_school where user_id = #{userId}"
)
int
deleteSupervisorSchoolByUserId
(
@Param
(
"userId"
)
String
userId
);
@Select
(
"SELECT s.* FROM hhr_user u"
+
" LEFT JOIN hhr_user_school us ON u.`id`=us.`user_id`"
+
" LEFT JOIN hhr_school s ON s.`id`=us.`school_id`"
+
" WHERE u.id=#{id}"
)
Map
<
String
,
Object
>
querySchoolById
(
@Param
(
"id"
)
String
id
);
}
common/src/main/java/com/winsun/mapper/UniversityInfoMapper.java
View file @
8548bcb6
...
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.plugins.Page;
import
com.winsun.bean.UniversityInfo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
...
...
@@ -17,4 +18,5 @@ public interface UniversityInfoMapper extends BaseMapper<UniversityInfo> {
List
<
Map
<
String
,
Object
>>
getBroadBandConfigList
(
Page
page
,
@Param
(
"productUniversity"
)
String
productUniversity
,
@Param
(
"productRegion"
)
String
productRegion
);
}
common/src/main/java/com/winsun/utils/Base64ToImgUtils.java
0 → 100644
View file @
8548bcb6
package
com
.
winsun
.
utils
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.UUID
;
/**
* Base64流转图片工具类
* @author calvin
*/
public
class
Base64ToImgUtils
{
public
static
String
base64ToImg
(
String
imgData
,
String
hhr_img
)
throws
IOException
{
String
filePath
=
""
;
String
uuid
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
uuid
=
uuid
.
substring
(
1
,
12
);
SimpleDateFormat
sd
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
SimpleDateFormat
sd2
=
new
SimpleDateFormat
(
"yyyyMM"
);
String
orderNumber
=
"YRYM"
+
sd
.
format
(
new
Date
())
+
uuid
;
Date
date
=
new
Date
();
String
createdate
=
sd2
.
format
(
date
);
File
file
=
new
File
(
hhr_img
+
"/"
+
createdate
+
"/"
+
sd
.
format
(
date
)
+
"/"
+
orderNumber
);
if
(!
file
.
exists
()
&&
!
file
.
isDirectory
())
{
file
.
mkdirs
();
}
if
(!
imgData
.
isEmpty
())
{
String
name
=
orderNumber
;
String
base64Data
=
imgData
.
split
(
","
)[
1
];
String
houzhui
=
imgData
.
split
(
","
)[
0
].
split
(
"/"
)[
1
].
split
(
";"
)[
0
];
/**
* 2.解码成字节数组
*/
filePath
=
hhr_img
+
"/"
+
createdate
+
"/"
+
sd
.
format
(
date
)
+
"/"
+
orderNumber
+
"/"
+
"O"
+
name
+
"."
+
houzhui
;
java
.
util
.
Base64
.
Decoder
decoder
=
java
.
util
.
Base64
.
getDecoder
();
byte
[]
bytes
=
decoder
.
decode
(
base64Data
);
FileOutputStream
fos
=
null
;
try
{
fos
=
new
FileOutputStream
(
filePath
);
fos
.
write
(
bytes
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
fos
!=
null
){
try
{
fos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
return
filePath
;
}
}
common/src/main/java/com/winsun/utils/RandomUtil.java
View file @
8548bcb6
package
com
.
winsun
.
utils
;
import
java.security.SecureRandom
;
import
java.util.Random
;
/**
* 随机数工具类
...
...
@@ -34,4 +35,19 @@ public class RandomUtil {
}
return
0
;
}
/* 组成20个随机数的订单号 */
public
static
String
RandomNumber
(
int
length
){
String
str
=
"1234567890abcdefghijklmnopqrstuvwxyz"
;
Random
random
=
new
Random
();
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++){
int
number
=
random
.
nextInt
(
36
);
sb
.
append
(
str
.
charAt
(
number
));
}
return
sb
.
toString
();
}
}
common/src/main/java/com/winsun/utils/SignUtil.java
0 → 100644
View file @
8548bcb6
package
com
.
winsun
.
utils
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.security.MessageDigest
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
/**
* Created by wangwenbo on 2018/5/24.
*/
/* 签名验证相关utilS*/
public
class
SignUtil
{
/**
* 将输入的参数转换成sign
* @param param 请求的参数(不包含sign,否则会把sign当作数据一齐处理)
* @param appKey 指定的秘钥
* @return
*/
public
static
String
createUnifiedOrderSign
(
final
Map
<
String
,
String
>
param
,
String
appKey
)
{
List
<
String
>
keies
=
new
ArrayList
<>();
keies
.
addAll
(
param
.
keySet
());
Collections
.
sort
(
keies
);
List
<
String
>
datas
=
new
ArrayList
<>();
keies
.
forEach
(
key
->
{
datas
.
add
(
key
+
"="
+
param
.
getOrDefault
(
key
,
""
));
});
datas
.
add
(
appKey
);
return
DigestUtils
.
md5Hex
(
StringUtils
.
join
(
datas
,
"&"
)).
toLowerCase
();
}
private
static
final
String
TOKEN
=
"supperapp"
;
// 加密token
/***
* MD5加密 生成32位md5码 速度比较快 性能高 安全强度比sha1要低
*
* @param 待加密字符串
* @return 返回32位md5码
*/
public
static
String
md5EncodeSignature
(
String
inStr
)
throws
Exception
{
MessageDigest
md5
=
null
;
try
{
md5
=
MessageDigest
.
getInstance
(
"MD5"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
""
;
}
byte
[]
byteArray
=
inStr
.
getBytes
(
"UTF-8"
);
byte
[]
md5Bytes
=
md5
.
digest
(
byteArray
);
StringBuffer
hexValue
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
md5Bytes
.
length
;
i
++)
{
int
val
=
((
int
)
md5Bytes
[
i
])
&
0xff
;
if
(
val
<
16
)
{
hexValue
.
append
(
"0"
);
}
hexValue
.
append
(
Integer
.
toHexString
(
val
));
}
return
hexValue
.
toString
();
}
/***
* SHA加密 生成40位SHA码 加密速度比md5慢 性能比md5低 安全强度比md5高
*
* @param 待加密字符串
* @return 返回40位SHA码
*/
public
static
String
shaEncodeSignature
(
String
inStr
)
throws
Exception
{
MessageDigest
sha
=
null
;
try
{
sha
=
MessageDigest
.
getInstance
(
"SHA"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
""
;
}
byte
[]
byteArray
=
inStr
.
getBytes
(
"UTF-8"
);
byte
[]
md5Bytes
=
sha
.
digest
(
byteArray
);
StringBuffer
hexValue
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
md5Bytes
.
length
;
i
++)
{
int
val
=
((
int
)
md5Bytes
[
i
])
&
0xff
;
if
(
val
<
16
)
{
hexValue
.
append
(
"0"
);
}
hexValue
.
append
(
Integer
.
toHexString
(
val
));
}
return
hexValue
.
toString
();
}
/**
* 签名加密
*
* @param inStr
* @param type
* 加密方式 1,MD5 2,SHA
* @return
*/
public
static
String
signature
(
String
inStr
,
int
type
)
{
String
encodeStr
=
""
;
int
sel
=
type
;
if
(
sel
==
0
)
{
try
{
encodeStr
=
md5EncodeSignature
(
TOKEN
+
":"
+
inStr
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
else
{
try
{
encodeStr
=
shaEncodeSignature
(
TOKEN
+
":"
+
inStr
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
encodeStr
;
}
//把一个字符串中的大写转为小写,小写转换为大写
public
static
String
exChange
(
String
str
){
StringBuffer
sb
=
new
StringBuffer
();
if
(
str
!=
null
){
for
(
int
i
=
0
;
i
<
str
.
length
();
i
++){
char
c
=
str
.
charAt
(
i
);
if
(
Character
.
isLowerCase
(
c
)){
sb
.
append
(
Character
.
toUpperCase
(
c
));
// 小转大
}
else
{
sb
.
append
(
c
);
}
}
}
return
sb
.
toString
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment