|
|
@@ -392,6 +392,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (Constant.realGoodsType.contains(goodsDon.getType()) && !goodsDon.getId().equals(27l)) {
|
|
|
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) {
|
|
|
jobManager.addJob(EXPIRY_TIME, () -> {
|
|
|
closeOrder(orderDon.getId(), null);
|
|
|
@@ -994,15 +998,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (address == null) {
|
|
|
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
|
|
|
@@ -1235,12 +1231,12 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
//发送优惠加购 规格车票
|
|
|
List<Long> dis_relation_ids = null;
|
|
|
List<Long> plus_order_ids = null;
|
|
|
- OrderDonTransport orderDonTransport = null;
|
|
|
+ Address address = null;
|
|
|
for (Long plus_skuId : plusSkuIds) {
|
|
|
GoodsDonSku plus_sku = goodsDonSkuMapper.selectById(plus_skuId);
|
|
|
if (plus_sku == null) {
|
|
|
log.error("订单id:{}优惠加购规格已被删除 skuId:{},车票未发送", order.getId(), plus_skuId);
|
|
|
- return;
|
|
|
+ continue;
|
|
|
}
|
|
|
GoodsDon plus_goods = goodsDonMapper.selectById(plus_sku.getGoodsId());
|
|
|
if (plus_goods.getType() != 1) {
|
|
|
@@ -1248,19 +1244,28 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (plus_order_ids == null) {
|
|
|
plus_order_ids = new ArrayList<>();
|
|
|
}
|
|
|
- if (orderDonTransport == null) {
|
|
|
- orderDonTransport = transportMapper.selectOne(Wrappers.lambdaQuery(OrderDonTransport.class)
|
|
|
- .eq(OrderDonTransport::getOrderId, order.getId()).last("limit 1"));
|
|
|
+ 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(), orderDonTransport, plus_goods, plus_sku, plus_order_ids);
|
|
|
- return;
|
|
|
+ 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());
|
|
|
dis_relation_ids.add(relationNoOrder.getId());
|
|
|
+ redisService.del(RedisService.key.PLUS_GOODS_ADDRESS_KEY.getName() + order.getId());
|
|
|
}
|
|
|
//保存订单关联优惠加购车票
|
|
|
orderDiscountPlusPurchaseSkuRelationMapper.update(null, Wrappers.lambdaUpdate(OrderDiscountPlusPurchaseSkuRelation.class)
|
|
|
@@ -2154,7 +2159,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
/**
|
|
|
* 生成实物订单
|
|
|
*/
|
|
|
- public void createRealOrderAndTransport(Long userId, OrderDonTransport transport, GoodsDon goodsDon, GoodsDonSku sku, List<Long> plusOrderIds) {
|
|
|
+ public void createRealOrderAndTransport(Long userId, Address address, GoodsDon goodsDon, GoodsDonSku sku, List<Long> plusOrderIds) {
|
|
|
OrderDon orderDon = new OrderDon();
|
|
|
orderDon.setUserId(userId);
|
|
|
orderDon.setRelationId(0l);
|
|
|
@@ -2166,9 +2171,20 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setStatus(OrderDon.Status.hasPayment);
|
|
|
orderDonMapper.insert(orderDon);
|
|
|
//处理收货地址
|
|
|
- transport.setOrderId(orderDon.getId());
|
|
|
- transportMapper.insert(transport);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|