Browse Source

1.平台端微信支付业务逻辑新增动态获取商家微信支付配置信息处理 2.PC端微信支付业务逻辑新增动态获取商家微信支付配置信息处理

multiwx
dy-hu 4 months ago
parent
commit
e0e381c330
  1. 7
      cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/PayService.java
  2. 4
      cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/alipay/service/impl/AliPayServiceImpl.java
  3. 4
      cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/hnapay/impl/HnaPayServiceImpl.java
  4. 65
      cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/weixin/service/impl/WxPayServiceImpl.java
  5. 4
      cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/impl/XsPayServiceImpl.java
  6. 2
      cereshop-admin/src/main/java/com/shop/cereshop/admin/redis/listener/RedisListener.java
  7. 2
      cereshop-admin/src/main/java/com/shop/cereshop/admin/service/after/impl/CereOrderAfterServiceImpl.java
  8. 1
      cereshop-admin/src/main/java/com/shop/cereshop/admin/service/bwxpay/CereBusinessWxpayService.java
  9. 13
      cereshop-app/src/main/java/com/shop/cereshop/app/controller/index/LoginController.java
  10. 1
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/bwxpay/CereBusinessWxpayDao.java
  11. 94
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/weixin/service/impl/WxPayServiceImpl.java
  12. 8
      cereshop-app/src/main/java/com/shop/cereshop/app/service/buyer/impl/CereBuyerUserServiceImpl.java
  13. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/service/bwxpay/CereBusinessWxpayService.java
  14. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/service/bwxpay/impl/CereBusinessWxpayServiceImpl.java
  15. 10
      cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java
  16. 9
      cereshop-app/src/main/java/com/shop/cereshop/app/service/shop/impl/CerePlatformShopServiceImpl.java
  17. 18
      cereshop-app/src/main/java/com/shop/cereshop/app/utils/WechatUtil.java
  18. 19
      cereshop-app/src/main/resources/mybatis/mapper/bwxpay/CereBusinessWxpayDAO.xml
  19. 20
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/bwxpay/CereBusinessWxpayDao.java
  20. 3
      cereshop-business/src/main/java/com/shop/cereshop/business/pay/PayService.java
  21. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/pay/alipay/service/impl/AliPayServiceImpl.java
  22. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/pay/alipay/service/impl/HuabeiPayServiceImpl.java
  23. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/pay/hnapay/impl/HnaPayServiceImpl.java
  24. 6
      cereshop-business/src/main/java/com/shop/cereshop/business/pay/weixin/service/impl/WxPayServiceImpl.java
  25. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/pay/xs/service/impl/XsPayServiceImpl.java
  26. 4
      cereshop-business/src/main/java/com/shop/cereshop/business/service/after/impl/CereOrderAfterServiceImpl.java
  27. 19
      cereshop-business/src/main/java/com/shop/cereshop/business/service/bwxpay/CereBusinessWxpayService.java
  28. 40
      cereshop-business/src/main/java/com/shop/cereshop/business/service/bwxpay/impl/CereBusinessWxpayServiceImpl.java
  29. 19
      cereshop-business/src/main/resources/mybatis/mapper/bwxpay/CereBusinessWxpayDAO.xml

7
cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/PayService.java

@ -14,6 +14,8 @@ public interface PayService {
/** /**
* 售后微信退款 * 售后微信退款
* @param project 所属平台号(即商家id)
* @param orderFormId
* @param transactionId 第三方支付单号 * @param transactionId 第三方支付单号
* @param outRefundNo 支付生成的退款单号 * @param outRefundNo 支付生成的退款单号
* @param total 订单总金额 * @param total 订单总金额
@ -21,10 +23,11 @@ public interface PayService {
* @throws CoBusinessException * @throws CoBusinessException
* @throws Exception * @throws Exception
*/ */
Map<String,String> refund(String orderFormId, String outTradeNo, String transactionId,String outRefundNo,BigDecimal total,BigDecimal refund) throws CoBusinessException,Exception;
Map<String,String> refund(String project, String orderFormId, String outTradeNo, String transactionId,String outRefundNo,BigDecimal total,BigDecimal refund) throws CoBusinessException,Exception;
/** /**
* 保证金退款 * 保证金退款
* @param project 所属平台号(即商家id)
* @param transactionId 支付单号 * @param transactionId 支付单号
* @param outRefundNo 支付生成的退款单号 * @param outRefundNo 支付生成的退款单号
* @param total 订单总金额 * @param total 订单总金额
@ -32,6 +35,6 @@ public interface PayService {
* @throws CoBusinessException * @throws CoBusinessException
* @throws Exception * @throws Exception
*/ */
Map<String,String> refundBond(String transactionId,String outRefundNo,BigDecimal total,BigDecimal refund) throws CoBusinessException,Exception;
Map<String,String> refundBond(String project, String transactionId,String outRefundNo,BigDecimal total,BigDecimal refund) throws CoBusinessException,Exception;
} }

4
cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/alipay/service/impl/AliPayServiceImpl.java

@ -27,7 +27,7 @@ import java.util.Map;
public class AliPayServiceImpl implements AliPayService { public class AliPayServiceImpl implements AliPayService {
@Override @Override
public Map<String, String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
public Map<String, String> refund(String project, String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
Map<String, String> result = new HashMap<>(); Map<String, String> result = new HashMap<>();
AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE); AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE);
@ -52,7 +52,7 @@ public class AliPayServiceImpl implements AliPayService {
} }
@Override @Override
public Map<String, String> refundBond(String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
public Map<String, String> refundBond(String project, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
Map<String, String> result = new HashMap<>(); Map<String, String> result = new HashMap<>();
AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE); AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE);

4
cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/hnapay/impl/HnaPayServiceImpl.java

@ -154,7 +154,7 @@ public class HnaPayServiceImpl implements HnaPayService {
} }
@Override @Override
public Map<String, String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
public Map<String, String> refund(String project, String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
List<CereShopOrder> orderList = null; List<CereShopOrder> orderList = null;
String cereOrderFormId = orderFormId; String cereOrderFormId = orderFormId;
String[] split = orderFormId.split("-"); String[] split = orderFormId.split("-");
@ -223,7 +223,7 @@ public class HnaPayServiceImpl implements HnaPayService {
} }
@Override @Override
public Map<String, String> refundBond(String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
public Map<String, String> refundBond(String project, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
throw new CoBusinessException("10000","新生通道保证金退款功能待开发", ""); throw new CoBusinessException("10000","新生通道保证金退款功能待开发", "");
} }

65
cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/weixin/service/impl/WxPayServiceImpl.java

@ -11,7 +11,9 @@ import com.shop.cereshop.admin.pay.weixin.service.WxPayService;
import com.shop.cereshop.admin.pay.weixin.skd.PaymentKit; import com.shop.cereshop.admin.pay.weixin.skd.PaymentKit;
import com.shop.cereshop.admin.pay.weixin.skd.WXPayUtil; import com.shop.cereshop.admin.pay.weixin.skd.WXPayUtil;
import com.shop.cereshop.admin.pay.weixin.skd.WXPayV3Util; import com.shop.cereshop.admin.pay.weixin.skd.WXPayV3Util;
import com.shop.cereshop.admin.service.bwxpay.CereBusinessWxpayService;
import com.shop.cereshop.commons.constant.WxPayEnum; import com.shop.cereshop.commons.constant.WxPayEnum;
import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay;
import com.shop.cereshop.commons.exception.CoBusinessException; import com.shop.cereshop.commons.exception.CoBusinessException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -29,32 +31,32 @@ public class WxPayServiceImpl implements WxPayService {
/** /**
* 支付小程序appid * 支付小程序appid
*/ */
@Value("${weixin.appid}")
private String appid;
// @Value("${weixin.appid}")
// private String appid;
/** /**
* 支付APP端的appid * 支付APP端的appid
*/ */
@Value("${weixin.app_appid}")
private String app_appid;
// @Value("${weixin.app_appid}")
// private String app_appid;
/** /**
* 支付小程序秘钥 * 支付小程序秘钥
*/ */
@Value("${weixin.secret}")
private String secret;
// @Value("${weixin.secret}")
// private String secret;
/** /**
* 商户号 * 商户号
*/ */
@Value("${weixin.mchid}")
private String mch_id;
// @Value("${weixin.mchid}")
// private String mch_id;
/** /**
* 证书路径 * 证书路径
*/ */
@Value("${weixin.certurl}")
private String cert_url;
// @Value("${weixin.certurl}")
// private String cert_url;
/** /**
* pc回调地址 * pc回调地址
@ -86,30 +88,33 @@ public class WxPayServiceImpl implements WxPayService {
/** /**
* 商户秘钥 * 商户秘钥
*/ */
@Value("${weixin.key}")
private String key;
// @Value("${weixin.key}")
// private String key;
@Autowired @Autowired
private WXPayV3Util wxPayV3Util; private WXPayV3Util wxPayV3Util;
@Autowired
private CereBusinessWxpayService cereBusinessWxpayService;
@Override @Override
public Map<String, String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
public Map<String, String> refund(String project, String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
//APPV3版本的退款以APPV3开头 //APPV3版本的退款以APPV3开头
if (outRefundNo.startsWith("APPV3")) { if (outRefundNo.startsWith("APPV3")) {
return refundWithV3(transactionId, outRefundNo, total, refund);
return refundWithV3(project, transactionId, outRefundNo, total, refund);
} else { } else {
return refundWithNormal(transactionId, outRefundNo, total, refund);
return refundWithNormal(project, transactionId, outRefundNo, total, refund);
} }
} }
private Map<String, String> refundWithV3(String transactionId, String outRefundNo,
private Map<String, String> refundWithV3(String project, String transactionId, String outRefundNo,
BigDecimal total, BigDecimal refund) throws Exception { BigDecimal total, BigDecimal refund) throws Exception {
log.info(" orderRefund refundWithV3 {}, {}, {}, {}", transactionId, outRefundNo, log.info(" orderRefund refundWithV3 {}, {}, {}, {}", transactionId, outRefundNo,
total, refund); total, refund);
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("transaction_id", transactionId); params.put("transaction_id", transactionId);
params.put("out_refund_no", outRefundNo); params.put("out_refund_no", outRefundNo);
params.put("notify_url", appV3NotifyUrl);
params.put("notify_url", appV3NotifyUrl + "/" + project);
params.put("amount", new HashMap<String, Object>(){ params.put("amount", new HashMap<String, Object>(){
{ {
put("refund", refund.multiply(new BigDecimal(100)).intValue()); put("refund", refund.multiply(new BigDecimal(100)).intValue());
@ -131,18 +136,19 @@ public class WxPayServiceImpl implements WxPayService {
return result; return result;
} }
private Map<String, String> refundWithNormal(String transactionId, String outRefundNo,
private Map<String, String> refundWithNormal(String project, String transactionId, String outRefundNo,
BigDecimal total, BigDecimal refund) throws Exception { BigDecimal total, BigDecimal refund) throws Exception {
CereBusinessWxpay businessWxpay = cereBusinessWxpayService.getByBusinessId(Long.valueOf(project));
//退款资金来源-可用余额退款 //退款资金来源-可用余额退款
String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS"; String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS";
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
if(outRefundNo.contains("APP")){ if(outRefundNo.contains("APP")){
//APP微信退款 //APP微信退款
params.put("appid", app_appid);
params.put("appid", businessWxpay.getAppAppId());
} else { } else {
params.put("appid", appid);
params.put("appid", businessWxpay.getAppId());
} }
params.put("mch_id",mch_id);
params.put("mch_id",businessWxpay.getMchId());
params.put("nonce_str", System.currentTimeMillis() / 1000 + ""); params.put("nonce_str", System.currentTimeMillis() / 1000 + "");
//商户订单号和微信订单号二选一 //商户订单号和微信订单号二选一
// params.put("out_trade_no", wxPayLog.getOutTradeNo()); // params.put("out_trade_no", wxPayLog.getOutTradeNo());
@ -156,11 +162,11 @@ public class WxPayServiceImpl implements WxPayService {
//退款回调 //退款回调
params.put("notify_url", pc_refund_notify_url); params.put("notify_url", pc_refund_notify_url);
//签名算法 //签名算法
String sign = WXPayUtil.generateSignature(params,key);
String sign = WXPayUtil.generateSignature(params, businessWxpay.getMchKey());
params.put("sign", sign); params.put("sign", sign);
String xml = PaymentKit.toXml(params); String xml = PaymentKit.toXml(params);
log.info(xml); log.info(xml);
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml,cert_url,mch_id);
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml,businessWxpay.getCertUrl(), businessWxpay.getMchId());
log.info(xmlStr); log.info(xmlStr);
//加入微信支付日志 //加入微信支付日志
Map map = PaymentKit.xmlToMap(xmlStr); Map map = PaymentKit.xmlToMap(xmlStr);
@ -168,17 +174,18 @@ public class WxPayServiceImpl implements WxPayService {
} }
@Override @Override
public Map<String, String> refundBond(String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
public Map<String, String> refundBond(String project, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
CereBusinessWxpay businessWxpay = cereBusinessWxpayService.getByBusinessId(Long.valueOf(project));
//退款资金来源-可用余额退款 //退款资金来源-可用余额退款
String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS"; String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS";
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
if(outRefundNo.contains("APP")){ if(outRefundNo.contains("APP")){
//APP微信退款 //APP微信退款
params.put("appid", app_appid);
params.put("appid", businessWxpay.getAppAppId());
} else { } else {
params.put("appid", appid);
params.put("appid", businessWxpay.getAppId());
} }
params.put("mch_id",mch_id);
params.put("mch_id",businessWxpay.getMchId());
params.put("nonce_str", System.currentTimeMillis() / 1000 + ""); params.put("nonce_str", System.currentTimeMillis() / 1000 + "");
//商户订单号和微信订单号二选一 //商户订单号和微信订单号二选一
// params.put("out_trade_no", wxPayLog.getOutTradeNo()); // params.put("out_trade_no", wxPayLog.getOutTradeNo());
@ -192,11 +199,11 @@ public class WxPayServiceImpl implements WxPayService {
//退款回调 //退款回调
params.put("notify_url", pc_bond_refund_notify_url); params.put("notify_url", pc_bond_refund_notify_url);
//签名算法 //签名算法
String sign = WXPayUtil.generateSignature(params,key);
String sign = WXPayUtil.generateSignature(params, businessWxpay.getMchKey());
params.put("sign", sign); params.put("sign", sign);
String xml = PaymentKit.toXml(params); String xml = PaymentKit.toXml(params);
log.info(xml); log.info(xml);
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml,cert_url,mch_id);
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml, businessWxpay.getCertUrl(), businessWxpay.getMchId());
log.info(xmlStr); log.info(xmlStr);
//加入微信支付日志 //加入微信支付日志
Map map = PaymentKit.xmlToMap(xmlStr); Map map = PaymentKit.xmlToMap(xmlStr);

4
cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/impl/XsPayServiceImpl.java

@ -65,7 +65,7 @@ public class XsPayServiceImpl implements XsPayService {
//售后退款中需要仲裁的售后退款 //售后退款中需要仲裁的售后退款
@Override @Override
public Map<String, String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
public Map<String, String> refund(String project, String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
Map<String, Object> contentMap = build22ContentMap(orderFormId, outRefundNo, outTradeNo, transactionId, refund, XspayConfig.BUSINESS_RETURN_NOTICE_URL); Map<String, Object> contentMap = build22ContentMap(orderFormId, outRefundNo, outTradeNo, transactionId, refund, XspayConfig.BUSINESS_RETURN_NOTICE_URL);
String respMsg = XsPayUtils.requestByXs(SHARE_REFUND_SER_CODE, contentMap); String respMsg = XsPayUtils.requestByXs(SHARE_REFUND_SER_CODE, contentMap);
@ -110,7 +110,7 @@ public class XsPayServiceImpl implements XsPayService {
//保证金退款 //保证金退款
//TODO 待开发 //TODO 待开发
@Override @Override
public Map<String, String> refundBond(String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
public Map<String, String> refundBond(String project, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
throw new CoBusinessException("10000","新生通道保证金退款功能待开发", ""); throw new CoBusinessException("10000","新生通道保证金退款功能待开发", "");
} }

2
cereshop-admin/src/main/java/com/shop/cereshop/admin/redis/listener/RedisListener.java

@ -534,7 +534,7 @@ public class RedisListener extends KeyExpirationEventMessageListener {
* @throws Exception * @throws Exception
*/ */
private void refundBond(CerePayLog bondPayLog,int signType) throws Exception { private void refundBond(CerePayLog bondPayLog,int signType) throws Exception {
Map<String, String> resultMap = PayFactory.getPayService(bondPaymentMode).refundBond(bondPayLog.getTransactionId(),bondPayLog.getOutRefundNo(),bondPayLog.getTotalFee(),bondPayLog.getTotalFee());
Map<String, String> resultMap = PayFactory.getPayService(bondPaymentMode).refundBond(bondPayLog.getProject(), bondPayLog.getTransactionId(),bondPayLog.getOutRefundNo(),bondPayLog.getTotalFee(),bondPayLog.getTotalFee());
if(!EmptyUtils.isEmpty(resultMap)){ if(!EmptyUtils.isEmpty(resultMap)){
if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&& if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&&
resultMap.get("return_code").equals(WxPayEnum.REFUND_OK.getCode())){ resultMap.get("return_code").equals(WxPayEnum.REFUND_OK.getCode())){

2
cereshop-admin/src/main/java/com/shop/cereshop/admin/service/after/impl/CereOrderAfterServiceImpl.java

@ -247,7 +247,7 @@ public class CereOrderAfterServiceImpl implements CereOrderAfterService {
//第一次售后退款 //第一次售后退款
payLog.setAfter(String.valueOf(param.getAfterId())); payLog.setAfter(String.valueOf(param.getAfterId()));
} }
Map<String, String> resultMap = PayFactory.getPayService(payLog.getPaymentMode()).refund(refund.getOrderFormid(), refund.getOutTradeNo(), refund.getTransactionId(),
Map<String, String> resultMap = PayFactory.getPayService(payLog.getPaymentMode()).refund(payLog.getProject(), refund.getOrderFormid(), refund.getOutTradeNo(), refund.getTransactionId(),
refund.getOutRefundNo(), refund.getOrderPrice(), refund.getPrice()); refund.getOutRefundNo(), refund.getOrderPrice(), refund.getPrice());
if(!EmptyUtils.isEmpty(resultMap)){ if(!EmptyUtils.isEmpty(resultMap)){
if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&& if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&&

1
cereshop-admin/src/main/java/com/shop/cereshop/admin/service/bwxpay/CereBusinessWxpayService.java

@ -1,6 +1,5 @@
package com.shop.cereshop.admin.service.bwxpay; package com.shop.cereshop.admin.service.bwxpay;
import com.shop.cereshop.commons.domain.buyer.CereBuyerBank;
import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay; import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay;
import com.shop.cereshop.commons.exception.CoBusinessException; import com.shop.cereshop.commons.exception.CoBusinessException;

13
cereshop-app/src/main/java/com/shop/cereshop/app/controller/index/LoginController.java

@ -20,6 +20,7 @@ import com.shop.cereshop.app.redis.service.api.StringRedisService;
import com.shop.cereshop.app.redis.service.api.UserRedisService; import com.shop.cereshop.app.redis.service.api.UserRedisService;
import com.shop.cereshop.app.service.buyer.CereBuyerSearchService; import com.shop.cereshop.app.service.buyer.CereBuyerSearchService;
import com.shop.cereshop.app.service.buyer.CereBuyerUserService; import com.shop.cereshop.app.service.buyer.CereBuyerUserService;
import com.shop.cereshop.app.service.bwxpay.CereBusinessWxpayService;
import com.shop.cereshop.app.service.dict.CerePlatformDictService; import com.shop.cereshop.app.service.dict.CerePlatformDictService;
import com.shop.cereshop.app.service.index.IndexService; import com.shop.cereshop.app.service.index.IndexService;
import com.shop.cereshop.app.service.message.CereMessageLogService; import com.shop.cereshop.app.service.message.CereMessageLogService;
@ -32,6 +33,7 @@ import com.shop.cereshop.commons.constant.CoReturnFormat;
import com.shop.cereshop.commons.constant.IntegerEnum; import com.shop.cereshop.commons.constant.IntegerEnum;
import com.shop.cereshop.commons.domain.buyer.CereBuyerSearch; import com.shop.cereshop.commons.domain.buyer.CereBuyerSearch;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser; import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay;
import com.shop.cereshop.commons.domain.common.Page; import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.dict.CerePlatformDict; import com.shop.cereshop.commons.domain.dict.CerePlatformDict;
import com.shop.cereshop.commons.domain.product.CereProductSku; import com.shop.cereshop.commons.domain.product.CereProductSku;
@ -78,7 +80,7 @@ public class LoginController {
private MiaoxinMessageService miaoxinMessageService; private MiaoxinMessageService miaoxinMessageService;
@Autowired @Autowired
private CereMessageLogService cereMessageLogService;
private CereBusinessWxpayService businessWxpayService;
@Autowired @Autowired
private IndexService indexService; private IndexService indexService;
@ -221,7 +223,14 @@ public class LoginController {
@ApiOperation(value = "获取微信加密秘钥") @ApiOperation(value = "获取微信加密秘钥")
public Result<BuyerUser> getSessionKey(@RequestBody LoginParam param){ public Result<BuyerUser> getSessionKey(@RequestBody LoginParam param){
//传入code后然后获取openid和session_key的把他们封装到json里面 //传入code后然后获取openid和session_key的把他们封装到json里面
JSONObject json = WechatUtil.getSessionKeyOropenid(param.getCode());
CereBusinessWxpay businessWxpay = null;
try {
businessWxpay = businessWxpayService.getByBusinessId(Long.valueOf(ContextUtil.getProject()));
} catch (CoBusinessException e) {
e.printStackTrace();
}
JSONObject json = WechatUtil.getSessionKeyOropenid(businessWxpay.getAppId(), businessWxpay.getSecret(), param.getCode());
String session_key = json.getString("session_key"); String session_key = json.getString("session_key");
String openid = json.get("openid").toString(); String openid = json.get("openid").toString();
BuyerUser buyerUser=new BuyerUser(); BuyerUser buyerUser=new BuyerUser();

1
cereshop-app/src/main/java/com/shop/cereshop/app/dao/bwxpay/CereBusinessWxpayDao.java

@ -14,7 +14,6 @@ import org.apache.ibatis.annotations.Param;
*/ */
@Mapper @Mapper
public interface CereBusinessWxpayDao extends BaseMapper<CereBusinessWxpay> { public interface CereBusinessWxpayDao extends BaseMapper<CereBusinessWxpay> {
int insertSelective(CereBusinessWxpay record);
CereBusinessWxpay getByBusinessId(@Param("businessId") Long businessId); CereBusinessWxpay getByBusinessId(@Param("businessId") Long businessId);

94
cereshop-app/src/main/java/com/shop/cereshop/app/pay/weixin/service/impl/WxPayServiceImpl.java

@ -14,7 +14,10 @@ import com.shop.cereshop.app.pay.weixin.skd.PaymentKit;
import com.shop.cereshop.app.pay.weixin.skd.WXPayUtil; import com.shop.cereshop.app.pay.weixin.skd.WXPayUtil;
import com.shop.cereshop.app.pay.weixin.skd.WXPayV3Util; import com.shop.cereshop.app.pay.weixin.skd.WXPayV3Util;
import com.shop.cereshop.app.pay.weixin.strategy.WxPayStrategy; import com.shop.cereshop.app.pay.weixin.strategy.WxPayStrategy;
import com.shop.cereshop.app.service.bwxpay.CereBusinessWxpayService;
import com.shop.cereshop.app.utils.ContextUtil;
import com.shop.cereshop.commons.constant.WxPayEnum; import com.shop.cereshop.commons.constant.WxPayEnum;
import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay;
import com.shop.cereshop.commons.exception.CoBusinessException; import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.RandomStringUtil; import com.shop.cereshop.commons.utils.RandomStringUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -33,32 +36,32 @@ public class WxPayServiceImpl implements WxPayService {
/** /**
* 支付小程序appid * 支付小程序appid
*/ */
@Value("${weixin.appid}")
private String appid;
// @Value("${weixin.appid}")
// private String appid;
/** /**
* 支付APP端的appid * 支付APP端的appid
*/ */
@Value("${weixin.app_appid}")
private String app_appid;
// @Value("${weixin.app_appid}")
// private String app_appid;
/** /**
* 支付小程序秘钥 * 支付小程序秘钥
*/ */
@Value("${weixin.secret}")
private String secret;
// @Value("${weixin.secret}")
// private String secret;
/** /**
* 商户号 * 商户号
*/ */
@Value("${weixin.mchid}")
private String mch_id;
// @Value("${weixin.mchid}")
// private String mch_id;
/** /**
* 证书路径 * 证书路径
*/ */
@Value("${weixin.certurl}")
private String cert_url;
// @Value("${weixin.certurl}")
// private String cert_url;
/** /**
* pc回调地址 * pc回调地址
@ -96,8 +99,8 @@ public class WxPayServiceImpl implements WxPayService {
/** /**
* 商户秘钥 * 商户秘钥
*/ */
@Value("${weixin.key}")
private String key;
// @Value("${weixin.key}")
// private String key;
/** /**
* h5支付跳转地址 * h5支付跳转地址
@ -108,27 +111,37 @@ public class WxPayServiceImpl implements WxPayService {
@Autowired @Autowired
private WXPayV3Util wxPayV3Util; private WXPayV3Util wxPayV3Util;
@Autowired
private CereBusinessWxpayService cereBusinessWxpayService;
@Override @Override
public Map<String, String> gotoPay(String orderFormId, BigDecimal money, String openid, String ip, public Map<String, String> gotoPay(String orderFormId, BigDecimal money, String openid, String ip,
Integer type, Integer huabeiPeriod) throws CoBusinessException, Exception { Integer type, Integer huabeiPeriod) throws CoBusinessException, Exception {
WxPayStrategy wxPayStrategy = PayFactory.getWxPayStrategy(type); WxPayStrategy wxPayStrategy = PayFactory.getWxPayStrategy(type);
return wxPayStrategy.prepay(appid, app_appid, openid,
mch_id, app_notify_url, redirectUrl, ip, money,
orderFormId, key);
//获取商家id
String businessId = ContextUtil.getProject();
CereBusinessWxpay businessWxpay = cereBusinessWxpayService.getByBusinessId(Long.valueOf(businessId));
return wxPayStrategy.prepay(businessWxpay.getAppId(), businessWxpay.getAppAppId(), openid,
businessWxpay.getMchId(), app_notify_url, redirectUrl, ip, money,
orderFormId, businessWxpay.getMchKey());
} }
@Override @Override
public Map<String, String> refund(String orderFormId,String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception { public Map<String, String> refund(String orderFormId,String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
String businessId = ContextUtil.getProject();
CereBusinessWxpay businessWxpay = cereBusinessWxpayService.getByBusinessId(Long.valueOf(businessId));
//退款资金来源-可用余额退款 //退款资金来源-可用余额退款
String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS"; String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS";
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
if(outRefundNo.contains("APP")){ if(outRefundNo.contains("APP")){
//APP微信退款 //APP微信退款
params.put("appid", app_appid);
params.put("appid", businessWxpay.getAppAppId());
} else { } else {
params.put("appid", appid);
params.put("appid", businessWxpay.getAppId());
} }
params.put("mch_id",mch_id);
params.put("mch_id",businessWxpay.getMchId());
params.put("nonce_str", System.currentTimeMillis() / 1000 + ""); params.put("nonce_str", System.currentTimeMillis() / 1000 + "");
//商户订单号和微信订单号二选一 //商户订单号和微信订单号二选一
// params.put("out_trade_no", wxPayLog.getOutTradeNo()); // params.put("out_trade_no", wxPayLog.getOutTradeNo());
@ -142,11 +155,11 @@ public class WxPayServiceImpl implements WxPayService {
//退款回调 //退款回调
params.put("notify_url", pc_refund_notify_url); params.put("notify_url", pc_refund_notify_url);
//签名算法 //签名算法
String sign = WXPayUtil.generateSignature(params,key);
String sign = WXPayUtil.generateSignature(params, businessWxpay.getMchKey());
params.put("sign", sign); params.put("sign", sign);
String xml = PaymentKit.toXml(params); String xml = PaymentKit.toXml(params);
log.info(xml); log.info(xml);
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml,cert_url,mch_id);
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml,businessWxpay.getCertUrl(),businessWxpay.getMchId());
log.info(xmlStr); log.info(xmlStr);
//加入微信支付日志 //加入微信支付日志
Map map = PaymentKit.xmlToMap(xmlStr); Map map = PaymentKit.xmlToMap(xmlStr);
@ -194,16 +207,18 @@ public class WxPayServiceImpl implements WxPayService {
private Map<String, String> refundWithNormal(String transactionId, String outRefundNo, private Map<String, String> refundWithNormal(String transactionId, String outRefundNo,
BigDecimal total, BigDecimal refund) throws Exception { BigDecimal total, BigDecimal refund) throws Exception {
String businessId = ContextUtil.getProject();
CereBusinessWxpay businessWxpay = cereBusinessWxpayService.getByBusinessId(Long.valueOf(businessId));
//退款资金来源-可用余额退款 //退款资金来源-可用余额退款
String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS"; String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS";
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
if(outRefundNo.contains("APP")){ if(outRefundNo.contains("APP")){
//APP微信退款 //APP微信退款
params.put("appid", app_appid);
params.put("appid", businessWxpay.getAppAppId());
} else { } else {
params.put("appid", appid);
params.put("appid", businessWxpay.getAppId());
} }
params.put("mch_id",mch_id);
params.put("mch_id",businessWxpay.getMchId());
params.put("nonce_str", System.currentTimeMillis() / 1000 + ""); params.put("nonce_str", System.currentTimeMillis() / 1000 + "");
//商户订单号和微信订单号二选一 //商户订单号和微信订单号二选一
// params.put("out_trade_no", wxPayLog.getOutTradeNo()); // params.put("out_trade_no", wxPayLog.getOutTradeNo());
@ -217,11 +232,11 @@ public class WxPayServiceImpl implements WxPayService {
//退款回调 //退款回调
params.put("notify_url", order_refund_notifyurl); params.put("notify_url", order_refund_notifyurl);
//签名算法 //签名算法
String sign = WXPayUtil.generateSignature(params,key);
String sign = WXPayUtil.generateSignature(params, businessWxpay.getMchKey());
params.put("sign", sign); params.put("sign", sign);
String xml = PaymentKit.toXml(params); String xml = PaymentKit.toXml(params);
log.info(xml); log.info(xml);
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml, cert_url, mch_id);
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml, businessWxpay.getCertUrl(), businessWxpay.getMchId());
log.info(xmlStr); log.info(xmlStr);
//加入微信支付日志 //加入微信支付日志
return PaymentKit.xmlToMap(xmlStr); return PaymentKit.xmlToMap(xmlStr);
@ -229,16 +244,19 @@ public class WxPayServiceImpl implements WxPayService {
@Override @Override
public Map<String, String> refundBond(String orderFormId,String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception { public Map<String, String> refundBond(String orderFormId,String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
String businessId = ContextUtil.getProject();
CereBusinessWxpay businessWxpay = cereBusinessWxpayService.getByBusinessId(Long.valueOf(businessId));
//退款资金来源-可用余额退款 //退款资金来源-可用余额退款
String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS"; String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS";
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
if(outRefundNo.contains("APP")){ if(outRefundNo.contains("APP")){
//APP微信退款 //APP微信退款
params.put("appid", app_appid);
params.put("appid", businessWxpay.getAppAppId());
} else { } else {
params.put("appid", appid);
params.put("appid", businessWxpay.getAppId());
} }
params.put("mch_id",mch_id);
params.put("mch_id",businessWxpay.getMchId());
params.put("nonce_str", System.currentTimeMillis() / 1000 + ""); params.put("nonce_str", System.currentTimeMillis() / 1000 + "");
//商户订单号和微信订单号二选一 //商户订单号和微信订单号二选一
// params.put("out_trade_no", wxPayLog.getOutTradeNo()); // params.put("out_trade_no", wxPayLog.getOutTradeNo());
@ -252,11 +270,11 @@ public class WxPayServiceImpl implements WxPayService {
//退款回调 //退款回调
params.put("notify_url", pc_bond_refund_notify_url); params.put("notify_url", pc_bond_refund_notify_url);
//签名算法 //签名算法
String sign = WXPayUtil.generateSignature(params,key);
String sign = WXPayUtil.generateSignature(params, businessWxpay.getMchKey());
params.put("sign", sign); params.put("sign", sign);
String xml = PaymentKit.toXml(params); String xml = PaymentKit.toXml(params);
log.info(xml); log.info(xml);
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml,cert_url,mch_id);
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml,businessWxpay.getCertUrl(),businessWxpay.getMchId());
log.info(xmlStr); log.info(xmlStr);
//加入微信支付日志 //加入微信支付日志
Map map = PaymentKit.xmlToMap(xmlStr); Map map = PaymentKit.xmlToMap(xmlStr);
@ -265,13 +283,15 @@ public class WxPayServiceImpl implements WxPayService {
@Override @Override
public String getCollectionCode(String orderFormid, BigDecimal money, String ip, String tradeType) throws CoBusinessException,Exception { public String getCollectionCode(String orderFormid, BigDecimal money, String ip, String tradeType) throws CoBusinessException,Exception {
String businessId = ContextUtil.getProject();
CereBusinessWxpay businessWxpay = cereBusinessWxpayService.getByBusinessId(Long.valueOf(businessId));
Map<String, String> reqParams = new HashMap<>(); Map<String, String> reqParams = new HashMap<>();
//生成一个新的订单支付编号 //生成一个新的订单支付编号
String outTradeNo=orderFormid+"-"+ RandomStringUtil.getRandomCode(3,0); String outTradeNo=orderFormid+"-"+ RandomStringUtil.getRandomCode(3,0);
//微信分配的小程序ID //微信分配的小程序ID
reqParams.put("appid",appid);
reqParams.put("appid",businessWxpay.getAppId());
//微信支付分配的商户号 //微信支付分配的商户号
reqParams.put("mch_id",mch_id);
reqParams.put("mch_id",businessWxpay.getMchId());
//随机字符串 //随机字符串
reqParams.put("nonce_str", System.currentTimeMillis() / 1000 + ""); reqParams.put("nonce_str", System.currentTimeMillis() / 1000 + "");
//签名类型 //签名类型
@ -293,7 +313,7 @@ public class WxPayServiceImpl implements WxPayService {
//用户标识 //用户标识
// reqParams.put("openid", openid); // reqParams.put("openid", openid);
//签名 //签名
String sign = WXPayUtil.generateSignature(reqParams,key);
String sign = WXPayUtil.generateSignature(reqParams, businessWxpay.getMchKey());
reqParams.put("sign", sign); reqParams.put("sign", sign);
/* /*
调用支付定义下单API,返回预付单信息 prepay_id 调用支付定义下单API,返回预付单信息 prepay_id
@ -307,13 +327,15 @@ public class WxPayServiceImpl implements WxPayService {
@Override @Override
public String getOrderCollectionCode(String orderFormid, BigDecimal money, String ip, String tradeType) throws CoBusinessException,Exception { public String getOrderCollectionCode(String orderFormid, BigDecimal money, String ip, String tradeType) throws CoBusinessException,Exception {
String businessId = ContextUtil.getProject();
CereBusinessWxpay businessWxpay = cereBusinessWxpayService.getByBusinessId(Long.valueOf(businessId));
Map<String, String> reqParams = new HashMap<>(); Map<String, String> reqParams = new HashMap<>();
//生成一个新的订单支付编号 //生成一个新的订单支付编号
String outTradeNo=orderFormid+"-"+ RandomStringUtil.getRandomCode(3,0); String outTradeNo=orderFormid+"-"+ RandomStringUtil.getRandomCode(3,0);
//微信分配的小程序ID //微信分配的小程序ID
reqParams.put("appid",appid);
reqParams.put("appid",businessWxpay.getAppId());
//微信支付分配的商户号 //微信支付分配的商户号
reqParams.put("mch_id",mch_id);
reqParams.put("mch_id",businessWxpay.getMchId());
//随机字符串 //随机字符串
reqParams.put("nonce_str", System.currentTimeMillis() / 1000 + ""); reqParams.put("nonce_str", System.currentTimeMillis() / 1000 + "");
//签名类型 //签名类型
@ -335,7 +357,7 @@ public class WxPayServiceImpl implements WxPayService {
//用户标识 //用户标识
// reqParams.put("openid", openid); // reqParams.put("openid", openid);
//签名 //签名
String sign = WXPayUtil.generateSignature(reqParams,key);
String sign = WXPayUtil.generateSignature(reqParams, businessWxpay.getMchKey());
reqParams.put("sign", sign); reqParams.put("sign", sign);
/* /*
调用支付定义下单API,返回预付单信息 prepay_id 调用支付定义下单API,返回预付单信息 prepay_id

8
cereshop-app/src/main/java/com/shop/cereshop/app/service/buyer/impl/CereBuyerUserServiceImpl.java

@ -32,6 +32,7 @@ import com.shop.cereshop.app.redis.service.api.UserRedisService;
import com.shop.cereshop.app.service.activity.CereBuyerCouponService; import com.shop.cereshop.app.service.activity.CereBuyerCouponService;
import com.shop.cereshop.app.service.after.CereOrderAfterService; import com.shop.cereshop.app.service.after.CereOrderAfterService;
import com.shop.cereshop.app.service.buyer.*; import com.shop.cereshop.app.service.buyer.*;
import com.shop.cereshop.app.service.bwxpay.CereBusinessWxpayService;
import com.shop.cereshop.app.service.cart.CereShopCartService; import com.shop.cereshop.app.service.cart.CereShopCartService;
import com.shop.cereshop.app.service.collect.CereBuyerCollectService; import com.shop.cereshop.app.service.collect.CereBuyerCollectService;
import com.shop.cereshop.app.service.collect.CereBuyerFootprintService; import com.shop.cereshop.app.service.collect.CereBuyerFootprintService;
@ -55,6 +56,7 @@ import com.shop.cereshop.commons.constant.CreditOptTypeEnum;
import com.shop.cereshop.commons.constant.IntegerEnum; import com.shop.cereshop.commons.constant.IntegerEnum;
import com.shop.cereshop.commons.domain.buyer.CereBuyerTrackReport; import com.shop.cereshop.commons.domain.buyer.CereBuyerTrackReport;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser; import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay;
import com.shop.cereshop.commons.domain.canvas.CerePlatformCanvas; import com.shop.cereshop.commons.domain.canvas.CerePlatformCanvas;
import com.shop.cereshop.commons.domain.common.Page; import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.common.PageParam; import com.shop.cereshop.commons.domain.common.PageParam;
@ -180,6 +182,9 @@ public class CereBuyerUserServiceImpl implements CereBuyerUserService {
@Value("${scrmTrackReportUrl}") @Value("${scrmTrackReportUrl}")
private String scrmTrackReportUrl; private String scrmTrackReportUrl;
@Autowired
private CereBusinessWxpayService businessWxpayService;
@Override @Override
public CereBuyerUser findByToken(String token) { public CereBuyerUser findByToken(String token) {
Long buyerUserId = userRedisService.getBuyerUserIdByToken(token); Long buyerUserId = userRedisService.getBuyerUserIdByToken(token);
@ -219,7 +224,8 @@ public class CereBuyerUserServiceImpl implements CereBuyerUserService {
BuyerUser user=null; BuyerUser user=null;
String time = TimeUtils.yyMMddHHmmss(); String time = TimeUtils.yyMMddHHmmss();
//根据微信code获取unionId //根据微信code获取unionId
JSONObject wx = WechatUtil.getOpenId(param.getCode());
CereBusinessWxpay businessWxpay = businessWxpayService.getByBusinessId(Long.valueOf(ContextUtil.getProject()));
JSONObject wx = WechatUtil.getOpenId(businessWxpay.getAppId(), businessWxpay.getSecret(), param.getCode());
String openid=wx.get("openid").toString(); String openid=wx.get("openid").toString();
String unionId=""; String unionId="";
if(!EmptyUtils.isEmpty(wx.get("unionid"))){ if(!EmptyUtils.isEmpty(wx.get("unionid"))){

2
cereshop-app/src/main/java/com/shop/cereshop/app/service/bwxpay/CereBusinessWxpayService.java

@ -17,5 +17,5 @@ public interface CereBusinessWxpayService {
void update(CereBusinessWxpay businessWxpay) throws CoBusinessException; void update(CereBusinessWxpay businessWxpay) throws CoBusinessException;
CereBuyerBank getByBusinessId(Long businessId) throws CoBusinessException;
CereBusinessWxpay getByBusinessId(Long businessId) throws CoBusinessException;
} }

2
cereshop-app/src/main/java/com/shop/cereshop/app/service/bwxpay/impl/CereBusinessWxpayServiceImpl.java

@ -35,7 +35,7 @@ public class CereBusinessWxpayServiceImpl implements CereBusinessWxpayService {
} }
@Override @Override
public CereBuyerBank getByBusinessId(Long businessId) throws CoBusinessException {
public CereBusinessWxpay getByBusinessId(Long businessId) throws CoBusinessException {
cereBusinessWxpayDao.getByBusinessId(businessId); cereBusinessWxpayDao.getByBusinessId(businessId);
return null; return null;
} }

10
cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java

@ -39,6 +39,7 @@ import com.shop.cereshop.app.service.activity.CerePlatformActivityService;
import com.shop.cereshop.app.service.business.CereBusinessBuyerUserService; import com.shop.cereshop.app.service.business.CereBusinessBuyerUserService;
import com.shop.cereshop.app.service.buyer.CereBuyerCommentLikeService; import com.shop.cereshop.app.service.buyer.CereBuyerCommentLikeService;
import com.shop.cereshop.app.service.buyer.CereBuyerReceiveService; import com.shop.cereshop.app.service.buyer.CereBuyerReceiveService;
import com.shop.cereshop.app.service.bwxpay.CereBusinessWxpayService;
import com.shop.cereshop.app.service.collect.CereBuyerCollectService; import com.shop.cereshop.app.service.collect.CereBuyerCollectService;
import com.shop.cereshop.app.service.collect.CereBuyerFootprintService; import com.shop.cereshop.app.service.collect.CereBuyerFootprintService;
import com.shop.cereshop.app.service.coupon.CereShopCouponService; import com.shop.cereshop.app.service.coupon.CereShopCouponService;
@ -73,6 +74,7 @@ import com.shop.cereshop.commons.constant.ParamEnum;
import com.shop.cereshop.commons.domain.business.CereBusinessBuyerUser; import com.shop.cereshop.commons.domain.business.CereBusinessBuyerUser;
import com.shop.cereshop.commons.domain.buyer.CereBuyerCommentLike; import com.shop.cereshop.commons.domain.buyer.CereBuyerCommentLike;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser; import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay;
import com.shop.cereshop.commons.domain.collect.CereBuyerCollect; import com.shop.cereshop.commons.domain.collect.CereBuyerCollect;
import com.shop.cereshop.commons.domain.collect.CereBuyerFootprint; import com.shop.cereshop.commons.domain.collect.CereBuyerFootprint;
import com.shop.cereshop.commons.domain.common.Page; import com.shop.cereshop.commons.domain.common.Page;
@ -231,7 +233,7 @@ public class CereShopProductServiceImpl implements CereShopProductService {
private CereShopProductLangInfoService shopProductLangInfoService; private CereShopProductLangInfoService shopProductLangInfoService;
@Autowired @Autowired
private CereShopProductLangInfoDAO shopProductLangInfoDAO;
private CereBusinessWxpayService businessWxpayService;
@Autowired @Autowired
private CereSkuNameLangInfoService cereSkuNameLangInfoService; private CereSkuNameLangInfoService cereSkuNameLangInfoService;
@ -1177,7 +1179,8 @@ public class CereShopProductServiceImpl implements CereShopProductService {
distributorId = distributor.getDistributorId(); distributorId = distributor.getDistributorId();
} }
String itemUrlSuffix = "?shopId="+param.getShopId()+"&productId="+param.getProductId()+"&skuId="+param.getSkuId()+"&salesId="+distributorId; String itemUrlSuffix = "?shopId="+param.getShopId()+"&productId="+param.getProductId()+"&skuId="+param.getSkuId()+"&salesId="+distributorId;
String accessToken = WechatUtil.getAccessToken();
CereBusinessWxpay businessWxpay = businessWxpayService.getByBusinessId(Long.valueOf(user.getProject()));
String accessToken = WechatUtil.getAccessToken(businessWxpay.getAppId(), businessWxpay.getSecret());
return genPoster(env,itemPicUrl,shareHeadUrl,shareName,itemName,itemPrice,itemUrlSuffix,accessToken); return genPoster(env,itemPicUrl,shareHeadUrl,shareName,itemName,itemPrice,itemUrlSuffix,accessToken);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -1411,7 +1414,8 @@ public class CereShopProductServiceImpl implements CereShopProductService {
String itemUrlSuffix = "?shopId="+param.getShopId()+"&productId="+param.getProductId()+"&skuId="+param.getSkuId()+"&salesId="+distributorId; String itemUrlSuffix = "?shopId="+param.getShopId()+"&productId="+param.getProductId()+"&skuId="+param.getSkuId()+"&salesId="+distributorId;
String accessToken = null; String accessToken = null;
if (env == 1 || env == 2) { if (env == 1 || env == 2) {
accessToken = WechatUtil.getAccessToken();
CereBusinessWxpay businessWxpay = businessWxpayService.getByBusinessId(Long.valueOf(user.getProject()));
accessToken = WechatUtil.getAccessToken(businessWxpay.getAppId(), businessWxpay.getSecret());
} }
String qrCodeBase64 = genPosterSimple(env,itemUrlSuffix,accessToken); String qrCodeBase64 = genPosterSimple(env,itemUrlSuffix,accessToken);
ShareProduct result = new ShareProduct(); ShareProduct result = new ShareProduct();

9
cereshop-app/src/main/java/com/shop/cereshop/app/service/shop/impl/CerePlatformShopServiceImpl.java

@ -20,6 +20,7 @@ import com.shop.cereshop.app.page.shop.*;
import com.shop.cereshop.app.param.shop.ShopParam; import com.shop.cereshop.app.param.shop.ShopParam;
import com.shop.cereshop.app.param.shop.ShopPosterParam; import com.shop.cereshop.app.param.shop.ShopPosterParam;
import com.shop.cereshop.app.service.buyer.CereBuyerShopCouponService; import com.shop.cereshop.app.service.buyer.CereBuyerShopCouponService;
import com.shop.cereshop.app.service.bwxpay.CereBusinessWxpayService;
import com.shop.cereshop.app.service.collect.CereBuyerCollectService; import com.shop.cereshop.app.service.collect.CereBuyerCollectService;
import com.shop.cereshop.app.service.distributor.CereShopDistributorService; import com.shop.cereshop.app.service.distributor.CereShopDistributorService;
import com.shop.cereshop.app.service.product.CereShopProductService; import com.shop.cereshop.app.service.product.CereShopProductService;
@ -31,6 +32,7 @@ import com.shop.cereshop.commons.cache.product.ProductBo;
import com.shop.cereshop.commons.constant.CoReturnFormat; import com.shop.cereshop.commons.constant.CoReturnFormat;
import com.shop.cereshop.commons.constant.IntegerEnum; import com.shop.cereshop.commons.constant.IntegerEnum;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser; import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay;
import com.shop.cereshop.commons.domain.collect.CereBuyerCollect; import com.shop.cereshop.commons.domain.collect.CereBuyerCollect;
import com.shop.cereshop.commons.domain.common.Page; import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.shop.CerePlatformShop; import com.shop.cereshop.commons.domain.shop.CerePlatformShop;
@ -87,6 +89,9 @@ public class CerePlatformShopServiceImpl implements CerePlatformShopService {
@Autowired @Autowired
private FileStrategy fileStrategy; private FileStrategy fileStrategy;
@Autowired
private CereBusinessWxpayService businessWxpayService;
/** /**
* 店铺页面前缀 * 店铺页面前缀
*/ */
@ -412,8 +417,8 @@ public class CerePlatformShopServiceImpl implements CerePlatformShopService {
if (param.getDistributorId() != null) { if (param.getDistributorId() != null) {
invitationCode = cereShopDistributorService.findInvitationCode(param.getDistributorId()); invitationCode = cereShopDistributorService.findInvitationCode(param.getDistributorId());
} }
String accessToken = WechatUtil.getAccessToken();
CereBusinessWxpay businessWxpay = businessWxpayService.getByBusinessId(Long.valueOf(user.getProject()));
String accessToken = WechatUtil.getAccessToken(businessWxpay.getAppId(), businessWxpay.getSecret());
return genPoster(env,param.getType(),shop.getShopId(),shareHeadUrl,shareName,shop.getShopBrief(),invitationCode,list,accessToken,param.getDistributorId()); return genPoster(env,param.getType(),shop.getShopId(),shareHeadUrl,shareName,shop.getShopBrief(),invitationCode,list,accessToken,param.getDistributorId());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

18
cereshop-app/src/main/java/com/shop/cereshop/app/utils/WechatUtil.java

@ -45,14 +45,14 @@ public class WechatUtil {
/** /**
* 支付小程序appid * 支付小程序appid
*/ */
private static String appId;
//private static String appId;
/** /**
* 支付小程序秘钥 * 支付小程序秘钥
*/ */
private static String secret;
//private static String secret;
@Value("${weixin.appid}")
/* @Value("${weixin.appid}")
public void setAppId(String appId){ public void setAppId(String appId){
this.appId = appId; this.appId = appId;
} }
@ -60,14 +60,14 @@ public class WechatUtil {
@Value("${weixin.secret}") @Value("${weixin.secret}")
public void setSecret(String secret){ public void setSecret(String secret){
this.secret = secret; this.secret = secret;
}
}*/
/** /**
* 获取小程序codeid换取openid * 获取小程序codeid换取openid
* @param code * @param code
* @return * @return
*/ */
public static JSONObject getOpenId(String code) {
public static JSONObject getOpenId(String appId, String secret, String code) {
String url = "https://api.weixin.qq.com/sns/jscode2session?appid="+ appId +"&secret=" + String url = "https://api.weixin.qq.com/sns/jscode2session?appid="+ appId +"&secret=" +
secret +"&js_code="+code+"&grant_type=authorization_code"; secret +"&js_code="+code+"&grant_type=authorization_code";
PrintWriter out = null; PrintWriter out = null;
@ -125,7 +125,7 @@ public class WechatUtil {
* 获取小程序token * 获取小程序token
* @return * @return
*/ */
public static String getAccessToken() {
public static String getAccessToken(String appId, String secret) {
String url = "https://api.weixin.qq.com/cgi-bin/token?" + String url = "https://api.weixin.qq.com/cgi-bin/token?" +
"appid="+ appId + "&secret=" + secret + "&grant_type=client_credential"; "appid="+ appId + "&secret=" + secret + "&grant_type=client_credential";
PrintWriter out = null; PrintWriter out = null;
@ -184,7 +184,7 @@ public class WechatUtil {
* @param code * @param code
* @return * @return
*/ */
public static JSONObject getAccessTokenOrOpenid(String code) {
public static JSONObject getAccessTokenOrOpenid(String appId, String secret, String code) {
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?" + String url = "https://api.weixin.qq.com/sns/oauth2/access_token?" +
"appid="+ appId +"&secret="+ secret +"&code="+code+"&grant_type=authorization_code"; "appid="+ appId +"&secret="+ secret +"&code="+code+"&grant_type=authorization_code";
PrintWriter out = null; PrintWriter out = null;
@ -346,10 +346,12 @@ public class WechatUtil {
/** /**
* 获取微信小程序 session_key openid * 获取微信小程序 session_key openid
* *
* @param appId
* @param secret
* @param code 调用微信登陆返回的Code * @param code 调用微信登陆返回的Code
* @return * @return
*/ */
public static JSONObject getSessionKeyOropenid(String code) {
public static JSONObject getSessionKeyOropenid(String appId, String secret, String code) {
//微信端登录code值 //微信端登录code值
String wxCode = code; String wxCode = code;
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session"; //请求地址 https://api.weixin.qq.com/sns/jscode2session String requestUrl = "https://api.weixin.qq.com/sns/jscode2session"; //请求地址 https://api.weixin.qq.com/sns/jscode2session

19
cereshop-app/src/main/resources/mybatis/mapper/bwxpay/CereBusinessWxpayDAO.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shop.cereshop.app.dao.bwxpay.CereBusinessWxpayDao">
<resultMap id="BaseResultMap" type="com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="business_id" jdbcType="BIGINT" property="businessId" />
<result column="app_id" jdbcType="VARCHAR" property="appId" />
<result column="app_app_id" jdbcType="VARCHAR" property="appAppId" />
<result column="mch_id" jdbcType="VARCHAR" property="mchId" />
<result column="cert_url" jdbcType="VARCHAR" property="certUrl" />
<result column="mch_key" jdbcType="VARCHAR" property="mchKey" />
<result column="secret" jdbcType="VARCHAR" property="secret" />
</resultMap>
<select id="getByBusinessId" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay">
SELECT * FROM cere_business_wxpay where business_id = #{businessId}
</select>
</mapper>

20
cereshop-business/src/main/java/com/shop/cereshop/business/dao/bwxpay/CereBusinessWxpayDao.java

@ -0,0 +1,20 @@
package com.shop.cereshop.business.dao.bwxpay;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 描述
*
* @author stevenhu
* @version 2025/02/20 11:49
*/
@Mapper
public interface CereBusinessWxpayDao extends BaseMapper<CereBusinessWxpay> {
CereBusinessWxpay getByBusinessId(@Param("businessId") Long businessId);
}

3
cereshop-business/src/main/java/com/shop/cereshop/business/pay/PayService.java

@ -15,6 +15,7 @@ public interface PayService {
/** /**
* 退款 * 退款
* @param project 所属平台号(即商家id)
* @param outTradeNo 支付时使用的商家订单号 * @param outTradeNo 支付时使用的商家订单号
* @param transactionId 支付单号 * @param transactionId 支付单号
* @param outRefundNo 支付生成的退款单号 * @param outRefundNo 支付生成的退款单号
@ -24,7 +25,7 @@ public interface PayService {
* @throws CoBusinessException * @throws CoBusinessException
* @throws Exception * @throws Exception
*/ */
Map<String,String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws CoBusinessException, Exception;
Map<String,String> refund(String project, String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws CoBusinessException, Exception;
/** /**

2
cereshop-business/src/main/java/com/shop/cereshop/business/pay/alipay/service/impl/AliPayServiceImpl.java

@ -37,7 +37,7 @@ import java.util.Map;
public class AliPayServiceImpl implements AliPayService { public class AliPayServiceImpl implements AliPayService {
@Override @Override
public Map<String, String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws CoBusinessException, Exception {
public Map<String, String> refund(String project, String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws CoBusinessException, Exception {
Map<String, String> result = new HashMap<>(); Map<String, String> result = new HashMap<>();
AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE); AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE);

2
cereshop-business/src/main/java/com/shop/cereshop/business/pay/alipay/service/impl/HuabeiPayServiceImpl.java

@ -31,7 +31,7 @@ import java.util.Map;
public class HuabeiPayServiceImpl implements HuabeiPayService { public class HuabeiPayServiceImpl implements HuabeiPayService {
@Override @Override
public Map<String, String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws CoBusinessException, Exception {
public Map<String, String> refund(String project, String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws CoBusinessException, Exception {
Map<String, String> result = new HashMap<>(); Map<String, String> result = new HashMap<>();
AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE); AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE);

2
cereshop-business/src/main/java/com/shop/cereshop/business/pay/hnapay/impl/HnaPayServiceImpl.java

@ -116,7 +116,7 @@ public class HnaPayServiceImpl implements HnaPayService {
} }
@Override @Override
public Map<String, String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws CoBusinessException, Exception {
public Map<String, String> refund(String project, String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws CoBusinessException, Exception {
List<CereShopOrder> orderList = null; List<CereShopOrder> orderList = null;
String cereOrderFormId = orderFormId; String cereOrderFormId = orderFormId;
String[] split = orderFormId.split("-"); String[] split = orderFormId.split("-");

6
cereshop-business/src/main/java/com/shop/cereshop/business/pay/weixin/service/impl/WxPayServiceImpl.java

@ -12,6 +12,7 @@ import com.shop.cereshop.business.pay.weixin.skd.PaymentApi;
import com.shop.cereshop.business.pay.weixin.skd.PaymentKit; import com.shop.cereshop.business.pay.weixin.skd.PaymentKit;
import com.shop.cereshop.business.pay.weixin.skd.WXPayUtil; import com.shop.cereshop.business.pay.weixin.skd.WXPayUtil;
import com.shop.cereshop.business.pay.weixin.skd.WXPayV3Util; import com.shop.cereshop.business.pay.weixin.skd.WXPayV3Util;
import com.shop.cereshop.business.service.bwxpay.CereBusinessWxpayService;
import com.shop.cereshop.commons.constant.WxPayEnum; import com.shop.cereshop.commons.constant.WxPayEnum;
import com.shop.cereshop.commons.exception.CoBusinessException; import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.RandomStringUtil; import com.shop.cereshop.commons.utils.RandomStringUtil;
@ -94,8 +95,11 @@ public class WxPayServiceImpl implements WxPayService {
@Autowired @Autowired
private WXPayV3Util wxPayV3Util; private WXPayV3Util wxPayV3Util;
@Autowired
private CereBusinessWxpayService cereBusinessWxpayService;
@Override @Override
public Map<String, String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws CoBusinessException, Exception {
public Map<String, String> refund(String project, String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws CoBusinessException, Exception {
//APPV3版本的退款以APPV3开头 //APPV3版本的退款以APPV3开头
if (outRefundNo.startsWith("APPV3")) { if (outRefundNo.startsWith("APPV3")) {
return refundWithV3(transactionId, outRefundNo, total, refund); return refundWithV3(transactionId, outRefundNo, total, refund);

2
cereshop-business/src/main/java/com/shop/cereshop/business/pay/xs/service/impl/XsPayServiceImpl.java

@ -69,7 +69,7 @@ public class XsPayServiceImpl implements XsPayService {
private CereShopBankDAO cereShopBankDAO; private CereShopBankDAO cereShopBankDAO;
@Override @Override
public Map<String, String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws Exception {
public Map<String, String> refund(String project, String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws Exception {
Map<String, Object> contentMap = build22ContentMap(orderFormId, outRefundNo, outTradeNo, transactionId, refund, Map<String, Object> contentMap = build22ContentMap(orderFormId, outRefundNo, outTradeNo, transactionId, refund,
XspayConfig.BUSINESS_RETURN_NOTICE_URL); XspayConfig.BUSINESS_RETURN_NOTICE_URL);
String respMsg = XsPayUtils.requestByXs(SHARE_REFUND_SER_CODE, contentMap); String respMsg = XsPayUtils.requestByXs(SHARE_REFUND_SER_CODE, contentMap);

4
cereshop-business/src/main/java/com/shop/cereshop/business/service/after/impl/CereOrderAfterServiceImpl.java

@ -201,7 +201,7 @@ public class CereOrderAfterServiceImpl implements CereOrderAfterService {
CereShopOrder order = cereShopOrderService.findById(param.getOrderId()); CereShopOrder order = cereShopOrderService.findById(param.getOrderId());
// handleWxLogTest(refund.getOrderFormid(),refund.getTransactionId(),refund.getOutTradeNo(),param.getAfterId()); // handleWxLogTest(refund.getOrderFormid(),refund.getTransactionId(),refund.getOutTradeNo(),param.getAfterId());
PayService payService = PayFactory.getPayService(order.getPaymentMode()); PayService payService = PayFactory.getPayService(order.getPaymentMode());
Map<String, String> resultMap = payService.refund( refund.getOrderFormid(), refund.getOutTradeNo(), refund.getTransactionId(), refund.getOutRefundNo(), refund.getOrderPrice(), refund.getPrice(), param.getAfterId());
Map<String, String> resultMap = payService.refund(order.getProject(), refund.getOrderFormid(), refund.getOutTradeNo(), refund.getTransactionId(), refund.getOutRefundNo(), refund.getOrderPrice(), refund.getPrice(), param.getAfterId());
if(!EmptyUtils.isEmpty(resultMap)){ if(!EmptyUtils.isEmpty(resultMap)){
if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&& if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&&
resultMap.get("return_code").equals(WxPayEnum.REFUND_OK.getCode())){ resultMap.get("return_code").equals(WxPayEnum.REFUND_OK.getCode())){
@ -339,7 +339,7 @@ public class CereOrderAfterServiceImpl implements CereOrderAfterService {
cerePayLogService.update(payLog); cerePayLogService.update(payLog);
CereShopOrder order = cereShopOrderService.findById(param.getOrderId()); CereShopOrder order = cereShopOrderService.findById(param.getOrderId());
PayService payService = PayFactory.getPayService(order.getPaymentMode()); PayService payService = PayFactory.getPayService(order.getPaymentMode());
Map<String, String> resultMap = payService.refund(refund.getOrderFormid(), refund.getOutTradeNo(), refund.getTransactionId(), refund.getOutRefundNo(), refund.getOrderPrice(), refund.getPrice(), param.getAfterId());
Map<String, String> resultMap = payService.refund(order.getProject(), refund.getOrderFormid(), refund.getOutTradeNo(), refund.getTransactionId(), refund.getOutRefundNo(), refund.getOrderPrice(), refund.getPrice(), param.getAfterId());
if(!EmptyUtils.isEmpty(resultMap)){ if(!EmptyUtils.isEmpty(resultMap)){
if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&& if(resultMap.get("return_msg").equals(WxPayEnum.REFUND_SUCCESS.getCode())&&
resultMap.get("return_code").equals(WxPayEnum.REFUND_OK.getCode())){ resultMap.get("return_code").equals(WxPayEnum.REFUND_OK.getCode())){

19
cereshop-business/src/main/java/com/shop/cereshop/business/service/bwxpay/CereBusinessWxpayService.java

@ -0,0 +1,19 @@
package com.shop.cereshop.business.service.bwxpay;
import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay;
import com.shop.cereshop.commons.exception.CoBusinessException;
/**
* 描述
*
* @author stevenhu
* @version 2025/02/20 14:19
*/
public interface CereBusinessWxpayService {
void save(CereBusinessWxpay record) throws CoBusinessException;
void update(CereBusinessWxpay businessWxpay) throws CoBusinessException;
CereBusinessWxpay getByBusinessId(Long businessId) throws CoBusinessException;
}

40
cereshop-business/src/main/java/com/shop/cereshop/business/service/bwxpay/impl/CereBusinessWxpayServiceImpl.java

@ -0,0 +1,40 @@
package com.shop.cereshop.business.service.bwxpay.impl;
import com.shop.cereshop.business.dao.bwxpay.CereBusinessWxpayDao;
import com.shop.cereshop.business.service.bwxpay.CereBusinessWxpayService;
import com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay;
import com.shop.cereshop.commons.exception.CoBusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* 描述
*
* @author stevenhu
* @version 2025/02/20 14:21
*/
@Service
public class CereBusinessWxpayServiceImpl implements CereBusinessWxpayService {
@Autowired
private CereBusinessWxpayDao cereBusinessWxpayDao;
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class})
public void save(CereBusinessWxpay record) throws CoBusinessException {
cereBusinessWxpayDao.insert(record);
}
@Override
public void update(CereBusinessWxpay businessWxpay) throws CoBusinessException {
cereBusinessWxpayDao.updateById(businessWxpay);
}
@Override
public CereBusinessWxpay getByBusinessId(Long businessId) throws CoBusinessException {
return cereBusinessWxpayDao.getByBusinessId(businessId);
}
}

19
cereshop-business/src/main/resources/mybatis/mapper/bwxpay/CereBusinessWxpayDAO.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shop.cereshop.business.dao.bwxpay.CereBusinessWxpayDao">
<resultMap id="BaseResultMap" type="com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="business_id" jdbcType="BIGINT" property="businessId" />
<result column="app_id" jdbcType="VARCHAR" property="appId" />
<result column="app_app_id" jdbcType="VARCHAR" property="appAppId" />
<result column="mch_id" jdbcType="VARCHAR" property="mchId" />
<result column="cert_url" jdbcType="VARCHAR" property="certUrl" />
<result column="mch_key" jdbcType="VARCHAR" property="mchKey" />
<result column="secret" jdbcType="VARCHAR" property="secret" />
</resultMap>
<select id="getByBusinessId" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.bwxpay.CereBusinessWxpay">
SELECT * FROM cere_business_wxpay where business_id = #{businessId}
</select>
</mapper>
Loading…
Cancel
Save