fix: 修复分账配置更新不生效问题, 修复wxjava配置使用base64无法解析问题, 修复微信分账同步有空指针问题

This commit is contained in:
DaxPay
2024-12-17 16:50:05 +08:00
parent 98b07dba77
commit c0ee1dd7f8
7 changed files with 41 additions and 38 deletions

View File

@@ -1,11 +1,14 @@
# 单商户
## 3.0.1 功能优化
- [ ] 网关配套移动端开发
- [ ] 同步回调页
- [ ] 收银台功能优化
- [ ] 支持配置背景色和图标
- [ ] 定时同步任务频次不要太高, 预防产生过多的数据
- [ ] 增加首页驾驶舱功能
- [ ] 商户应用应该要有一个类似删除的功能, 实现停用冻结, 但不影响数据的关联
## 3.0.0.bate3: 功能完善
- 优化:
- [ ] 增加首页驾驶舱功能
- [x] 分账界面功能
- [x] 分账接收方配置
- [x] 分账单管理
@@ -18,8 +21,6 @@
- [ ] 自动完成
- [ ] 自动同步状态
- [ ] 分账消息通知和回调
- [ ] 网关配套移动端开发
- [ ] 同步回调页
- [x] 分账接收方和分账组优化, 后台管理时, 编号自动生成
- [x] 微信通道添加单独的认证跳转地址, 处理它的特殊情况
- [x] 支付订单新增待支付状态
@@ -47,7 +48,7 @@
- [x] 码牌不再使用应用号作为标识, 使用独立的编码
- [x] 码牌H5页面对接
- [ ] 分账配置/分账组/分账接收方合并为一个tabs页面
## 3.0.0.beta2 收银台
## 3.0.0.beta1 收银台
- [x] 收银台功能
- [x] 收银台配置
- [x] 分类配置
@@ -63,8 +64,6 @@
- [x] H5收银台
- [x] 跳转支付
- [x] 升级为聚合支付
- [ ] ~~APP调起支付~~
- [ ] ~~小程序支付~~
- [x] 聚合收银台
- [x] Jsapi调用
- [x] 跳转支付
@@ -80,5 +79,3 @@
## 任务池
- [ ] 退款支持以撤销的方式进行退款
- [ ] 商户应用增加启停用状态
- [ ] 商户应用应该要有一个类似删除的功能, 实现停用冻结, 但不影响数据的关联

View File

@@ -30,8 +30,10 @@ import org.dromara.daxpay.service.entity.allocation.transaction.AllocOrder;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -126,7 +128,7 @@ public class WeChatPayAllocationV2Service {
}
var detailMap = details.stream()
.collect(Collectors.toMap(AllocDetail::getReceiverAccount, Function.identity(), CollectorsFunction::retainLatest));
var royaltyDetailList = result.getReceivers();
var royaltyDetailList = Optional.ofNullable( result.getReceivers()).orElse(new ArrayList<>(0));
for (var receiver : royaltyDetailList) {
var detail = detailMap.get(receiver.getAccount());
if (Objects.nonNull(detail)) {

View File

@@ -28,8 +28,10 @@ import org.dromara.daxpay.service.entity.allocation.transaction.AllocOrder;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -124,7 +126,7 @@ public class WeChatPayAllocationV3Service {
}
var detailMap = details.stream()
.collect(Collectors.toMap(AllocDetail::getReceiverAccount, Function.identity(), CollectorsFunction::retainLatest));
var royaltyDetailList = result.getReceivers();
var royaltyDetailList = Optional.ofNullable(result.getReceivers()).orElse(new ArrayList<>(0));
for (var receiver : royaltyDetailList) {
var detail = detailMap.get(receiver.getAccount());
if (Objects.nonNull(detail)) {

View File

@@ -2,6 +2,7 @@ package org.dromara.daxpay.channel.wechat.service.config;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.StrUtil;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
@@ -146,10 +147,11 @@ public class WechatPayConfigService {
payConfig.setAppId(wechatPayConfig.getWxAppId());
payConfig.setMchKey(wechatPayConfig.getApiKeyV2());
payConfig.setApiV3Key(wechatPayConfig.getApiKeyV3());
payConfig.setPrivateKeyString(wechatPayConfig.getPrivateKey());
payConfig.setPrivateCertString(wechatPayConfig.getPrivateCert());
// 注意不要使用base64的方式进行配置, 因为wxjava 是直接读取文本并不会进行解码
payConfig.setPrivateKeyContent(Base64.decode(wechatPayConfig.getPrivateKey()));
payConfig.setPrivateCertContent(Base64.decode(wechatPayConfig.getPrivateCert()));
payConfig.setCertSerialNo(wechatPayConfig.getCertSerialNo());
payConfig.setKeyString(wechatPayConfig.getP12());
payConfig.setKeyContent(Base64.decode(wechatPayConfig.getP12()));
WxPayService wxPayService = new WxPayServiceImpl();
wxPayService.setConfig(payConfig);
return wxPayService;

View File

@@ -191,32 +191,32 @@ public class WechatPayV3Service {
*/
private void barCodePay(PayOrder payOrder, String authCode, WechatPayConfig config, PayResultBo payResult) {
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(config);
WxPayCodepayRequest request = new WxPayCodepayRequest();
request.setDescription(payOrder.getTitle());
request.setOutTradeNo(payOrder.getOrderNo());
// 金额
var amount = new WxPayCodepayRequest.Amount();
amount.setTotal(PayUtil.convertCentAmount(payOrder.getAmount()));
request.setAmount(amount);
WxPayCodepayRequest request = new WxPayCodepayRequest();
request.setDescription(payOrder.getTitle());
request.setOutTradeNo(payOrder.getOrderNo());
// 金额
var amount = new WxPayCodepayRequest.Amount();
amount.setTotal(PayUtil.convertCentAmount(payOrder.getAmount()));
request.setAmount(amount);
// 场景信息
var sceneInfo = new WxPayCodepayRequest.SceneInfo();
var storeInfo = new WxPayCodepayRequest.StoreInfo();
storeInfo.setOutId("1");
sceneInfo.setStoreInfo(storeInfo);
request.setSceneInfo(sceneInfo);
// 场景信息
var sceneInfo = new WxPayCodepayRequest.SceneInfo();
var storeInfo = new WxPayCodepayRequest.StoreInfo();
storeInfo.setOutId("1");
sceneInfo.setStoreInfo(storeInfo);
request.setSceneInfo(sceneInfo);
// 条码参数
var payer = new WxPayCodepayRequest.Payer();
payer.setAuthCode(authCode);
request.setPayer(payer);
// 条码参数
var payer = new WxPayCodepayRequest.Payer();
payer.setAuthCode(authCode);
request.setPayer(payer);
// 分账参数
if (payOrder.getAllocation()){
var settleInfo = new WxPayCodepayRequest.SettleInfo();
settleInfo.setProfitSharing(true);
request.setSettleInfo(settleInfo);
}
// 分账参数
if (payOrder.getAllocation()){
var settleInfo = new WxPayCodepayRequest.SettleInfo();
settleInfo.setProfitSharing(true);
request.setSettleInfo(settleInfo);
}
try {
// 发送请求
var result = wxPayService.codepay(request);

View File

@@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.*;
@RequestGroup(groupCode = "AllocConfig", groupName = "分账配置", moduleCode = "Alloc", moduleName = "分账管理" )
@RequestMapping("/allocation/config")
@RequiredArgsConstructor
public class AllocController {
public class AllocConfigController {
private final AllocConfigService allocConfigService;
@RequestPath("保存")

View File

@@ -43,7 +43,7 @@ public class AllocConfigService {
public void update(AllocConfigParam param) {
AllocConfig config = allocConfigManger.findById(param.getId())
.orElseThrow(() -> new DataNotExistException("分账配置不存在"));
BeanUtil.copyProperties(config, param, CopyOptions.create().ignoreNullValue());
BeanUtil.copyProperties(param, config, CopyOptions.create().ignoreNullValue());
allocConfigManger.updateById(config);
}