|
@@ -70,6 +70,7 @@ import com.cyksj.service.exchange.ExchangeCodeService;
|
|
|
import com.cyksj.service.mange.stock.GoodsDonStockService;
|
|
import com.cyksj.service.mange.stock.GoodsDonStockService;
|
|
|
import com.cyksj.service.market.MarketFrontService;
|
|
import com.cyksj.service.market.MarketFrontService;
|
|
|
import com.cyksj.service.market.task.TaskService;
|
|
import com.cyksj.service.market.task.TaskService;
|
|
|
|
|
+import com.cyksj.service.order.OrderCommonService;
|
|
|
import com.cyksj.service.order.OrderDonService;
|
|
import com.cyksj.service.order.OrderDonService;
|
|
|
import com.cyksj.service.order.UserRealOrderBenefitsService;
|
|
import com.cyksj.service.order.UserRealOrderBenefitsService;
|
|
|
import com.cyksj.service.relation.GroupRelationClearService;
|
|
import com.cyksj.service.relation.GroupRelationClearService;
|
|
@@ -203,6 +204,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
|
|
private final UserBindDetailMapper userBindDetailMapper;
|
|
private final UserBindDetailMapper userBindDetailMapper;
|
|
|
|
|
|
|
|
|
|
+ private final OrderCommonService orderCommonService;
|
|
|
|
|
+
|
|
|
private final List<String> noChekGoodsTemp = List.of("Apple One", "Youtube", "Spotify");
|
|
private final List<String> noChekGoodsTemp = List.of("Apple One", "Youtube", "Spotify");
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
@@ -619,7 +622,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
groupsRelation.setUserId(0L);
|
|
groupsRelation.setUserId(0L);
|
|
|
groupsRelation.setStatus(GroupsRelation.Status.none);
|
|
groupsRelation.setStatus(GroupsRelation.Status.none);
|
|
|
groupsRelationMapper.updateById(groupsRelation);
|
|
groupsRelationMapper.updateById(groupsRelation);
|
|
|
- delRelation(groupsRelation.getId());
|
|
|
|
|
|
|
+ orderCommonService.delRelation(groupsRelation.getId());
|
|
|
|
|
|
|
|
//车位空余发送模板消息
|
|
//车位空余发送模板消息
|
|
|
// TASK_POOL.execute(() -> {
|
|
// TASK_POOL.execute(() -> {
|
|
@@ -961,20 +964,24 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (orderDon.getIsDistribute()) {
|
|
if (orderDon.getIsDistribute()) {
|
|
|
distributeWaitingSendPointsMapper.updateOrderStatus(orderDon.getId(), DistributeWaitingSendPoints.Status.close);
|
|
distributeWaitingSendPointsMapper.updateOrderStatus(orderDon.getId(), DistributeWaitingSendPoints.Status.close);
|
|
|
}
|
|
}
|
|
|
- orderDonMapper.updateById(orderDon);
|
|
|
|
|
//记录退款信息
|
|
//记录退款信息
|
|
|
final String outNo = outRefundNo;
|
|
final String outNo = outRefundNo;
|
|
|
THREAD_POOL_TASK_EXECUTOR.execute(()->{
|
|
THREAD_POOL_TASK_EXECUTOR.execute(()->{
|
|
|
refundRecord(orderDon, goodsDon, sku, outNo);
|
|
refundRecord(orderDon, goodsDon, sku, outNo);
|
|
|
goodsDonStockService.upStockRelate(null, orderDon.getId(),"refund");
|
|
goodsDonStockService.upStockRelate(null, orderDon.getId(),"refund");
|
|
|
});
|
|
});
|
|
|
- //虚物订单退款,清出车队,车票变为已过期
|
|
|
|
|
- clearUnrealGoodsDetail(orderDon, goodsDon, sku);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ //虚物订单退款,清出车队,车票变为已过期
|
|
|
|
|
+ orderCommonService.clearUnrealGoodsDetail(orderDon, goodsDon.getType(), sku.getMonths());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("清除车票错误:{}", StringUtil.getErrorText(e));
|
|
|
|
|
+ }
|
|
|
//若存在优惠券使用,退还优惠券
|
|
//若存在优惠券使用,退还优惠券
|
|
|
if (orderDon.getCouponUserId() != 0) {
|
|
if (orderDon.getCouponUserId() != 0) {
|
|
|
redisService.set(String.format("%s-%s", orderDon.getId(), orderDon.getCouponUserId()), orderDon.getId(), 120l);
|
|
redisService.set(String.format("%s-%s", orderDon.getId(), orderDon.getCouponUserId()), orderDon.getId(), 120l);
|
|
|
updateOrderDonCouponStatus(orderDon);
|
|
updateOrderDonCouponStatus(orderDon);
|
|
|
}
|
|
}
|
|
|
|
|
+ orderDonMapper.updateById(orderDon);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("退款成功");
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("退款成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1041,7 +1048,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (orderDon.getIsDistribute()) {
|
|
if (orderDon.getIsDistribute()) {
|
|
|
distributeWaitingSendPointsMapper.updateOrderStatus(orderDon.getId(), DistributeWaitingSendPoints.Status.close);
|
|
distributeWaitingSendPointsMapper.updateOrderStatus(orderDon.getId(), DistributeWaitingSendPoints.Status.close);
|
|
|
}
|
|
}
|
|
|
- orderDonMapper.updateById(orderDon);
|
|
|
|
|
//记录退款信息
|
|
//记录退款信息
|
|
|
THREAD_POOL_TASK_EXECUTOR.execute(()->{
|
|
THREAD_POOL_TASK_EXECUTOR.execute(()->{
|
|
|
refundRecord(orderDon, goodsDon, sku, outNo);
|
|
refundRecord(orderDon, goodsDon, sku, outNo);
|
|
@@ -1057,100 +1063,22 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
log.error("zfb减少抽奖机会错误,orderId:{},error:{}", orderDon.getId(), e);
|
|
log.error("zfb减少抽奖机会错误,orderId:{},error:{}", orderDon.getId(), e);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- //虚物订单退款,清出车队,车票变为已过期
|
|
|
|
|
- clearUnrealGoodsDetail(orderDon, goodsDon, sku);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ //虚物订单退款,清出车队,车票变为已过期
|
|
|
|
|
+ orderCommonService.clearUnrealGoodsDetail(orderDon, goodsDon.getType(), sku.getMonths());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("清除车票错误:{}", StringUtil.getErrorText(e));
|
|
|
|
|
+ }
|
|
|
if (orderDon.getCouponUserId() != 0) {
|
|
if (orderDon.getCouponUserId() != 0) {
|
|
|
//zfb订单退款,返还优惠券
|
|
//zfb订单退款,返还优惠券
|
|
|
updateOrderDonCouponStatus(orderDon);
|
|
updateOrderDonCouponStatus(orderDon);
|
|
|
}
|
|
}
|
|
|
|
|
+ orderDonMapper.updateById(orderDon);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("退款成功");
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("退款成功");
|
|
|
}
|
|
}
|
|
|
throw BusinessRuntimeException.getInstance("退款失败,e:{0}", response.getBody());
|
|
throw BusinessRuntimeException.getInstance("退款失败,e:{0}", response.getBody());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 虚物订单退款,清出车队,车票变成已过期
|
|
|
|
|
- * @param orderDon
|
|
|
|
|
- * @param goodsDon
|
|
|
|
|
- */
|
|
|
|
|
- private void clearUnrealGoodsDetail(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku) {
|
|
|
|
|
- if (goodsDon != null && goodsDon.getType() == 1) {
|
|
|
|
|
- //清出车队,车位变为已过期
|
|
|
|
|
- Long relationId = orderDon.getRelationId();
|
|
|
|
|
- //更换车票前后的座位id集合
|
|
|
|
|
- List<Long> relationIds = new ArrayList<>();
|
|
|
|
|
- relationIds.add(relationId);
|
|
|
|
|
- Integer months = sku.getMonths();
|
|
|
|
|
- Integer num = orderDon.getNum();
|
|
|
|
|
- DateTime now = DateTime.now();
|
|
|
|
|
- GroupsRelation relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
|
|
- .eq(GroupsRelation::getUserId, orderDon.getUserId())
|
|
|
|
|
- .eq(GroupsRelation::getId, relationId)
|
|
|
|
|
- .eq(GroupsRelation::getStatus, GroupsRelation.Status.validity));
|
|
|
|
|
- //车票变更之后
|
|
|
|
|
- if (relation == null || orderDon.getIsChangeTicket()) {
|
|
|
|
|
- UserRenewChangeTicketRecord record = userRenewChangeTicketRecordMapper.selectOne(Wrappers.lambdaQuery(UserRenewChangeTicketRecord.class)
|
|
|
|
|
- .eq(UserRenewChangeTicketRecord::getUserId, orderDon.getUserId())
|
|
|
|
|
- .eq(UserRenewChangeTicketRecord::getPreRelationId, relationId)
|
|
|
|
|
- .orderByDesc(UserRenewChangeTicketRecord::getId).last("limit 1"));
|
|
|
|
|
- if (record != null && relationId.equals(record.getPreRelationId())) {
|
|
|
|
|
- relation = groupsRelationMapper.selectById(record.getAfterRelationId());
|
|
|
|
|
- Optional.ofNullable(relation).ifPresent((re) -> relationIds.add(re.getId()));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (relation != null) {
|
|
|
|
|
- Boolean isFlag = true;
|
|
|
|
|
- Date expiryTime = relation.getExpiryTime();
|
|
|
|
|
- if (orderDon.getOrderType() == 2 || relationIds.size() > 1) {
|
|
|
|
|
- //是否有其他付款订单是否过期
|
|
|
|
|
- OrderDon otherOrder = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
- .in(OrderDon::getRelationId, relationIds)
|
|
|
|
|
- .eq(OrderDon::getUserId, orderDon.getUserId())
|
|
|
|
|
- .ne(OrderDon::getId, orderDon.getId())
|
|
|
|
|
- .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
|
|
- .orderByDesc(OrderDon::getId)
|
|
|
|
|
- .last("limit 1"));
|
|
|
|
|
- if (otherOrder != null) {
|
|
|
|
|
- Long otherSkuId = otherOrder.getSkuId();
|
|
|
|
|
- GoodsDonSku otherGoodsSku = goodsDonSkuMapper.selectById(otherSkuId);
|
|
|
|
|
- DateTime endTime = DateUtil.offsetMonth(otherOrder.getCreatedTime(), otherGoodsSku.getMonths() * num);
|
|
|
|
|
- if (now.isBefore(endTime)) {
|
|
|
|
|
- isFlag = false;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- //续费更换后的座位 过期时间
|
|
|
|
|
- if (expiryTime != null) {
|
|
|
|
|
- DateTime refundExpiryTime = DateUtil.offsetMonth(expiryTime, -sku.getMonths() * num);
|
|
|
|
|
- if (now.isBefore(refundExpiryTime)) {
|
|
|
|
|
- isFlag = false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (isFlag) {
|
|
|
|
|
- relation.setUserId(0l);
|
|
|
|
|
- relation.setStatus(GroupsRelation.Status.none);
|
|
|
|
|
- if (expiryTime != null) {
|
|
|
|
|
- relation.setStartTime(null);
|
|
|
|
|
- relation.setExpiryTime(null);
|
|
|
|
|
- relation.setIsHandle(false);
|
|
|
|
|
- relation.setRenewStatus(false);
|
|
|
|
|
- relation.setAccount(null);
|
|
|
|
|
- groupsRelationMapper.updateExpiryTime(relation, expiryTime);
|
|
|
|
|
- } else {
|
|
|
|
|
- groupsRelationMapper.updateById(relation);
|
|
|
|
|
- }
|
|
|
|
|
- delRelation(relation.getId());
|
|
|
|
|
- } else {
|
|
|
|
|
- if (expiryTime != null) {
|
|
|
|
|
- relation.setExpiryTime(DateUtil.offsetMonth(expiryTime, -months * num));
|
|
|
|
|
- groupsRelationMapper.updateById(relation);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 校验订单是否符合退款操作
|
|
* 校验订单是否符合退款操作
|
|
|
* @param orderDon
|
|
* @param orderDon
|
|
@@ -1320,16 +1248,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void delRelation(Long relationId) {
|
|
|
|
|
- redisService.del(RedisKey.GROUPS_RELATION_NUM_KEY + relationId);
|
|
|
|
|
- GroupsRelation relation = groupsRelationMapper.selectById(relationId);
|
|
|
|
|
- int count = groupsMapper.incrAvailableNum(relation.getGroupsId());
|
|
|
|
|
- if (count == 0) {
|
|
|
|
|
- log.error("车位异常 groupId:{}", relation.getGroupsId());
|
|
|
|
|
- throw new BusinessRuntimeException("车位异常");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void saveTransport(Long addressId, Long orderId) {
|
|
public void saveTransport(Long addressId, Long orderId) {
|
|
|
if (addressId == null) {
|
|
if (addressId == null) {
|