Browse Source

修改订单状态,组合码计算

yuhongqi 2 days ago
parent
commit
14a385a895

+ 4 - 0
fs-service-system/src/main/java/com/fs/live/domain/LiveUserLotteryRecord.java

@@ -35,5 +35,9 @@ public class LiveUserLotteryRecord extends BaseEntity{
     @Excel(name = "商品ID")
     private Long productId;
 
+    /** 商品ID */
+    @Excel(name = "订单ID")
+    private Long orderId;
+
 
 }

+ 1 - 0
fs-service-system/src/main/java/com/fs/live/dto/LiveOrderItemDTO.java

@@ -13,6 +13,7 @@ public class LiveOrderItemDTO implements Serializable {
     private String sku;
 
     private String barCode;
+    private String groupBarCode;
 
     String productName;
 

+ 41 - 8
fs-service-system/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -18,6 +18,7 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 
@@ -56,6 +57,8 @@ import com.fs.live.vo.LiveOrderItemVo;
 import com.fs.live.vo.LiveOrderListVo;
 import com.fs.live.vo.LiveOrderVo;
 import com.fs.store.cache.IFsExpressCacheService;
+import com.fs.store.cache.IFsStoreProductAttrValueCacheService;
+import com.fs.store.cache.impl.IFsStoreProductCacheServiceImpl;
 import com.fs.store.domain.*;
 import com.fs.store.dto.*;
 import com.fs.store.enums.*;
@@ -175,6 +178,15 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 
     @Autowired
     private LiveOrderPaymentErrorMapper liveOrderPaymentErrorMapper;
+    @Autowired
+    private IFsStoreProductGroupService storeProductGroupService;
+
+    @Autowired
+    private IFsStoreProductAttrValueCacheService fsStoreProductAttrValueCacheService;
+
+
+    @Autowired
+    private IFsStoreProductCacheServiceImpl fsStoreProductCacheService;
 
 
     @Autowired
@@ -1295,7 +1307,28 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             FsStoreCartDTO cartDTO= JSONUtil.toBean(orderItem.getJsonInfo(),FsStoreCartDTO.class);
             //如果是组合码,查询出真实的商品数据 然后写入
             if(StringUtils.isNotEmpty(cartDTO.getGroupBarCode())){
-
+                FsStoreProductGroup group=storeProductGroupService.selectFsStoreProductGroupByBarCode(cartDTO.getGroupBarCode().trim());
+                if(group!=null){
+                    JSONArray jsonArray=JSONUtil.parseArray(group.getProducts());
+                    List<StoreProductGroupDTO> productGroupDTOS=JSONUtil.toList(jsonArray, StoreProductGroupDTO.class);
+                    if(productGroupDTOS!=null){
+                        for(StoreProductGroupDTO dto:productGroupDTOS){
+                            FsStoreProductAttrValue attrValue=fsStoreProductAttrValueCacheService.selectFsStoreProductAttrValueById(dto.getId());
+
+                            ErpOrderItem item=new ErpOrderItem();
+                            item.setItem_code(attrValue.getBarCode());
+                            item.setPrice(attrValue.getPrice().toString());
+                            item.setQty(dto.getCount()*cartDTO.getNum());
+                            item.setRefund(0);
+                            // 查询仓库代码
+                            String warehouseCode = fsStoreProductCacheService.getWarehouseCodeByProductId(attrValue.getProductId());
+                            if(StringUtils.isNotBlank(warehouseCode)){
+                                item.setWarehouseCode(warehouseCode);
+                            }
+                            details.add(item);
+                        }
+                    }
+                }
             }
             else{
                 ErpOrderItem item=new ErpOrderItem();
@@ -2217,14 +2250,13 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 LiveOrderItemDTO dto=new LiveOrderItemDTO();
                 dto.setImage(fsStoreProduct.getImage());
                 dto.setSku(String.valueOf(fsStoreProduct.getStock()));
-                if (StringUtils.isEmpty(fsStoreProduct.getBarCode())) {
-                    FsStoreProductAttrValue fsStoreProductAttrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProduct.getProductId()).stream().filter(attrValue -> StringUtils.isNotEmpty(attrValue.getBarCode())).findFirst().orElse(null);
-                    if (fsStoreProductAttrValue != null) {
-                        dto.setBarCode(fsStoreProductAttrValue.getBarCode());
-                    }
-                } else {
-                    dto.setBarCode(fsStoreProduct.getBarCode());
+
+                FsStoreProductAttrValue fsStoreProductAttrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProduct.getProductId()).stream().filter(attrValue -> StringUtils.isNotEmpty(attrValue.getBarCode())).findFirst().orElse(null);
+                if (fsStoreProductAttrValue != null) {
+                    dto.setBarCode(fsStoreProductAttrValue.getBarCode());
+                    dto.setGroupBarCode(fsStoreProductAttrValue.getGroupBarCode());
                 }
+
                 dto.setPrice(fsStoreProduct.getPrice());
                 dto.setProductName(fsStoreProduct.getProductName());
                 dto.setNum(Long.valueOf(liveOrder.getTotalNum()));
@@ -2427,6 +2459,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                     FsStoreProductAttrValue fsStoreProductAttrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProduct.getProductId()).stream().filter(attrValue -> StringUtils.isNotEmpty(attrValue.getBarCode())).findFirst().orElse(null);
                     if (fsStoreProductAttrValue != null) {
                         dto.setBarCode(fsStoreProductAttrValue.getBarCode());
+                        dto.setGroupBarCode(fsStoreProductAttrValue.getGroupBarCode());
                     }
                 } else {
                     dto.setBarCode(fsStoreProduct.getBarCode());

+ 11 - 1
fs-service-system/src/main/resources/mapper/live/LiveUserLotteryRecordMapper.xml

@@ -14,10 +14,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"    column="update_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateBy"    column="update_by"    />
+        <result property="orderId"    column="order_id"    />
+        <result property="orderStatus"    column="order_status"    />
     </resultMap>
 
     <sql id="selectLiveUserLotteryRecordVo">
-        select id, lottery_id, live_id, user_id, product_id, create_time, update_time, create_by, update_by from live_user_lottery_record
+        select id, lottery_id, live_id, user_id, product_id, create_time, update_time, create_by, update_by,order_id,order_status from live_user_lottery_record
     </sql>
 
     <select id="selectLiveUserLotteryRecordList" parameterType="LiveUserLotteryRecord" resultMap="LiveUserLotteryRecordResult">
@@ -27,6 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null "> and user_id = #{userId}</if>
             <if test="productId != null "> and product_id = #{productId}</if>
             <if test="createTime != null "> and create_time = #{createTime}</if>
+            <if test="orderId != null "> and order_id = #{orderId}</if>
+            <if test="orderStatus != null "> and order_status = #{orderStatus}</if>
         </where>
     </select>
 
@@ -52,6 +56,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
+            <if test="orderId != null">order_id,</if>
+            <if test="orderStatus != null">order_status,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="lotteryId != null">#{lotteryId},</if>
@@ -62,6 +68,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">#{updateTime},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="updateBy != null">#{updateBy},</if>
+            <if test="orderId != null">#{orderId},</if>
+            <if test="orderStatus != null">#{orderStatus},</if>
          </trim>
     </insert>
 
@@ -76,6 +84,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="orderId != null">order_id = #{orderId},</if>
+            <if test="orderStatus != null">order_status = #{orderStatus},</if>
         </trim>
         where id = #{id}
     </update>