|
@@ -296,9 +296,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
|
|
List<Long> dpSkuIds = payRequest.getDpSkuIds();
|
|
List<Long> dpSkuIds = payRequest.getDpSkuIds();
|
|
|
if (CollUtil.isNotEmpty(dpSkuIds)) {
|
|
if (CollUtil.isNotEmpty(dpSkuIds)) {
|
|
|
- if (dpSkuIds.size() > 1) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("暂只支持优惠加购一件商品");
|
|
|
|
|
- }
|
|
|
|
|
//是否满足关联
|
|
//是否满足关联
|
|
|
List<GoodsDiscountPlusPurchaseRelation> ds_relations = discountPlusPurchaseRelationMapper.selectList(Wrappers.lambdaQuery(GoodsDiscountPlusPurchaseRelation.class)
|
|
List<GoodsDiscountPlusPurchaseRelation> ds_relations = discountPlusPurchaseRelationMapper.selectList(Wrappers.lambdaQuery(GoodsDiscountPlusPurchaseRelation.class)
|
|
|
.eq(GoodsDiscountPlusPurchaseRelation::getSkuId, sku.getId())
|
|
.eq(GoodsDiscountPlusPurchaseRelation::getSkuId, sku.getId())
|
|
@@ -395,6 +392,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (Constant.realGoodsType.contains(goodsDon.getType()) && !goodsDon.getId().equals(27l)) {
|
|
if (Constant.realGoodsType.contains(goodsDon.getType()) && !goodsDon.getId().equals(27l)) {
|
|
|
saveTransport(payRequest.getAddressId(), orderDon.getId());
|
|
saveTransport(payRequest.getAddressId(), orderDon.getId());
|
|
|
}
|
|
}
|
|
|
|
|
+ //保存加购发货地址
|
|
|
|
|
+ if (orderDon.getIsDp() && payRequest.getAddressId() != null) {
|
|
|
|
|
+ redisService.set(RedisService.key.PLUS_GOODS_ADDRESS_KEY.getName() + orderDon.getId(), payRequest.getAddressId(), RedisService.key.PLUS_GOODS_ADDRESS_KEY.getTimeout());
|
|
|
|
|
+ }
|
|
|
if (orderDon.getStatus() == OrderDon.Status.noPayment) {
|
|
if (orderDon.getStatus() == OrderDon.Status.noPayment) {
|
|
|
jobManager.addJob(EXPIRY_TIME, () -> {
|
|
jobManager.addJob(EXPIRY_TIME, () -> {
|
|
|
closeOrder(orderDon.getId(), null);
|
|
closeOrder(orderDon.getId(), null);
|
|
@@ -608,11 +609,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- TASK_POOL.execute(()->{
|
|
|
|
|
|
|
+ TASK_POOL.execute(() -> {
|
|
|
try {
|
|
try {
|
|
|
orderDonPostService.postData((order.getId()));
|
|
orderDonPostService.postData((order.getId()));
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("回传错误 {}",StringUtil.getErrorText(e));
|
|
|
|
|
|
|
+ log.error("回传错误 {}", StringUtil.getErrorText(e));
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -959,11 +960,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- TASK_POOL.execute(()->{
|
|
|
|
|
|
|
+ TASK_POOL.execute(() -> {
|
|
|
try {
|
|
try {
|
|
|
orderDonPostService.postData((orderDon.getId()));
|
|
orderDonPostService.postData((orderDon.getId()));
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("回传错误 {}",StringUtil.getErrorText(e));
|
|
|
|
|
|
|
+ log.error("回传错误 {}", StringUtil.getErrorText(e));
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -997,15 +998,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (address == null) {
|
|
if (address == null) {
|
|
|
throw new BusinessRuntimeException("请添加收货地址.");
|
|
throw new BusinessRuntimeException("请添加收货地址.");
|
|
|
}
|
|
}
|
|
|
- OrderDonTransport transport = new OrderDonTransport();
|
|
|
|
|
- transport.setOrderId(orderId);
|
|
|
|
|
- transport.setReceiver(address.getReceiver());
|
|
|
|
|
- transport.setPhone(address.getPhone());
|
|
|
|
|
- transport.setProvince(address.getProvince());
|
|
|
|
|
- transport.setCity(address.getCity());
|
|
|
|
|
- transport.setDistrict(address.getDistrict());
|
|
|
|
|
- transport.setAddress(address.getAddress());
|
|
|
|
|
- orderDonTransportMapper.insert(transport);
|
|
|
|
|
|
|
+ saveTransportByAddress(address, orderId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1129,6 +1122,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0) {
|
|
if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
throw BusinessRuntimeException.getInstance("订单异常");
|
|
throw BusinessRuntimeException.getInstance("订单异常");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (orderDon.getStatus() != OrderDon.Status.noPayment) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单状态已修改");
|
|
|
|
|
+ }
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
@@ -1236,21 +1232,49 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
try {
|
|
try {
|
|
|
List<Long> plusSkuIds = Jsons.parseList(plusSkuIdsStr, Long.class);
|
|
List<Long> plusSkuIds = Jsons.parseList(plusSkuIdsStr, Long.class);
|
|
|
//发送优惠加购 规格车票
|
|
//发送优惠加购 规格车票
|
|
|
- List<Long> dis_relation_ids = new ArrayList<>();
|
|
|
|
|
- plusSkuIds.forEach(plus_skuId -> {
|
|
|
|
|
|
|
+ List<Long> dis_relation_ids = null;
|
|
|
|
|
+ List<Long> plus_order_ids = null;
|
|
|
|
|
+ Address address = null;
|
|
|
|
|
+ for (Long plus_skuId : plusSkuIds) {
|
|
|
GoodsDonSku plus_sku = goodsDonSkuMapper.selectById(plus_skuId);
|
|
GoodsDonSku plus_sku = goodsDonSkuMapper.selectById(plus_skuId);
|
|
|
if (plus_sku == null) {
|
|
if (plus_sku == null) {
|
|
|
log.error("订单id:{}优惠加购规格已被删除 skuId:{},车票未发送", order.getId(), plus_skuId);
|
|
log.error("订单id:{}优惠加购规格已被删除 skuId:{},车票未发送", order.getId(), plus_skuId);
|
|
|
- return;
|
|
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ GoodsDon plus_goods = goodsDonMapper.selectById(plus_sku.getGoodsId());
|
|
|
|
|
+ if (plus_goods.getType() != 1) {
|
|
|
|
|
+ log.info("orderId:{}存在非虚拟规格加购,添加{}发货信息", order.getId(), plus_goods.getTitle());
|
|
|
|
|
+ if (plus_order_ids == null) {
|
|
|
|
|
+ plus_order_ids = new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (address == null) {
|
|
|
|
|
+ Long addressId = Long.parseLong(redisService.getStr(RedisService.key.PLUS_GOODS_ADDRESS_KEY.getName() + order.getId()));
|
|
|
|
|
+ if (addressId == null) {
|
|
|
|
|
+ log.error("用户userId{}缓存的收货地址addressId:{}不存在", order.getUserId(), addressId);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ address = addressMapper.selectById(addressId);
|
|
|
|
|
+ if (address == null) {
|
|
|
|
|
+ log.error("用户userId{}收货地址addressId:{}已不存在", order.getUserId(), addressId);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //生成实物订单 0元实物订单
|
|
|
|
|
+ createRealOrderAndTransport(order.getUserId(), address, plus_goods, plus_sku, plus_order_ids);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dis_relation_ids == null) {
|
|
|
|
|
+ dis_relation_ids = new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
GroupsRelation relationNoOrder = exchangeCodeService.getRelationNoOrder(plus_sku, order.getUserId());
|
|
GroupsRelation relationNoOrder = exchangeCodeService.getRelationNoOrder(plus_sku, order.getUserId());
|
|
|
dis_relation_ids.add(relationNoOrder.getId());
|
|
dis_relation_ids.add(relationNoOrder.getId());
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ redisService.del(RedisService.key.PLUS_GOODS_ADDRESS_KEY.getName() + order.getId());
|
|
|
//保存订单关联优惠加购车票
|
|
//保存订单关联优惠加购车票
|
|
|
orderDiscountPlusPurchaseSkuRelationMapper.update(null, Wrappers.lambdaUpdate(OrderDiscountPlusPurchaseSkuRelation.class)
|
|
orderDiscountPlusPurchaseSkuRelationMapper.update(null, Wrappers.lambdaUpdate(OrderDiscountPlusPurchaseSkuRelation.class)
|
|
|
- .set(OrderDiscountPlusPurchaseSkuRelation::getRelationIds, dis_relation_ids.toString())
|
|
|
|
|
- .eq(OrderDiscountPlusPurchaseSkuRelation::getOrderId, order.getId())
|
|
|
|
|
- .isNull(OrderDiscountPlusPurchaseSkuRelation::getRelationIds));
|
|
|
|
|
|
|
+ .set(CollUtil.isNotEmpty(dis_relation_ids), OrderDiscountPlusPurchaseSkuRelation::getRelationIds, Jsons.toJson(dis_relation_ids))
|
|
|
|
|
+ .set(CollUtil.isNotEmpty(plus_order_ids), OrderDiscountPlusPurchaseSkuRelation::getPlusOrderIds, Jsons.toJson(plus_order_ids))
|
|
|
|
|
+ .eq(OrderDiscountPlusPurchaseSkuRelation::getOrderId, order.getId()));
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1957,14 +1981,14 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
relation = groupRelationFrontService.getSimilarExpiredGroupRelation(sku.getId(), sku.getDays(), sku.getMonths(), null);
|
|
relation = groupRelationFrontService.getSimilarExpiredGroupRelation(sku.getId(), sku.getDays(), sku.getMonths(), null);
|
|
|
if (relation == null) {
|
|
if (relation == null) {
|
|
|
//TODO 如果没指定座位,等待逻辑确认
|
|
//TODO 如果没指定座位,等待逻辑确认
|
|
|
- GroupsTrips groups = groupsMapper.selectOne( Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
|
|
|
|
+ GroupsTrips groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
.eq(GroupsTrips::getSkuId, sku.getId())
|
|
.eq(GroupsTrips::getSkuId, sku.getId())
|
|
|
.gt(GroupsTrips::getAvailableNum, 0).last("limit 1")
|
|
.gt(GroupsTrips::getAvailableNum, 0).last("limit 1")
|
|
|
.eq(GroupsTrips::getStatus, GroupsTrips.Status.validity)
|
|
.eq(GroupsTrips::getStatus, GroupsTrips.Status.validity)
|
|
|
.orderByAsc(GroupsTrips::getAvailableNum));
|
|
.orderByAsc(GroupsTrips::getAvailableNum));
|
|
|
//待发车
|
|
//待发车
|
|
|
if (groups == null) {
|
|
if (groups == null) {
|
|
|
- groups = groupsMapper.selectOne( Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
|
|
|
|
+ groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
.eq(GroupsTrips::getSkuId, sku.getId())
|
|
.eq(GroupsTrips::getSkuId, sku.getId())
|
|
|
.gt(GroupsTrips::getAvailableNum, 0).last("limit 1")
|
|
.gt(GroupsTrips::getAvailableNum, 0).last("limit 1")
|
|
|
.eq(GroupsTrips::getStatus, GroupsTrips.Status.waiting)
|
|
.eq(GroupsTrips::getStatus, GroupsTrips.Status.waiting)
|
|
@@ -2072,7 +2096,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void orderNotify(OrderDon orderDon){
|
|
|
|
|
|
|
+ public void orderNotify(OrderDon orderDon) {
|
|
|
Long goodsId = orderDon.getGoodsId();
|
|
Long goodsId = orderDon.getGoodsId();
|
|
|
if (orderDon.getIsNoLogin()) {
|
|
if (orderDon.getIsNoLogin()) {
|
|
|
orderDon.setExCode(exchangeCodeService.getExCode(goodsId, orderDon.getSkuId(), 1));
|
|
orderDon.setExCode(exchangeCodeService.getExCode(goodsId, orderDon.getSkuId(), 1));
|
|
@@ -2133,4 +2157,36 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 生成实物订单
|
|
|
|
|
+ */
|
|
|
|
|
+ public void createRealOrderAndTransport(Long userId, Address address, GoodsDon goodsDon, GoodsDonSku sku, List<Long> plusOrderIds) {
|
|
|
|
|
+ OrderDon orderDon = new OrderDon();
|
|
|
|
|
+ orderDon.setUserId(userId);
|
|
|
|
|
+ orderDon.setRelationId(0l);
|
|
|
|
|
+ orderDon.setMoney(BigDecimal.ZERO);
|
|
|
|
|
+ orderDon.setIsDp(true);
|
|
|
|
|
+ orderDon.setSkuId(sku.getId());
|
|
|
|
|
+ orderDon.setGoodsId(goodsDon.getId());
|
|
|
|
|
+ orderDon.setPayTitle(goodsDon.getTitle() + sku.getSpecVal());
|
|
|
|
|
+ orderDon.setStatus(OrderDon.Status.hasPayment);
|
|
|
|
|
+ orderDonMapper.insert(orderDon);
|
|
|
|
|
+ //处理收货地址
|
|
|
|
|
+ saveTransportByAddress(address, orderDon.getId());
|
|
|
|
|
+
|
|
|
|
|
+ plusOrderIds.add(orderDon.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void saveTransportByAddress(Address address,Long orderId) {
|
|
|
|
|
+ OrderDonTransport transport = new OrderDonTransport();
|
|
|
|
|
+ transport.setOrderId(orderId);
|
|
|
|
|
+ transport.setReceiver(address.getReceiver());
|
|
|
|
|
+ transport.setPhone(address.getPhone());
|
|
|
|
|
+ transport.setProvince(address.getProvince());
|
|
|
|
|
+ transport.setCity(address.getCity());
|
|
|
|
|
+ transport.setDistrict(address.getDistrict());
|
|
|
|
|
+ transport.setAddress(address.getAddress());
|
|
|
|
|
+ orderDonTransportMapper.insert(transport);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|