feat: 小程序订单过期返还券
This commit is contained in:
parent
ab78aa6ac8
commit
7995746c5d
|
|
@ -450,6 +450,25 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
keys.add(CacheKey.PRODUCT_SKU + detail.getShopId() + ":" + detail.getId());
|
||||
}
|
||||
|
||||
// 查询是否消耗了积分优惠券返还对应的卷或商品
|
||||
if (tbOrderInfo.getCouponInfoList() != null) {
|
||||
OrderCouponInfoDTO couponInfoDTO = JSONObject.parseObject(tbOrderInfo.getCouponInfoList(), OrderCouponInfoDTO.class);
|
||||
// 券返还
|
||||
if (!couponInfoDTO.getOutRecordList().isEmpty()) {
|
||||
couponInfoDTO.getOutRecordList().forEach(item -> {
|
||||
item.setRefNum(item.getUseNum());
|
||||
});
|
||||
shopCouponService.refund(couponInfoDTO.getOutRecordList());
|
||||
couponInfoDTO.setOutRecordList(new ArrayList<>());
|
||||
tbOrderInfo.setCouponInfoList(null);
|
||||
}
|
||||
}
|
||||
|
||||
// 返还积分
|
||||
if (tbOrderInfo.getPointsNum() != null && tbOrderInfo.getPointsNum() != 0 && tbOrderInfo.getMemberId() != null) {
|
||||
memberPointsService.addPoints(Long.valueOf(tbOrderInfo.getMemberId()), tbOrderInfo.getPointsNum(), "订单取消返还: " + tbOrderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId()));
|
||||
}
|
||||
|
||||
mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, tbOrderInfo.getId());
|
||||
String[] keysArray = keys.toArray(new String[keys.size()]);
|
||||
redisUtils.del(keysArray);
|
||||
|
|
@ -653,7 +672,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
return;
|
||||
}
|
||||
TbOrderInfo returnOrder = orderInfoMapper.selectOne(new LambdaQueryWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getStatus, "refunding")
|
||||
.eq(TbOrderInfo::getStatus, "refunding")
|
||||
.eq(TbOrderInfo::getSource, orderInfo.getId()));
|
||||
if (returnOrder == null) {
|
||||
log.warn("订单信息不存在: {}", payOrderId);
|
||||
|
|
@ -705,7 +724,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
.set(TbOrderInfo::getPointsNum, 0)
|
||||
.set(TbOrderInfo::getUpdatedAt, cn.hutool.core.date.DateUtil.current())
|
||||
.set(TbOrderInfo::getStatus, "cancelled"));
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.error("取消订单失败: 订单信息: {}", orderInfo);
|
||||
log.error("异常信息: ", e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue