|
|
@@ -17,8 +17,10 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.modules.pay.config.*;
|
|
|
import org.jeecg.modules.pay.serverPay.WXPayUtility;
|
|
|
+import org.jeecg.modules.system.app.dto.receiptPaymentDetails.ReceiptPaymentDetailsInfoVo;
|
|
|
import org.jeecg.modules.system.app.entity.*;
|
|
|
import org.jeecg.modules.system.app.mapper.*;
|
|
|
+import org.jeecg.modules.system.app.service.IReceiptPaymentDetailsInfoService;
|
|
|
import org.jeecg.modules.system.entity.SysDepart;
|
|
|
import org.jeecg.modules.system.mapper.SysDepartMapper;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
@@ -75,6 +77,9 @@ public class WeChatPayService {
|
|
|
@Resource
|
|
|
private WeChatProfitSharingService weChatProfitSharingService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IReceiptPaymentDetailsInfoService iReceiptPaymentDetailsInfoService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 小程序支付拉起
|
|
|
@@ -520,6 +525,37 @@ public class WeChatPayService {
|
|
|
|
|
|
parm.put("code", "SUCCESS");
|
|
|
parm.put("message", "成功");
|
|
|
+ SysDepart sysDepart = sysDepartMapper.findByOrgCodeAndParentId(order.getOrgCode());
|
|
|
+ SeparateAccounts separateAccounts = separateAccountsMapper.findByDeptIdAndStatus(sysDepart.getId());
|
|
|
+ BigDecimal shBigDecimal = BigDecimal.ZERO;
|
|
|
+ try {
|
|
|
+ shBigDecimal = getBigDecimal(order.getPrice(), separateAccounts.getShSeparateAccounts());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("百分比计算错误", e);
|
|
|
+ }
|
|
|
+ BigDecimal ptBigDecimal = BigDecimal.ZERO;
|
|
|
+ try {
|
|
|
+ ptBigDecimal = getBigDecimal(order.getPrice(), separateAccounts.getPtSeparateAccounts());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("百分比计算错误", e);
|
|
|
+ }
|
|
|
+ SysDepart byOrgCode = sysDepartMapper.findByOrgCode("A01");
|
|
|
+ BigDecimal mdBigDecimal = order.getPrice().subtract(shBigDecimal).subtract(ptBigDecimal).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ log.info("退款成功消息通知,金额:" + mdBigDecimal + ";" + shBigDecimal + ";" + ptBigDecimal);
|
|
|
+ ReceiptPaymentDetailsInfoVo receiptPaymentDetailsInfoVo = new ReceiptPaymentDetailsInfoVo();
|
|
|
+ receiptPaymentDetailsInfoVo.setMoney(order.getPrice());
|
|
|
+ receiptPaymentDetailsInfoVo.setChangeMoney(appOrderRefundsInfo.getAmount());
|
|
|
+ receiptPaymentDetailsInfoVo.setPayType(1);
|
|
|
+ receiptPaymentDetailsInfoVo.setPurseChangeReason(1);
|
|
|
+ receiptPaymentDetailsInfoVo.setCreateTime(new Date());
|
|
|
+ receiptPaymentDetailsInfoVo.setUpdateTime(new Date());
|
|
|
+ receiptPaymentDetailsInfoVo.setOrderId(appOrderRefundsInfo.getOrderId());
|
|
|
+ ReceiptPaymentDetailsInfoVo receiptPaymentDetailsInfoVoMd = getChangeMoney(receiptPaymentDetailsInfoVo, order.getOrgCode(), order.getTenantId(), 2, mdBigDecimal);
|
|
|
+ ReceiptPaymentDetailsInfoVo receiptPaymentDetailsInfoVoSh = getChangeMoney(receiptPaymentDetailsInfoVo, order.getOrgCode(), sysDepart.getId(), 1, shBigDecimal);
|
|
|
+ ReceiptPaymentDetailsInfoVo receiptPaymentDetailsInfoVoPt = getChangeMoney(receiptPaymentDetailsInfoVo, order.getOrgCode(), byOrgCode.getId(), 0, ptBigDecimal);
|
|
|
+ iReceiptPaymentDetailsInfoService.add(receiptPaymentDetailsInfoVoPt);
|
|
|
+ iReceiptPaymentDetailsInfoService.add(receiptPaymentDetailsInfoVoSh);
|
|
|
+ iReceiptPaymentDetailsInfoService.add(receiptPaymentDetailsInfoVoMd);
|
|
|
} else {
|
|
|
parm.put("code", "FAIL");
|
|
|
parm.put("message", "失败");
|
|
|
@@ -528,6 +564,26 @@ public class WeChatPayService {
|
|
|
return parm; //返回给前端的参数
|
|
|
}
|
|
|
|
|
|
+ private ReceiptPaymentDetailsInfoVo getChangeMoney(ReceiptPaymentDetailsInfoVo receiptPaymentDetailsInfoVo, String orgCode, String deptId, Integer deptType, BigDecimal changeMoney) {
|
|
|
+ receiptPaymentDetailsInfoVo.setDeptId(deptId);
|
|
|
+ receiptPaymentDetailsInfoVo.setDeptType(deptType);
|
|
|
+ receiptPaymentDetailsInfoVo.setOrgCode(orgCode);
|
|
|
+ receiptPaymentDetailsInfoVo.setChangeMoney(changeMoney);
|
|
|
+ return receiptPaymentDetailsInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private BigDecimal getBigDecimal(BigDecimal bigDecimal1 ,BigDecimal bigDecimal2 ){
|
|
|
+ if (bigDecimal2.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ throw new IllegalArgumentException("扣款金额必须大于0");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bigDecimal1.compareTo(bigDecimal2) < 0) {
|
|
|
+ throw new IllegalArgumentException("余额不足");
|
|
|
+ }
|
|
|
+
|
|
|
+ return bigDecimal1.subtract(bigDecimal2);
|
|
|
+ }
|
|
|
+
|
|
|
//退款回调 解密数据
|
|
|
public String decryptToString(byte[] associatedData, byte[] nonce, String ciphertext) throws GeneralSecurityException, IOException {
|
|
|
try {
|