diff --git a/_doc/Task.md b/_doc/Task.md index 0f70f7ac..03091d6d 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -12,6 +12,9 @@ - [ ] 分账接口开发 - [ ] 网关配套移动端开发 - [ ] 同步回调页 +- [ ] 分账接收方和分账组优化 + - [ ] 后台管理时, 编号自动生成 + - [ ] 显示数据 - [x] 微信通道添加单独的认证跳转地址, 处理它的特殊情况 - [x] 支付订单新增待支付状态 ## 3.0.0.beta2 收银台 diff --git a/daxpay-single-channel/daxpay-single-alipay/src/main/java/org/dromara/daxpay/channel/alipay/service/allocation/AliPayAllocationService.java b/daxpay-single-channel/daxpay-single-alipay/src/main/java/org/dromara/daxpay/channel/alipay/service/allocation/AliPayAllocationService.java index bf53d56e..d9bf9c45 100644 --- a/daxpay-single-channel/daxpay-single-alipay/src/main/java/org/dromara/daxpay/channel/alipay/service/allocation/AliPayAllocationService.java +++ b/daxpay-single-channel/daxpay-single-alipay/src/main/java/org/dromara/daxpay/channel/alipay/service/allocation/AliPayAllocationService.java @@ -148,11 +148,11 @@ public class AliPayAllocationService { /** * 验证错误信息 */ - private void verifyErrorMsg(AlipayResponse alipayResponse) { - if (alipayResponse.isSuccess()) { - String errorMsg = alipayResponse.getSubMsg(); + private void verifyErrorMsg(AlipayResponse response) { + if (!response.isSuccess()) { + String errorMsg = response.getSubMsg(); if (StrUtil.isBlank(errorMsg)) { - errorMsg = alipayResponse.getMsg(); + errorMsg = response.getMsg(); } log.error("分账处理失败 {}", errorMsg); throw new TradeFailException(errorMsg); diff --git a/daxpay-single-channel/daxpay-single-wechat/src/main/java/org/dromara/daxpay/channel/wechat/service/pay/WechatPayV2Service.java b/daxpay-single-channel/daxpay-single-wechat/src/main/java/org/dromara/daxpay/channel/wechat/service/pay/WechatPayV2Service.java index 36e2850b..4bf4e0b8 100644 --- a/daxpay-single-channel/daxpay-single-wechat/src/main/java/org/dromara/daxpay/channel/wechat/service/pay/WechatPayV2Service.java +++ b/daxpay-single-channel/daxpay-single-wechat/src/main/java/org/dromara/daxpay/channel/wechat/service/pay/WechatPayV2Service.java @@ -142,6 +142,8 @@ public class WechatPayV2Service { private String qrCodePay(PayOrder payOrder, WechatPayConfig wechatPayConfig) { WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(wechatPayConfig); WxPayUnifiedOrderRequest request = this.buildRequest(payOrder); + // NATIVE此参数必传。此id为二维码中包含的商品Id,商户自行定义。 + request.setProductId(payOrder.getOrderNo()); try { var result = wxPayService.createOrder(WxPayConstants.TradeType.Specific.NATIVE, request); return result.getCodeUrl(); diff --git a/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/enums/AllocationResultEnum.java b/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/enums/AllocationResultEnum.java index 2fe616f4..7d88671d 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/enums/AllocationResultEnum.java +++ b/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/enums/AllocationResultEnum.java @@ -5,6 +5,7 @@ import lombok.Getter; /** * 分账订单处理结果 + * 字典: allocation_result * @author xxm * @since 2024/4/16 */ diff --git a/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/enums/AllocationStatusEnum.java b/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/enums/AllocationStatusEnum.java index dfb29d12..851eb7b7 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/enums/AllocationStatusEnum.java +++ b/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/enums/AllocationStatusEnum.java @@ -5,6 +5,7 @@ import lombok.Getter; /** * 分账状态枚举 + * 字典 allocation_status * @author xxm * @since 2024/4/7 */ diff --git a/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/param/allocation/receiver/AllocReceiverAddParam.java b/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/param/allocation/receiver/AllocReceiverAddParam.java index eeb7c64b..5ef01c57 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/param/allocation/receiver/AllocReceiverAddParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/org/dromara/daxpay/core/param/allocation/receiver/AllocReceiverAddParam.java @@ -28,6 +28,10 @@ public class AllocReceiverAddParam extends PaymentCommonParam { @Size(max = 32, message = "接收者编号不可超过32位") private String receiverNo; + @Schema(description = "接收方名称") + @Size(max = 50, message = "接收方名称不可超过50位") + private String name; + /** * 所属通道 * @see ChannelEnum diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocGroupController.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocGroupController.java index 672d3e6a..722e04f7 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocGroupController.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocGroupController.java @@ -51,13 +51,6 @@ public class AllocGroupController { return Res.ok(allocGroupService.findById(id)); } - @RequestPath("编码是否存在") - @Operation(summary = "编码是否存在") - @GetMapping("/existsByGroupNo") - public Result existsByGroupNo(String groupNo, String appId){ - return Res.ok(allocGroupService.existsByGroupNo(groupNo, appId)); - } - @RequestPath("查询分账接收方信息") @Operation(summary = "查询分账接收方信息") @GetMapping("/findReceiversByGroups") diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocReceiverController.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocReceiverController.java index 1dbd279b..13e06c66 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocReceiverController.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocReceiverController.java @@ -10,12 +10,11 @@ import cn.bootx.platform.core.rest.result.Result; import cn.bootx.platform.core.util.ValidationUtil; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.constraints.NotBlank; import lombok.RequiredArgsConstructor; import org.dromara.daxpay.core.param.allocation.receiver.AllocReceiverAddParam; import org.dromara.daxpay.core.param.allocation.receiver.AllocReceiverRemoveParam; -import org.dromara.daxpay.service.result.allocation.receiver.AllocReceiverVo; import org.dromara.daxpay.service.param.allocation.receiver.AllocReceiverQuery; +import org.dromara.daxpay.service.result.allocation.receiver.AllocReceiverVo; import org.dromara.daxpay.service.service.allocation.receiver.AllocReceiverService; import org.dromara.daxpay.service.service.assist.PaymentAssistService; import org.springframework.validation.annotation.Validated; @@ -53,20 +52,13 @@ public class AllocReceiverController { return Res.ok(receiverService.findById(id)); } - @RequestPath("编码是否存在") - @Operation(summary = "编码是否存在") - @GetMapping("/existsByReceiverNo") - public Result existsByReceiverNo(@NotBlank(message = "接收者编号必填") String receiverNo,@NotBlank(message = "商户应用ID必填") String appId){ - return Res.ok(receiverService.existsByReceiverNo(receiverNo, appId)); - } - @RequestPath("添加") @Operation(summary = "添加") @PostMapping("/add") public Result add(@RequestBody AllocReceiverAddParam param){ ValidationUtil.validateParam(param); paymentAssistService.initMchApp(param.getAppId()); - receiverService.addAndSync(param); + receiverService.add(param); return Res.ok(); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/receiver/AllocGroup.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/receiver/AllocGroup.java index d77c7863..6a529f4e 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/receiver/AllocGroup.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/receiver/AllocGroup.java @@ -41,6 +41,7 @@ public class AllocGroup extends MchAppBaseEntity implements ToResult { /** 分账单号 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/result/allocation/receiver/AllocGroupReceiverVo.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/result/allocation/receiver/AllocGroupReceiverVo.java index 4a3918f7..4945337e 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/result/allocation/receiver/AllocGroupReceiverVo.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/result/allocation/receiver/AllocGroupReceiverVo.java @@ -27,6 +27,9 @@ public class AllocGroupReceiverVo extends MchAppResult { @Schema(description = "接收方编号") private String receiverNo; + @Schema(description = "接收方名称") + private String name; + @Schema(description = "分账比例(百分之多少)") private BigDecimal rate; diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/result/allocation/receiver/AllocReceiverVo.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/result/allocation/receiver/AllocReceiverVo.java index 7774b416..25790e91 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/result/allocation/receiver/AllocReceiverVo.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/result/allocation/receiver/AllocReceiverVo.java @@ -22,6 +22,9 @@ public class AllocReceiverVo extends MchAppResult { @Schema(description = "接收方编号") private String receiverNo; + /** 名称 */ + private String name; + /** * @see ChannelEnum */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/receiver/AllocGroupService.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/receiver/AllocGroupService.java index 40e3a974..d95036c5 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/receiver/AllocGroupService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/receiver/AllocGroupService.java @@ -8,6 +8,7 @@ import cn.bootx.platform.core.rest.param.PageParam; import cn.bootx.platform.core.rest.result.PageResult; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.lang.UUID; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.dromara.daxpay.service.result.allocation.receiver.AllocGroupReceiverVo; @@ -76,6 +77,7 @@ public class AllocGroupService { AllocGroupReceiverVo result = new AllocGroupReceiverVo() .setReceiverId(receiver.getId()) .setReceiverNo(receiver.getReceiverNo()) + .setName(receiver.getName()) .setReceiverAccount(receiver.getReceiverAccount()) .setReceiverName(receiver.getReceiverName()) .setRate(o.getRate()) @@ -92,8 +94,11 @@ public class AllocGroupService { * 创建分账组 */ public void create(AllocGroupParam param){ + String uuid = UUID.fastUUID().toString(true); AllocGroup group = AllocGroupConvert.CONVERT.toEntity(param); group.setTotalRate(BigDecimal.ZERO); + // 默认设置分账组编号 + group.setGroupNo(uuid); groupManager.save(group); } @@ -241,11 +246,4 @@ public class AllocGroupService { groupReceiverManager.updateById(groupReceiver); groupManager.updateById(group); } - - /** - * 判断分账组编号是否存在 - */ - public boolean existsByGroupNo(String groupNo, String appId) { - return groupManager.existedByGroupNo(groupNo, appId); - } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/receiver/AllocReceiverService.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/receiver/AllocReceiverService.java index 009e4a65..20229570 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/receiver/AllocReceiverService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/receiver/AllocReceiverService.java @@ -6,6 +6,7 @@ import cn.bootx.platform.core.exception.ValidationFailedException; import cn.bootx.platform.core.rest.dto.LabelValue; import cn.bootx.platform.core.rest.param.PageParam; import cn.bootx.platform.core.rest.result.PageResult; +import cn.hutool.core.lang.UUID; import cn.hutool.core.util.IdUtil; import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; @@ -86,6 +87,17 @@ public class AllocReceiverService { return new AllocReceiverResult().setReceivers(list); } + /** + * 添加. 通过界面操作 + */ + @Transactional(rollbackFor = Exception.class) + public void add(AllocReceiverAddParam param){ + // 生成编码 + String uuid = UUID.fastUUID().toString(true); + param.setReceiverNo(uuid); + this.addAndSync(param); + } + /** * 添加分账接收方并同步到三方支付系统中