mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-02 02:34:34 +00:00
feat(payment): 添加分账功能并优化相关服务
- 新增分账功能,支持支付宝和微信支付的分账操作 - 重构支付宝支付流程,使用新的SDK- 更新微信支付示例,调整相关参数 - 优化收银台配置和支付订单相关服务- 调整分账比例的验证规则,支持更灵活的比例设置
This commit is contained in:
@@ -7,6 +7,7 @@ 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.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;
|
||||
@@ -62,7 +63,8 @@ public class AllocReceiverController {
|
||||
@RequestPath("添加")
|
||||
@Operation(summary = "添加")
|
||||
@PostMapping("/add")
|
||||
public Result<Void> add(@RequestBody @Validated AllocReceiverAddParam param){
|
||||
public Result<Void> add(@RequestBody AllocReceiverAddParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
paymentAssistService.initMchApp(param.getAppId());
|
||||
receiverService.addAndSync(param);
|
||||
return Res.ok();
|
||||
@@ -71,7 +73,8 @@ public class AllocReceiverController {
|
||||
@RequestPath("删除")
|
||||
@Operation(summary = "删除")
|
||||
@PostMapping("/delete")
|
||||
public Result<Void> delete(@RequestBody @Validated AllocReceiverRemoveParam param){
|
||||
public Result<Void> delete(@RequestBody AllocReceiverRemoveParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
paymentAssistService.initMchApp(param.getAppId());
|
||||
receiverService.removeAndSync(param);
|
||||
return Res.ok();
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package org.dromara.daxpay.service.controller.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 收银台配置
|
||||
* @author xxm
|
||||
* @since 2024/11/22
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "收银台配置")
|
||||
public class CheckoutConfig {
|
||||
}
|
@@ -97,4 +97,12 @@ public class PayOrderController {
|
||||
payOrderService.cancel(id);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("分账")
|
||||
@Operation(summary = "分账")
|
||||
@PostMapping("/allocation")
|
||||
public Result<Void> allocation(@NotNull(message = "支付订单id不能为空") Long id){
|
||||
payOrderService.allocation(id);
|
||||
return Res.ok();
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package org.dromara.daxpay.service.entity.allocation.transaction;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.function.ToResult;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -21,6 +22,7 @@ import java.time.LocalDateTime;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("pay_alloc_detail")
|
||||
public class AllocDetail extends MchAppBaseEntity implements ToResult<AllocDetailResult> {
|
||||
|
||||
/** 分账订单ID */
|
||||
|
@@ -1,14 +1,13 @@
|
||||
package org.dromara.daxpay.service.param.allocation.group;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.DecimalMax;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import jakarta.validation.constraints.Digits;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import jakarta.validation.constraints.DecimalMax;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
@@ -27,9 +26,8 @@ public class AllocGroupReceiverParam {
|
||||
|
||||
@Schema(description = "分账比例(百分之多少)")
|
||||
@NotNull(message = "分账比例不可为空")
|
||||
@Min(value = 0,message = "分账比例不可为负数")
|
||||
@DecimalMax(value = "100",message = "分账比例不可大于100%")
|
||||
@DecimalMin(value = "0.01", message = "分账比例不可小于0.01%")
|
||||
@DecimalMin(value = "0.00", message = "分账比例不可为负数")
|
||||
@Digits(integer = 3, fraction = 2, message = "分账比例最多只允许两位小数")
|
||||
private BigDecimal rate;
|
||||
}
|
||||
|
@@ -1,8 +1,12 @@
|
||||
package org.dromara.daxpay.service.service.order.pay;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.daxpay.core.exception.TradeNotExistException;
|
||||
import org.dromara.daxpay.core.param.allocation.transaction.AllocationParam;
|
||||
import org.dromara.daxpay.core.util.TradeNoGenerateUtil;
|
||||
import org.dromara.daxpay.service.dao.order.pay.PayOrderManager;
|
||||
import org.dromara.daxpay.service.entity.order.pay.PayOrder;
|
||||
import org.dromara.daxpay.service.service.allocation.AllocationService;
|
||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||
import org.dromara.daxpay.service.service.trade.pay.PayCloseService;
|
||||
import org.dromara.daxpay.service.service.trade.pay.PaySyncService;
|
||||
@@ -24,6 +28,7 @@ public class PayOrderService {
|
||||
|
||||
private final PaymentAssistService paymentAssistService;
|
||||
private final PayCloseService payCloseService;
|
||||
private final AllocationService allocationService;
|
||||
|
||||
/**
|
||||
* 同步
|
||||
@@ -55,4 +60,16 @@ public class PayOrderService {
|
||||
payCloseService.closeOrder(payOrder,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分账
|
||||
*/
|
||||
public void allocation(@NotNull(message = "支付订单id不能为空") Long id) {
|
||||
PayOrder payOrder = payOrderManager.findById(id).orElseThrow(() -> new TradeNotExistException("支付订单不存在"));
|
||||
paymentAssistService.initMchApp(payOrder.getAppId());
|
||||
AllocationParam param = new AllocationParam()
|
||||
.setBizAllocNo("B"+TradeNoGenerateUtil.allocation());
|
||||
param.setAppId(payOrder.getAppId());
|
||||
allocationService.allocation(param, payOrder);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user