mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
新增刷数据接口
This commit is contained in:
@@ -167,66 +167,64 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
return orderListVOS;
|
||||
}
|
||||
|
||||
private void tempUpdateVirtualAmount(List<OrderListVO> orderListVOS) {
|
||||
for (OrderListVO orderListVO : orderListVOS) {
|
||||
if (orderListVO.getVirtualAmount() != null) {
|
||||
continue;
|
||||
}
|
||||
// 订单总消费金额
|
||||
BigDecimal orderAmount = new BigDecimal(orderListVO.getOrderAmount());
|
||||
// 支付金额
|
||||
BigDecimal payAmount = new BigDecimal(orderListVO.getPayAmount());
|
||||
private void tempUpdateVirtualAmount(OrderListVO orderListVO) {
|
||||
if (orderListVO.getVirtualAmount() != null) {
|
||||
return;
|
||||
}
|
||||
// 订单总消费金额
|
||||
BigDecimal orderAmount = new BigDecimal(orderListVO.getOrderAmount());
|
||||
// 支付金额
|
||||
BigDecimal payAmount = new BigDecimal(orderListVO.getPayAmount());
|
||||
|
||||
if (orderAmount.compareTo(payAmount) > 0) {
|
||||
orderAmount = payAmount;
|
||||
}
|
||||
if (orderAmount.compareTo(payAmount) > 0) {
|
||||
orderAmount = payAmount;
|
||||
}
|
||||
|
||||
// 使用虚拟金额消费 金额
|
||||
BigDecimal virtualAmount = BigDecimal.ZERO;
|
||||
// 结算金额
|
||||
BigDecimal settleAmount = BigDecimal.ZERO;
|
||||
// 使用虚拟金额消费 金额
|
||||
BigDecimal virtualAmount = BigDecimal.ZERO;
|
||||
// 结算金额
|
||||
BigDecimal settleAmount = BigDecimal.ZERO;
|
||||
|
||||
if (orderAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (StringUtils.equals(orderListVO.getPayMode(), OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue())) {
|
||||
if (orderAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (StringUtils.equals(orderListVO.getPayMode(), OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue())) {
|
||||
/*
|
||||
余额支付 查询支付记录,如全部用本金支付,则虚拟金额为0,结算金额为订单消费金额,
|
||||
如果使用了赠送金额,虚拟金额为赠送金额支付部分,结算金额=订单消费金额-虚拟金额消费部分
|
||||
*/
|
||||
// 查询支付记录
|
||||
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderListVO.getOrderCode());
|
||||
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
||||
if (StringUtils.equals(orderPayRecord.getPayMode(), OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue())) {
|
||||
BigDecimal refundAmount = orderPayRecord.getRefundAmount();
|
||||
if (refundAmount == null) {
|
||||
// 退款金额为null, 需要退款的金额 = 支付金额 - 订单金额
|
||||
refundAmount = orderPayRecord.getPayAmount().subtract(orderAmount);
|
||||
}
|
||||
// 赠送金额消费部分 = 支付金额 - 需要退款金额
|
||||
virtualAmount = orderPayRecord.getPayAmount().subtract(refundAmount);
|
||||
// 结算金额 = 订单金额 - 赠送金额消费部分
|
||||
settleAmount = orderAmount.subtract(virtualAmount);
|
||||
} else {
|
||||
// 没有使用赠送金额支付,那么虚拟金额就是0,结算金额就等于订单金额
|
||||
settleAmount = orderAmount;
|
||||
// 查询支付记录
|
||||
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderListVO.getOrderCode());
|
||||
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
||||
if (StringUtils.equals(orderPayRecord.getPayMode(), OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue())) {
|
||||
BigDecimal refundAmount = orderPayRecord.getRefundAmount();
|
||||
if (refundAmount == null) {
|
||||
// 退款金额为null, 需要退款的金额 = 支付金额 - 订单金额
|
||||
refundAmount = orderPayRecord.getPayAmount().subtract(orderAmount);
|
||||
}
|
||||
// 赠送金额消费部分 = 支付金额 - 需要退款金额
|
||||
virtualAmount = orderPayRecord.getPayAmount().subtract(refundAmount);
|
||||
// 结算金额 = 订单金额 - 赠送金额消费部分
|
||||
settleAmount = orderAmount.subtract(virtualAmount);
|
||||
} else {
|
||||
// 没有使用赠送金额支付,那么虚拟金额就是0,结算金额就等于订单金额
|
||||
settleAmount = orderAmount;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
微信支付 虚拟金额为0 结算金额等于订单消费金额
|
||||
*/
|
||||
settleAmount = orderAmount;
|
||||
}
|
||||
settleAmount = orderAmount;
|
||||
}
|
||||
|
||||
OrderBasicInfo build = OrderBasicInfo.builder()
|
||||
.id(Long.parseLong(orderListVO.getId()))
|
||||
.orderCode(orderListVO.getOrderCode())
|
||||
.orderAmount(orderAmount)
|
||||
.virtualAmount(virtualAmount)
|
||||
.settleAmount(settleAmount)
|
||||
.build();
|
||||
updateOrderBasicInfo(build);
|
||||
}
|
||||
|
||||
OrderBasicInfo build = OrderBasicInfo.builder()
|
||||
.id(Long.parseLong(orderListVO.getId()))
|
||||
.orderCode(orderListVO.getOrderCode())
|
||||
.orderAmount(orderAmount)
|
||||
.virtualAmount(virtualAmount)
|
||||
.settleAmount(settleAmount)
|
||||
.build();
|
||||
updateOrderBasicInfo(build);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1713,8 +1711,15 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
if (CollectionUtils.isEmpty(orderListVOS)) {
|
||||
return "没有订单需要修改";
|
||||
}
|
||||
|
||||
tempUpdateVirtualAmount(orderListVOS);
|
||||
return "共修改" + orderListVOS.size() + "条订单数据";
|
||||
int i = 0;
|
||||
for (OrderListVO orderListVO : orderListVOS) {
|
||||
try {
|
||||
tempUpdateVirtualAmount(orderListVO);
|
||||
i += 1;
|
||||
} catch (Exception e) {
|
||||
logger.error("修改虚拟金额字段失败", e);
|
||||
}
|
||||
}
|
||||
return "共查询到" + i + "条订单,修改成功" + i + "条订单数据";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user