mirror of
https://gitee.com/dromara/dax-pay
synced 2026-08-12 23:45:39 +08:00
refactor(payment): 金额字段统一改为Long(分), 消除元/分混用桥接
- 对外API(PayParam/PayOrderResult/GoodsDetail/Quickly*)、old包实体/Result/Vo/Bo、Mapper汇总链路(getTotalAmount)金额字段 BigDecimal 改为 Long(分) - 消除散落的元<->分x100桥接(PayAssistService/PayService/PaySyncService/Alipay/Douyin) - PayUtil删除无调用的convertCentAmount/conversionAmount及HUNDRED常量 - 校验注解@DecimalMin/@Digits改为@Min/@Max, i18n zh-CN/en-US validation.json同步 - 保留费率rate/profitRate、经纬度等非金额字段为BigDecimal - 清理old包死import(BigDecimalUtil/BigDecimal)
This commit is contained in:
@@ -13,7 +13,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
@@ -27,8 +26,6 @@ import java.util.Map;
|
||||
@RequiredArgsConstructor
|
||||
public class AlipayPayService {
|
||||
|
||||
private static final BigDecimal HUNDRED = new BigDecimal("100");
|
||||
|
||||
private final AlipayChannelClient alipayChannelClient;
|
||||
|
||||
/// 执行支付宝支付
|
||||
@@ -43,7 +40,7 @@ public class AlipayPayService {
|
||||
req.setChannel("alipay");
|
||||
// 使用支付交易号作为商户订单号透传给支付宝, 回调时凭此反查 PayTrade
|
||||
req.setBizOrderNo(order.getTradeNo());
|
||||
req.setAmount(payParam.getAmount().multiply(HUNDRED).longValue());
|
||||
req.setAmount(payParam.getAmount());
|
||||
req.setSubject(payParam.getTitle());
|
||||
req.setDescription(payParam.getDescription());
|
||||
// 将平台支付方式(PayMethodEnum code)映射为支付宝通道识别码
|
||||
|
||||
@@ -12,7 +12,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/// # 抖音支付直连支付策略
|
||||
@@ -24,8 +23,6 @@ import java.util.Map;
|
||||
@RequiredArgsConstructor
|
||||
public class DouyinDirectPayStrategy extends AbsPayStrategy {
|
||||
|
||||
private static final BigDecimal HUNDRED = new BigDecimal("100");
|
||||
|
||||
private final DouyinChannelClient douyinChannelClient;
|
||||
|
||||
@Override
|
||||
@@ -39,7 +36,7 @@ public class DouyinDirectPayStrategy extends AbsPayStrategy {
|
||||
DouyinPayReq req = new DouyinPayReq();
|
||||
req.setChannel(ProductEnum.DOUYIN_PAY.getChannel());
|
||||
req.setBizOrderNo(context.getPayParam().getBizOrderNo());
|
||||
req.setAmount(context.getPayParam().getAmount().multiply(HUNDRED).longValue());
|
||||
req.setAmount(context.getPayParam().getAmount());
|
||||
req.setSubject(context.getPayParam().getTitle());
|
||||
req.setMethod(context.getPayParam().getMethod());
|
||||
// TODO 从数据库获取抖音通道配置
|
||||
|
||||
@@ -25,7 +25,6 @@ import cn.daxpay.open.platform.core.code.CommonCode;
|
||||
///
|
||||
@UtilityClass
|
||||
public class PayUtil {
|
||||
private static final BigDecimal HUNDRED = new BigDecimal(100);
|
||||
|
||||
/// 获取支付单的超时时间
|
||||
public OffsetDateTime getPaymentExpiredTime(Integer minute) {
|
||||
@@ -38,25 +37,6 @@ public class PayUtil {
|
||||
return Math.toIntExact(duration.getSeconds() / 60);
|
||||
}
|
||||
|
||||
/// 元转分
|
||||
///
|
||||
/// @param amount 元的金额
|
||||
/// @return 分的金额
|
||||
public int convertCentAmount(BigDecimal amount) {
|
||||
return amount.multiply(HUNDRED)
|
||||
.setScale(0, RoundingMode.HALF_UP)
|
||||
.intValue();
|
||||
}
|
||||
|
||||
/// 分转元,保留两位小数
|
||||
///
|
||||
/// @param amount 元的金额
|
||||
/// @return 元的金额 两位小数
|
||||
public BigDecimal conversionAmount(int amount) {
|
||||
return BigDecimal.valueOf(amount)
|
||||
.divide(HUNDRED, 2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
/// xx.xx%转换为基点表示费率(万分之多少)
|
||||
public String toBasisPointRate(BigDecimal rate) {
|
||||
return Opt.ofBlankAble(rate)
|
||||
|
||||
@@ -5,7 +5,6 @@ import cn.daxpay.open.platform.core.enums.pay.channel.PayProviderEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/// # 支付同步结果
|
||||
@@ -23,11 +22,11 @@ public class PaySyncResultBo {
|
||||
/// 支付通道对应系统的交易号, 用与和本地记录关联起来
|
||||
private String outOrderNo;
|
||||
|
||||
/// 交易金额
|
||||
private BigDecimal amount;
|
||||
/// 交易金额(分,最小货币单位)
|
||||
private Long amount;
|
||||
|
||||
/// 实收金额
|
||||
private BigDecimal realAmount;
|
||||
/// 实收金额(分,最小货币单位)
|
||||
private Long realAmount;
|
||||
|
||||
/// 支付完成时间
|
||||
private OffsetDateTime finishTime;
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.daxpay.open.platform.core.enums.unipay.PayBodyTypeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/// # 支付结果业务类
|
||||
@@ -21,8 +20,8 @@ public class PayResultBo {
|
||||
/// 是否支付完成
|
||||
private boolean complete;
|
||||
|
||||
/// 实收金额
|
||||
private BigDecimal realAmount;
|
||||
/// 实收金额(分,最小货币单位)
|
||||
private Long realAmount;
|
||||
|
||||
/// 完成时间
|
||||
private OffsetDateTime finishTime;
|
||||
|
||||
@@ -23,8 +23,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// # 支付订单控制器
|
||||
///
|
||||
@Validated
|
||||
@@ -70,7 +68,7 @@ public class PayOrderController {
|
||||
|
||||
@Operation(summary = "查询金额汇总")
|
||||
@GetMapping("/get-total-amount")
|
||||
public Result<BigDecimal> getTotalAmount(PayOrderQuery query){
|
||||
public Result<Long> getTotalAmount(PayOrderQuery query){
|
||||
return Res.ok(queryService.getTotalAmount(query));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
@@ -77,7 +76,7 @@ public class PayOrderManager extends BaseManager<PayOrderMapper, PayOrder> {
|
||||
}
|
||||
|
||||
/// 查询汇总金额
|
||||
public BigDecimal getTotalAmount(PayOrderQuery query){
|
||||
public Long getTotalAmount(PayOrderQuery query){
|
||||
QueryWrapper<PayOrder> generator = QueryGenerator.generator(query);
|
||||
// 商户和应用AppId
|
||||
generator.eq(MpUtil.getColumnName(PayOrder::getStatus), PayStatusEnum.SUCCESS.getCode());
|
||||
|
||||
@@ -8,12 +8,10 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface PayOrderMapper extends MPJBaseMapper<PayOrder> {
|
||||
|
||||
@Select("select sum(amount) from pay_order ${ew.customSqlSegment}")
|
||||
BigDecimal getTotalAmount(@Param(Constants.WRAPPER) QueryWrapper<PayOrder> param);
|
||||
@Select("select sum(amount)::bigint from pay_order ${ew.customSqlSegment}")
|
||||
Long getTotalAmount(@Param(Constants.WRAPPER) QueryWrapper<PayOrder> param);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// # 交易流水
|
||||
///
|
||||
@Slf4j
|
||||
@@ -30,7 +28,7 @@ public class TradeFlowRecordManager extends BaseManager<TradeFlowRecordMapper, T
|
||||
}
|
||||
|
||||
/// 查询汇总金额
|
||||
public BigDecimal getTotalAmount(TradeFlowRecordQuery query, TradeTypeEnum tradeTypeEnum){
|
||||
public Long getTotalAmount(TradeFlowRecordQuery query, TradeTypeEnum tradeTypeEnum){
|
||||
QueryWrapper<TradeFlowRecord> generator = QueryGenerator.generator(query);
|
||||
generator.eq(MpUtil.getColumnName(TradeFlowRecord::getType), tradeTypeEnum.getCode());
|
||||
return baseMapper.getTotalAmount(generator);
|
||||
|
||||
@@ -8,13 +8,11 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// # 交易流水
|
||||
///
|
||||
@Mapper
|
||||
public interface TradeFlowRecordMapper extends MPJBaseMapper<TradeFlowRecord> {
|
||||
|
||||
@Select("select sum(amount) from pay_trade_flow_record ${ew.customSqlSegment}")
|
||||
BigDecimal getTotalAmount(@Param(Constants.WRAPPER) QueryWrapper<TradeFlowRecord> generator);
|
||||
@Select("select sum(amount)::bigint from pay_trade_flow_record ${ew.customSqlSegment}")
|
||||
Long getTotalAmount(@Param(Constants.WRAPPER) QueryWrapper<TradeFlowRecord> generator);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/// # 支付订单
|
||||
@@ -75,11 +74,11 @@ public class PayOrder extends MchBaseEntity implements ToResult<PayOrderVo> {
|
||||
/// @see PayLimitPayEnum
|
||||
private String limitPay;
|
||||
|
||||
/// 金额(元)
|
||||
private BigDecimal amount;
|
||||
/// 金额(分,最小货币单位)
|
||||
private Long amount;
|
||||
|
||||
/// 可退金额(元)
|
||||
private BigDecimal refundableBalance;
|
||||
/// 可退金额(分,最小货币单位)
|
||||
private Long refundableBalance;
|
||||
|
||||
/// 支付状态
|
||||
/// @see PayStatusEnum
|
||||
|
||||
@@ -12,7 +12,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/// # 支付订单扩展存储参数
|
||||
@@ -42,8 +41,8 @@ public class PayOrderExpand extends MchBaseEntity implements ToResult<PayOrderEx
|
||||
/// 请求时间
|
||||
private OffsetDateTime reqTime;
|
||||
|
||||
/// 实收金额
|
||||
private BigDecimal realAmount;
|
||||
/// 实收金额(分,最小货币单位)
|
||||
private Long realAmount;
|
||||
|
||||
/// 终端设备编码
|
||||
private String terminalNo;
|
||||
|
||||
@@ -15,8 +15,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// # 交易流水记录
|
||||
///
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -32,8 +30,8 @@ public class TradeFlowRecord extends MchBaseEntity implements ToResult<TradeFlow
|
||||
/// 订单标题
|
||||
private String title;
|
||||
|
||||
/// 金额
|
||||
private BigDecimal amount;
|
||||
/// 金额(分,最小货币单位)
|
||||
private Long amount;
|
||||
|
||||
/// 业务类型
|
||||
/// @see TradeTypeEnum
|
||||
|
||||
@@ -6,7 +6,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/// # 支付订单扩展信息
|
||||
@@ -32,8 +31,8 @@ public class PayOrderExpandResult extends BaseResult {
|
||||
@Schema(description = "请求时间(UTC)")
|
||||
private OffsetDateTime reqTime;
|
||||
|
||||
@Schema(description = "实收金额")
|
||||
private BigDecimal realAmount;
|
||||
@Schema(description = "实收金额(分)")
|
||||
private Long realAmount;
|
||||
|
||||
@Schema(description = "终端设备编码")
|
||||
private String terminalNo;
|
||||
|
||||
@@ -11,7 +11,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/// # 支付订单
|
||||
@@ -64,17 +63,17 @@ public class PayOrderVo extends MchTradeBaseResult {
|
||||
@Schema(description = "限制用户支付类型")
|
||||
private String limitPay;
|
||||
|
||||
/// 金额
|
||||
@Schema(description = "金额")
|
||||
private BigDecimal amount;
|
||||
/// 金额(分,最小货币单位)
|
||||
@Schema(description = "金额(分)")
|
||||
private Long amount;
|
||||
|
||||
/// 实收金额
|
||||
@Schema(description = "实收金额")
|
||||
private BigDecimal realAmount;
|
||||
/// 实收金额(分,最小货币单位)
|
||||
@Schema(description = "实收金额(分)")
|
||||
private Long realAmount;
|
||||
|
||||
/// 可退款余额
|
||||
@Schema(description = "可退款余额")
|
||||
private BigDecimal refundableBalance;
|
||||
/// 可退款余额(分,最小货币单位)
|
||||
@Schema(description = "可退款余额(分)")
|
||||
private Long refundableBalance;
|
||||
|
||||
/// 支付状态
|
||||
/// @see PayStatusEnum
|
||||
|
||||
@@ -4,18 +4,16 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// # 各类型流水汇总金额
|
||||
///
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "各类型流水汇总金额")
|
||||
public class TradeFlowAmountResult {
|
||||
@Schema(description = "收入金额")
|
||||
private BigDecimal incomeAmount;
|
||||
@Schema(description = "退款金额")
|
||||
private BigDecimal refundAmount;
|
||||
@Schema(description = "转账金额")
|
||||
private BigDecimal transferAmount;
|
||||
@Schema(description = "收入金额(分)")
|
||||
private Long incomeAmount;
|
||||
@Schema(description = "退款金额(分)")
|
||||
private Long refundAmount;
|
||||
@Schema(description = "转账金额(分)")
|
||||
private Long transferAmount;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// # 资金流水记录
|
||||
///
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -21,8 +19,8 @@ public class TradeFlowRecordResult extends MchTradeBaseResult {
|
||||
/// 订单标题
|
||||
private String title;
|
||||
|
||||
/// 金额
|
||||
private BigDecimal amount;
|
||||
/// 金额(分,最小货币单位)
|
||||
private Long amount;
|
||||
|
||||
/// 业务类型
|
||||
/// @see TradeFlowTypeEnum
|
||||
|
||||
@@ -27,7 +27,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -118,7 +117,7 @@ public class PayOrderQueryService {
|
||||
}
|
||||
|
||||
/// 查询支付总金额
|
||||
public BigDecimal getTotalAmount(PayOrderQuery param) {
|
||||
public Long getTotalAmount(PayOrderQuery param) {
|
||||
return payOrderManager.getTotalAmount(param);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package cn.daxpay.open.payment.old.pay.service.trade;
|
||||
|
||||
import cn.daxpay.open.platform.core.annotation.IgnoreTenant;
|
||||
import cn.daxpay.open.platform.core.util.BigDecimalUtil;
|
||||
import cn.daxpay.open.payment.old.pay.dao.order.pay.PayOrderExpandManager;
|
||||
import cn.daxpay.open.payment.old.pay.dao.order.pay.PayOrderManager;
|
||||
import cn.daxpay.open.payment.old.pay.entity.order.pay.PayOrder;
|
||||
@@ -14,7 +13,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -3,7 +3,6 @@ package cn.daxpay.open.payment.old.pay.service.trade.pay;
|
||||
import cn.daxpay.open.platform.core.exception.ValidationFailedException;
|
||||
import cn.daxpay.open.platform.core.exception.BizInfoException;
|
||||
import cn.daxpay.open.platform.core.code.CommonErrorCode;
|
||||
import cn.daxpay.open.platform.core.util.BigDecimalUtil;
|
||||
import cn.daxpay.open.platform.core.util.DateTimeUtil;
|
||||
import cn.daxpay.open.platform.core.code.DaxPayErrorCode;
|
||||
import cn.daxpay.open.platform.core.exception.business.AmountExceedLimitException;
|
||||
@@ -31,7 +30,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
|
||||
@@ -109,7 +109,7 @@ public class PayService {
|
||||
trade.setProduct(payOrder.getProduct());
|
||||
trade.setChannel(payOrder.getChannel());
|
||||
trade.setMethod(payOrder.getMethod());
|
||||
trade.setAmount(payOrder.getAmount().multiply(java.math.BigDecimal.valueOf(100)).longValue());
|
||||
trade.setAmount(payOrder.getAmount());
|
||||
context.setTrade(trade);
|
||||
PayResultBo result;
|
||||
try {
|
||||
@@ -118,7 +118,7 @@ public class PayService {
|
||||
result = new PayResultBo();
|
||||
result.setOutOrderNo(newResult.getOutOrderNo());
|
||||
result.setComplete(newResult.isComplete());
|
||||
result.setRealAmount(newResult.getRealAmount() != null ? java.math.BigDecimal.valueOf(newResult.getRealAmount(), 2) : null);
|
||||
result.setRealAmount(newResult.getRealAmount());
|
||||
result.setFinishTime(newResult.getFinishTime());
|
||||
result.setPayBody(newResult.getPayBody());
|
||||
result.setPayBodyType(newResult.getPayBodyType());
|
||||
|
||||
@@ -39,7 +39,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Objects;
|
||||
@@ -102,7 +101,7 @@ public class PaySyncService {
|
||||
trade.setProduct(payOrder.getProduct());
|
||||
trade.setChannel(payOrder.getChannel());
|
||||
trade.setMethod(payOrder.getMethod());
|
||||
trade.setAmount(payOrder.getAmount().multiply(BigDecimal.valueOf(100)).longValue());
|
||||
trade.setAmount(payOrder.getAmount());
|
||||
try {
|
||||
// 执行操作, 获取支付网关同步的结果
|
||||
var newResult = syncPayStrategy.doSync(trade);
|
||||
@@ -118,8 +117,8 @@ public class PaySyncService {
|
||||
});
|
||||
}
|
||||
syncResult.setOutOrderNo(newResult.getOutOrderNo());
|
||||
syncResult.setAmount(newResult.getAmount() != null ? BigDecimal.valueOf(newResult.getAmount(), 2) : null);
|
||||
syncResult.setRealAmount(newResult.getRealAmount() != null ? BigDecimal.valueOf(newResult.getRealAmount(), 2) : null);
|
||||
syncResult.setAmount(newResult.getAmount());
|
||||
syncResult.setRealAmount(newResult.getRealAmount());
|
||||
syncResult.setFinishTime(newResult.getFinishTime());
|
||||
syncResult.setSyncData(newResult.getSyncData());
|
||||
syncResult.setSyncErrorCode(newResult.getSyncErrorCode());
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PayAssistService {
|
||||
public PayTrade createOrder(PayParam payParam) {
|
||||
String appId = payParam.getAppId();
|
||||
OffsetDateTime expiredTime = this.getExpiredTime(payParam.getExpiredTime());
|
||||
Long amount = Long.valueOf(PayUtil.convertCentAmount(payParam.getAmount()));
|
||||
Long amount = payParam.getAmount();
|
||||
// 从产品编码派生通道编码
|
||||
String channel = payParam.getProduct();
|
||||
if (StrUtil.isNotBlank(channel)) {
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package cn.daxpay.open.payment.unipay.param.trade.pay;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import jakarta.validation.constraints.Digits;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// # 订单商品明细
|
||||
///
|
||||
/// 对应支付宝 goods_detail 和微信支付 detail.goods_detail,
|
||||
@@ -38,13 +35,13 @@ public class GoodsDetail {
|
||||
@Schema(description = "商品数量")
|
||||
private Integer quantity;
|
||||
|
||||
/// 商品单价(分)
|
||||
/// 商品单价(分,最小货币单位)
|
||||
/// Alipay 需转为元,WeChat 直接使用分
|
||||
@NotNull(message = "{validation.field.unitPrice.notNull}")
|
||||
@DecimalMin(value = "0.01", message = "{validation.field.unitPrice.decimalMin}")
|
||||
@Digits(integer = 10, fraction = 2, message = "{validation.field.unitPrice.digits}")
|
||||
@Min(value = 1, message = "{validation.field.unitPrice.min}")
|
||||
@Max(value = 9999999999L, message = "{validation.field.unitPrice.max}")
|
||||
@Schema(description = "商品单价(分)")
|
||||
private BigDecimal unitPrice;
|
||||
private Long unitPrice;
|
||||
|
||||
/// 商品分类(Alipay 独有,选填)
|
||||
@Size(max = 32, message = "{validation.field.goodsCategory.size}")
|
||||
|
||||
@@ -11,7 +11,6 @@ import jakarta.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@@ -41,12 +40,12 @@ public class PayParam extends MerchantPaymentCommonParam {
|
||||
@Size(max = 50, message = "{validation.field.description.size}")
|
||||
private String description;
|
||||
|
||||
/// 支付金额(元)
|
||||
@Schema(description = "支付金额")
|
||||
/// 支付金额(分,最小货币单位)
|
||||
@Schema(description = "支付金额(分)")
|
||||
@NotNull(message = "{validation.field.amount.notNull}")
|
||||
@DecimalMin(value = "0.01", message = "{validation.field.amount.decimalMin}")
|
||||
@Digits(integer = 8, fraction = 2, message = "{validation.field.amount.digits}")
|
||||
private BigDecimal amount;
|
||||
@Min(value = 1, message = "{validation.field.amount.min}")
|
||||
@Max(value = 9999999999L, message = "{validation.field.amount.max}")
|
||||
private Long amount;
|
||||
|
||||
// ===== 支付路由 =====
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/// # 支付订单
|
||||
@@ -57,17 +56,17 @@ public class PayOrderResult {
|
||||
@Schema(description = "限制用户支付类型")
|
||||
private String limitPay;
|
||||
|
||||
/// 金额
|
||||
@Schema(description = "金额")
|
||||
private BigDecimal amount;
|
||||
/// 金额(分,最小货币单位)
|
||||
@Schema(description = "金额(分)")
|
||||
private Long amount;
|
||||
|
||||
/// 实收金额
|
||||
@Schema(description = "实收金额")
|
||||
private BigDecimal realAmount;
|
||||
/// 实收金额(分,最小货币单位)
|
||||
@Schema(description = "实收金额(分)")
|
||||
private Long realAmount;
|
||||
|
||||
/// 可退款余额
|
||||
@Schema(description = "可退款余额")
|
||||
private BigDecimal refundableBalance;
|
||||
/// 可退款余额(分,最小货币单位)
|
||||
@Schema(description = "可退款余额(分)")
|
||||
private Long refundableBalance;
|
||||
|
||||
/// 支付状态
|
||||
/// @see PayStatusEnum
|
||||
|
||||
@@ -5,8 +5,6 @@ import jakarta.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// # 小程序快捷被扫支付参数
|
||||
///
|
||||
@Data
|
||||
@@ -15,10 +13,10 @@ import java.math.BigDecimal;
|
||||
public class QuicklyBarPayParam {
|
||||
|
||||
@NotNull(message = "{validation.field.amount.notNull}")
|
||||
@DecimalMin(value = "0.01", message = "{validation.field.amount.decimalMin}")
|
||||
@Digits(integer = 8, fraction = 2, message = "{validation.field.amount.digits}")
|
||||
@Schema(description = "支付金额")
|
||||
private BigDecimal amount;
|
||||
@Min(value = 1, message = "{validation.field.amount.min}")
|
||||
@Max(value = 9999999999L, message = "{validation.field.amount.max}")
|
||||
@Schema(description = "支付金额(分)")
|
||||
private Long amount;
|
||||
|
||||
/// 支付描述
|
||||
@Schema(description = "支付描述")
|
||||
|
||||
@@ -5,8 +5,6 @@ import jakarta.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// # 小程序快捷二维码支付参数
|
||||
///
|
||||
@Data
|
||||
@@ -15,10 +13,10 @@ import java.math.BigDecimal;
|
||||
public class QuicklyQrPayParam {
|
||||
|
||||
@NotNull(message = "{validation.field.amount.notNull}")
|
||||
@DecimalMin(value = "0.01", message = "{validation.field.amount.decimalMin}")
|
||||
@Digits(integer = 8, fraction = 2, message = "{validation.field.amount.digits}")
|
||||
@Schema(description = "支付金额")
|
||||
private BigDecimal amount;
|
||||
@Min(value = 1, message = "{validation.field.amount.min}")
|
||||
@Max(value = 9999999999L, message = "{validation.field.amount.max}")
|
||||
@Schema(description = "支付金额(分)")
|
||||
private Long amount;
|
||||
|
||||
/// 支付描述
|
||||
@Schema(description = "支付描述")
|
||||
|
||||
@@ -141,9 +141,9 @@
|
||||
"size": "Payment order no. cannot exceed 100 characters"
|
||||
},
|
||||
"amount": {
|
||||
"notNull": "Refund amount cannot be blank",
|
||||
"decimalMin": "Payment amount cannot be less than 0.01",
|
||||
"digits": "Payment amount must be accurate to cents and less than 100 million"
|
||||
"notNull": "Payment amount cannot be blank",
|
||||
"min": "Payment amount cannot be less than 1 cent",
|
||||
"max": "Payment amount cannot exceed 100 million yuan"
|
||||
},
|
||||
"title": {
|
||||
"notBlank": "Title cannot be blank",
|
||||
@@ -225,8 +225,8 @@
|
||||
},
|
||||
"unitPrice": {
|
||||
"notNull": "Unit price cannot be null",
|
||||
"decimalMin": "Unit price cannot be less than 0.01",
|
||||
"digits": "Unit price precision up to cents"
|
||||
"min": "Unit price cannot be less than 1 cent",
|
||||
"max": "Unit price cannot exceed 100 million yuan"
|
||||
},
|
||||
"goodsCategory": {
|
||||
"size": "Goods category cannot exceed 32 characters"
|
||||
|
||||
@@ -141,9 +141,9 @@
|
||||
"size": "支付订单号不可超过100位"
|
||||
},
|
||||
"amount": {
|
||||
"notNull": "退款金额不可为空",
|
||||
"decimalMin": "支付金额不可小于0.01元",
|
||||
"digits": "支付金额精度到分, 且要小于一亿元"
|
||||
"notNull": "支付金额不可为空",
|
||||
"min": "支付金额不能小于1分",
|
||||
"max": "支付金额不能大于一亿元"
|
||||
},
|
||||
"title": {
|
||||
"notBlank": "名称不可为空",
|
||||
@@ -225,8 +225,8 @@
|
||||
},
|
||||
"unitPrice": {
|
||||
"notNull": "商品单价不可为空",
|
||||
"decimalMin": "商品单价不可小于0.01元",
|
||||
"digits": "商品单价精度到分"
|
||||
"min": "商品单价不能小于1分",
|
||||
"max": "商品单价不能大于一亿元"
|
||||
},
|
||||
"goodsCategory": {
|
||||
"size": "商品分类不可超过32位"
|
||||
|
||||
Reference in New Issue
Block a user