|
@@ -1,7 +1,9 @@
|
|
|
package cn.rankin.task.task.order;
|
|
|
|
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
|
+import cn.rankin.common.utils.constant.Constant;
|
|
|
import cn.rankin.common.utils.enums.BaseStatusEnum;
|
|
|
+import cn.rankin.common.utils.enums.OrderDetailTypeEnum;
|
|
|
import cn.rankin.common.utils.enums.ProductTypeEnum;
|
|
|
import cn.rankin.data.api.product.entity.Goods;
|
|
|
import cn.rankin.data.api.product.entity.Package;
|
|
@@ -40,7 +42,7 @@ public class OrderSplitTask {
|
|
|
@Scheduled(fixedDelay = ONE_MINUTE)
|
|
|
public void run() {
|
|
|
// 查询订单
|
|
|
- List<Order> orderList = orderService.findSplitList(SIZE);
|
|
|
+ List<Order> orderList = orderService.findOrderSplitList(SIZE);
|
|
|
if (CollectionUtils.isEmpty(orderList)) {
|
|
|
log.info("不存在需要处理的订单");
|
|
|
return;
|
|
@@ -55,6 +57,7 @@ public class OrderSplitTask {
|
|
|
continue;
|
|
|
}
|
|
|
log.info("start split order, orderId={}", orderId);
|
|
|
+ // 开始保存数据库了啊,更改状态,保存分拆的订单
|
|
|
Boolean result = orderService.split(orderId, orderDetailList);
|
|
|
if (result) {
|
|
|
log.info("split order success, orderId={}", orderId);
|
|
@@ -65,8 +68,6 @@ public class OrderSplitTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 开始早错数据库了啊,更改状态,保存分拆的订单
|
|
|
-
|
|
|
// 将一个订单分拆处理成多个
|
|
|
public List<OrderDetail> splitOrder(Order order) {
|
|
|
// 将一个订单的虚拟商品拆成一个单,其他类型商品(周边)按厂商分拆到多个单
|
|
@@ -141,19 +142,35 @@ public class OrderSplitTask {
|
|
|
for (String cpId : orderDetailCpIdMap.keySet()) {
|
|
|
OrderDetail orderDetail = orderDetailCpIdMap.get(cpId);
|
|
|
if (orderDetail != null) {
|
|
|
+ orderDetail.setType(OrderDetailTypeEnum.ENTITY);
|
|
|
orderDetail.setCpId(cpId);
|
|
|
List<OrderGoods> orderGoodsList = orderDetail.getGoods();
|
|
|
+ BigDecimal price = BigDecimal.ZERO;
|
|
|
if (!CollectionUtils.isEmpty(orderGoodsList)) {
|
|
|
for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
Goods goods = goodsMap.get(orderGoods.getGoodsId());
|
|
|
- orderDetail.setOriginPrice(orderDetail.getOriginPrice().add(goods.getMerchantPrice()));
|
|
|
+ log.info("price={}, good_price={}", price, goods.getMerchantPrice());
|
|
|
+ price = price.add(goods.getMerchantPrice());
|
|
|
}
|
|
|
}
|
|
|
+ orderDetail.setOriginPrice(price);
|
|
|
orderDetailList.add(orderDetail);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (virtualOrder != null) {
|
|
|
+ virtualOrder.setCpId(Constant.PLAT_MERCHANT_ID);
|
|
|
+ virtualOrder.setType(OrderDetailTypeEnum.VIRTUAL);
|
|
|
+ BigDecimal price = BigDecimal.ZERO;
|
|
|
+ List<OrderGoods> orderGoodsList = virtualOrder.getGoods();
|
|
|
+ if (!CollectionUtils.isEmpty(orderGoodsList)) {
|
|
|
+ for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
+ Goods goods = goodsMap.get(orderGoods.getGoodsId());
|
|
|
+ log.info("price={}, good_price={}", price, goods.getMerchantPrice());
|
|
|
+ price = price.add(goods.getMerchantPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ virtualOrder.setOriginPrice(price);
|
|
|
orderDetailList.add(virtualOrder);
|
|
|
}
|
|
|
|