Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Jeepay
Commits
3d882d97
Commit
3d882d97
authored
Nov 19, 2021
by
terrfly
Browse files
商户、应用、服务商配置信息支持直接数据库查询(第三卷);
parent
021f010a
Changes
3
Hide whitespace changes
Inline
Side-by-side
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/wxpay/WxpayRefundService.java
View file @
3d882d97
...
...
@@ -32,6 +32,7 @@ import com.jeequan.jeepay.pay.channel.AbstractRefundService;
import
com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit
;
import
com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayV3Util
;
import
com.jeequan.jeepay.pay.model.MchAppConfigContext
;
import
com.jeequan.jeepay.pay.model.WxServiceWrapper
;
import
com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg
;
import
com.jeequan.jeepay.pay.rqrs.refund.RefundOrderRQ
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -62,8 +63,12 @@ public class WxpayRefundService extends AbstractRefundService {
@Override
public
ChannelRetMsg
refund
(
RefundOrderRQ
bizRQ
,
RefundOrder
refundOrder
,
PayOrder
payOrder
,
MchAppConfigContext
mchAppConfigContext
)
throws
Exception
{
try
{
ChannelRetMsg
channelRetMsg
=
new
ChannelRetMsg
();
if
(
CS
.
PAY_IF_VERSION
.
WX_V2
.
equals
(
mchAppConfigContext
.
getWxServiceWrapper
().
getApiVersion
()))
{
//V2
WxServiceWrapper
wxServiceWrapper
=
configContextQueryService
.
getWxServiceWrapper
(
mchAppConfigContext
);
if
(
CS
.
PAY_IF_VERSION
.
WX_V2
.
equals
(
wxServiceWrapper
.
getApiVersion
()))
{
//V2
WxPayRefundRequest
req
=
new
WxPayRefundRequest
();
...
...
@@ -74,7 +79,7 @@ public class WxpayRefundService extends AbstractRefundService {
req
.
setOutRefundNo
(
refundOrder
.
getRefundOrderId
());
// 退款单号
req
.
setTotalFee
(
payOrder
.
getAmount
().
intValue
());
// 订单总金额
req
.
setRefundFee
(
refundOrder
.
getRefundAmount
().
intValue
());
// 退款金额
WxPayService
wxPayService
=
mchAppConfigContext
.
getW
xServiceWrapper
()
.
getWxPayService
();
WxPayService
wxPayService
=
w
xServiceWrapper
.
getWxPayService
();
setCretPath
(
mchAppConfigContext
,
wxPayService
);
// 证书路径
WxPayRefundResult
result
=
wxPayService
.
refundV2
(
req
);
...
...
@@ -86,7 +91,7 @@ public class WxpayRefundService extends AbstractRefundService {
channelRetMsg
.
setChannelErrCode
(
result
.
getErrCode
());
channelRetMsg
.
setChannelErrMsg
(
WxpayKit
.
appendErrMsg
(
result
.
getReturnMsg
(),
result
.
getErrCodeDes
()));
}
}
else
if
(
CS
.
PAY_IF_VERSION
.
WX_V3
.
equals
(
mchAppConfigContext
.
getW
xServiceWrapper
()
.
getApiVersion
()))
{
//V3
}
else
if
(
CS
.
PAY_IF_VERSION
.
WX_V3
.
equals
(
w
xServiceWrapper
.
getApiVersion
()))
{
//V3
// 微信统一下单请求对象
JSONObject
reqJSON
=
new
JSONObject
();
reqJSON
.
put
(
"out_trade_no"
,
refundOrder
.
getPayOrderId
());
// 订单号
...
...
@@ -97,15 +102,15 @@ public class WxpayRefundService extends AbstractRefundService {
amountJson
.
put
(
"total"
,
payOrder
.
getAmount
());
// 订单总金额
amountJson
.
put
(
"currency"
,
"CNY"
);
// 币种
reqJSON
.
put
(
"amount"
,
amountJson
);
WxPayService
wxPayService
=
mchAppConfigContext
.
getW
xServiceWrapper
()
.
getWxPayService
();
WxPayService
wxPayService
=
w
xServiceWrapper
.
getWxPayService
();
setCretPath
(
mchAppConfigContext
,
wxPayService
);
// 证书路径
if
(
mchAppConfigContext
.
isIsvsubMch
()){
// 特约商户
WxpayIsvsubMchParams
isvsubMchParams
=
mchAppConfigContext
.
getIsvsubMchParamsByIfCode
(
getIfCode
(),
WxpayIsvsubMchParams
.
class
);
WxpayIsvsubMchParams
isvsubMchParams
=
(
WxpayIsvsubMchParams
)
configContextQueryService
.
queryIsvsubMchParams
(
mchAppConfigContext
.
getMchNo
(),
mchAppConfigContext
.
getAppId
(),
getIfCode
()
);
reqJSON
.
put
(
"sub_mchid"
,
isvsubMchParams
.
getSubMchId
());
}
JSONObject
resultJSON
=
WxpayV3Util
.
refundV3
(
reqJSON
,
mchAppConfigContext
.
getW
xServiceWrapper
()
.
getWxPayService
().
getConfig
());
JSONObject
resultJSON
=
WxpayV3Util
.
refundV3
(
reqJSON
,
w
xServiceWrapper
.
getWxPayService
().
getConfig
());
String
status
=
resultJSON
.
getString
(
"status"
);
if
(
"SUCCESS"
.
equals
(
status
)){
// 退款成功
String
refundId
=
resultJSON
.
getString
(
"refund_id"
);
...
...
@@ -139,7 +144,11 @@ public class WxpayRefundService extends AbstractRefundService {
public
ChannelRetMsg
query
(
RefundOrder
refundOrder
,
MchAppConfigContext
mchAppConfigContext
)
throws
Exception
{
try
{
ChannelRetMsg
channelRetMsg
=
new
ChannelRetMsg
();
if
(
CS
.
PAY_IF_VERSION
.
WX_V2
.
equals
(
mchAppConfigContext
.
getWxServiceWrapper
().
getApiVersion
()))
{
//V2
WxServiceWrapper
wxServiceWrapper
=
configContextQueryService
.
getWxServiceWrapper
(
mchAppConfigContext
);
if
(
CS
.
PAY_IF_VERSION
.
WX_V2
.
equals
(
wxServiceWrapper
.
getApiVersion
()))
{
//V2
WxPayRefundQueryRequest
req
=
new
WxPayRefundQueryRequest
();
...
...
@@ -147,7 +156,7 @@ public class WxpayRefundService extends AbstractRefundService {
WxpayKit
.
putApiIsvInfo
(
mchAppConfigContext
,
req
);
req
.
setOutRefundNo
(
refundOrder
.
getRefundOrderId
());
// 退款单号
WxPayService
wxPayService
=
mchAppConfigContext
.
getW
xServiceWrapper
()
.
getWxPayService
();
WxPayService
wxPayService
=
w
xServiceWrapper
.
getWxPayService
();
setCretPath
(
mchAppConfigContext
,
wxPayService
);
// 证书路径
WxPayRefundQueryResult
result
=
wxPayService
.
refundQueryV2
(
req
);
...
...
@@ -158,12 +167,12 @@ public class WxpayRefundService extends AbstractRefundService {
channelRetMsg
.
setChannelErrMsg
(
result
.
getReturnMsg
());
}
}
else
if
(
CS
.
PAY_IF_VERSION
.
WX_V3
.
equals
(
mchAppConfigContext
.
getW
xServiceWrapper
()
.
getApiVersion
()))
{
//V3
WxPayService
wxPayService
=
mchAppConfigContext
.
getW
xServiceWrapper
()
.
getWxPayService
();
}
else
if
(
CS
.
PAY_IF_VERSION
.
WX_V3
.
equals
(
w
xServiceWrapper
.
getApiVersion
()))
{
//V3
WxPayService
wxPayService
=
w
xServiceWrapper
.
getWxPayService
();
setCretPath
(
mchAppConfigContext
,
wxPayService
);
// 证书路径
JSONObject
resultJSON
=
null
;
if
(
mchAppConfigContext
.
isIsvsubMch
())
{
WxpayIsvsubMchParams
isvsubMchParams
=
mchAppConfigContext
.
getIsvsubMchParamsByIfCode
(
getIfCode
(),
WxpayIsvsubMchParams
.
class
);
WxpayIsvsubMchParams
isvsubMchParams
=
(
WxpayIsvsubMchParams
)
configContextQueryService
.
queryIsvsubMchParams
(
mchAppConfigContext
.
getMchNo
(),
mchAppConfigContext
.
getAppId
(),
getIfCode
()
);
wxPayService
.
getConfig
().
setSubMchId
(
isvsubMchParams
.
getSubMchId
());
resultJSON
=
WxpayV3Util
.
refundQueryV3Isv
(
refundOrder
.
getRefundOrderId
(),
wxPayService
.
getConfig
());
}
else
{
...
...
@@ -190,11 +199,11 @@ public class WxpayRefundService extends AbstractRefundService {
private
void
setCretPath
(
MchAppConfigContext
mchAppConfigContext
,
WxPayService
wxPayService
)
{
if
(
mchAppConfigContext
.
isIsvsubMch
()){
// 获取服务商配置信息
WxpayIsvParams
wxpayIsvParams
=
mchAppConfigContext
.
getIsvConfigContext
().
getIsvParamsByIfCode
(
CS
.
IF_CODE
.
WXPAY
,
WxpayIsvParams
.
class
);
WxpayIsvParams
wxpayIsvParams
=
(
WxpayIsvParams
)
configContextQueryService
.
queryIsvParams
(
mchAppConfigContext
.
getMchInfo
().
getIsvNo
(),
CS
.
IF_CODE
.
WXPAY
);
wxPayService
.
getConfig
().
setKeyPath
(
channelCertConfigKitBean
.
getCertFilePath
(
wxpayIsvParams
.
getCert
()));
}
else
{
// 获取商户配置信息
WxpayNormalMchParams
normalMchParams
=
mchAppConfigContext
.
getNormalMchParamsByIfCode
(
CS
.
IF_CODE
.
WXPAY
,
WxpayNormalMchParams
.
class
);
WxpayNormalMchParams
normalMchParams
=
(
WxpayNormalMchParams
)
configContextQueryService
.
queryNormalMchParams
(
mchAppConfigContext
.
getMchNo
(),
mchAppConfigContext
.
getAppId
(),
CS
.
IF_CODE
.
WXPAY
);
wxPayService
.
getConfig
().
setKeyPath
(
channelCertConfigKitBean
.
getCertFilePath
(
normalMchParams
.
getCert
()));
}
}
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/wxpay/payway/WxBar.java
View file @
3d882d97
...
...
@@ -24,6 +24,7 @@ import com.jeequan.jeepay.core.entity.PayOrder;
import
com.jeequan.jeepay.core.exception.BizException
;
import
com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService
;
import
com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit
;
import
com.jeequan.jeepay.pay.model.WxServiceWrapper
;
import
com.jeequan.jeepay.pay.rqrs.AbstractRS
;
import
com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ
;
import
com.jeequan.jeepay.pay.rqrs.payorder.payway.WxBarOrderRQ
;
...
...
@@ -86,7 +87,8 @@ public class WxBar extends WxpayPaymentService {
// 调起上游接口:
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
WxPayService
wxPayService
=
mchAppConfigContext
.
getWxServiceWrapper
().
getWxPayService
();
WxServiceWrapper
wxServiceWrapper
=
configContextQueryService
.
getWxServiceWrapper
(
mchAppConfigContext
);
WxPayService
wxPayService
=
wxServiceWrapper
.
getWxPayService
();
try
{
WxPayMicropayResult
wxPayMicropayResult
=
wxPayService
.
micropay
(
request
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/ApiController.java
View file @
3d882d97
...
...
@@ -19,13 +19,12 @@ import com.alibaba.fastjson.JSONObject;
import
com.jeequan.jeepay.core.constants.CS
;
import
com.jeequan.jeepay.core.ctrls.AbstractCtrl
;
import
com.jeequan.jeepay.core.entity.MchApp
;
import
com.jeequan.jeepay.core.entity.MchInfo
;
import
com.jeequan.jeepay.core.exception.BizException
;
import
com.jeequan.jeepay.core.utils.JeepayKit
;
import
com.jeequan.jeepay.pay.model.MchAppConfigContext
;
import
com.jeequan.jeepay.pay.rqrs.AbstractMchAppRQ
;
import
com.jeequan.jeepay.pay.rqrs.AbstractRQ
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.pay.service.ConfigContext
Query
Service
;
import
com.jeequan.jeepay.pay.service.ValidateService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -40,7 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public
abstract
class
ApiController
extends
AbstractCtrl
{
@Autowired
private
ValidateService
validateService
;
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
/** 获取请求参数并转换为对象,通用验证 **/
...
...
@@ -72,7 +71,7 @@ public abstract class ApiController extends AbstractCtrl {
throw
new
BizException
(
"参数有误!"
);
}
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
mchNo
,
appId
);
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
mchNo
,
appId
);
if
(
mchAppConfigContext
==
null
){
throw
new
BizException
(
"商户或商户应用不存在"
);
...
...
Write
Preview
Supports
Markdown
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