|
|
@@ -54,6 +54,7 @@ import com.yami.shop.service.OrderService;
|
|
|
import com.yami.shop.service.OrderSettlementService;
|
|
|
import com.yami.shop.utils.CullenUtils;
|
|
|
import com.yami.shop.utils.ExportUtils;
|
|
|
+import com.yami.shop.utils.HBSignUtil;
|
|
|
import com.yami.shop.wx.po.RefundInfoPo;
|
|
|
import com.yami.shop.wx.service.WxProviderService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
@@ -971,7 +972,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
.eq(OrderRefund::getHandler, Boolean.FALSE)
|
|
|
);
|
|
|
if (ObjectUtils.isNotEmpty(orderRefund)) {
|
|
|
- Order order = orderMapper.selectById(orderRefund.getOrderId());
|
|
|
+ Order order = orderMapper.selectById(orderRefund.getOrderId());
|
|
|
|
|
|
//生成待商家审核记录
|
|
|
addOrderRefundRecord(orderRefund.getRefundId(), 25, 6, "平台已退款到微信账户中");
|
|
|
@@ -980,46 +981,90 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
updateOrderStatus(order);
|
|
|
|
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(orderRefund)) {
|
|
|
- //退款的金额
|
|
|
- BigDecimal refundActual = BigDecimal.ZERO;
|
|
|
- //退款的积分
|
|
|
- Long refundScore = 0L;
|
|
|
- //过期的积分
|
|
|
- long refundExpiredScore = 0L;
|
|
|
- //退款总积分
|
|
|
- Long refundOffsetPoints=0L;
|
|
|
-
|
|
|
- if (null == order) throw new GlobalException("该订单不支持退款");
|
|
|
- //判定已完成的时间
|
|
|
- if (Objects.equals(order.getHbOrderStatus(), OrderStatus.SUCCESS.value()) && isPaymentOver7Days(order.getPayTime())) {
|
|
|
- throw new GlobalException("支付完成已经超过7天,不支持退款");
|
|
|
- }
|
|
|
- //"订单退款状态(1:申请退款 2:退款成功 3:部分退款成功 4:退款失败)"
|
|
|
- switch (orderRefund.getRefundType()) {
|
|
|
- case 1://1:整单退款
|
|
|
- order.setRefundStatus(2);
|
|
|
- if (order.getActualTotal() > 0) {
|
|
|
- OrderSettlement orderSettlement = orderSettlementMapper.selectOne(new LambdaQueryWrapper<OrderSettlement>()
|
|
|
- .eq(OrderSettlement::getOrderNumber, order.getOrderNumber())
|
|
|
- .eq(OrderSettlement::getPayType, 1));
|
|
|
- if (ObjectUtil.isNotEmpty(order.getOffsetPoints()) && order.getOffsetPoints() > 0) {//混合支付
|
|
|
- //退钱
|
|
|
- RefundInfoPo po = new RefundInfoPo();
|
|
|
- po.setOutTradeNo(orderSettlement.getPayNo());
|
|
|
- //混合支付,有积分时运费优先扣积分
|
|
|
- po.setTotal((int) Arith.mul(order.getActualTotal(), 100));
|
|
|
- po.setRefundMoney((int) Arith.mul(order.getActualTotal(), 100));
|
|
|
- String s = wxProviderService.refundOrder(po);
|
|
|
- System.out.println("微信退款结果:" + s);
|
|
|
- refundActual = BigDecimal.valueOf(order.getActualTotal());
|
|
|
- //优先退未过期的积分,退积分
|
|
|
+ if (ObjectUtils.isNotEmpty(orderRefund)) {
|
|
|
+ //退款的金额
|
|
|
+ BigDecimal refundActual = BigDecimal.ZERO;
|
|
|
+ //退款的积分
|
|
|
+ Long refundScore = 0L;
|
|
|
+ //过期的积分
|
|
|
+ long refundExpiredScore = 0L;
|
|
|
+ //退款总积分
|
|
|
+ Long refundOffsetPoints = 0L;
|
|
|
+
|
|
|
+ if (null == order) throw new GlobalException("该订单不支持退款");
|
|
|
+ //判定已完成的时间
|
|
|
+ if (Objects.equals(order.getHbOrderStatus(), OrderStatus.SUCCESS.value()) && isPaymentOver7Days(order.getPayTime())) {
|
|
|
+ throw new GlobalException("支付完成已经超过7天,不支持退款");
|
|
|
+ }
|
|
|
+ //"订单退款状态(1:申请退款 2:退款成功 3:部分退款成功 4:退款失败)"
|
|
|
+ switch (orderRefund.getRefundType()) {
|
|
|
+ case 1://1:整单退款
|
|
|
+ order.setRefundStatus(2);
|
|
|
+ if (order.getActualTotal() > 0) {
|
|
|
+ OrderSettlement orderSettlement = orderSettlementMapper.selectOne(new LambdaQueryWrapper<OrderSettlement>()
|
|
|
+ .eq(OrderSettlement::getOrderNumber, order.getOrderNumber())
|
|
|
+ .eq(OrderSettlement::getPayType, 1));
|
|
|
+ if (ObjectUtil.isNotEmpty(order.getOffsetPoints()) && order.getOffsetPoints() > 0) {//混合支付
|
|
|
+ //退钱
|
|
|
+ RefundInfoPo po = new RefundInfoPo();
|
|
|
+ po.setOutTradeNo(orderSettlement.getPayNo());
|
|
|
+ //混合支付,有积分时运费优先扣积分
|
|
|
+ po.setTotal((int) Arith.mul(order.getActualTotal(), 100));
|
|
|
+ po.setRefundMoney((int) Arith.mul(order.getActualTotal(), 100));
|
|
|
+ String s = wxProviderService.refundOrder(po);
|
|
|
+ System.out.println("微信退款结果:" + s);
|
|
|
+ refundActual = BigDecimal.valueOf(order.getActualTotal());
|
|
|
+ //优先退未过期的积分,退积分
|
|
|
// List<PointsRecord> pointsRecords = pointsRecordMapper.selectList(new LambdaQueryWrapper<PointsRecord>()
|
|
|
// .eq(PointsRecord::getOrderNumber, order.getOrderNumber()).eq(PointsRecord::getPointsType, 2)
|
|
|
// .orderByDesc(PointsRecord::getExpiryDate));
|
|
|
+ List<PointsRecord> pointsRecords = pointsRecordMapper.findByOrderNumber(order.getOrderNumber(), 2);
|
|
|
+ for (PointsRecord pointsRecord : pointsRecords) {
|
|
|
+// refundScore = (refundScore + order.getOffsetPoints());
|
|
|
+ PointsRecord npr = new PointsRecord();
|
|
|
+ BeanUtils.copyProperties(pointsRecord, npr);
|
|
|
+ npr.setId(null);
|
|
|
+ npr.setPointsType(3);
|
|
|
+ npr.setPointsAudit(1);
|
|
|
+ npr.setPoints(pointsRecord.getVariablePoints());
|
|
|
+ npr.setVariablePoints(BigDecimal.valueOf(0));
|
|
|
+ Long l = pointsRecordMapper.statisticsPoint(pointsRecord.getUserId(), Math.toIntExact(pointsRecord.getChannelId()));
|
|
|
+ if (null == l) {
|
|
|
+ l = 0L;
|
|
|
+ }
|
|
|
+ if (null != pointsRecord.getVariablePoints()) {
|
|
|
+ if (pointsRecord.getExpiryStatus() == 1) {
|
|
|
+ npr.setCurrentlyAvailablePoints(pointsRecord.getVariablePoints().add(BigDecimal.valueOf(l)));
|
|
|
+ } else {
|
|
|
+ npr.setCurrentlyAvailablePoints(BigDecimal.ZERO.add(BigDecimal.valueOf(l)));
|
|
|
+ }
|
|
|
+ if (pointsRecord.getExpiryStatus() == 2) {
|
|
|
+ refundExpiredScore += pointsRecord.getVariablePoints().longValue();
|
|
|
+ }
|
|
|
+ refundScore = (refundScore + pointsRecord.getVariablePoints().intValue());
|
|
|
+ } else {
|
|
|
+ npr.setCurrentlyAvailablePoints(BigDecimal.ZERO.add(BigDecimal.valueOf(l)));
|
|
|
+ }
|
|
|
+ npr.setCreationDate(new Date());
|
|
|
+ pointsRecordMapper.insert(npr);
|
|
|
+ }
|
|
|
+// refundExpiredScore = order.getOffsetPoints() - refundScore;
|
|
|
+ } else {//仅微信支付
|
|
|
+ RefundInfoPo po = new RefundInfoPo();
|
|
|
+ po.setOutTradeNo(orderSettlement.getPayNo());
|
|
|
+ po.setTotal((int) Arith.mul(Arith.add(order.getTotal(), order.getFreightAmount()), 100));
|
|
|
+ po.setRefundMoney((int) Arith.mul(Arith.add(order.getTotal(), order.getFreightAmount()), 100));
|
|
|
+ String s = wxProviderService.refundOrder(po);
|
|
|
+ System.out.println("微信退款结果:" + s);
|
|
|
+ refundActual = BigDecimal.valueOf(Arith.add(order.getTotal(), order.getFreightAmount()));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //退,积分【优先退未过期的积分】
|
|
|
+// List<PointsRecord> pointsRecords = pointsRecordMapper.selectList(new LambdaQueryWrapper<PointsRecord>()
|
|
|
+// .eq(PointsRecord::getOrderNumber, order.getOrderNumber()).eq(PointsRecord::getPointsType, 2)
|
|
|
+// .orderByDesc(PointsRecord::getExpiryDate));
|
|
|
List<PointsRecord> pointsRecords = pointsRecordMapper.findByOrderNumber(order.getOrderNumber(), 2);
|
|
|
for (PointsRecord pointsRecord : pointsRecords) {
|
|
|
-// refundScore = (refundScore + order.getOffsetPoints());
|
|
|
PointsRecord npr = new PointsRecord();
|
|
|
BeanUtils.copyProperties(pointsRecord, npr);
|
|
|
npr.setId(null);
|
|
|
@@ -1032,78 +1077,34 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
l = 0L;
|
|
|
}
|
|
|
if (null != pointsRecord.getVariablePoints()) {
|
|
|
- if (pointsRecord.getExpiryStatus()==1){
|
|
|
+ if (pointsRecord.getExpiryStatus() == 1) {
|
|
|
npr.setCurrentlyAvailablePoints(pointsRecord.getVariablePoints().add(BigDecimal.valueOf(l)));
|
|
|
- }else {
|
|
|
- npr.setCurrentlyAvailablePoints(BigDecimal.ZERO.add(BigDecimal.valueOf(l)));
|
|
|
+ } else {
|
|
|
+ npr.setCurrentlyAvailablePoints(BigDecimal.valueOf(0.0).add(BigDecimal.valueOf(l)));
|
|
|
}
|
|
|
- if (pointsRecord.getExpiryStatus()==2){
|
|
|
+ if (pointsRecord.getExpiryStatus() == 2) {
|
|
|
refundExpiredScore += pointsRecord.getVariablePoints().longValue();
|
|
|
}
|
|
|
- refundScore = (refundScore + pointsRecord.getVariablePoints().intValue());
|
|
|
+ refundScore = (refundScore + pointsRecord.getVariablePoints().intValue());
|
|
|
} else {
|
|
|
npr.setCurrentlyAvailablePoints(BigDecimal.ZERO.add(BigDecimal.valueOf(l)));
|
|
|
}
|
|
|
npr.setCreationDate(new Date());
|
|
|
pointsRecordMapper.insert(npr);
|
|
|
}
|
|
|
-// refundExpiredScore = order.getOffsetPoints() - refundScore;
|
|
|
- } else {//仅微信支付
|
|
|
- RefundInfoPo po = new RefundInfoPo();
|
|
|
- po.setOutTradeNo(orderSettlement.getPayNo());
|
|
|
- po.setTotal((int) Arith.mul(Arith.add(order.getTotal(), order.getFreightAmount()), 100));
|
|
|
- po.setRefundMoney((int) Arith.mul(Arith.add(order.getTotal(), order.getFreightAmount()), 100));
|
|
|
- String s = wxProviderService.refundOrder(po);
|
|
|
- System.out.println("微信退款结果:" + s);
|
|
|
- refundActual = BigDecimal.valueOf(Arith.add(order.getTotal(), order.getFreightAmount()));
|
|
|
+// refundExpiredScore = order.getOffsetPoints() - refundScore;
|
|
|
}
|
|
|
- } else {
|
|
|
- //退,积分【优先退未过期的积分】
|
|
|
-// List<PointsRecord> pointsRecords = pointsRecordMapper.selectList(new LambdaQueryWrapper<PointsRecord>()
|
|
|
-// .eq(PointsRecord::getOrderNumber, order.getOrderNumber()).eq(PointsRecord::getPointsType, 2)
|
|
|
-// .orderByDesc(PointsRecord::getExpiryDate));
|
|
|
+ break;
|
|
|
+ case 2://2:单个物品退款
|
|
|
+ order.setRefundStatus(3);
|
|
|
+ List<OrderRefundSku> orderRefundSkus = orderRefundSkuMapper.selectList(new LambdaQueryWrapper<OrderRefundSku>()
|
|
|
+ .eq(OrderRefundSku::getOrderRefundId, orderRefund.getRefundId()));
|
|
|
List<PointsRecord> pointsRecords = pointsRecordMapper.findByOrderNumber(order.getOrderNumber(), 2);
|
|
|
- for (PointsRecord pointsRecord : pointsRecords) {
|
|
|
- PointsRecord npr = new PointsRecord();
|
|
|
- BeanUtils.copyProperties(pointsRecord, npr);
|
|
|
- npr.setId(null);
|
|
|
- npr.setPointsType(3);
|
|
|
- npr.setPointsAudit(1);
|
|
|
- npr.setPoints(pointsRecord.getVariablePoints());
|
|
|
- npr.setVariablePoints(BigDecimal.valueOf(0));
|
|
|
- Long l = pointsRecordMapper.statisticsPoint(pointsRecord.getUserId(), Math.toIntExact(pointsRecord.getChannelId()));
|
|
|
- if (null == l) {
|
|
|
- l = 0L;
|
|
|
- }
|
|
|
- if (null != pointsRecord.getVariablePoints()) {
|
|
|
- if (pointsRecord.getExpiryStatus()==1){
|
|
|
- npr.setCurrentlyAvailablePoints(pointsRecord.getVariablePoints().add(BigDecimal.valueOf(l)));
|
|
|
- }else {
|
|
|
- npr.setCurrentlyAvailablePoints(BigDecimal.valueOf(0.0).add(BigDecimal.valueOf(l)));
|
|
|
- }
|
|
|
- if (pointsRecord.getExpiryStatus()==2){
|
|
|
- refundExpiredScore += pointsRecord.getVariablePoints().longValue();
|
|
|
- }
|
|
|
- refundScore = (refundScore + pointsRecord.getVariablePoints().intValue());
|
|
|
- } else {
|
|
|
- npr.setCurrentlyAvailablePoints(BigDecimal.ZERO.add(BigDecimal.valueOf(l)));
|
|
|
- }
|
|
|
- npr.setCreationDate(new Date());
|
|
|
- pointsRecordMapper.insert(npr);
|
|
|
+ List<OrderRefund> orderRefundList = orderRefundMapper.findByOrderNumber(order.getOrderNumber(), 70);
|
|
|
+
|
|
|
+ for (OrderRefund refund : orderRefundList) {
|
|
|
+ refundOffsetPoints += refund.getOffsetPoints();
|
|
|
}
|
|
|
-// refundExpiredScore = order.getOffsetPoints() - refundScore;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2://2:单个物品退款
|
|
|
- order.setRefundStatus(3);
|
|
|
- List<OrderRefundSku> orderRefundSkus = orderRefundSkuMapper.selectList(new LambdaQueryWrapper<OrderRefundSku>()
|
|
|
- .eq(OrderRefundSku::getOrderRefundId, orderRefund.getRefundId()));
|
|
|
- List<PointsRecord> pointsRecords = pointsRecordMapper.findByOrderNumber(order.getOrderNumber(), 2);
|
|
|
- List<OrderRefund> orderRefundList = orderRefundMapper.findByOrderNumber(order.getOrderNumber(),70);
|
|
|
-
|
|
|
- for (OrderRefund refund : orderRefundList) {
|
|
|
- refundOffsetPoints += refund.getOffsetPoints();
|
|
|
- }
|
|
|
// pointsRecordMapper.selectList(new LambdaQueryWrapper<PointsRecord>()
|
|
|
// .eq(PointsRecord::getOrderNumber, order.getOrderNumber())
|
|
|
// .eq(PointsRecord::getPointsType, 2)
|
|
|
@@ -1112,143 +1113,144 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
//// .or()
|
|
|
// .isNull(PointsRecord::getExpiryDate)
|
|
|
// ).orderByDesc(PointsRecord::getExpiryDate));
|
|
|
- //TODO (int) Arith.mul(order.getFreightAmount(), 100),加在这里就是每次部分退单都要减掉,有可能会出现退的积分比下单总积分少。少的值恰好为一次运费
|
|
|
- int totalRefundScore = 0;//需要退款的金额,部分退款时不需要退运费。
|
|
|
- int freightAmountScore = -(int) Arith.mul(order.getFreightAmount(), 100);//需要退的总积分,先把运费剔除掉
|
|
|
- double totalRefundActual = 0.0;//需要退的总金额
|
|
|
- int shoppingScore= 0;
|
|
|
- for (OrderRefundSku refundSkus : orderRefundSkus) {
|
|
|
- Integer productCount = refundSkus.getProductCount();//退款的数量
|
|
|
- OrderItem orderItem = orderItemMapper.selectById(refundSkus.getOrderItemId());
|
|
|
- Double actualTotal = orderItem.getActualTotal();//付的钱
|
|
|
- Integer useScore = orderItem.getUseScore();//使用的总积分
|
|
|
- if (ObjectUtil.isNotEmpty(order.getOffsetPoints())){
|
|
|
- shoppingScore = order.getOffsetPoints().intValue()+freightAmountScore;//退款商品的总积分
|
|
|
- }
|
|
|
+ //TODO (int) Arith.mul(order.getFreightAmount(), 100),加在这里就是每次部分退单都要减掉,有可能会出现退的积分比下单总积分少。少的值恰好为一次运费
|
|
|
+ int totalRefundScore = 0;//需要退款的金额,部分退款时不需要退运费。
|
|
|
+ int freightAmountScore = -(int) Arith.mul(order.getFreightAmount(), 100);//需要退的总积分,先把运费剔除掉
|
|
|
+ double totalRefundActual = 0.0;//需要退的总金额
|
|
|
+ int shoppingScore = 0;
|
|
|
+ for (OrderRefundSku refundSkus : orderRefundSkus) {
|
|
|
+ Integer productCount = refundSkus.getProductCount();//退款的数量
|
|
|
+ OrderItem orderItem = orderItemMapper.selectById(refundSkus.getOrderItemId());
|
|
|
+ Double actualTotal = orderItem.getActualTotal();//付的钱
|
|
|
+ Integer useScore = orderItem.getUseScore();//使用的总积分
|
|
|
+ if (ObjectUtil.isNotEmpty(order.getOffsetPoints())) {
|
|
|
+ shoppingScore = order.getOffsetPoints().intValue() + freightAmountScore;//退款商品的总积分
|
|
|
+ }
|
|
|
|
|
|
- if (useScore > 0) {
|
|
|
- //退的积分不一定等于下单的数量
|
|
|
- totalRefundScore = (int) (totalRefundScore + Arith.mul(productCount * orderItem.getPrice(), 100));
|
|
|
- }
|
|
|
- if (actualTotal > 0) {
|
|
|
- totalRefundActual = Arith.add(totalRefundActual, productCount * orderItem.getPrice());
|
|
|
- }
|
|
|
- }
|
|
|
- log.info("退款积分:refundOffsetPoints:"+refundOffsetPoints +";shoppingScore:"+shoppingScore+";totalRefundScore:"+totalRefundScore);
|
|
|
- //退积分
|
|
|
- if (totalRefundScore > 0) {
|
|
|
- refundScore = (long) totalRefundScore;
|
|
|
- for (PointsRecord pointsRecord : pointsRecords) {
|
|
|
- //下单支付的金额
|
|
|
- int variablePoints = pointsRecord.getVariablePoints().intValue();//574
|
|
|
- PointsRecord npr = new PointsRecord();
|
|
|
- BeanUtils.copyProperties(pointsRecord, npr);
|
|
|
- npr.setId(null);
|
|
|
- npr.setPointsType(3);
|
|
|
- Long l = pointsRecordMapper.statisticsPoint(pointsRecord.getUserId(), Math.toIntExact(pointsRecord.getChannelId()));
|
|
|
- if (null == l) {
|
|
|
- l = 0L;
|
|
|
+ if (useScore > 0) {
|
|
|
+ //退的积分不一定等于下单的数量
|
|
|
+ totalRefundScore = (int) (totalRefundScore + Arith.mul(productCount * orderItem.getPrice(), 100));
|
|
|
}
|
|
|
- npr.setCreationDate(new Date());
|
|
|
- //574>188
|
|
|
- if (variablePoints < totalRefundScore) {//下单金额全退
|
|
|
- npr.setPoints(pointsRecord.getVariablePoints());
|
|
|
- npr.setVariablePoints(BigDecimal.valueOf(0));
|
|
|
- npr.setPointsAudit(1);
|
|
|
- if (pointsRecord.getExpiryStatus()==1){//当过期状态等于1时才进行变更可用金额 否则不变更
|
|
|
- if (null != pointsRecord.getVariablePoints()) {
|
|
|
- npr.setCurrentlyAvailablePoints(pointsRecord.getVariablePoints().add(BigDecimal.valueOf(l)));
|
|
|
+ if (actualTotal > 0) {
|
|
|
+ totalRefundActual = Arith.add(totalRefundActual, productCount * orderItem.getPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("退款积分:refundOffsetPoints:" + refundOffsetPoints + ";shoppingScore:" + shoppingScore + ";totalRefundScore:" + totalRefundScore);
|
|
|
+ //退积分
|
|
|
+ if (totalRefundScore > 0) {
|
|
|
+ refundScore = (long) totalRefundScore;
|
|
|
+ for (PointsRecord pointsRecord : pointsRecords) {
|
|
|
+ //下单支付的金额
|
|
|
+ int variablePoints = pointsRecord.getVariablePoints().intValue();//574
|
|
|
+ PointsRecord npr = new PointsRecord();
|
|
|
+ BeanUtils.copyProperties(pointsRecord, npr);
|
|
|
+ npr.setId(null);
|
|
|
+ npr.setPointsType(3);
|
|
|
+ Long l = pointsRecordMapper.statisticsPoint(pointsRecord.getUserId(), Math.toIntExact(pointsRecord.getChannelId()));
|
|
|
+ if (null == l) {
|
|
|
+ l = 0L;
|
|
|
+ }
|
|
|
+ npr.setCreationDate(new Date());
|
|
|
+ //574>188
|
|
|
+ if (variablePoints < totalRefundScore) {//下单金额全退
|
|
|
+ npr.setPoints(pointsRecord.getVariablePoints());
|
|
|
+ npr.setVariablePoints(BigDecimal.valueOf(0));
|
|
|
+ npr.setPointsAudit(1);
|
|
|
+ if (pointsRecord.getExpiryStatus() == 1) {//当过期状态等于1时才进行变更可用金额 否则不变更
|
|
|
+ if (null != pointsRecord.getVariablePoints()) {
|
|
|
+ npr.setCurrentlyAvailablePoints(pointsRecord.getVariablePoints().add(BigDecimal.valueOf(l)));
|
|
|
+ } else {
|
|
|
+ npr.setCurrentlyAvailablePoints(BigDecimal.valueOf(0.0).add(BigDecimal.valueOf(l)));
|
|
|
+ }
|
|
|
} else {
|
|
|
npr.setCurrentlyAvailablePoints(BigDecimal.valueOf(0.0).add(BigDecimal.valueOf(l)));
|
|
|
}
|
|
|
- } else {
|
|
|
- npr.setCurrentlyAvailablePoints(BigDecimal.valueOf(0.0).add(BigDecimal.valueOf(l)));
|
|
|
+ if (pointsRecord.getExpiryStatus() == 2) {
|
|
|
+ refundExpiredScore += variablePoints;
|
|
|
+ }
|
|
|
+ totalRefundScore -= variablePoints;
|
|
|
+ pointsRecordMapper.insert(npr);
|
|
|
+ } else if (totalRefundScore > 0) {//574>188,应退188
|
|
|
+ npr.setPoints(BigDecimal.valueOf(totalRefundScore));
|
|
|
+ npr.setVariablePoints(BigDecimal.valueOf(0));
|
|
|
+ npr.setPointsAudit(1);
|
|
|
+ if (pointsRecord.getExpiryStatus() == 1) {//当过期状态等于1时才进行变更可用金额 否则不变更
|
|
|
+ BigDecimal bigDecimal = BigDecimal.valueOf(totalRefundScore);
|
|
|
+ npr.setCurrentlyAvailablePoints(bigDecimal.add(BigDecimal.valueOf(l)));
|
|
|
+ } else {
|
|
|
+ npr.setCurrentlyAvailablePoints(BigDecimal.valueOf(0.0).add(BigDecimal.valueOf(l)));
|
|
|
+ }
|
|
|
+ if (pointsRecord.getExpiryStatus() == 2) {
|
|
|
+ refundExpiredScore += totalRefundScore;
|
|
|
+ }
|
|
|
+ totalRefundScore = 0;
|
|
|
+ pointsRecordMapper.insert(npr);
|
|
|
}
|
|
|
- if (pointsRecord.getExpiryStatus()==2){
|
|
|
- refundExpiredScore += variablePoints;
|
|
|
+ log.info("退积分:当前退款金额为:totalRefundScore:" + totalRefundScore);
|
|
|
+ if (totalRefundScore == 0 && shoppingScore >= refundOffsetPoints) {
|
|
|
+ orderRefund.setRefundAmount(refundActual.doubleValue());
|
|
|
+ orderRefund.setOffsetPoints(refundScore);
|
|
|
+ orderRefund.setHandler(Boolean.TRUE);
|
|
|
+ orderRefund.setRefundExpiredScore(refundExpiredScore);
|
|
|
+ log.info("仅退积分-退款单修改状态和积分{}", orderRefund);
|
|
|
+ orderRefundMapper.updateById(orderRefund);
|
|
|
+ return;
|
|
|
}
|
|
|
- totalRefundScore -= variablePoints;
|
|
|
- pointsRecordMapper.insert(npr);
|
|
|
- } else if(totalRefundScore>0){//574>188,应退188
|
|
|
- npr.setPoints(BigDecimal.valueOf(totalRefundScore));
|
|
|
- npr.setVariablePoints(BigDecimal.valueOf(0));
|
|
|
- npr.setPointsAudit(1);
|
|
|
- if (pointsRecord.getExpiryStatus()==1){//当过期状态等于1时才进行变更可用金额 否则不变更
|
|
|
- BigDecimal bigDecimal = BigDecimal.valueOf(totalRefundScore);
|
|
|
- npr.setCurrentlyAvailablePoints(bigDecimal.add(BigDecimal.valueOf(l)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //退钱
|
|
|
+ if (totalRefundActual > 0) {
|
|
|
+ int refundMoney = 0;//需要退款的金额
|
|
|
+ if (totalRefundScore > 0) {
|
|
|
+ if (totalRefundActual >= totalRefundScore) {
|
|
|
+ refundMoney = totalRefundScore;
|
|
|
} else {
|
|
|
- npr.setCurrentlyAvailablePoints(BigDecimal.valueOf(0.0).add(BigDecimal.valueOf(l)));
|
|
|
- }
|
|
|
- if (pointsRecord.getExpiryStatus()==2){
|
|
|
- refundExpiredScore += totalRefundScore;
|
|
|
+ System.out.println("退款金额大于支付金额");
|
|
|
}
|
|
|
- totalRefundScore=0;
|
|
|
- pointsRecordMapper.insert(npr);
|
|
|
- }
|
|
|
- log.info("退积分:当前退款金额为:totalRefundScore:"+totalRefundScore);
|
|
|
- if (totalRefundScore==0 && shoppingScore>=refundOffsetPoints) {
|
|
|
- orderRefund.setRefundAmount(refundActual.doubleValue());
|
|
|
- orderRefund.setOffsetPoints(refundScore);
|
|
|
- orderRefund.setHandler(Boolean.TRUE);
|
|
|
- orderRefund.setRefundExpiredScore(refundExpiredScore);
|
|
|
- log.info("仅退积分-退款单修改状态和积分{}",orderRefund);
|
|
|
- orderRefundMapper.updateById(orderRefund);
|
|
|
- return;
|
|
|
+ } else if (totalRefundScore == 0) {
|
|
|
+ refundMoney = (int) Arith.mul(totalRefundActual, 100);
|
|
|
+ } else {
|
|
|
+ System.out.println("单笔退款未知状态");
|
|
|
+ break;
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- //退钱
|
|
|
- if (totalRefundActual > 0) {
|
|
|
- int refundMoney=0;//需要退款的金额
|
|
|
- if (totalRefundScore>0){
|
|
|
- if (totalRefundActual>=totalRefundScore){
|
|
|
- refundMoney = totalRefundScore;
|
|
|
- }else {
|
|
|
- System.out.println("退款金额大于支付金额");
|
|
|
+ OrderSettlement orderSettlement = orderSettlementMapper.selectOne(new LambdaQueryWrapper<OrderSettlement>()
|
|
|
+ .eq(OrderSettlement::getOrderNumber, order.getOrderNumber())
|
|
|
+ .eq(OrderSettlement::getPayType, 1));
|
|
|
+ RefundInfoPo po = new RefundInfoPo();
|
|
|
+ po.setOutTradeNo(orderSettlement.getPayNo());
|
|
|
+ po.setTotal((int) Arith.mul(order.getActualTotal(), 100));
|
|
|
+ po.setRefundMoney(refundMoney);
|
|
|
+ if (refundMoney != 0) {
|
|
|
+ String s = wxProviderService.refundOrder(po);
|
|
|
+ System.out.println("微信退款结果:" + s);
|
|
|
}
|
|
|
- }else if (totalRefundScore==0){
|
|
|
- refundMoney =(int) Arith.mul(totalRefundActual, 100);
|
|
|
- }else {
|
|
|
- System.out.println("单笔退款未知状态");
|
|
|
- break;
|
|
|
- }
|
|
|
- OrderSettlement orderSettlement = orderSettlementMapper.selectOne(new LambdaQueryWrapper<OrderSettlement>()
|
|
|
- .eq(OrderSettlement::getOrderNumber, order.getOrderNumber())
|
|
|
- .eq(OrderSettlement::getPayType, 1));
|
|
|
- RefundInfoPo po = new RefundInfoPo();
|
|
|
- po.setOutTradeNo(orderSettlement.getPayNo());
|
|
|
- po.setTotal((int) Arith.mul(order.getActualTotal(), 100));
|
|
|
- po.setRefundMoney(refundMoney);
|
|
|
- if (refundMoney!=0){
|
|
|
- String s = wxProviderService.refundOrder(po);
|
|
|
- System.out.println("微信退款结果:" + s);
|
|
|
+ refundActual = BigDecimal.valueOf(refundMoney);
|
|
|
}
|
|
|
- refundActual = BigDecimal.valueOf(refundMoney);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- if (1 == orderRefund.getRefundType()) {
|
|
|
- order.setHbOrderStatus(OrderStatus.CLOSE.value());
|
|
|
- }else {
|
|
|
- List<OrderRefund> orderRefundList = orderRefundMapper.selectList(new LambdaQueryWrapper<OrderRefund>()
|
|
|
- .eq(OrderRefund::getOrderNumber, orderNumber)
|
|
|
- .eq(OrderRefund::getReturnMoneySts, 70)
|
|
|
- );
|
|
|
- //统计全部退货商品数量(goodsNum)
|
|
|
- int goodsNum = orderRefundList.stream().mapToInt(OrderRefund::getGoodsNum).sum();
|
|
|
- if (goodsNum == order.getProductNums()) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (1 == orderRefund.getRefundType()) {
|
|
|
order.setHbOrderStatus(OrderStatus.CLOSE.value());
|
|
|
+ } else {
|
|
|
+ List<OrderRefund> orderRefundList = orderRefundMapper.selectList(new LambdaQueryWrapper<OrderRefund>()
|
|
|
+ .eq(OrderRefund::getOrderNumber, orderNumber)
|
|
|
+ .eq(OrderRefund::getReturnMoneySts, 70)
|
|
|
+ );
|
|
|
+ //统计全部退货商品数量(goodsNum)
|
|
|
+ int goodsNum = orderRefundList.stream().mapToInt(OrderRefund::getGoodsNum).sum();
|
|
|
+ if (goodsNum == order.getProductNums()) {
|
|
|
+ order.setHbOrderStatus(OrderStatus.CLOSE.value());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- orderMapper.updateById(order);
|
|
|
+ orderMapper.updateById(order);
|
|
|
|
|
|
- orderRefund.setRefundAmount(refundActual.doubleValue());
|
|
|
- orderRefund.setOffsetPoints(refundScore);
|
|
|
- orderRefund.setHandler(Boolean.TRUE);
|
|
|
- orderRefund.setRefundExpiredScore(refundExpiredScore);
|
|
|
- log.info("退款单修改状态和积分{}",orderRefund);
|
|
|
- orderRefundMapper.updateById(orderRefund);
|
|
|
+ orderRefund.setRefundAmount(refundActual.doubleValue());
|
|
|
+ orderRefund.setOffsetPoints(refundScore);
|
|
|
+ orderRefund.setHandler(Boolean.TRUE);
|
|
|
+ orderRefund.setRefundExpiredScore(refundExpiredScore);
|
|
|
+ log.info("退款单修改状态和积分{}", orderRefund);
|
|
|
+ orderRefundMapper.updateById(orderRefund);
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|