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
ca31cf06
Commit
ca31cf06
authored
Nov 18, 2021
by
terrfly
Browse files
商户、应用、服务商配置信息支持直接数据库查询(第一卷);
parent
30b232b1
Changes
58
Hide whitespace changes
Inline
Side-by-side
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/payorder/ChannelNoticeController.java
View file @
ca31cf06
...
...
@@ -23,6 +23,7 @@ import com.jeequan.jeepay.core.utils.SpringBeansUtil;
import
com.jeequan.jeepay.pay.channel.IChannelNoticeService
;
import
com.jeequan.jeepay.pay.model.MchAppConfigContext
;
import
com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg
;
import
com.jeequan.jeepay.pay.service.ConfigContextQueryService
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.pay.service.PayMchNotifyService
;
import
com.jeequan.jeepay.pay.service.PayOrderProcessService
;
...
...
@@ -51,7 +52,7 @@ import javax.servlet.http.HttpServletRequest;
public
class
ChannelNoticeController
extends
AbstractCtrl
{
@Autowired
private
PayOrderService
payOrderService
;
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
@Autowired
private
PayMchNotifyService
payMchNotifyService
;
@Autowired
private
PayOrderProcessService
payOrderProcessService
;
...
...
@@ -105,7 +106,7 @@ public class ChannelNoticeController extends AbstractCtrl {
}
//查询出商户应用的配置信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
());
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
());
//调起接口的回调判断
ChannelRetMsg
notifyResult
=
payNotifyService
.
doNotice
(
request
,
mutablePair
.
getRight
(),
payOrder
,
mchAppConfigContext
,
IChannelNoticeService
.
NoticeTypeEnum
.
DO_RETURN
);
...
...
@@ -202,7 +203,8 @@ public class ChannelNoticeController extends AbstractCtrl {
}
//查询出商户应用的配置信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
());
MchAppConfigContext
mchAppConfigContext
=
configContextQueryService
.
queryMchInfoAndAppInfo
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
());
//调起接口的回调判断
ChannelRetMsg
notifyResult
=
payNotifyService
.
doNotice
(
request
,
mutablePair
.
getRight
(),
payOrder
,
mchAppConfigContext
,
IChannelNoticeService
.
NoticeTypeEnum
.
DO_NOTIFY
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/payorder/QueryOrderController.java
View file @
ca31cf06
...
...
@@ -21,6 +21,7 @@ import com.jeequan.jeepay.core.model.ApiRes;
import
com.jeequan.jeepay.pay.ctrl.ApiController
;
import
com.jeequan.jeepay.pay.rqrs.payorder.QueryPayOrderRQ
;
import
com.jeequan.jeepay.pay.rqrs.payorder.QueryPayOrderRS
;
import
com.jeequan.jeepay.pay.service.ConfigContextQueryService
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.service.impl.PayOrderService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -41,7 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
public
class
QueryOrderController
extends
ApiController
{
@Autowired
private
PayOrderService
payOrderService
;
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
/**
* 查单接口
...
...
@@ -62,7 +63,7 @@ public class QueryOrderController extends ApiController {
}
QueryPayOrderRS
bizRes
=
QueryPayOrderRS
.
buildByPayOrder
(
payOrder
);
return
ApiRes
.
okWithSign
(
bizRes
,
configContextService
.
get
MchApp
ConfigContext
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getMchApp
().
getAppSecret
());
return
ApiRes
.
okWithSign
(
bizRes
,
configContext
Query
Service
.
query
MchApp
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getAppSecret
());
}
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/payorder/UnifiedOrderController.java
View file @
ca31cf06
...
...
@@ -24,7 +24,7 @@ import com.jeequan.jeepay.core.utils.JeepayKit;
import
com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ
;
import
com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRS
;
import
com.jeequan.jeepay.pay.rqrs.payorder.payway.AutoBarOrderRQ
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.pay.service.ConfigContext
Query
Service
;
import
com.jeequan.jeepay.service.impl.PayWayService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.RestController;
public
class
UnifiedOrderController
extends
AbstractPayOrderController
{
@Autowired
private
PayWayService
payWayService
;
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
/**
* 统一下单接口
...
...
@@ -75,7 +75,7 @@ public class UnifiedOrderController extends AbstractPayOrderController {
res
.
setPayData
(
bizRes
.
buildPayData
());
}
return
ApiRes
.
okWithSign
(
res
,
configContextService
.
get
MchApp
ConfigContext
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getMchApp
().
getAppSecret
());
return
ApiRes
.
okWithSign
(
res
,
configContext
Query
Service
.
query
MchApp
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getAppSecret
());
}
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/qr/ChannelUserIdController.java
View file @
ca31cf06
...
...
@@ -26,6 +26,7 @@ import com.jeequan.jeepay.pay.channel.IChannelUserService;
import
com.jeequan.jeepay.pay.ctrl.payorder.AbstractPayOrderController
;
import
com.jeequan.jeepay.pay.model.MchAppConfigContext
;
import
com.jeequan.jeepay.pay.rqrs.ChannelUserIdRQ
;
import
com.jeequan.jeepay.pay.service.ConfigContextQueryService
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.service.impl.SysConfigService
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -45,7 +46,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"/api/channelUserId"
)
public
class
ChannelUserIdController
extends
AbstractPayOrderController
{
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
@Autowired
private
SysConfigService
sysConfigService
;
/** 重定向到微信地址 **/
...
...
@@ -79,7 +80,7 @@ public class ChannelUserIdController extends AbstractPayOrderController {
String
callbackUrl
=
sysConfigService
.
getDBApplicationConfig
().
genMchChannelUserIdApiOauth2RedirectUrlEncode
(
jsonObject
);
//获取商户配置信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
rq
.
getMchNo
(),
rq
.
getAppId
());
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
rq
.
getMchNo
(),
rq
.
getAppId
());
String
redirectUrl
=
channelUserService
.
buildUserRedirectUrl
(
callbackUrl
,
mchAppConfigContext
);
response
.
sendRedirect
(
redirectUrl
);
...
...
@@ -106,7 +107,7 @@ public class ChannelUserIdController extends AbstractPayOrderController {
}
//获取商户配置信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
mchNo
,
appId
);
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
mchNo
,
appId
);
//获取渠道用户ID
String
channelUserId
=
channelUserService
.
getChannelUserId
(
getReqParamJSON
(),
mchAppConfigContext
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/qr/QrCashierController.java
View file @
ca31cf06
...
...
@@ -26,6 +26,7 @@ import com.jeequan.jeepay.pay.channel.IChannelUserService;
import
com.jeequan.jeepay.pay.ctrl.payorder.AbstractPayOrderController
;
import
com.jeequan.jeepay.pay.rqrs.payorder.payway.AliJsapiOrderRQ
;
import
com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRQ
;
import
com.jeequan.jeepay.pay.service.ConfigContextQueryService
;
import
com.jeequan.jeepay.pay.service.PayMchNotifyService
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.pay.model.MchAppConfigContext
;
...
...
@@ -48,7 +49,7 @@ import org.springframework.web.bind.annotation.RestController;
public
class
QrCashierController
extends
AbstractPayOrderController
{
@Autowired
private
PayOrderService
payOrderService
;
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
@Autowired
private
SysConfigService
sysConfigService
;
@Autowired
private
PayMchNotifyService
payMchNotifyService
;
...
...
@@ -65,7 +66,7 @@ public class QrCashierController extends AbstractPayOrderController {
String
redirectUrlEncode
=
sysConfigService
.
getDBApplicationConfig
().
genOauth2RedirectUrlEncode
(
payOrder
.
getPayOrderId
());
//获取商户配置信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
());
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
());
//获取接口并返回数据
IChannelUserService
channelUserService
=
getServiceByWayCode
(
getWayCode
(),
"ChannelUserService"
,
IChannelUserService
.
class
);
...
...
@@ -85,7 +86,7 @@ public class QrCashierController extends AbstractPayOrderController {
String
wayCode
=
getWayCode
();
//获取商户配置信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
());
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
());
IChannelUserService
channelUserService
=
getServiceByWayCode
(
wayCode
,
"ChannelUserService"
,
IChannelUserService
.
class
);
return
ApiRes
.
ok
(
channelUserService
.
getChannelUserId
(
getReqParamJSON
(),
mchAppConfigContext
));
...
...
@@ -106,7 +107,7 @@ public class QrCashierController extends AbstractPayOrderController {
resOrder
.
setMchOrderNo
(
payOrder
.
getMchOrderNo
());
resOrder
.
setMchName
(
payOrder
.
getMchName
());
resOrder
.
setAmount
(
payOrder
.
getAmount
());
resOrder
.
setReturnUrl
(
payMchNotifyService
.
createReturnUrl
(
payOrder
,
configContextService
.
getMchAppConfigContext
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
()).
getMchApp
().
getAppSecret
()));
resOrder
.
setReturnUrl
(
payMchNotifyService
.
createReturnUrl
(
payOrder
,
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
()).
getMchApp
().
getAppSecret
()));
return
ApiRes
.
ok
(
resOrder
);
}
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/refund/ChannelRefundNoticeController.java
View file @
ca31cf06
...
...
@@ -23,6 +23,7 @@ import com.jeequan.jeepay.core.utils.SpringBeansUtil;
import
com.jeequan.jeepay.pay.channel.IChannelRefundNoticeService
;
import
com.jeequan.jeepay.pay.model.MchAppConfigContext
;
import
com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg
;
import
com.jeequan.jeepay.pay.service.ConfigContextQueryService
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.pay.service.RefundOrderProcessService
;
import
com.jeequan.jeepay.service.impl.RefundOrderService
;
...
...
@@ -50,7 +51,7 @@ import javax.servlet.http.HttpServletRequest;
public
class
ChannelRefundNoticeController
extends
AbstractCtrl
{
@Autowired
private
RefundOrderService
refundOrderService
;
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
@Autowired
private
RefundOrderProcessService
refundOrderProcessService
;
/** 异步回调入口 **/
...
...
@@ -104,7 +105,7 @@ public class ChannelRefundNoticeController extends AbstractCtrl {
}
//查询出商户应用的配置信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
refundOrder
.
getMchNo
(),
refundOrder
.
getAppId
());
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
refundOrder
.
getMchNo
(),
refundOrder
.
getAppId
());
//调起接口的回调判断
ChannelRetMsg
notifyResult
=
refundNotifyService
.
doNotice
(
request
,
mutablePair
.
getRight
(),
refundOrder
,
mchAppConfigContext
,
IChannelRefundNoticeService
.
NoticeTypeEnum
.
DO_NOTIFY
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/refund/QueryRefundOrderController.java
View file @
ca31cf06
...
...
@@ -21,6 +21,7 @@ import com.jeequan.jeepay.core.model.ApiRes;
import
com.jeequan.jeepay.pay.ctrl.ApiController
;
import
com.jeequan.jeepay.pay.rqrs.refund.QueryRefundOrderRQ
;
import
com.jeequan.jeepay.pay.rqrs.refund.QueryRefundOrderRS
;
import
com.jeequan.jeepay.pay.service.ConfigContextQueryService
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.service.impl.RefundOrderService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -41,7 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
public
class
QueryRefundOrderController
extends
ApiController
{
@Autowired
private
RefundOrderService
refundOrderService
;
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
/**
* 查单接口
...
...
@@ -62,6 +63,6 @@ public class QueryRefundOrderController extends ApiController {
}
QueryRefundOrderRS
bizRes
=
QueryRefundOrderRS
.
buildByRefundOrder
(
refundOrder
);
return
ApiRes
.
okWithSign
(
bizRes
,
configContextService
.
get
MchApp
ConfigContext
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getMchApp
().
getAppSecret
());
return
ApiRes
.
okWithSign
(
bizRes
,
configContext
Query
Service
.
query
MchApp
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getAppSecret
());
}
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/refund/RefundOrderController.java
View file @
ca31cf06
...
...
@@ -32,6 +32,7 @@ import com.jeequan.jeepay.pay.model.MchAppConfigContext;
import
com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg
;
import
com.jeequan.jeepay.pay.rqrs.refund.RefundOrderRQ
;
import
com.jeequan.jeepay.pay.rqrs.refund.RefundOrderRS
;
import
com.jeequan.jeepay.pay.service.ConfigContextQueryService
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.pay.service.PayMchNotifyService
;
import
com.jeequan.jeepay.service.impl.PayOrderService
;
...
...
@@ -57,8 +58,9 @@ public class RefundOrderController extends ApiController {
@Autowired
private
PayOrderService
payOrderService
;
@Autowired
private
RefundOrderService
refundOrderService
;
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
PayMchNotifyService
payMchNotifyService
;
@Autowired
private
ConfigContextQueryService
configContextQueryService
;
/** 申请退款 **/
@PostMapping
(
"/api/refund/refundOrder"
)
...
...
@@ -120,7 +122,7 @@ public class RefundOrderController extends ApiController {
}
//获取支付参数 (缓存数据) 和 商户信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
mchNo
,
appId
);
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
mchNo
,
appId
);
if
(
mchAppConfigContext
==
null
){
throw
new
BizException
(
"获取商户应用信息失败"
);
}
...
...
@@ -148,7 +150,7 @@ public class RefundOrderController extends ApiController {
this
.
processChannelMsg
(
channelRetMsg
,
refundOrder
);
RefundOrderRS
bizRes
=
RefundOrderRS
.
buildByRefundOrder
(
refundOrder
);
return
ApiRes
.
okWithSign
(
bizRes
,
configContextService
.
get
MchApp
ConfigContext
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getMchApp
().
getAppSecret
());
return
ApiRes
.
okWithSign
(
bizRes
,
configContext
Query
Service
.
query
MchApp
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getAppSecret
());
}
catch
(
BizException
e
)
{
...
...
@@ -164,7 +166,7 @@ public class RefundOrderController extends ApiController {
}
RefundOrderRS
bizRes
=
RefundOrderRS
.
buildByRefundOrder
(
refundOrder
);
return
ApiRes
.
okWithSign
(
bizRes
,
configContextService
.
get
MchApp
ConfigContext
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getMchApp
().
getAppSecret
());
return
ApiRes
.
okWithSign
(
bizRes
,
configContext
Query
Service
.
query
MchApp
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getAppSecret
());
}
catch
(
Exception
e
)
{
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/transfer/QueryTransferOrderController.java
View file @
ca31cf06
...
...
@@ -21,7 +21,7 @@ import com.jeequan.jeepay.core.model.ApiRes;
import
com.jeequan.jeepay.pay.ctrl.ApiController
;
import
com.jeequan.jeepay.pay.rqrs.transfer.QueryTransferOrderRQ
;
import
com.jeequan.jeepay.pay.rqrs.transfer.QueryTransferOrderRS
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.pay.service.ConfigContext
Query
Service
;
import
com.jeequan.jeepay.service.impl.TransferOrderService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -41,7 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
public
class
QueryTransferOrderController
extends
ApiController
{
@Autowired
private
TransferOrderService
transferOrderService
;
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
/**
* 查单接口
...
...
@@ -62,6 +62,6 @@ public class QueryTransferOrderController extends ApiController {
}
QueryTransferOrderRS
bizRes
=
QueryTransferOrderRS
.
buildByRecord
(
refundOrder
);
return
ApiRes
.
okWithSign
(
bizRes
,
configContextService
.
get
MchApp
ConfigContext
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getMchApp
().
getAppSecret
());
return
ApiRes
.
okWithSign
(
bizRes
,
configContext
Query
Service
.
query
MchApp
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getAppSecret
());
}
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/transfer/TransferOrderController.java
View file @
ca31cf06
...
...
@@ -30,6 +30,7 @@ import com.jeequan.jeepay.pay.model.MchAppConfigContext;
import
com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg
;
import
com.jeequan.jeepay.pay.rqrs.transfer.TransferOrderRQ
;
import
com.jeequan.jeepay.pay.rqrs.transfer.TransferOrderRS
;
import
com.jeequan.jeepay.pay.service.ConfigContextQueryService
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.pay.service.PayMchNotifyService
;
import
com.jeequan.jeepay.service.impl.PayInterfaceConfigService
;
...
...
@@ -53,7 +54,7 @@ import java.util.Date;
@RestController
public
class
TransferOrderController
extends
ApiController
{
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
@Autowired
private
TransferOrderService
transferOrderService
;
@Autowired
private
PayInterfaceConfigService
payInterfaceConfigService
;
@Autowired
private
PayMchNotifyService
payMchNotifyService
;
...
...
@@ -86,7 +87,7 @@ public class TransferOrderController extends ApiController {
}
// 商户配置信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
mchNo
,
appId
);
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
mchNo
,
appId
);
if
(
mchAppConfigContext
==
null
){
throw
new
BizException
(
"获取商户应用信息失败"
);
}
...
...
@@ -142,7 +143,7 @@ public class TransferOrderController extends ApiController {
}
TransferOrderRS
bizRes
=
TransferOrderRS
.
buildByRecord
(
transferOrder
);
return
ApiRes
.
okWithSign
(
bizRes
,
configContextService
.
get
MchApp
ConfigContext
(
bizRQ
.
getMchNo
(),
bizRQ
.
getAppId
()).
getMchApp
().
getAppSecret
());
return
ApiRes
.
okWithSign
(
bizRes
,
configContext
Query
Service
.
query
MchApp
(
bizRQ
.
getMchNo
(),
bizRQ
.
getAppId
()).
getAppSecret
());
}
catch
(
Exception
e
)
{
log
.
error
(
"系统异常:{}"
,
e
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/model/AlipayClientWrapper.java
View file @
ca31cf06
...
...
@@ -15,12 +15,14 @@
*/
package
com.jeequan.jeepay.pay.model
;
import
com.alipay.api.AlipayApiException
;
import
com.alipay.api.AlipayClient
;
import
com.alipay.api.AlipayRequest
;
import
com.alipay.api.AlipayResponse
;
import
com.alipay.api.*
;
import
com.jeequan.jeepay.core.constants.CS
;
import
com.jeequan.jeepay.core.model.params.alipay.AlipayConfig
;
import
com.jeequan.jeepay.core.model.params.alipay.AlipayIsvParams
;
import
com.jeequan.jeepay.core.model.params.alipay.AlipayNormalMchParams
;
import
com.jeequan.jeepay.core.utils.SpringBeansUtil
;
import
com.jeequan.jeepay.pay.exception.ChannelException
;
import
com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -71,5 +73,104 @@ public class AlipayClientWrapper {
throw
ChannelException
.
sysError
(
"调用支付宝client服务异常"
);
}
}
/*
* 构建支付宝client 包装类
*
* @author terrfly
* @site https://www.jeequan.com
* @date 2021/6/8 17:46
*/
public
static
AlipayClientWrapper
buildAlipayClientWrapper
(
Byte
useCert
,
Byte
sandbox
,
String
appId
,
String
privateKey
,
String
alipayPublicKey
,
String
signType
,
String
appCert
,
String
alipayPublicCert
,
String
alipayRootCert
){
//避免空值
sandbox
=
sandbox
==
null
?
CS
.
NO
:
sandbox
;
AlipayClient
alipayClient
=
null
;
if
(
useCert
!=
null
&&
useCert
==
CS
.
YES
){
//证书的方式
ChannelCertConfigKitBean
channelCertConfigKitBean
=
SpringBeansUtil
.
getBean
(
ChannelCertConfigKitBean
.
class
);
CertAlipayRequest
certAlipayRequest
=
new
CertAlipayRequest
();
certAlipayRequest
.
setServerUrl
(
sandbox
==
CS
.
YES
?
com
.
jeequan
.
jeepay
.
core
.
model
.
params
.
alipay
.
AlipayConfig
.
SANDBOX_SERVER_URL
:
com
.
jeequan
.
jeepay
.
core
.
model
.
params
.
alipay
.
AlipayConfig
.
PROD_SERVER_URL
);
certAlipayRequest
.
setAppId
(
appId
);
certAlipayRequest
.
setPrivateKey
(
privateKey
);
certAlipayRequest
.
setFormat
(
com
.
jeequan
.
jeepay
.
core
.
model
.
params
.
alipay
.
AlipayConfig
.
FORMAT
);
certAlipayRequest
.
setCharset
(
com
.
jeequan
.
jeepay
.
core
.
model
.
params
.
alipay
.
AlipayConfig
.
CHARSET
);
certAlipayRequest
.
setSignType
(
signType
);
certAlipayRequest
.
setCertPath
(
channelCertConfigKitBean
.
getCertFilePath
(
appCert
));
certAlipayRequest
.
setAlipayPublicCertPath
(
channelCertConfigKitBean
.
getCertFilePath
(
alipayPublicCert
));
certAlipayRequest
.
setRootCertPath
(
channelCertConfigKitBean
.
getCertFilePath
(
alipayRootCert
));
try
{
alipayClient
=
new
DefaultAlipayClient
(
certAlipayRequest
);
}
catch
(
AlipayApiException
e
)
{
log
.
error
(
"error"
,
e
);
alipayClient
=
null
;
}
}
else
{
alipayClient
=
new
DefaultAlipayClient
(
sandbox
==
CS
.
YES
?
com
.
jeequan
.
jeepay
.
core
.
model
.
params
.
alipay
.
AlipayConfig
.
SANDBOX_SERVER_URL
:
com
.
jeequan
.
jeepay
.
core
.
model
.
params
.
alipay
.
AlipayConfig
.
PROD_SERVER_URL
,
appId
,
privateKey
,
com
.
jeequan
.
jeepay
.
core
.
model
.
params
.
alipay
.
AlipayConfig
.
FORMAT
,
AlipayConfig
.
CHARSET
,
alipayPublicKey
,
signType
);
}
return
new
AlipayClientWrapper
(
useCert
,
alipayClient
);
}
public
static
AlipayClientWrapper
buildAlipayClientWrapper
(
AlipayIsvParams
alipayParams
){
return
buildAlipayClientWrapper
(
alipayParams
.
getUseCert
(),
alipayParams
.
getSandbox
(),
alipayParams
.
getAppId
(),
alipayParams
.
getPrivateKey
(),
alipayParams
.
getAlipayPublicKey
(),
alipayParams
.
getSignType
(),
alipayParams
.
getAppPublicCert
(),
alipayParams
.
getAlipayPublicCert
(),
alipayParams
.
getAlipayRootCert
()
);
}
public
static
AlipayClientWrapper
buildAlipayClientWrapper
(
AlipayNormalMchParams
alipayParams
){
return
buildAlipayClientWrapper
(
alipayParams
.
getUseCert
(),
alipayParams
.
getSandbox
(),
alipayParams
.
getAppId
(),
alipayParams
.
getPrivateKey
(),
alipayParams
.
getAlipayPublicKey
(),
alipayParams
.
getSignType
(),
alipayParams
.
getAppPublicCert
(),
alipayParams
.
getAlipayPublicCert
(),
alipayParams
.
getAlipayRootCert
()
);
}
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/model/WxServiceWrapper.java
View file @
ca31cf06
...
...
@@ -15,10 +15,21 @@
*/
package
com.jeequan.jeepay.pay.model
;
import
com.github.binarywang.wxpay.config.WxPayConfig
;
import
com.github.binarywang.wxpay.constant.WxPayConstants
;
import
com.github.binarywang.wxpay.service.WxPayService
;
import
com.github.binarywang.wxpay.service.impl.WxPayServiceImpl
;
import
com.jeequan.jeepay.core.constants.CS
;
import
com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvParams
;
import
com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams
;
import
com.jeequan.jeepay.core.utils.SpringBeansUtil
;
import
com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.api.impl.WxMpServiceImpl
;
import
me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl
;
import
org.apache.commons.lang3.StringUtils
;
/*
* wxService 包装类
...
...
@@ -40,4 +51,61 @@ public class WxServiceWrapper {
/** 缓存 wxJavaService 对象 **/
private
WxMpService
wxMpService
;
public
static
WxServiceWrapper
buildWxServiceWrapper
(
String
mchId
,
String
appId
,
String
appSecret
,
String
mchKey
,
String
apiVersion
,
String
apiV3Key
,
String
serialNo
,
String
cert
,
String
apiClientKey
){
WxPayConfig
wxPayConfig
=
new
WxPayConfig
();
wxPayConfig
.
setMchId
(
mchId
);
wxPayConfig
.
setAppId
(
appId
);
wxPayConfig
.
setMchKey
(
mchKey
);
if
(
CS
.
PAY_IF_VERSION
.
WX_V2
.
equals
(
apiVersion
))
{
// 微信API V2
wxPayConfig
.
setSignType
(
WxPayConstants
.
SignType
.
MD5
);
ChannelCertConfigKitBean
channelCertConfigKitBean
=
SpringBeansUtil
.
getBean
(
ChannelCertConfigKitBean
.
class
);
// api证书。
if
(
StringUtils
.
isNotBlank
(
cert
)){
wxPayConfig
.
setKeyPath
(
channelCertConfigKitBean
.
getCertFilePath
(
cert
));
}
}
else
if
(
CS
.
PAY_IF_VERSION
.
WX_V3
.
equals
(
apiVersion
))
{
// 微信API V3
ChannelCertConfigKitBean
channelCertConfigKitBean
=
SpringBeansUtil
.
getBean
(
ChannelCertConfigKitBean
.
class
);
wxPayConfig
.
setApiV3Key
(
apiV3Key
);
wxPayConfig
.
setCertSerialNo
(
serialNo
);
wxPayConfig
.
setPrivateCertPath
(
channelCertConfigKitBean
.
getCertFilePath
(
cert
));
wxPayConfig
.
setPrivateKeyPath
(
channelCertConfigKitBean
.
getCertFilePath
(
apiClientKey
));
}
WxPayService
wxPayService
=
new
WxPayServiceImpl
();
wxPayService
.
setConfig
(
wxPayConfig
);
//微信配置信息
WxMpDefaultConfigImpl
wxMpConfigStorage
=
new
WxMpDefaultConfigImpl
();
wxMpConfigStorage
.
setAppId
(
appId
);
wxMpConfigStorage
.
setSecret
(
appSecret
);
WxMpService
wxMpService
=
new
WxMpServiceImpl
();
wxMpService
.
setWxMpConfigStorage
(
wxMpConfigStorage
);
//微信配置信息
return
new
WxServiceWrapper
(
apiVersion
,
wxPayService
,
wxMpService
);
}
public
static
WxServiceWrapper
buildWxServiceWrapper
(
WxpayIsvParams
wxpayParams
){
//放置 wxJavaService
return
buildWxServiceWrapper
(
wxpayParams
.
getMchId
(),
wxpayParams
.
getAppId
(),
wxpayParams
.
getAppSecret
(),
wxpayParams
.
getKey
(),
wxpayParams
.
getApiVersion
(),
wxpayParams
.
getApiV3Key
(),
wxpayParams
.
getSerialNo
(),
wxpayParams
.
getCert
(),
wxpayParams
.
getApiClientKey
());
}
public
static
WxServiceWrapper
buildWxServiceWrapper
(
WxpayNormalMchParams
wxpayParams
){
//放置 wxJavaService
return
buildWxServiceWrapper
(
wxpayParams
.
getMchId
(),
wxpayParams
.
getAppId
(),
wxpayParams
.
getAppSecret
(),
wxpayParams
.
getKey
(),
wxpayParams
.
getApiVersion
(),
wxpayParams
.
getApiV3Key
(),
wxpayParams
.
getSerialNo
(),
wxpayParams
.
getCert
(),
wxpayParams
.
getApiClientKey
());
}
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/service/ChannelOrderReissueService.java
View file @
ca31cf06
...
...
@@ -23,9 +23,7 @@ import com.jeequan.jeepay.pay.channel.IRefundService;
import
com.jeequan.jeepay.pay.model.MchAppConfigContext
;
import
com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg
;
import
com.jeequan.jeepay.service.impl.PayOrderService
;
import
com.jeequan.jeepay.service.impl.RefundOrderService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -41,11 +39,9 @@ import org.springframework.stereotype.Service;
@Slf4j
public
class
ChannelOrderReissueService
{
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
@Autowired
private
PayOrderService
payOrderService
;
@Autowired
private
RefundOrderService
refundOrderService
;
@Autowired
private
PayOrderProcessService
payOrderProcessService
;
@Autowired
private
PayMchNotifyService
payMchNotifyService
;
@Autowired
private
RefundOrderProcessService
refundOrderProcessService
;
...
...
@@ -66,7 +62,7 @@ public class ChannelOrderReissueService {
}
//查询出商户应用的配置信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
());
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
());
ChannelRetMsg
channelRetMsg
=
queryService
.
query
(
payOrder
,
mchAppConfigContext
);
if
(
channelRetMsg
==
null
){
...
...
@@ -116,7 +112,7 @@ public class ChannelOrderReissueService {
}
//查询出商户应用的配置信息
MchAppConfigContext
mchAppConfigContext
=
configContextService
.
getMchAppConfigContext
(
refundOrder
.
getMchNo
(),
refundOrder
.
getAppId
());
MchAppConfigContext
mchAppConfigContext
=
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
refundOrder
.
getMchNo
(),
refundOrder
.
getAppId
());
ChannelRetMsg
channelRetMsg
=
queryService
.
query
(
refundOrder
,
mchAppConfigContext
);
if
(
channelRetMsg
==
null
){
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/service/ConfigContextQueryService.java
0 → 100644
View file @
ca31cf06
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.jeequan.jeepay.pay.service
;
import
com.alipay.api.AlipayApiException
;
import
com.alipay.api.AlipayClient
;
import
com.alipay.api.CertAlipayRequest
;
import
com.alipay.api.DefaultAlipayClient
;
import
com.github.binarywang.wxpay.config.WxPayConfig
;
import
com.github.binarywang.wxpay.constant.WxPayConstants
;
import
com.github.binarywang.wxpay.service.WxPayService
;
import
com.github.binarywang.wxpay.service.impl.WxPayServiceImpl
;
import
com.jeequan.jeepay.core.constants.CS
;
import
com.jeequan.jeepay.core.entity.IsvInfo
;
import
com.jeequan.jeepay.core.entity.MchApp
;
import
com.jeequan.jeepay.core.entity.MchInfo
;
import
com.jeequan.jeepay.core.entity.PayInterfaceConfig
;
import
com.jeequan.jeepay.core.model.params.IsvParams
;
import
com.jeequan.jeepay.core.model.params.IsvsubMchParams
;
import
com.jeequan.jeepay.core.model.params.NormalMchParams
;
import
com.jeequan.jeepay.core.model.params.alipay.AlipayConfig
;
import
com.jeequan.jeepay.core.model.params.alipay.AlipayIsvParams
;
import
com.jeequan.jeepay.core.model.params.alipay.AlipayNormalMchParams
;
import
com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvParams
;
import
com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams
;
import
com.jeequan.jeepay.pay.model.*
;
import
com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean
;
import
com.jeequan.jeepay.service.impl.IsvInfoService
;
import
com.jeequan.jeepay.service.impl.MchAppService
;
import
com.jeequan.jeepay.service.impl.MchInfoService
;
import
com.jeequan.jeepay.service.impl.PayInterfaceConfigService
;
import
lombok.extern.slf4j.Slf4j
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.api.impl.WxMpServiceImpl
;
import
me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
/*
* 配置信息查询服务 (兼容 缓存 和 直接查询方式)
*
* @author terrfly
* @site https://www.jeequan.com
* @date 2021/11/18 14:41
*/
@Slf4j
@Service
public
class
ConfigContextQueryService
{
@Autowired
ConfigContextService
configContextService
;
@Autowired
private
MchInfoService
mchInfoService
;
@Autowired
private
MchAppService
mchAppService
;
@Autowired
private
PayInterfaceConfigService
payInterfaceConfigService
;
private
boolean
isCache
(){
return
false
;
}
public
MchApp
queryMchApp
(
String
mchNo
,
String
mchAppId
){
if
(
isCache
()){
return
configContextService
.
getMchAppConfigContext
(
mchNo
,
mchAppId
).
getMchApp
();
}
return
mchAppService
.
getOneByMch
(
mchNo
,
mchAppId
);
}
public
MchAppConfigContext
queryMchInfoAndAppInfo
(
String
mchNo
,
String
mchAppId
){
if
(
isCache
()){
return
configContextService
.
getMchAppConfigContext
(
mchNo
,
mchAppId
);
}
MchInfo
mchInfo
=
mchInfoService
.
getById
(
mchNo
);
MchApp
mchApp
=
queryMchApp
(
mchNo
,
mchAppId
);
if
(
mchInfo
==
null
||
mchApp
==
null
){
return
null
;
}
MchAppConfigContext
result
=
new
MchAppConfigContext
();
result
.
setMchInfo
(
mchInfo
);
result
.
setMchNo
(
mchNo
);
result
.
setMchType
(
mchInfo
.
getType
());
result
.
setMchApp
(
mchApp
);
result
.
setAppId
(
mchAppId
);
return
result
;
}
public
NormalMchParams
queryNormalMchParams
(
String
mchNo
,
String
mchAppId
,
String
ifCode
){
if
(
isCache
()){
return
configContextService
.
getMchAppConfigContext
(
mchNo
,
mchAppId
).
getNormalMchParamsByIfCode
(
ifCode
);
}
// 查询商户的所有支持的参数配置
PayInterfaceConfig
payInterfaceConfig
=
payInterfaceConfigService
.
getOne
(
PayInterfaceConfig
.
gw
()
.
select
(
PayInterfaceConfig:
:
getIfCode
,
PayInterfaceConfig:
:
getIfParams
)
.
eq
(
PayInterfaceConfig:
:
getState
,
CS
.
YES
)
.
eq
(
PayInterfaceConfig:
:
getInfoType
,
CS
.
INFO_TYPE_MCH_APP
)
.
eq
(
PayInterfaceConfig:
:
getInfoId
,
mchAppId
)
.
eq
(
PayInterfaceConfig:
:
getIfCode
,
ifCode
)
);
if
(
payInterfaceConfig
==
null
){
return
null
;
}
return
NormalMchParams
.
factory
(
payInterfaceConfig
.
getIfCode
(),
payInterfaceConfig
.
getIfParams
());
}
public
IsvsubMchParams
queryIsvsubMchParams
(
String
mchNo
,
String
mchAppId
,
String
ifCode
){
if
(
isCache
()){
return
configContextService
.
getMchAppConfigContext
(
mchNo
,
mchAppId
).
getIsvsubMchParamsByIfCode
(
ifCode
);
}
// 查询商户的所有支持的参数配置
PayInterfaceConfig
payInterfaceConfig
=
payInterfaceConfigService
.
getOne
(
PayInterfaceConfig
.
gw
()
.
select
(
PayInterfaceConfig:
:
getIfCode
,
PayInterfaceConfig:
:
getIfParams
)
.
eq
(
PayInterfaceConfig:
:
getState
,
CS
.
YES
)
.
eq
(
PayInterfaceConfig:
:
getInfoType
,
CS
.
INFO_TYPE_MCH_APP
)
.
eq
(
PayInterfaceConfig:
:
getInfoId
,
mchAppId
)
.
eq
(
PayInterfaceConfig:
:
getIfCode
,
ifCode
)
);
if
(
payInterfaceConfig
==
null
){
return
null
;
}
return
IsvsubMchParams
.
factory
(
payInterfaceConfig
.
getIfCode
(),
payInterfaceConfig
.
getIfParams
());
}
public
IsvParams
queryIsvParams
(
String
isvNo
,
String
ifCode
){
if
(
isCache
()){
IsvConfigContext
isvConfigContext
=
configContextService
.
getIsvConfigContext
(
isvNo
);
return
isvConfigContext
==
null
?
null
:
isvConfigContext
.
getIsvParamsByIfCode
(
ifCode
);
}
// 查询商户的所有支持的参数配置
PayInterfaceConfig
payInterfaceConfig
=
payInterfaceConfigService
.
getOne
(
PayInterfaceConfig
.
gw
()
.
select
(
PayInterfaceConfig:
:
getIfCode
,
PayInterfaceConfig:
:
getIfParams
)
.
eq
(
PayInterfaceConfig:
:
getState
,
CS
.
YES
)
.
eq
(
PayInterfaceConfig:
:
getInfoType
,
CS
.
INFO_TYPE_ISV
)
.
eq
(
PayInterfaceConfig:
:
getInfoId
,
isvNo
)
.
eq
(
PayInterfaceConfig:
:
getIfCode
,
ifCode
)
);
if
(
payInterfaceConfig
==
null
){
return
null
;
}
return
IsvParams
.
factory
(
payInterfaceConfig
.
getIfCode
(),
payInterfaceConfig
.
getIfParams
());
}
public
AlipayClientWrapper
getAlipayClientWrapper
(
MchAppConfigContext
mchAppConfigContext
){
if
(
isCache
()){
return
configContextService
.
getMchAppConfigContext
(
mchAppConfigContext
.
getMchNo
(),
mchAppConfigContext
.
getAppId
()).
getAlipayClientWrapper
();
}
if
(
mchAppConfigContext
.
isIsvsubMch
()){
AlipayIsvParams
alipayParams
=
(
AlipayIsvParams
)
queryIsvParams
(
mchAppConfigContext
.
getMchInfo
().
getIsvNo
(),
CS
.
IF_CODE
.
ALIPAY
);
return
AlipayClientWrapper
.
buildAlipayClientWrapper
(
alipayParams
);
}
else
{
AlipayNormalMchParams
alipayParams
=
(
AlipayNormalMchParams
)
queryNormalMchParams
(
mchAppConfigContext
.
getMchNo
(),
mchAppConfigContext
.
getAppId
(),
CS
.
IF_CODE
.
ALIPAY
);
return
AlipayClientWrapper
.
buildAlipayClientWrapper
(
alipayParams
);
}
}
public
WxServiceWrapper
getWxServiceWrapper
(
MchAppConfigContext
mchAppConfigContext
){
if
(
isCache
()){
return
configContextService
.
getMchAppConfigContext
(
mchAppConfigContext
.
getMchNo
(),
mchAppConfigContext
.
getAppId
()).
getWxServiceWrapper
();
}
if
(
mchAppConfigContext
.
isIsvsubMch
()){
WxpayIsvParams
wxParams
=
(
WxpayIsvParams
)
queryIsvParams
(
mchAppConfigContext
.
getMchInfo
().
getIsvNo
(),
CS
.
IF_CODE
.
WXPAY
);
return
WxServiceWrapper
.
buildWxServiceWrapper
(
wxParams
);
}
else
{
WxpayNormalMchParams
wxParams
=
(
WxpayNormalMchParams
)
queryNormalMchParams
(
mchAppConfigContext
.
getMchNo
(),
mchAppConfigContext
.
getAppId
(),
CS
.
IF_CODE
.
WXPAY
);
return
WxServiceWrapper
.
buildWxServiceWrapper
(
wxParams
);
}
}
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/service/ConfigContextService.java
View file @
ca31cf06
...
...
@@ -15,14 +15,6 @@
*/
package
com.jeequan.jeepay.pay.service
;
import
com.alipay.api.AlipayApiException
;
import
com.alipay.api.AlipayClient
;
import
com.alipay.api.CertAlipayRequest
;
import
com.alipay.api.DefaultAlipayClient
;
import
com.github.binarywang.wxpay.config.WxPayConfig
;
import
com.github.binarywang.wxpay.constant.WxPayConstants
;
import
com.github.binarywang.wxpay.service.WxPayService
;
import
com.github.binarywang.wxpay.service.impl.WxPayServiceImpl
;
import
com.jeequan.jeepay.core.constants.CS
;
import
com.jeequan.jeepay.core.entity.IsvInfo
;
import
com.jeequan.jeepay.core.entity.MchApp
;
...
...
@@ -31,22 +23,16 @@ import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
import
com.jeequan.jeepay.core.model.params.IsvParams
;
import
com.jeequan.jeepay.core.model.params.IsvsubMchParams
;
import
com.jeequan.jeepay.core.model.params.NormalMchParams
;
import
com.jeequan.jeepay.core.model.params.alipay.AlipayConfig
;
import
com.jeequan.jeepay.core.model.params.alipay.AlipayIsvParams
;
import
com.jeequan.jeepay.core.model.params.alipay.AlipayNormalMchParams
;
import
com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvParams
;
import
com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams
;
import
com.jeequan.jeepay.pay.model.*
;
import
com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean
;
import
com.jeequan.jeepay.service.impl.IsvInfoService
;
import
com.jeequan.jeepay.service.impl.MchAppService
;
import
com.jeequan.jeepay.service.impl.MchInfoService
;
import
com.jeequan.jeepay.service.impl.PayInterfaceConfigService
;
import
lombok.extern.slf4j.Slf4j
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.api.impl.WxMpServiceImpl
;
import
me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -79,7 +65,6 @@ public class ConfigContextService {
@Autowired
private
MchAppService
mchAppService
;
@Autowired
private
IsvInfoService
isvInfoService
;
@Autowired
private
PayInterfaceConfigService
payInterfaceConfigService
;
@Autowired
private
ChannelCertConfigKitBean
channelCertConfigKitBean
;
/** 获取 [商户配置信息] **/
...
...
@@ -224,22 +209,13 @@ public class ConfigContextService {
AlipayNormalMchParams
alipayParams
=
mchAppConfigContext
.
getNormalMchParamsByIfCode
(
CS
.
IF_CODE
.
ALIPAY
,
AlipayNormalMchParams
.
class
);
if
(
alipayParams
!=
null
){
mchAppConfigContext
.
setAlipayClientWrapper
(
buildAlipayClientWrapper
(
alipayParams
.
getUseCert
(),
alipayParams
.
getSandbox
(),
alipayParams
.
getAppId
(),
alipayParams
.
getPrivateKey
(),
alipayParams
.
getAlipayPublicKey
(),
alipayParams
.
getSignType
(),
alipayParams
.
getAppPublicCert
(),
alipayParams
.
getAlipayPublicCert
(),
alipayParams
.
getAlipayRootCert
()
)
);
mchAppConfigContext
.
setAlipayClientWrapper
(
AlipayClientWrapper
.
buildAlipayClientWrapper
(
alipayParams
));
}
//放置 wxJavaService
WxpayNormalMchParams
wxpayParams
=
mchAppConfigContext
.
getNormalMchParamsByIfCode
(
CS
.
IF_CODE
.
WXPAY
,
WxpayNormalMchParams
.
class
);
if
(
wxpayParams
!=
null
){
mchAppConfigContext
.
setWxServiceWrapper
(
buildWxServiceWrapper
(
wxpayParams
.
getMchId
(),
wxpayParams
.
getAppId
(),
wxpayParams
.
getAppSecret
(),
wxpayParams
.
getKey
(),
wxpayParams
.
getApiVersion
(),
wxpayParams
.
getApiV3Key
(),
wxpayParams
.
getSerialNo
(),
wxpayParams
.
getCert
(),
wxpayParams
.
getApiClientKey
()));
mchAppConfigContext
.
setWxServiceWrapper
(
WxServiceWrapper
.
buildWxServiceWrapper
(
wxpayParams
));
}
...
...
@@ -311,20 +287,13 @@ public class ConfigContextService {
//放置alipay client
AlipayIsvParams
alipayParams
=
isvConfigContext
.
getIsvParamsByIfCode
(
CS
.
IF_CODE
.
ALIPAY
,
AlipayIsvParams
.
class
);
if
(
alipayParams
!=
null
){
isvConfigContext
.
setAlipayClientWrapper
(
buildAlipayClientWrapper
(
alipayParams
.
getUseCert
(),
alipayParams
.
getSandbox
(),
alipayParams
.
getAppId
(),
alipayParams
.
getPrivateKey
(),
alipayParams
.
getAlipayPublicKey
(),
alipayParams
.
getSignType
(),
alipayParams
.
getAppPublicCert
(),
alipayParams
.
getAlipayPublicCert
(),
alipayParams
.
getAlipayRootCert
()
)
);
isvConfigContext
.
setAlipayClientWrapper
(
AlipayClientWrapper
.
buildAlipayClientWrapper
(
alipayParams
));
}
//放置 wxJavaService
WxpayIsvParams
wxpayParams
=
isvConfigContext
.
getIsvParamsByIfCode
(
CS
.
IF_CODE
.
WXPAY
,
WxpayIsvParams
.
class
);
if
(
wxpayParams
!=
null
){
isvConfigContext
.
setWxServiceWrapper
(
buildWxServiceWrapper
(
wxpayParams
.
getMchId
(),
wxpayParams
.
getAppId
(),
wxpayParams
.
getAppSecret
(),
wxpayParams
.
getKey
(),
wxpayParams
.
getApiVersion
(),
wxpayParams
.
getApiV3Key
(),
wxpayParams
.
getSerialNo
(),
wxpayParams
.
getCert
(),
wxpayParams
.
getApiClientKey
()));
isvConfigContext
.
setWxServiceWrapper
(
WxServiceWrapper
.
buildWxServiceWrapper
(
wxpayParams
));
}
isvConfigContextMap
.
put
(
isvNo
,
isvConfigContext
);
...
...
@@ -340,81 +309,8 @@ public class ConfigContextService {
}
/*
* 构建支付宝client 包装类
*
* @author terrfly
* @site https://www.jeequan.com
* @date 2021/6/8 17:46
*/
private
AlipayClientWrapper
buildAlipayClientWrapper
(
Byte
useCert
,
Byte
sandbox
,
String
appId
,
String
privateKey
,
String
alipayPublicKey
,
String
signType
,
String
appCert
,
String
alipayPublicCert
,
String
alipayRootCert
){
//避免空值
sandbox
=
sandbox
==
null
?
CS
.
NO
:
sandbox
;
AlipayClient
alipayClient
=
null
;
if
(
useCert
!=
null
&&
useCert
==
CS
.
YES
){
//证书的方式
CertAlipayRequest
certAlipayRequest
=
new
CertAlipayRequest
();
certAlipayRequest
.
setServerUrl
(
sandbox
==
CS
.
YES
?
AlipayConfig
.
SANDBOX_SERVER_URL
:
AlipayConfig
.
PROD_SERVER_URL
);
certAlipayRequest
.
setAppId
(
appId
);
certAlipayRequest
.
setPrivateKey
(
privateKey
);
certAlipayRequest
.
setFormat
(
AlipayConfig
.
FORMAT
);
certAlipayRequest
.
setCharset
(
AlipayConfig
.
CHARSET
);
certAlipayRequest
.
setSignType
(
signType
);
certAlipayRequest
.
setCertPath
(
channelCertConfigKitBean
.
getCertFilePath
(
appCert
));
certAlipayRequest
.
setAlipayPublicCertPath
(
channelCertConfigKitBean
.
getCertFilePath
(
alipayPublicCert
));
certAlipayRequest
.
setRootCertPath
(
channelCertConfigKitBean
.
getCertFilePath
(
alipayRootCert
));
try
{
alipayClient
=
new
DefaultAlipayClient
(
certAlipayRequest
);
}
catch
(
AlipayApiException
e
)
{
log
.
error
(
"error"
,
e
);
alipayClient
=
null
;
}
}
else
{
alipayClient
=
new
DefaultAlipayClient
(
sandbox
==
CS
.
YES
?
AlipayConfig
.
SANDBOX_SERVER_URL
:
AlipayConfig
.
PROD_SERVER_URL
,
appId
,
privateKey
,
AlipayConfig
.
FORMAT
,
AlipayConfig
.
CHARSET
,
alipayPublicKey
,
signType
);
}
return
new
AlipayClientWrapper
(
useCert
,
alipayClient
);
}
private
WxServiceWrapper
buildWxServiceWrapper
(
String
mchId
,
String
appId
,
String
appSecret
,
String
mchKey
,
String
apiVersion
,
String
apiV3Key
,
String
serialNo
,
String
cert
,
String
apiClientKey
){
WxPayConfig
wxPayConfig
=
new
WxPayConfig
();
wxPayConfig
.
setMchId
(
mchId
);
wxPayConfig
.
setAppId
(
appId
);
wxPayConfig
.
setMchKey
(
mchKey
);
if
(
CS
.
PAY_IF_VERSION
.
WX_V2
.
equals
(
apiVersion
))
{
// 微信API V2
wxPayConfig
.
setSignType
(
WxPayConstants
.
SignType
.
MD5
);
// api证书。
if
(
StringUtils
.
isNotBlank
(
cert
)){
wxPayConfig
.
setKeyPath
(
channelCertConfigKitBean
.
getCertFilePath
(
cert
));
}
}
else
if
(
CS
.
PAY_IF_VERSION
.
WX_V3
.
equals
(
apiVersion
))
{
// 微信API V3
wxPayConfig
.
setApiV3Key
(
apiV3Key
);
wxPayConfig
.
setCertSerialNo
(
serialNo
);
wxPayConfig
.
setPrivateCertPath
(
channelCertConfigKitBean
.
getCertFilePath
(
cert
));
wxPayConfig
.
setPrivateKeyPath
(
channelCertConfigKitBean
.
getCertFilePath
(
apiClientKey
));
}
WxPayService
wxPayService
=
new
WxPayServiceImpl
();
wxPayService
.
setConfig
(
wxPayConfig
);
//微信配置信息
WxMpDefaultConfigImpl
wxMpConfigStorage
=
new
WxMpDefaultConfigImpl
();
wxMpConfigStorage
.
setAppId
(
appId
);
wxMpConfigStorage
.
setSecret
(
appSecret
);
WxMpService
wxMpService
=
new
WxMpServiceImpl
();
wxMpService
.
setWxMpConfigStorage
(
wxMpConfigStorage
);
//微信配置信息
return
new
WxServiceWrapper
(
apiVersion
,
wxPayService
,
wxMpService
);
}
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/service/PayMchNotifyService.java
View file @
ca31cf06
...
...
@@ -45,7 +45,7 @@ import org.springframework.stereotype.Service;
public
class
PayMchNotifyService
{
@Autowired
private
MchNotifyRecordService
mchNotifyRecordService
;
@Autowired
private
ConfigContextService
configContextService
;
@Autowired
private
ConfigContext
Query
Service
configContext
Query
Service
;
@Autowired
private
IMQSender
mqSender
;
...
...
@@ -68,7 +68,7 @@ public class PayMchNotifyService {
}
//商户app私钥
String
appSecret
=
configContextService
.
get
MchApp
ConfigContext
(
dbPayOrder
.
getMchNo
(),
dbPayOrder
.
getAppId
()).
getMchApp
().
getAppSecret
();
String
appSecret
=
configContext
Query
Service
.
query
MchApp
(
dbPayOrder
.
getMchNo
(),
dbPayOrder
.
getAppId
()).
getAppSecret
();
// 封装通知url
String
notifyUrl
=
createNotifyUrl
(
dbPayOrder
,
appSecret
);
...
...
@@ -119,7 +119,7 @@ public class PayMchNotifyService {
}
//商户app私钥
String
appSecret
=
configContextService
.
get
MchApp
ConfigContext
(
dbRefundOrder
.
getMchNo
(),
dbRefundOrder
.
getAppId
()).
getMchApp
().
getAppSecret
();
String
appSecret
=
configContext
Query
Service
.
query
MchApp
(
dbRefundOrder
.
getMchNo
(),
dbRefundOrder
.
getAppId
()).
getAppSecret
();
// 封装通知url
String
notifyUrl
=
createNotifyUrl
(
dbRefundOrder
,
appSecret
);
...
...
@@ -170,7 +170,7 @@ public class PayMchNotifyService {
}
//商户app私钥
String
appSecret
=
configContextService
.
get
MchApp
ConfigContext
(
dbTransferOrder
.
getMchNo
(),
dbTransferOrder
.
getAppId
()).
getMchApp
().
getAppSecret
();
String
appSecret
=
configContext
Query
Service
.
query
MchApp
(
dbTransferOrder
.
getMchNo
(),
dbTransferOrder
.
getAppId
()).
getAppSecret
();
// 封装通知url
String
notifyUrl
=
createNotifyUrl
(
dbTransferOrder
,
appSecret
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/service/PayOrderDivisionProcessService.java
View file @
ca31cf06
...
...
@@ -61,7 +61,7 @@ public class PayOrderDivisionProcessService {
@Autowired
private
PayOrderDivisionRecordService
payOrderDivisionRecordService
;
@Autowired
private
ConfigContextService
configContextService
;
private
ConfigContext
Query
Service
configContext
Query
Service
;
/***
* 处理分账,
...
...
@@ -147,7 +147,7 @@ public class PayOrderDivisionProcessService {
throw
new
BizException
(
"通道无此分账接口"
);
}
channelRetMsg
=
divisionService
.
singleDivision
(
payOrder
,
recordList
,
configContextService
.
getMchAppConfigContext
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
()));
channelRetMsg
=
divisionService
.
singleDivision
(
payOrder
,
recordList
,
configContext
Query
Service
.
queryMchInfoAndAppInfo
(
payOrder
.
getMchNo
(),
payOrder
.
getAppId
()));
// 确认分账成功
if
(
channelRetMsg
.
getChannelState
()
==
ChannelRetMsg
.
ChannelState
.
CONFIRM_SUCCESS
)
{
...
...
jeepay-service/src/main/java/com/jeequan/jeepay/service/impl/MchAppService.java
View file @
ca31cf06
...
...
@@ -89,4 +89,9 @@ public class MchAppService extends ServiceImpl<MchAppMapper, MchApp> {
return
pages
;
}
public
MchApp
getOneByMch
(
String
mchNo
,
String
appId
){
return
getOne
(
MchApp
.
gw
().
eq
(
MchApp:
:
getMchNo
,
mchNo
).
eq
(
MchApp:
:
getAppId
,
appId
));
}
}
Prev
1
2
3
Next
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