Browse Source

修改中奖信息订单状态

yuhongqi 1 day ago
parent
commit
1875a3b618

+ 2 - 0
fs-live-socket/src/main/java/com/fs/live/task/Task.java

@@ -294,6 +294,7 @@ public class Task {
                     record.setUserId(winningUser.getUserId());
                     record.setProductId(liveLotteryProductListVo.getProductId());
                     record.setCreateTime(new Date());
+                    record.setOrderStatus(-9);
 
                     // 保存中奖记录
                     liveUserLotteryRecordService.insertLiveUserLotteryRecord(record);
@@ -313,6 +314,7 @@ public class Task {
                     lotteryVo.setPrizeLevel(liveLotteryProductListVo.getPrizeLevel());
                     lotteryVo.setProductName(liveLotteryProductListVo.getProductName());
                     lotteryVo.setProductId(liveLotteryProductListVo.getProductId());
+                    lotteryVo.setRecordId(record.getId());
                     lotteryVos.add(lotteryVo);
                 }
             }

+ 1 - 0
fs-live-socket/src/main/java/com/fs/live/vo/LotteryVo.java

@@ -14,5 +14,6 @@ public class LotteryVo {
     private String productName;
     private Long prizeLevel;
     private Long productId;
+    private Long recordId;
 
 }

+ 1 - 0
fs-service-system/src/main/java/com/fs/live/domain/LiveOrder.java

@@ -327,6 +327,7 @@ public class LiveOrder extends BaseEntity {
 
     private Long customerId;
     private Long couponUserId;
+    private Long recordId;
 
 
 }

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

@@ -39,5 +39,9 @@ public class LiveUserLotteryRecord extends BaseEntity{
     @Excel(name = "订单ID")
     private Long orderId;
 
+    @Excel(name = "订单状态")
+    /** 订单状态(-1 : 申请退款 -2 : 退货成功 0:已取消 1:待支付 2:待发货;3:待收货;4:待评价;5:已完成;-9 中奖未填写地址) */
+    private Integer orderStatus;
+
 
 }

+ 4 - 1
fs-service-system/src/main/java/com/fs/live/mapper/LiveUserLotteryRecordMapper.java

@@ -71,6 +71,9 @@ public interface LiveUserLotteryRecordMapper {
             "        from live_user_lottery_record lulr left join fs_user fu on lulr.user_id = fu.user_id\n" +
             "        " +
             "        left join fs_store_product fsp on lulr.product_id = fsp.product_id\n" +
-            "        where lulr.user_id = #{userId} order by lulr.created_time desc")
+            "        where lulr.user_id = #{userId} order by lulr.create_time desc")
     List<LiveUserLotteryRecordVo> selectLiveUserLotteryRecordByUserId(@Param("userId") long userId);
+
+    @Select("update live_user_lottery_record set order_status = #{status} where order_id = #{orderId}")
+    void updateOrderStatusByOrderId(@Param("orderId") Long orderId,@Param("status") int status);
 }

+ 23 - 9
fs-service-system/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -134,6 +134,9 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     @Autowired
     private FsStoreProductAttrValueMapper fsStoreProductAttrValueMapper;
 
+    @Autowired
+    private LiveUserLotteryRecordMapper liveUserLotteryRecordMapper;
+
     @Autowired
     ICompanyUserService companyUserService;
 
@@ -948,6 +951,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         order.setStatus(-2);
         order.setRefundMoney(order.getPayMoney());
         order.setRefundStatus(String.valueOf(OrderInfoEnum.REFUND_STATUS_2.getValue()));
+        liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), -2);
         baseMapper.updateLiveOrder(order);
 
         //退库存
@@ -1007,6 +1011,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         order.setStatus(-2);
         order.setRefundMoney(order.getPayMoney());
         order.setRefundStatus(String.valueOf(OrderInfoEnum.REFUND_STATUS_2.getValue()));
+        liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), -2);
         baseMapper.updateLiveOrder(order);
 
         //退库存
@@ -1484,7 +1489,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             order.setDeliveryName(deliverName);
             order.setDeliverySn(deliveryId);
             order.setDeliveryCode(express.getCode());
-
+            liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), 3);
             baseMapper.updateLiveOrder(order);
             if(ObjectUtil.isNotNull(express)) {
                 FsStoreDelivers fsStoreDeliver = new FsStoreDelivers();
@@ -1667,6 +1672,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                             map.setStatus(OrderInfoEnum.STATUS_2.getValue());
                             map.setOrderId(order.getOrderId());
                             map.setDeliverySn(response.getOrders().get(0).getDeliverys().get(0).getMail_no());
+                            liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), 2);
                             liveOrderMapper.updateLiveOrder(map);
                             liveOrderLogsService.create(order.getOrderId(), OrderLogEnum.DELIVERY_GOODS.getValue(),
                                     OrderLogEnum.DELIVERY_GOODS.getDesc());
@@ -1899,6 +1905,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         if(order.getStatus()==OrderInfoEnum.STATUS_3.getValue()){
             order.setFinishTime(new Date());
             order.setStatus(4);
+            liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), 4);
             baseMapper.updateLiveOrder(order);
             liveOrderLogsService.create(order.getOrderId(), OrderLogEnum.FINISH_ORDER.getValue(),
                     OrderLogEnum.FINISH_ORDER.getDesc());
@@ -1959,6 +1966,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     public int updateLiveOrder(LiveOrder liveOrder)
     {
         liveOrder.setUpdateTime(DateUtils.getNowDate());
+        liveUserLotteryRecordMapper.updateOrderStatusByOrderId(liveOrder.getOrderId(), liveOrder.getStatus());
         return baseMapper.updateLiveOrder(liveOrder);
     }
 
@@ -2116,6 +2124,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 //                OrderLogEnum.FINISH_ORDER.getDesc());
 
         int i = baseMapper.updateLiveOrder(updateEntity);
+        liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), OrderInfoEnum.STATUS_3.getValue());
 
         return i;
     }
@@ -2189,6 +2198,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         if (StringUtils.isEmpty(orderKey)) {
             return R.error("订单已过期");
         }
+        LiveUserLotteryRecord liveUserLotteryRecord = liveUserLotteryRecordMapper.selectLiveUserLotteryRecordById(liveOrder.getRecordId());
+        if(liveUserLotteryRecord == null) return R.error("未查询到中奖记录,请联系管理员处理!");
         if(liveOrder.getLiveId() == null) return R.error("直播ID不能为空");
         if(liveOrder.getProductId() == null) return R.error("购物商品ID不能为空");
         if(liveOrder.getUserName() == null) return R.error("用户名不能为空");
@@ -2253,6 +2264,9 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         liveOrder.setPayMoney(BigDecimal.ZERO);
         try {
             if (baseMapper.insertLiveOrder(liveOrder) > 0) {
+                liveUserLotteryRecord.setOrderId(liveOrder.getOrderId());
+                liveUserLotteryRecord.setOrderStatus(liveOrder.getStatus());
+                liveUserLotteryRecordMapper.updateLiveUserLotteryRecord(liveUserLotteryRecord);
                 LiveOrderItemDTO dto=new LiveOrderItemDTO();
                 dto.setImage(fsStoreProduct.getImage());
                 dto.setSku(String.valueOf(fsStoreProduct.getStock()));
@@ -2347,6 +2361,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 
             liveOrder.setStatus(2);
             liveOrder.setPayTime(LocalDateTime.now());
+            liveUserLotteryRecordMapper.updateOrderStatusByOrderId(liveOrder.getOrderId(), 2);
             baseMapper.updateLiveOrder(liveOrder);
             return R.ok("支付成功");
         }catch (Exception e){
@@ -2461,15 +2476,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());
-                        dto.setGroupBarCode(fsStoreProductAttrValue.getGroupBarCode());
-                    }
-                } 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()));
@@ -2594,6 +2607,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         if(order.getStatus() == 1){
             LiveOrder liveOrder = baseMapper.selectLiveOrderByOrderId(String.valueOf(order.getOrderId()));
             if(liveOrder == null) return R.error("订单不存在");
+            liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), -3);
             baseMapper.cancelOrder(order.getOrderId());
             liveOrderLogsService.create(order.getOrderId(), OrderLogEnum.CANCEL_ORDER.getValue(),
                     OrderLogEnum.CANCEL_ORDER.getDesc());

+ 2 - 0
fs-service-system/src/main/java/com/fs/live/vo/LiveUserLotteryRecordVo.java

@@ -37,6 +37,8 @@ public class LiveUserLotteryRecordVo extends BaseEntity{
 
     private String userName;
     private String productName;
+    private Long orderId;
+    private Integer orderStatus;
 
 
 }