Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
6e1df475
Commit
6e1df475
authored
Feb 28, 2024
by
YG8999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉充值代码
parent
9b36552f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
87 deletions
+87
-87
OrderPayService.java
...m/src/main/java/share/system/service/OrderPayService.java
+1
-1
OrderPayServiceImpl.java
...n/java/share/system/service/impl/OrderPayServiceImpl.java
+86
-86
No files found.
share-system/src/main/java/share/system/service/OrderPayService.java
View file @
6e1df475
...
...
@@ -30,6 +30,6 @@ public interface OrderPayService {
* @param recharge 支付参数
* @return OrderPayResultResponse
*/
RechargePayResultResponse
saobeiRechargePayment
(
Recharge
recharge
);
//
RechargePayResultResponse saobeiRechargePayment(Recharge recharge);
}
share-system/src/main/java/share/system/service/impl/OrderPayServiceImpl.java
View file @
6e1df475
...
...
@@ -108,33 +108,33 @@ public class OrderPayServiceImpl implements OrderPayService {
return
response
;
}
/**
* 充值支付(扫呗-微信支付)
* @param recharge 支付参数
* @return
*/
@Override
public
RechargePayResultResponse
saobeiRechargePayment
(
Recharge
recharge
)
{
RechargePayResultResponse
response
=
new
RechargePayResultResponse
();
response
.
setRechargeNo
(
recharge
.
getRechargeNo
());
response
.
setPayType
(
PayTypeEnum
.
getEnumByCode
(
recharge
.
getPayType
()).
getValue
());
response
.
setStatus
(
YesNoEnum
.
no
.
getFlag
());
// 扫呗支付
ConcurrentHashMap
<
String
,
String
>
unifiedorder
=
saobeiUnifiedRecharge
(
recharge
);
WxPayJsResultVo
vo
=
new
WxPayJsResultVo
();
vo
.
setAppId
(
unifiedorder
.
get
(
"appId"
));
vo
.
setNonceStr
(
unifiedorder
.
get
(
"nonceStr"
));
vo
.
setPackages
(
unifiedorder
.
get
(
"package"
));
vo
.
setSignType
(
unifiedorder
.
get
(
"signType"
));
vo
.
setTimeStamp
(
unifiedorder
.
get
(
"timeStamp"
));
vo
.
setPaySign
(
unifiedorder
.
get
(
"paySign"
));
// 更新商户订单号
recharge
.
setOutTradeNo
(
unifiedorder
.
get
(
"outTradeNo"
));
recharge
.
setTerminalTrace
(
unifiedorder
.
get
(
"terminalTrace"
));
rechargeService
.
updateById
(
recharge
);
response
.
setJsConfig
(
vo
);
return
response
;
}
//
/**
//
* 充值支付(扫呗-微信支付)
//
* @param recharge 支付参数
//
* @return
//
*/
//
@Override
//
public RechargePayResultResponse saobeiRechargePayment(Recharge recharge) {
//
RechargePayResultResponse response = new RechargePayResultResponse();
//
response.setRechargeNo(recharge.getRechargeNo());
//
response.setPayType(PayTypeEnum.getEnumByCode(recharge.getPayType()).getValue());
//
response.setStatus(YesNoEnum.no.getFlag());
//
// 扫呗支付
//
ConcurrentHashMap<String, String> unifiedorder = saobeiUnifiedRecharge(recharge);
//
WxPayJsResultVo vo = new WxPayJsResultVo();
//
vo.setAppId(unifiedorder.get("appId"));
//
vo.setNonceStr(unifiedorder.get("nonceStr"));
//
vo.setPackages(unifiedorder.get("package"));
//
vo.setSignType(unifiedorder.get("signType"));
//
vo.setTimeStamp(unifiedorder.get("timeStamp"));
//
vo.setPaySign(unifiedorder.get("paySign"));
//
// 更新商户订单号
//
recharge.setOutTradeNo(unifiedorder.get("outTradeNo"));
//
recharge.setTerminalTrace(unifiedorder.get("terminalTrace"));
//
rechargeService.updateById(recharge);
//
response.setJsConfig(vo);
//
return response;
//
}
/**
...
...
@@ -259,64 +259,64 @@ public class OrderPayServiceImpl implements OrderPayService {
return
vo
;
}
/**
* 预下单 (扫呗-微信)
* @param recharge 充值对象
* @return 预下单返回对象
*/
private
ConcurrentHashMap
<
String
,
String
>
saobeiUnifiedRecharge
(
Recharge
recharge
)
{
// 获取用户openId
SConsumerToken
userToken
=
consumerTokenService
.
getTokenByUserId
(
recharge
.
getConsumerId
());
if
(
ObjectUtil
.
isNull
(
userToken
))
{
throw
new
BaseException
(
"该用户没有openId"
);
}
// 获取appid、mch_id
// 微信签名key
String
appId
=
weChatConfig
.
getAppId
();
String
mchId
=
weChatConfig
.
getMchId
();
String
signKey
=
weChatConfig
.
getSignKey
();
// 获取扫呗微信预下单对象
SaobeiMiniPayRequestVo
unifiedorderVo
=
getSaobeiUnifiedRechargeVo
(
recharge
,
userToken
.
getToken
(),
appId
,
mchId
,
signKey
);
// 预下单(统一下单)
SaobeiMiniPayResponse
response
=
saobeiService
.
wechatMinipay
(
unifiedorderVo
);
logger
.
info
(
"SaobeiMiniPayResponse :"
,
JsonConvertUtil
.
write2JsonStr
(
response
));
// 组装前端预下单参数
ConcurrentHashMap
<
String
,
String
>
map
=
new
ConcurrentHashMap
<>();
map
.
put
(
"appId"
,
response
.
getAppId
());
map
.
put
(
"nonceStr"
,
response
.
getNonceStr
());
map
.
put
(
"package"
,
response
.
getPackage_str
());
map
.
put
(
"signType"
,
response
.
getSignType
());
map
.
put
(
"timeStamp"
,
response
.
getTimeStamp
());
map
.
put
(
"paySign"
,
response
.
getPaySign
());
map
.
put
(
"prepayTime"
,
DateUtil
.
nowDateTimeStr
());
map
.
put
(
"outTradeNo"
,
response
.
getOut_trade_no
());
map
.
put
(
"terminalTrace"
,
unifiedorderVo
.
getTerminal_trace
());
return
map
;
}
/**
* 获取预下单对象 (扫呗-微信)
* 充值
* @return 预下单对象
*/
private
SaobeiMiniPayRequestVo
getSaobeiUnifiedRechargeVo
(
Recharge
recharge
,
String
openid
,
String
appId
,
String
mchId
,
String
signKey
)
{
AttachVo
attachVo
=
new
AttachVo
(
OrderTypeEnum
.
RECHARGE
.
getValue
(),
recharge
.
getConsumerId
());
SaobeiMiniPayRequestVo
vo
=
new
SaobeiMiniPayRequestVo
();
vo
.
setSub_appid
(
appId
);
vo
.
setMerchant_no
(
saobeiConfig
.
getMerchantNo
());
vo
.
setTerminal_id
(
saobeiConfig
.
getTerminalId
());
vo
.
setAttach
(
JSONObject
.
toJSONString
(
attachVo
));
vo
.
setTerminal_trace
(
BaseUtil
.
getOrderNo
(
"WXNO"
));
vo
.
setTerminal_time
(
DateUtil
.
nowDate
(
Constants
.
DATE_TIME_FORMAT_NUM
));
vo
.
setOrder_body
(
StrUtil
.
concat
(
true
,
recharge
.
getRechargeAmount
().
toString
(),
"元充值!"
));
// 订单中使用的是BigDecimal,这里要转为Integer类型
vo
.
setTotal_fee
(
String
.
valueOf
(
recharge
.
getRechargeAmount
().
multiply
(
BigDecimal
.
TEN
).
multiply
(
BigDecimal
.
TEN
).
intValue
()));
vo
.
setNotify_url
(
apiDomain
+
PayConstants
.
SAOBEI_PAY_NOTIFY_API_URI
);
vo
.
setTrade_type
(
PayConstants
.
WX_PAY_TRADE_TYPE_JS
);
vo
.
setOpen_id
(
openid
);
vo
.
setDevice_no
(
"WEB"
);
return
vo
;
}
//
/**
//
* 预下单 (扫呗-微信)
//
* @param recharge 充值对象
//
* @return 预下单返回对象
//
*/
//
private ConcurrentHashMap<String, String> saobeiUnifiedRecharge(Recharge recharge) {
//
// 获取用户openId
//
SConsumerToken userToken = consumerTokenService.getTokenByUserId(recharge.getConsumerId());
//
if (ObjectUtil.isNull(userToken)) {
//
throw new BaseException("该用户没有openId");
//
}
//
// 获取appid、mch_id
//
// 微信签名key
//
String appId = weChatConfig.getAppId();
//
String mchId = weChatConfig.getMchId();
//
String signKey = weChatConfig.getSignKey();
//
// 获取扫呗微信预下单对象
//
SaobeiMiniPayRequestVo unifiedorderVo = getSaobeiUnifiedRechargeVo(recharge, userToken.getToken(), appId, mchId, signKey);
//
// 预下单(统一下单)
//
SaobeiMiniPayResponse response = saobeiService.wechatMinipay(unifiedorderVo);
//
logger.info("SaobeiMiniPayResponse :", JsonConvertUtil.write2JsonStr(response));
//
// 组装前端预下单参数
//
ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
//
map.put("appId", response.getAppId());
//
map.put("nonceStr", response.getNonceStr());
//
map.put("package", response.getPackage_str());
//
map.put("signType", response.getSignType());
//
map.put("timeStamp", response.getTimeStamp());
//
map.put("paySign", response.getPaySign());
//
map.put("prepayTime", DateUtil.nowDateTimeStr());
//
map.put("outTradeNo", response.getOut_trade_no());
//
map.put("terminalTrace", unifiedorderVo.getTerminal_trace());
//
return map;
//
}
//
//
/**
//
* 获取预下单对象 (扫呗-微信)
//
* 充值
//
* @return 预下单对象
//
*/
//
private SaobeiMiniPayRequestVo getSaobeiUnifiedRechargeVo(Recharge recharge, String openid, String appId, String mchId, String signKey) {
//
AttachVo attachVo = new AttachVo(OrderTypeEnum.RECHARGE.getValue(), recharge.getConsumerId());
//
//
SaobeiMiniPayRequestVo vo = new SaobeiMiniPayRequestVo();
//
vo.setSub_appid(appId);
//
vo.setMerchant_no(saobeiConfig.getMerchantNo());
//
vo.setTerminal_id(saobeiConfig.getTerminalId());
//
vo.setAttach(JSONObject.toJSONString(attachVo));
//
vo.setTerminal_trace(BaseUtil.getOrderNo("WXNO"));
//
vo.setTerminal_time(DateUtil.nowDate(Constants.DATE_TIME_FORMAT_NUM));
//
vo.setOrder_body(StrUtil.concat(true,recharge.getRechargeAmount().toString(),"元充值!"));
//
// 订单中使用的是BigDecimal,这里要转为Integer类型
//
vo.setTotal_fee(String.valueOf(recharge.getRechargeAmount().multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue()));
//
vo.setNotify_url(apiDomain + PayConstants.SAOBEI_PAY_NOTIFY_API_URI);
//
vo.setTrade_type(PayConstants.WX_PAY_TRADE_TYPE_JS);
//
vo.setOpen_id(openid);
//
vo.setDevice_no("WEB");
//
return vo;
//
}
}
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