fix: 退款比例修改,返还积分修改
This commit is contained in:
parent
9744aa3c9a
commit
514533bfed
|
|
@ -2867,7 +2867,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
throw new BadRequestException("退款金额为负数有误");
|
||||
}
|
||||
|
||||
if (hasNormalReturn && returnAmount.compareTo(new BigDecimal("0.01")) <= 0 && oldOrderInfo.getPayAmount().compareTo(BigDecimal.ZERO) != 0) {
|
||||
if (hasNormalReturn && returnAmount.compareTo(new BigDecimal("0")) <= 0 && oldOrderInfo.getPayAmount().compareTo(BigDecimal.ZERO) != 0) {
|
||||
throw new BadRequestException("退款金额必须大于0");
|
||||
}
|
||||
|
||||
|
|
@ -2922,12 +2922,17 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
totalAmount = totalAmount.add(item.getPriceAmount());
|
||||
}
|
||||
}
|
||||
if (orderDetail.getPriceAmount().compareTo(totalAmount) == 0) {
|
||||
if (orderDetail.getPriceAmount().compareTo(totalAmount) == 0 && orderDetail.getNum().compareTo(BigDecimal.ONE) == 0) {
|
||||
return BigDecimal.ONE;
|
||||
}
|
||||
|
||||
if (orderDetail.getNum().compareTo(returnNum) == 0) {
|
||||
return orderDetail.getPriceAmount().divide(totalAmount, 2, RoundingMode.HALF_DOWN);
|
||||
}
|
||||
|
||||
return orderDetail.getPriceAmount().divide(totalAmount, 10, RoundingMode.HALF_DOWN)
|
||||
.divide(orderDetail.getNum(), 10, RoundingMode.HALF_DOWN).multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN);
|
||||
.divide(orderDetail.getNum(), 10, RoundingMode.HALF_DOWN)
|
||||
.multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN);
|
||||
}
|
||||
|
||||
private void updateStockAndRecord(List<TbOrderDetail> orderDetailList) {
|
||||
|
|
@ -3013,26 +3018,35 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
// 订单金额全退,退优惠券以及积分
|
||||
if (orderInfo.getPayAmount().compareTo(orderInfo.getRefundAmount()) <= 0) {
|
||||
String couponInfoList = orderInfo.getCouponInfoList();
|
||||
if (StrUtil.isNotBlank(couponInfoList)) {
|
||||
OrderInfoCouponInfoDTO orderInfoCouponInfoDTO = JSONObject.parseObject(couponInfoList, OrderInfoCouponInfoDTO.class);
|
||||
if (orderInfoCouponInfoDTO.getProductCoupon() != null && !orderInfoCouponInfoDTO.getProductCoupon().isEmpty()) {
|
||||
int remainNum = 0;
|
||||
for (OrderInfoUserCouponVo item : orderInfoCouponInfoDTO.getProductCoupon()) {
|
||||
if (item.getFinalUseNum() > item.getReturnNum()) {
|
||||
remainNum = remainNum + (item.getFinalUseNum() - item.getReturnNum());
|
||||
}
|
||||
}
|
||||
|
||||
if (remainNum == 0) {
|
||||
returnCoupon(orderInfo, true);
|
||||
// 返还积分
|
||||
memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(),
|
||||
"用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId()));
|
||||
|
||||
}
|
||||
}
|
||||
long count = mpOrderDetailService.count(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||
.eq(TbOrderDetail::getStatus, TableConstant.OrderInfo.Status.CLOSED));
|
||||
if (count == 0) {
|
||||
returnCoupon(orderInfo, true);
|
||||
// 返还积分
|
||||
memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(),
|
||||
"用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId()));
|
||||
}
|
||||
// String couponInfoList = orderInfo.getCouponInfoList();
|
||||
// if (StrUtil.isNotBlank(couponInfoList)) {
|
||||
// OrderInfoCouponInfoDTO orderInfoCouponInfoDTO = JSONObject.parseObject(couponInfoList, OrderInfoCouponInfoDTO.class);
|
||||
// if (orderInfoCouponInfoDTO.getProductCoupon() != null && !orderInfoCouponInfoDTO.getProductCoupon().isEmpty()) {
|
||||
// int remainNum = 0;
|
||||
// for (OrderInfoUserCouponVo item : orderInfoCouponInfoDTO.getProductCoupon()) {
|
||||
// if (item.getFinalUseNum() > item.getReturnNum()) {
|
||||
// remainNum = remainNum + (item.getFinalUseNum() - item.getReturnNum());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (remainNum == 0) {
|
||||
// returnCoupon(orderInfo, true);
|
||||
// // 返还积分
|
||||
// memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(),
|
||||
// "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId()));
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
// 打印退款小票
|
||||
|
|
|
|||
Loading…
Reference in New Issue