|
@@ -81,7 +81,7 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
**/
|
|
|
public static Long convertPriceRatio(Long price) {
|
|
|
// return (price / 100) * RATIO_MULTIPLE;
|
|
|
- return price ;
|
|
|
+ return price;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -100,20 +100,20 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
public PayCurrencyRechargeDO createCurrencyRecharge(Long dataId, Long userId, Integer userType, String userIp,
|
|
|
AppPayCurrencyRechargeCreateReqVO reqVO) {
|
|
|
// 1.1 计算充值金额
|
|
|
- long payPrice;
|
|
|
+ long payPrice = 0;
|
|
|
long bonusPrice = 0;
|
|
|
+ long receiptPrice = 0;
|
|
|
if (Objects.nonNull(reqVO.getPackageId())) {
|
|
|
PayCurrencyRechargePackageDO rechargePackage = payCurrencyRechargePackageService
|
|
|
.validCurrencyRechargePackage(reqVO.getPackageId());
|
|
|
payPrice = rechargePackage.getPayPrice();
|
|
|
bonusPrice = rechargePackage.getBonusPrice();
|
|
|
- } else {
|
|
|
- payPrice = reqVO.getPayPrice();
|
|
|
+ receiptPrice = rechargePackage.getReceiptPrice();
|
|
|
}
|
|
|
// 1.2 插入充值记录
|
|
|
PayCurrencyDO currency = payCurrencyService.getOrCreateCurrency(dataId, userId, userType);
|
|
|
PayCurrencyRechargeDO recharge = PayCurrencyRechargeConvert.INSTANCE
|
|
|
- .convert(currency.getId(), payPrice, bonusPrice, reqVO.getPackageId());
|
|
|
+ .convert(currency.getId(), payPrice, receiptPrice, bonusPrice, reqVO.getPackageId());
|
|
|
currencyRechargeMapper.insert(recharge);
|
|
|
|
|
|
// 2.1 创建支付单
|
|
@@ -165,7 +165,7 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
PayCurrencyRechargeDO currencyRecharge = currencyRechargeMapper.selectById(id);
|
|
|
if (currencyRecharge == null) {
|
|
|
log.error("[updateCurrencyRechargerPaid][货币账户充值记录不存在,货币账户充值记录 id({})]", id);
|
|
|
- throw exception(WALLET_RECHARGE_NOT_FOUND);
|
|
|
+ throw exception(CURRENCY_RECHARGE_NOT_FOUND);
|
|
|
}
|
|
|
// 1.2 校验货币账户充值是否可以支付
|
|
|
PayOrderDO payOrderDO = validateCurrencyRechargerCanPaid(currencyRecharge, payOrderId);
|
|
@@ -175,7 +175,7 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
new PayCurrencyRechargeDO().setId(id).setPayStatus(true).setPayTime(LocalDateTime.now())
|
|
|
.setPayChannelCode(payOrderDO.getChannelCode()));
|
|
|
if (updateCount == 0) {
|
|
|
- throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID);
|
|
|
+ throw exception(CURRENCY_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID);
|
|
|
}
|
|
|
|
|
|
// 3. 更新货币账户余额
|
|
@@ -200,7 +200,8 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
.addMessage("character_string1", String.valueOf(payOrderId)) // 支付单编号
|
|
|
.addMessage("amount2", fenToYuanStr(Math.toIntExact(currencyRecharge.getTotalPrice()))) // 充值金额
|
|
|
.addMessage("time3", LocalDateTimeUtil.formatNormal(currencyRecharge.getCreateTime())) // 充值时间
|
|
|
- .addMessage("phrase4", "充值成功")).checkError();; // 充值状态
|
|
|
+ .addMessage("phrase4", "充值成功")).checkError();
|
|
|
+ ; // 充值状态
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -210,7 +211,7 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
PayCurrencyRechargeDO currencyRecharge = currencyRechargeMapper.selectById(id);
|
|
|
if (currencyRecharge == null) {
|
|
|
log.error("[refundCurrencyRecharge][货币账户充值记录不存在,货币账户充值记录 id({})]", id);
|
|
|
- throw exception(WALLET_RECHARGE_NOT_FOUND);
|
|
|
+ throw exception(CURRENCY_RECHARGE_NOT_FOUND);
|
|
|
}
|
|
|
// 1.2 校验货币账户充值是否可以发起退款
|
|
|
PayCurrencyDO currency = validateCurrencyRechargeCanRefund(currencyRecharge);
|
|
@@ -240,7 +241,7 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
PayCurrencyRechargeDO currencyRecharge = currencyRechargeMapper.selectById(id);
|
|
|
if (currencyRecharge == null) {
|
|
|
log.error("[updateCurrencyRechargerPaid][货币账户充值记录不存在,货币账户充值记录 id({})]", id);
|
|
|
- throw exception(WALLET_RECHARGE_NOT_FOUND);
|
|
|
+ throw exception(CURRENCY_RECHARGE_NOT_FOUND);
|
|
|
}
|
|
|
// 1.2 校验货币账户充值是否可以更新已退款
|
|
|
PayRefundDO payRefund = validateCurrencyRechargeCanRefunded(currencyRecharge, payRefundId);
|
|
@@ -273,26 +274,26 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
if (notEqual(currencyRecharge.getPayRefundId(), payRefundId)) {
|
|
|
log.error("[validateCurrencyRechargeCanRefunded][货币账户充值({}) 退款单不匹配({}),请进行处理!货币账户充值的数据是:{}]",
|
|
|
currencyRecharge.getId(), payRefundId, toJsonString(currencyRecharge));
|
|
|
- throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR);
|
|
|
+ throw exception(CURRENCY_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR);
|
|
|
}
|
|
|
|
|
|
// 2.1 校验退款订单
|
|
|
PayRefundDO payRefund = payRefundService.getRefund(payRefundId);
|
|
|
if (payRefund == null) {
|
|
|
log.error("[validateCurrencyRechargeCanRefunded][payRefund({})不存在]", payRefundId);
|
|
|
- throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND);
|
|
|
+ throw exception(CURRENCY_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND);
|
|
|
}
|
|
|
// 2.2 校验退款金额一致
|
|
|
if (notEqual(Long.valueOf(payRefund.getRefundPrice()), currencyRecharge.getPayPrice())) {
|
|
|
log.error("[validateCurrencyRechargeCanRefunded][货币账户({}) payRefund({}) 退款金额不匹配,请进行处理!货币账户数据是:{},payRefund 数据是:{}]",
|
|
|
currencyRecharge.getId(), payRefundId, toJsonString(currencyRecharge), toJsonString(payRefund));
|
|
|
- throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH);
|
|
|
+ throw exception(CURRENCY_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH);
|
|
|
}
|
|
|
// 2.3 校验退款订单商户订单是否匹配
|
|
|
if (notEqual(payRefund.getMerchantOrderId(), currencyRecharge.getId().toString())) {
|
|
|
log.error("[validateCurrencyRechargeCanRefunded][货币账户({}) 退款单不匹配({}),请进行处理!payRefund 数据是:{}]",
|
|
|
currencyRecharge.getId(), payRefundId, toJsonString(payRefund));
|
|
|
- throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR);
|
|
|
+ throw exception(CURRENCY_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR);
|
|
|
}
|
|
|
return payRefund;
|
|
|
}
|
|
@@ -300,17 +301,17 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
private PayCurrencyDO validateCurrencyRechargeCanRefund(PayCurrencyRechargeDO currencyRecharge) {
|
|
|
// 校验充值订单是否支付
|
|
|
if (!currencyRecharge.getPayStatus()) {
|
|
|
- throw exception(WALLET_RECHARGE_REFUND_FAIL_NOT_PAID);
|
|
|
+ throw exception(CURRENCY_RECHARGE_REFUND_FAIL_NOT_PAID);
|
|
|
}
|
|
|
// 校验充值订单是否已退款
|
|
|
if (currencyRecharge.getPayRefundId() != null) {
|
|
|
- throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUNDED);
|
|
|
+ throw exception(CURRENCY_RECHARGE_REFUND_FAIL_REFUNDED);
|
|
|
}
|
|
|
// 校验货币账户余额是否足够
|
|
|
PayCurrencyDO currency = payCurrencyService.getCurrency(currencyRecharge.getCurrencyId());
|
|
|
Assert.notNull(currency, "用户货币账户({}) 不存在", currency.getId());
|
|
|
if (revertConvertPriceRatio(currency.getBalance()) < currencyRecharge.getTotalPrice()) {
|
|
|
- throw exception(WALLET_RECHARGE_REFUND_BALANCE_NOT_ENOUGH);
|
|
|
+ throw exception(CURRENCY_RECHARGE_REFUND_BALANCE_NOT_ENOUGH);
|
|
|
}
|
|
|
// TODO @芋艿:需要考虑下,赠送的金额,会不会导致提现超过;
|
|
|
return currency;
|
|
@@ -321,13 +322,13 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
if (currencyRecharge.getPayStatus()) {
|
|
|
log.error("[validateCurrencyRechargerCanPaid][货币账户({}) 不处于未支付状态! 货币账户数据是:{}]",
|
|
|
currencyRecharge.getId(), toJsonString(currencyRecharge));
|
|
|
- throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID);
|
|
|
+ throw exception(CURRENCY_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID);
|
|
|
}
|
|
|
// 1.2 校验支付订单匹配
|
|
|
if (notEqual(currencyRecharge.getPayOrderId(), payOrderId)) { // 支付单号
|
|
|
log.error("[validateCurrencyRechargerCanPaid][货币账户({}) 支付单不匹配({}),请进行处理! 货币账户数据是:{}]",
|
|
|
currencyRecharge.getId(), payOrderId, toJsonString(currencyRecharge));
|
|
|
- throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR);
|
|
|
+ throw exception(CURRENCY_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR);
|
|
|
}
|
|
|
|
|
|
// 2.1 校验支付单是否存在
|
|
@@ -341,19 +342,19 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
|
|
|
if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) {
|
|
|
log.error("[validateCurrencyRechargerCanPaid][货币账户({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]",
|
|
|
currencyRecharge.getId(), payOrderId, toJsonString(payOrder));
|
|
|
- throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS);
|
|
|
+ throw exception(CURRENCY_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS);
|
|
|
}
|
|
|
// 2.3 校验支付金额一致
|
|
|
if (notEqual(Long.valueOf(payOrder.getPrice()), currencyRecharge.getPayPrice())) {
|
|
|
log.error("[validateDemoOrderCanPaid][货币账户({}) payOrder({}) 支付金额不匹配,请进行处理!货币账户 数据是:{},payOrder 数据是:{}]",
|
|
|
currencyRecharge.getId(), payOrderId, toJsonString(currencyRecharge), toJsonString(payOrder));
|
|
|
- throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH);
|
|
|
+ throw exception(CURRENCY_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH);
|
|
|
}
|
|
|
// 2.4 校验支付订单的商户订单匹配
|
|
|
if (notEqual(payOrder.getMerchantOrderId(), currencyRecharge.getId().toString())) {
|
|
|
log.error("[validateDemoOrderCanPaid][货币账户({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]",
|
|
|
currencyRecharge.getId(), payOrderId, toJsonString(payOrder));
|
|
|
- throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR);
|
|
|
+ throw exception(CURRENCY_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR);
|
|
|
}
|
|
|
return payOrder;
|
|
|
}
|