feat(allocation): 优化分账接收方和分账组功能- 后台管理时,分账组和接收方编号自动生成

This commit is contained in:
DaxPay
2024-12-10 20:53:15 +08:00
parent 5113993111
commit 2dfe9574bb
15 changed files with 45 additions and 29 deletions

View File

@@ -12,6 +12,9 @@
- [ ] 分账接口开发
- [ ] 网关配套移动端开发
- [ ] 同步回调页
- [ ] 分账接收方和分账组优化
- [ ] 后台管理时, 编号自动生成
- [ ] 显示数据
- [x] 微信通道添加单独的认证跳转地址, 处理它的特殊情况
- [x] 支付订单新增待支付状态
## 3.0.0.beta2 收银台

View File

@@ -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);

View File

@@ -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();

View File

@@ -5,6 +5,7 @@ import lombok.Getter;
/**
* 分账订单处理结果
* 字典: allocation_result
* @author xxm
* @since 2024/4/16
*/

View File

@@ -5,6 +5,7 @@ import lombok.Getter;
/**
* 分账状态枚举
* 字典 allocation_status
* @author xxm
* @since 2024/4/7
*/

View File

@@ -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

View File

@@ -51,13 +51,6 @@ public class AllocGroupController {
return Res.ok(allocGroupService.findById(id));
}
@RequestPath("编码是否存在")
@Operation(summary = "编码是否存在")
@GetMapping("/existsByGroupNo")
public Result<Boolean> existsByGroupNo(String groupNo, String appId){
return Res.ok(allocGroupService.existsByGroupNo(groupNo, appId));
}
@RequestPath("查询分账接收方信息")
@Operation(summary = "查询分账接收方信息")
@GetMapping("/findReceiversByGroups")

View File

@@ -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<Boolean> existsByReceiverNo(@NotBlank(message = "接收者编号必填") String receiverNo,@NotBlank(message = "商户应用ID必填") String appId){
return Res.ok(receiverService.existsByReceiverNo(receiverNo, appId));
}
@RequestPath("添加")
@Operation(summary = "添加")
@PostMapping("/add")
public Result<Void> add(@RequestBody AllocReceiverAddParam param){
ValidationUtil.validateParam(param);
paymentAssistService.initMchApp(param.getAppId());
receiverService.addAndSync(param);
receiverService.add(param);
return Res.ok();
}

View File

@@ -41,6 +41,7 @@ public class AllocGroup extends MchAppBaseEntity implements ToResult<AllocGroupV
private BigDecimal totalRate;
/** 备注 */
@Deprecated
private String remark;
@Override

View File

@@ -28,6 +28,9 @@ public class AllocReceiver extends MchAppBaseEntity implements ToResult<AllocRec
/** 分账接收方编号, 需要保证唯一 */
private String receiverNo;
/** 接收方名称 */
private String name;
/**
* 所属通道
* @see ChannelEnum

View File

@@ -25,7 +25,7 @@ import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@TableName("pay_alloc_transaction")
@TableName("pay_alloc_order")
public class AllocOrder extends MchAppBaseEntity implements ToResult<AllocOrderResult> {
/** 分账单号 */

View File

@@ -27,6 +27,9 @@ public class AllocGroupReceiverVo extends MchAppResult {
@Schema(description = "接收方编号")
private String receiverNo;
@Schema(description = "接收方名称")
private String name;
@Schema(description = "分账比例(百分之多少)")
private BigDecimal rate;

View File

@@ -22,6 +22,9 @@ public class AllocReceiverVo extends MchAppResult {
@Schema(description = "接收方编号")
private String receiverNo;
/** 名称 */
private String name;
/**
* @see ChannelEnum
*/

View File

@@ -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);
}
}

View File

@@ -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);
}
/**
* 添加分账接收方并同步到三方支付系统中