mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-10-13 21:30:25 +00:00
feat(allocation): 优化分账接收方和分账组功能- 后台管理时,分账组和接收方编号自动生成
This commit is contained in:
@@ -12,6 +12,9 @@
|
|||||||
- [ ] 分账接口开发
|
- [ ] 分账接口开发
|
||||||
- [ ] 网关配套移动端开发
|
- [ ] 网关配套移动端开发
|
||||||
- [ ] 同步回调页
|
- [ ] 同步回调页
|
||||||
|
- [ ] 分账接收方和分账组优化
|
||||||
|
- [ ] 后台管理时, 编号自动生成
|
||||||
|
- [ ] 显示数据
|
||||||
- [x] 微信通道添加单独的认证跳转地址, 处理它的特殊情况
|
- [x] 微信通道添加单独的认证跳转地址, 处理它的特殊情况
|
||||||
- [x] 支付订单新增待支付状态
|
- [x] 支付订单新增待支付状态
|
||||||
## 3.0.0.beta2 收银台
|
## 3.0.0.beta2 收银台
|
||||||
|
@@ -148,11 +148,11 @@ public class AliPayAllocationService {
|
|||||||
/**
|
/**
|
||||||
* 验证错误信息
|
* 验证错误信息
|
||||||
*/
|
*/
|
||||||
private void verifyErrorMsg(AlipayResponse alipayResponse) {
|
private void verifyErrorMsg(AlipayResponse response) {
|
||||||
if (alipayResponse.isSuccess()) {
|
if (!response.isSuccess()) {
|
||||||
String errorMsg = alipayResponse.getSubMsg();
|
String errorMsg = response.getSubMsg();
|
||||||
if (StrUtil.isBlank(errorMsg)) {
|
if (StrUtil.isBlank(errorMsg)) {
|
||||||
errorMsg = alipayResponse.getMsg();
|
errorMsg = response.getMsg();
|
||||||
}
|
}
|
||||||
log.error("分账处理失败 {}", errorMsg);
|
log.error("分账处理失败 {}", errorMsg);
|
||||||
throw new TradeFailException(errorMsg);
|
throw new TradeFailException(errorMsg);
|
||||||
|
@@ -142,6 +142,8 @@ public class WechatPayV2Service {
|
|||||||
private String qrCodePay(PayOrder payOrder, WechatPayConfig wechatPayConfig) {
|
private String qrCodePay(PayOrder payOrder, WechatPayConfig wechatPayConfig) {
|
||||||
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(wechatPayConfig);
|
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(wechatPayConfig);
|
||||||
WxPayUnifiedOrderRequest request = this.buildRequest(payOrder);
|
WxPayUnifiedOrderRequest request = this.buildRequest(payOrder);
|
||||||
|
// NATIVE此参数必传。此id为二维码中包含的商品Id,商户自行定义。
|
||||||
|
request.setProductId(payOrder.getOrderNo());
|
||||||
try {
|
try {
|
||||||
var result = wxPayService.createOrder(WxPayConstants.TradeType.Specific.NATIVE, request);
|
var result = wxPayService.createOrder(WxPayConstants.TradeType.Specific.NATIVE, request);
|
||||||
return result.getCodeUrl();
|
return result.getCodeUrl();
|
||||||
|
@@ -5,6 +5,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 分账订单处理结果
|
* 分账订单处理结果
|
||||||
|
* 字典: allocation_result
|
||||||
* @author xxm
|
* @author xxm
|
||||||
* @since 2024/4/16
|
* @since 2024/4/16
|
||||||
*/
|
*/
|
||||||
|
@@ -5,6 +5,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 分账状态枚举
|
* 分账状态枚举
|
||||||
|
* 字典 allocation_status
|
||||||
* @author xxm
|
* @author xxm
|
||||||
* @since 2024/4/7
|
* @since 2024/4/7
|
||||||
*/
|
*/
|
||||||
|
@@ -28,6 +28,10 @@ public class AllocReceiverAddParam extends PaymentCommonParam {
|
|||||||
@Size(max = 32, message = "接收者编号不可超过32位")
|
@Size(max = 32, message = "接收者编号不可超过32位")
|
||||||
private String receiverNo;
|
private String receiverNo;
|
||||||
|
|
||||||
|
@Schema(description = "接收方名称")
|
||||||
|
@Size(max = 50, message = "接收方名称不可超过50位")
|
||||||
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所属通道
|
* 所属通道
|
||||||
* @see ChannelEnum
|
* @see ChannelEnum
|
||||||
|
@@ -51,13 +51,6 @@ public class AllocGroupController {
|
|||||||
return Res.ok(allocGroupService.findById(id));
|
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("查询分账接收方信息")
|
@RequestPath("查询分账接收方信息")
|
||||||
@Operation(summary = "查询分账接收方信息")
|
@Operation(summary = "查询分账接收方信息")
|
||||||
@GetMapping("/findReceiversByGroups")
|
@GetMapping("/findReceiversByGroups")
|
||||||
|
@@ -10,12 +10,11 @@ import cn.bootx.platform.core.rest.result.Result;
|
|||||||
import cn.bootx.platform.core.util.ValidationUtil;
|
import cn.bootx.platform.core.util.ValidationUtil;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.dromara.daxpay.core.param.allocation.receiver.AllocReceiverAddParam;
|
import org.dromara.daxpay.core.param.allocation.receiver.AllocReceiverAddParam;
|
||||||
import org.dromara.daxpay.core.param.allocation.receiver.AllocReceiverRemoveParam;
|
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.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.allocation.receiver.AllocReceiverService;
|
||||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -53,20 +52,13 @@ public class AllocReceiverController {
|
|||||||
return Res.ok(receiverService.findById(id));
|
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("添加")
|
@RequestPath("添加")
|
||||||
@Operation(summary = "添加")
|
@Operation(summary = "添加")
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public Result<Void> add(@RequestBody AllocReceiverAddParam param){
|
public Result<Void> add(@RequestBody AllocReceiverAddParam param){
|
||||||
ValidationUtil.validateParam(param);
|
ValidationUtil.validateParam(param);
|
||||||
paymentAssistService.initMchApp(param.getAppId());
|
paymentAssistService.initMchApp(param.getAppId());
|
||||||
receiverService.addAndSync(param);
|
receiverService.add(param);
|
||||||
return Res.ok();
|
return Res.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@ public class AllocGroup extends MchAppBaseEntity implements ToResult<AllocGroupV
|
|||||||
private BigDecimal totalRate;
|
private BigDecimal totalRate;
|
||||||
|
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
|
@Deprecated
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -28,6 +28,9 @@ public class AllocReceiver extends MchAppBaseEntity implements ToResult<AllocRec
|
|||||||
/** 分账接收方编号, 需要保证唯一 */
|
/** 分账接收方编号, 需要保证唯一 */
|
||||||
private String receiverNo;
|
private String receiverNo;
|
||||||
|
|
||||||
|
/** 接收方名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所属通道
|
* 所属通道
|
||||||
* @see ChannelEnum
|
* @see ChannelEnum
|
||||||
|
@@ -25,7 +25,7 @@ import java.time.LocalDateTime;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("pay_alloc_transaction")
|
@TableName("pay_alloc_order")
|
||||||
public class AllocOrder extends MchAppBaseEntity implements ToResult<AllocOrderResult> {
|
public class AllocOrder extends MchAppBaseEntity implements ToResult<AllocOrderResult> {
|
||||||
|
|
||||||
/** 分账单号 */
|
/** 分账单号 */
|
||||||
|
@@ -27,6 +27,9 @@ public class AllocGroupReceiverVo extends MchAppResult {
|
|||||||
@Schema(description = "接收方编号")
|
@Schema(description = "接收方编号")
|
||||||
private String receiverNo;
|
private String receiverNo;
|
||||||
|
|
||||||
|
@Schema(description = "接收方名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "分账比例(百分之多少)")
|
@Schema(description = "分账比例(百分之多少)")
|
||||||
private BigDecimal rate;
|
private BigDecimal rate;
|
||||||
|
|
||||||
|
@@ -22,6 +22,9 @@ public class AllocReceiverVo extends MchAppResult {
|
|||||||
@Schema(description = "接收方编号")
|
@Schema(description = "接收方编号")
|
||||||
private String receiverNo;
|
private String receiverNo;
|
||||||
|
|
||||||
|
/** 名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ChannelEnum
|
* @see ChannelEnum
|
||||||
*/
|
*/
|
||||||
|
@@ -8,6 +8,7 @@ import cn.bootx.platform.core.rest.param.PageParam;
|
|||||||
import cn.bootx.platform.core.rest.result.PageResult;
|
import cn.bootx.platform.core.rest.result.PageResult;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import cn.hutool.core.lang.UUID;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.daxpay.service.result.allocation.receiver.AllocGroupReceiverVo;
|
import org.dromara.daxpay.service.result.allocation.receiver.AllocGroupReceiverVo;
|
||||||
@@ -76,6 +77,7 @@ public class AllocGroupService {
|
|||||||
AllocGroupReceiverVo result = new AllocGroupReceiverVo()
|
AllocGroupReceiverVo result = new AllocGroupReceiverVo()
|
||||||
.setReceiverId(receiver.getId())
|
.setReceiverId(receiver.getId())
|
||||||
.setReceiverNo(receiver.getReceiverNo())
|
.setReceiverNo(receiver.getReceiverNo())
|
||||||
|
.setName(receiver.getName())
|
||||||
.setReceiverAccount(receiver.getReceiverAccount())
|
.setReceiverAccount(receiver.getReceiverAccount())
|
||||||
.setReceiverName(receiver.getReceiverName())
|
.setReceiverName(receiver.getReceiverName())
|
||||||
.setRate(o.getRate())
|
.setRate(o.getRate())
|
||||||
@@ -92,8 +94,11 @@ public class AllocGroupService {
|
|||||||
* 创建分账组
|
* 创建分账组
|
||||||
*/
|
*/
|
||||||
public void create(AllocGroupParam param){
|
public void create(AllocGroupParam param){
|
||||||
|
String uuid = UUID.fastUUID().toString(true);
|
||||||
AllocGroup group = AllocGroupConvert.CONVERT.toEntity(param);
|
AllocGroup group = AllocGroupConvert.CONVERT.toEntity(param);
|
||||||
group.setTotalRate(BigDecimal.ZERO);
|
group.setTotalRate(BigDecimal.ZERO);
|
||||||
|
// 默认设置分账组编号
|
||||||
|
group.setGroupNo(uuid);
|
||||||
groupManager.save(group);
|
groupManager.save(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,11 +246,4 @@ public class AllocGroupService {
|
|||||||
groupReceiverManager.updateById(groupReceiver);
|
groupReceiverManager.updateById(groupReceiver);
|
||||||
groupManager.updateById(group);
|
groupManager.updateById(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断分账组编号是否存在
|
|
||||||
*/
|
|
||||||
public boolean existsByGroupNo(String groupNo, String appId) {
|
|
||||||
return groupManager.existedByGroupNo(groupNo, appId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -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.dto.LabelValue;
|
||||||
import cn.bootx.platform.core.rest.param.PageParam;
|
import cn.bootx.platform.core.rest.param.PageParam;
|
||||||
import cn.bootx.platform.core.rest.result.PageResult;
|
import cn.bootx.platform.core.rest.result.PageResult;
|
||||||
|
import cn.hutool.core.lang.UUID;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.baomidou.lock.LockInfo;
|
import com.baomidou.lock.LockInfo;
|
||||||
import com.baomidou.lock.LockTemplate;
|
import com.baomidou.lock.LockTemplate;
|
||||||
@@ -86,6 +87,17 @@ public class AllocReceiverService {
|
|||||||
return new AllocReceiverResult().setReceivers(list);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加分账接收方并同步到三方支付系统中
|
* 添加分账接收方并同步到三方支付系统中
|
||||||
|
Reference in New Issue
Block a user