Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rs-cloud-platform
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周健威
rs-cloud-platform
Commits
0b8fbd79
Commit
0b8fbd79
authored
Sep 28, 2021
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代码
parent
948baa89
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
126 deletions
+59
-126
SystemConfig.java
...ub/wxiaoqi/security/common/util/process/SystemConfig.java
+4
-4
systemconfig.properties
...mon/src/main/resources/properties/systemconfig.properties
+3
-3
WXPay.java
...va/com/upyuns/platform/rs/universal/weixin/api/WXPay.java
+45
-118
OrderPayBiz.java
...ava/com/upyuns/platform/rs/universal/biz/OrderPayBiz.java
+7
-1
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/process/SystemConfig.java
View file @
0b8fbd79
...
...
@@ -36,10 +36,10 @@ public class SystemConfig {
return
SystemProperty
.
getConfig
(
key
);
}
// 微信公众号的配置
public
static
final
String
WINXIN_AppID
=
SystemProperty
.
getConfig
(
"WINXIN_AppID"
);
public
static
final
String
WINXIN_AppSecret
=
SystemProperty
.
getConfig
(
"WINXIN_AppSecret"
);
public
static
final
String
WINXIN_PARTNER_KEY
=
SystemProperty
.
getConfig
(
"WINXIN_PARTNER_KEY"
);
public
static
final
String
WINXIN_PARTNER
=
SystemProperty
.
getConfig
(
"WINXIN_PARTNER"
);
//
public static final String WINXIN_AppID = SystemProperty.getConfig("WINXIN_AppID");
//
public static final String WINXIN_AppSecret = SystemProperty.getConfig("WINXIN_AppSecret");
//
public static final String WINXIN_PARTNER_KEY = SystemProperty.getConfig("WINXIN_PARTNER_KEY");
//
public static final String WINXIN_PARTNER = SystemProperty.getConfig("WINXIN_PARTNER");
// 移动端app微信支付配置参数
// 微信开发平台应用id(OK)
...
...
ace-common/src/main/resources/properties/systemconfig.properties
View file @
0b8fbd79
...
...
@@ -22,9 +22,9 @@ ACCESSKEYSECRET=OCKDEiwKGjePCZgPeWMEUFGwGbKYLA
TEMPLATECODE
=
SMS_170070101
SIGNNAME
=
\u
6EF4
\u
623F
\u
8F66
#\u5FAE\u4FE1\u652F\u4ED8\u914D\u7F6E
WINXIN_AppID
=
wx2e6ea283e99db7bf
WINXIN_PARTNER_KEY
=
fas4d6f54as4d6f4a5s6df45asd4f6as
WINXIN_PARTNER
=
1604632763
#
WINXIN_AppID=wx2e6ea283e99db7bf
#
WINXIN_PARTNER_KEY=fas4d6f54as4d6f4a5s6df45asd4f6as
#
WINXIN_PARTNER=1604632763
#邮件配置
mail.fromMail.addr
=
1367272022@qq.com
...
...
rs-universal/rs-universal-api/src/main/java/com/upyuns/platform/rs/universal/weixin/api/WXPay.java
View file @
0b8fbd79
...
...
@@ -30,46 +30,46 @@ import com.alibaba.fastjson.JSONObject;
*/
@Slf4j
public
class
WXPay
{
/**
* JSAPI支付
* @param total_fee
* @param body
* @param notify_url
* @param orderNo
* @param spbill_create_ip
* @param openid
* @return
*/
public
static
String
webPay
(
String
total_fee
,
String
body
,
String
notify_url
,
String
orderNo
,
String
spbill_create_ip
,
String
openid
,
String
wyAppid
){
WXPrepay
prePay
=
new
WXPrepay
();
if
(
StringUtils
.
isBlank
(
wyAppid
)){
wyAppid
=
SystemConfig
.
WINXIN_AppID
;
}
prePay
.
setAppid
(
wyAppid
);
//pay.getAppId()
prePay
.
setBody
(
body
);
prePay
.
setPartnerKey
(
SystemConfig
.
WINXIN_PARTNER_KEY
);
//pay.getPartnerKey()
prePay
.
setMch_id
(
SystemConfig
.
WINXIN_PARTNER
);
//pay.getPartnerId()
prePay
.
setNotify_url
(
notify_url
);
prePay
.
setOut_trade_no
(
orderNo
);
prePay
.
setSpbill_create_ip
(
spbill_create_ip
);
//"123.12.12.123"
prePay
.
setTotal_fee
(
total_fee
);
prePay
.
setTrade_type
(
"JSAPI"
);
prePay
.
setOpenid
(
openid
);
//此处添加获取openid的方法,获取预支付订单需要此参数!!!!!!!!!!!
// 获取预支付订单号
String
prepayid
=
prePay
.
submitXmlGetPrepayId
(
1
);
System
.
out
.
println
(
"获取的预支付订单是:"
+
prepayid
);
//PrepayIdRequestHandler prepayReqHandler = new PrepayIdRequestHandler(request, response);//获取prepayid的请求类
//logger.info("预支付签名:"+prepayReqHandler.createSHA1Sign());
String
jsParam
=
""
;
if
(
prepayid
!=
null
&&
prepayid
.
length
()
>
10
)
{
// 生成微信支付参数,此处拼接为完整的JSON格式,符合支付调起传入格式
jsParam
=
WXPay
.
createPackageValueWeb
(
wyAppid
,
SystemConfig
.
WINXIN_PARTNER_KEY
,
prepayid
);
}
return
jsParam
;
}
//
/**
//
* JSAPI支付
//
* @param total_fee
//
* @param body
//
* @param notify_url
//
* @param orderNo
//
* @param spbill_create_ip
//
* @param openid
//
* @return
//
*/
//
//
public static String webPay(String total_fee,String body,String notify_url,String orderNo,String spbill_create_ip,String openid,String wyAppid){
//
WXPrepay prePay = new WXPrepay();
//
if (StringUtils.isBlank(wyAppid)){
//
wyAppid=SystemConfig.WINXIN_AppID;
//
}
//
prePay.setAppid(wyAppid);//pay.getAppId()
//
prePay.setBody(body);
//
prePay.setPartnerKey(SystemConfig.WINXIN_PARTNER_KEY);//pay.getPartnerKey()
//
prePay.setMch_id(SystemConfig.WINXIN_PARTNER);//pay.getPartnerId()
//
prePay.setNotify_url(notify_url);
//
prePay.setOut_trade_no(orderNo);
//
prePay.setSpbill_create_ip(spbill_create_ip);//"123.12.12.123"
//
prePay.setTotal_fee(total_fee);
//
prePay.setTrade_type("JSAPI");
//
prePay.setOpenid(openid);
// //此处添加获取openid的方法,获取预支付订单需要此参数!!!!!!!!!!!
//
// 获取预支付订单号
//
String prepayid = prePay.submitXmlGetPrepayId(1);
//
System.out.println("获取的预支付订单是:" + prepayid);
//
//PrepayIdRequestHandler prepayReqHandler = new PrepayIdRequestHandler(request, response);//获取prepayid的请求类
//
//logger.info("预支付签名:"+prepayReqHandler.createSHA1Sign());
//
String jsParam = "";
//
if (prepayid != null && prepayid.length() > 10) {
//
// 生成微信支付参数,此处拼接为完整的JSON格式,符合支付调起传入格式
//
jsParam = WXPay.createPackageValueWeb(wyAppid, SystemConfig.WINXIN_PARTNER_KEY, prepayid);
//
//
}
//
return jsParam;
//
}
...
...
@@ -177,25 +177,23 @@ public class WXPay {
* @param amount
* @param spbill_create_ip
* @param orderNo
* @param activityId
* @param token
* @param body
* @param notify_url
* @return
*/
public
static
String
getH5PayParam
(
String
amount
,
String
spbill_create_ip
,
String
orderNo
,
String
a
ctivityId
,
String
token
,
String
body
,
String
notify_url
)
{
public
static
String
getH5PayParam
(
String
amount
,
String
spbill_create_ip
,
String
orderNo
,
String
a
ppId
,
String
partnerId
,
String
partnerKey
,
String
body
,
String
notify_url
)
{
WXPrepay
prePay
=
new
WXPrepay
();
prePay
.
setAppid
(
SystemConfig
.
WINXIN_AppID
);
//pay.getAppId()
prePay
.
setAppid
(
appId
);
//pay.getAppId()
prePay
.
setBody
(
body
);
prePay
.
setPartnerKey
(
SystemConfig
.
WINXIN_PARTNER_KEY
);
//pay.getPartnerKey()
prePay
.
setMch_id
(
SystemConfig
.
WINXIN_PARTNER
);
//pay.getPartnerId()
prePay
.
setPartnerKey
(
partnerKey
);
//pay.getPartnerKey()
prePay
.
setMch_id
(
partnerId
);
//pay.getPartnerId()
prePay
.
setNotify_url
(
notify_url
);
prePay
.
setOut_trade_no
(
orderNo
);
prePay
.
setSpbill_create_ip
(
spbill_create_ip
);
//"123.12.12.123"
prePay
.
setTotal_fee
(
amount
);
prePay
.
setTrade_type
(
"NATIVE"
);
log
.
error
(
"getH5PayParam->payOrderDto:{},appId:{},mchId:{},partnerKey:{},subMchId:{}"
,
prePay
,
prePay
.
getAppid
(),
prePay
.
getMch_id
(),
prePay
.
getPartnerKey
(),
SystemConfig
.
WINXIN_PARTNER
);
prePay
,
prePay
.
getAppid
(),
prePay
.
getMch_id
(),
prePay
.
getPartnerKey
(),
partnerId
);
String
xmlStr
=
prePay
.
getPackage
();
log
.
error
(
"xmlStr====="
+
xmlStr
);
...
...
@@ -245,72 +243,6 @@ public class WXPay {
System
.
out
.
println
(
response_body
);
}
public
static
String
getPackage
(
String
total_fee
,
String
body
,
String
notify_url
,
String
orderNo
,
String
spbill_create_ip
,
String
openid
,
String
appid
,
String
appsecret
){
Map
<
String
,
String
>
map
=
new
LinkedHashMap
<
String
,
String
>();
Random
random
=
new
Random
();
String
randomStr
=
MD5
.
GetMD5String
(
String
.
valueOf
(
random
.
nextInt
(
10000
)));
String
noceStr
=
MD5Util
.
MD5Encode
(
randomStr
,
"utf-8"
).
toLowerCase
();
SortedMap
<
String
,
String
>
packageParams
=
new
TreeMap
<
String
,
String
>();
packageParams
.
put
(
"appid"
,
appid
);
packageParams
.
put
(
"mch_id"
,
SystemConfig
.
WINXIN_PARTNER
);
packageParams
.
put
(
"nonce_str"
,
noceStr
);
packageParams
.
put
(
"body"
,
body
);
packageParams
.
put
(
"attach"
,
""
);
packageParams
.
put
(
"out_trade_no"
,
orderNo
);
// 这里写的金额为1 分到时修改
packageParams
.
put
(
"total_fee"
,
total_fee
);
packageParams
.
put
(
"spbill_create_ip"
,
spbill_create_ip
);
packageParams
.
put
(
"notify_url"
,
notify_url
);
String
trade_type
=
"JSAPI"
;
packageParams
.
put
(
"trade_type"
,
trade_type
);
packageParams
.
put
(
"openid"
,
openid
);
RequestHandler
reqHandler
=
new
RequestHandler
(
null
,
null
);
reqHandler
.
init
(
appid
,
appsecret
,
SystemConfig
.
WINXIN_PARTNER_KEY
);
String
sign
=
reqHandler
.
createSign
(
packageParams
);
WxPrepay
wxPrepay
=
new
WxPrepay
();
wxPrepay
.
setAppid
(
appid
);
wxPrepay
.
setMch_id
(
SystemConfig
.
WINXIN_PARTNER
);
wxPrepay
.
setNonce_str
(
noceStr
);
wxPrepay
.
setSign
(
sign
);
wxPrepay
.
setBody
(
body
);
wxPrepay
.
setOut_trade_no
(
orderNo
);
wxPrepay
.
setTotal_fee
(
total_fee
);
wxPrepay
.
setSpbill_create_ip
(
spbill_create_ip
);
wxPrepay
.
setNotify_url
(
notify_url
);
wxPrepay
.
setTrade_type
(
trade_type
);
wxPrepay
.
setOpenid
(
openid
);
wxPrepay
.
setAttach
(
""
);
String
xml
=
WeiXinPayUtil
.
toXml
(
wxPrepay
);
log
.
error
(
"post_prepay_xml: "
+
xml
);
//获取prepay_id
map
=
StringtoMap
(
WeiXinPayUtil
.
getPrepayId
(
xml
,
"POST"
));
//获取prepay_id后,拼接最后请求支付所需要的package
SortedMap
<
String
,
String
>
finalpackage
=
new
TreeMap
<
String
,
String
>();
String
timestamp
=
OrderUtil
.
GetTimestamp
();
String
packages
=
"prepay_id="
+
map
.
get
(
"prepay_id"
);
finalpackage
.
put
(
"appId"
,
appid
);
finalpackage
.
put
(
"timeStamp"
,
timestamp
);
finalpackage
.
put
(
"nonceStr"
,
noceStr
);
finalpackage
.
put
(
"package"
,
packages
);
finalpackage
.
put
(
"signType"
,
"MD5"
);
//要签名
String
finalsign
=
reqHandler
.
createSign
(
finalpackage
);
String
finaPackage
=
"\"appId\":\""
+
appid
+
"\",\"timeStamp\":\""
+
timestamp
+
"\",\"nonceStr\":\""
+
noceStr
+
"\",\"package\":\""
+
packages
+
"\",\"signType\" : \"MD5"
+
"\",\"paySign\":\""
+
finalsign
+
"\""
;
return
finaPackage
;
}
public
static
Map
<
String
,
String
>
StringtoMap
(
String
str
){
log
.
error
(
"respon_prepay_xml: "
+
str
);
Map
<
String
,
String
>
map
=
new
LinkedHashMap
<
String
,
String
>();
...
...
@@ -329,9 +261,4 @@ public class WXPay {
return
map
;
}
}
\ No newline at end of file
rs-universal/rs-universal-server/src/main/java/com/upyuns/platform/rs/universal/biz/OrderPayBiz.java
View file @
0b8fbd79
...
...
@@ -94,6 +94,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
@Value
(
"${wx.appPartner}"
)
public
String
APP_PARTNER
;
@Value
(
"${wx.appPartnerKey}"
)
public
String
APP_PARTNERKEY
;
@Value
(
"${wx.appid}"
)
public
String
APP_ID
;
// @Value("${wx.appSercet}")
// private String wy_secret;
...
...
@@ -160,7 +166,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
}
}
else
if
(
payWay
==
1
)
{
//微信支付
sellerAccount
=
APP_PARTNER
;
jsParam
=
WXPay
.
getH5PayParam
(
amount
+
""
,
orderPayVo
.
getBuyerIp
(),
trade_no
,
orderPayVo
.
getBody
(),
orderPayVo
.
getBody
()
,
orderPayVo
.
getBody
(),
notify_url
);
jsParam
=
WXPay
.
getH5PayParam
(
amount
+
""
,
orderPayVo
.
getBuyerIp
(),
trade_no
,
APP_ID
,
APP_PARTNER
,
APP_PARTNERKEY
,
orderPayVo
.
getBody
(),
notify_url
);
}
else
if
(
payWay
==
3
)
{
//对公账户支付
sellerAccount
=
APP_PARTNER
;
...
...
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