Переглянути джерело

Merge remote-tracking branch 'origin/master'

yfh 3 днів тому
батько
коміт
47de5b39b4

+ 6 - 4
fs-service/src/main/java/com/fs/erp/service/impl/JSTErpOrderServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.fs.common.utils.StringUtils;
 import com.fs.erp.constant.AfterSalesOrderStatusEnum;
 import com.fs.erp.constant.ErpQueryOrderStatusEnum;
 import com.fs.erp.constant.OrderStatusEnum;
@@ -44,10 +45,7 @@ import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -543,6 +541,7 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
         // 1. 构建查询请求DTO
         OrderQueryRequestDTO requestDTO = new OrderQueryRequestDTO();
         requestDTO.setOIds(Collections.singletonList(Long.valueOf(param.getCode())));
+        requestDTO.setOrderItemFlds(Arrays.asList("status"));
 
         // 2. 调用ERP服务查询订单
         OrderQueryResponseDTO query = jstErpHttpService.query(requestDTO);
@@ -742,6 +741,9 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
                     .sum();
             erpOrder.setQty(totalQty);
         }
+        if (StringUtils.isNotEmpty(order.getStatus()) && "Cancelled".equals(order.getStatus())) {
+            erpOrder.setCancle(true);
+        }
 
         // 设置金额相关信息
         erpOrder.setAmount(order.getAmount() != null ? order.getAmount().doubleValue() : null);

+ 2 - 0
fs-service/src/main/java/com/fs/live/domain/Live.java

@@ -124,5 +124,7 @@ public class   Live extends BaseEntity {
     private Date createTime;
     private String companyName;
     private Long fileSize;
+    private Long videoFileSize;
+    private Long videoDuration;
     private Integer globalVisible;
 }

+ 1 - 1
fs-service/src/main/java/com/fs/live/mapper/LiveOrderMapper.java

@@ -107,7 +107,7 @@ public interface LiveOrderMapper {
     @Select("select * from live_order where `status` = 1 and extend_order_id is not null and delivery_sn is null ")
     List<LiveOrder> selectUpdateExpress();
 
-    @Select("select order_id from live_order where `status` = 2")
+    @Select("select order_id from live_order where `status` = 2 and delivery_code is not null and delivery_sn is not null and is_pay = 1")
     List<Long> selectSyncExpressIds();
 
     @Select("select order_id from live_order where `status` = 1 and extend_order_id is null and is_pay='1'")

+ 1 - 1
fs-service/src/main/java/com/fs/live/service/ILiveOrderService.java

@@ -100,7 +100,7 @@ public interface ILiveOrderService {
      * @param orderId
      * @return
      */
-    int getGoods(Long orderId);
+    int finishishOrder(Long orderId);
 
     /**
      * 修改物流信息

+ 13 - 4
fs-service/src/main/java/com/fs/live/service/impl/LiveAfterSalesServiceImpl.java

@@ -25,6 +25,8 @@ import com.fs.config.cloud.CloudHostProper;
 import com.fs.erp.constant.AfterSalesOrderStatusEnum;
 import com.fs.erp.domain.FsJstAftersalePush;
 import com.fs.erp.dto.BaseResponse;
+import com.fs.erp.dto.ErpOrderQueryRequert;
+import com.fs.erp.dto.ErpOrderQueryResponse;
 import com.fs.erp.dto.ErpRefundUpdateRequest;
 import com.fs.erp.mapper.FsJstAftersalePushMapper;
 import com.fs.erp.service.IErpOrderService;
@@ -424,9 +426,16 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
         request.setRefund_state(1);
         request.setStoreAfterSalesId(storeAfterSales.getId());
         if (StringUtils.isNotBlank(order.getExtendOrderId())){
-            BaseResponse response=erpOrderService.refundUpdateLive(request);
-            if(response.getSuccess()){
-                return R.ok();
+            ErpOrderQueryRequert queryRequest = new ErpOrderQueryRequert();
+            queryRequest.setCode(order.getExtendOrderId());
+            ErpOrderQueryResponse response = erpOrderService.getLiveOrder(queryRequest);
+            if (response.getOrders() != null && response.getOrders().size() > 0) {
+                if (response.getOrders().get(0).getCancle() != null && !response.getOrders().get(0).getCancle()) {
+                    BaseResponse res = erpOrderService.refundUpdateLive(request);
+                    if(res.getSuccess()){
+                        return R.ok();
+                    }
+                }
             }
             else{
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -542,7 +551,7 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
     @Override
     public int updateLiveAfterSales(LiveAfterSales liveAfterSales)
     {
-        if (!"".equals(liveAfterSales.getDeliveryName()) && !"".equals(liveAfterSales.getDeliverySn())){
+        if (StringUtils.isNotEmpty(liveAfterSales.getDeliveryName()) && StringUtils.isNotEmpty(liveAfterSales.getDeliverySn()) && StringUtils.isNotEmpty(liveAfterSales.getDeliveryCode())) {
             liveAfterSales.setStatus(2);
         }
 

+ 46 - 12
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -91,6 +91,7 @@ import com.fs.live.dto.LiveOrderComputeDTO;
 import com.fs.live.dto.LiveOrderCustomerExportDTO;
 import com.fs.live.dto.LiveOrderDeliveryNoteDTO;
 import com.fs.live.dto.LiveOrderItemDTO;
+import com.fs.live.enums.LiveAfterSalesStatusEnum;
 import com.fs.live.mapper.*;
 import com.fs.live.param.*;
 import com.fs.live.service.*;
@@ -1133,6 +1134,15 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         IErpOrderService erpOrderService = getErpService();
         FsErpConfig erpConfig = configUtil.generateStructConfigByKey("his.config", FsErpConfig.class);
         LiveOrder order = baseMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
+        LiveAfterSales updateSales = liveAfterSalesMapper.getLiveAfterSalesByOrderId(orderId);
+        if (updateSales == null) {
+            return R.error("售后单不存在");
+        }
+        LiveAfterSales liveMp = new LiveAfterSales();
+        liveMp.setId(updateSales.getId());
+        liveMp.setStatus(LiveAfterSalesStatusEnum.STATUS_4.getValue());
+        liveMp.setSalesStatus(3);
+        liveAfterSalesMapper.updateLiveAfterSales(liveMp);
         if (order == null) {
             return R.error("订单不存在");
         }
@@ -1171,17 +1181,23 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 }
                 return liveAfterSalesService.applyForAfterSales(order.getUserId(), param);
             } else {
-
-
-                jSTOrderService.refundUpdateLive(request);
+                ErpOrderQueryRequert queryRequest = new ErpOrderQueryRequert();
+                queryRequest.setCode(order.getExtendOrderId());
+                ErpOrderQueryResponse response = erpOrderService.getLiveOrder(queryRequest);
+                if (response.getOrders() != null && response.getOrders().size() > 0) {
+                    if (response.getOrders().get(0).getCancle() != null && !response.getOrders().get(0).getCancle()) {
+                        jSTOrderService.refundUpdateLive(request);
+                    }
+                }
             }
         }
-        order.setStatus(OrderInfoEnum.STATUS_2.getValue());
+        order.setStatus(OrderInfoEnum.STATUS_NE2.getValue());
         order.setRefundMoney(order.getPayMoney());
         order.setRefundStatus(String.valueOf(OrderInfoEnum.REFUND_STATUS_2.getValue()));
         liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), -2);
         baseMapper.updateLiveOrder(order);
 
+
         //退库存
         //获取订单下的商品
         List<LiveOrderItem> orderItemVOS = liveOrderItemMapper.selectLiveOrderItemByOrderId(order.getOrderId());
@@ -1296,6 +1312,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 userService.subTuiMoney(storeOrder);
             }
         }
+
         return R.ok();
     }
 
@@ -1347,8 +1364,14 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 }
                 return liveAfterSalesService.applyForAfterSales(order.getUserId(), param);
             } else {
-
-                jSTOrderService.refundUpdateLive(request);
+                ErpOrderQueryRequert queryRequest = new ErpOrderQueryRequert();
+                queryRequest.setCode(order.getExtendOrderId());
+                ErpOrderQueryResponse response = erpOrderService.getLiveOrder(queryRequest);
+                if (response.getOrders() != null && response.getOrders().size() > 0) {
+                    if (response.getOrders().get(0).getCancle() != null && !response.getOrders().get(0).getCancle()) {
+                        jSTOrderService.refundUpdateLive(request);
+                    }
+                }
             }
         }
         order.setStatus(OrderInfoEnum.STATUS_NE2.getValue());
@@ -1471,6 +1494,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 userService.subLiveTuiMoney(liveOrder);
             }
         }
+
         return R.ok();
     }
 
@@ -2664,17 +2688,19 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         baseMapper.updateLiveOrder(updateEntity);
         //如果是正常签收,更新订单状态
         if(dto.getState().equals("3")&&(dto.getStateEx().equals("301")||dto.getStateEx().equals("302")||dto.getStateEx().equals("304")||dto.getStateEx().equals("311"))){
-            this.getGoods(order.getOrderId());
+            this.finishishOrder(order.getOrderId());
         }
         return R.ok();
     }
 
     @Override
-    public int getGoods(Long orderId) {
+    public int finishishOrder(Long orderId) {
 
         LiveOrder order = baseMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
         if (order==null)throw new CustomException("订单不存在");
-        if (order.getStatus()!= OrderInfoEnum.STATUS_3.getValue())throw new CustomException("非法更改");
+        if (!Objects.equals(order.getStatus(), OrderInfoEnum.STATUS_2.getValue()))throw new CustomException("非法更改");
+        liveOrderLogsService.create(order.getOrderId(), OrderLogEnum.FINISH_ORDER.getValue(),
+                OrderLogEnum.FINISH_ORDER.getDesc());
         LiveOrder updateEntity = new LiveOrder();
         updateEntity.setOrderId(order.getOrderId());
         updateEntity.setUpdateTime(new DateTime());
@@ -2693,8 +2719,16 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 //                OrderLogEnum.FINISH_ORDER.getDesc());
 
         int i = baseMapper.updateLiveOrder(updateEntity);
-        liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), OrderInfoEnum.STATUS_3.getValue());
-
+        //模板消息支付成功发布事件
+        TemplateBean templateBean = TemplateBean.builder()
+                .orderId(order.getOrderId().toString())
+                .orderCode(order.getOrderCode().toString())
+                .remark("您的订单已签收成功")
+                .finishTime(order.getFinishTime())
+                .userId(Long.valueOf(order.getUserId()))
+                .templateType(TemplateListenEnum.TYPE_3.getValue())
+                .build();
+        publisher.publishEvent(new TemplateEvent(this, templateBean));
         return i;
     }
 
@@ -3304,7 +3338,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 
         // 更改店铺库存
         fsStoreProduct.setStock(fsStoreProduct.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
-        fsStoreProduct.setSales(fsStoreProduct.getSales()+Long.parseLong(liveOrder.getTotalNum()));
+        fsStoreProduct.setSales(fsStoreProduct.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
         fsStoreProductService.updateFsStoreProduct(fsStoreProduct);
         // 更新直播间库存
         goods.setStock(goods.getStock()-Integer.parseInt(liveOrder.getTotalNum()));

+ 2 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -145,6 +145,8 @@ public class LiveServiceImpl implements ILiveService
             byId.setDuration(liveVideo.getDuration());
             byId.setVideoId(liveVideo.getVideoId());
             byId.setVideoType(liveVideo.getVideoType());
+            byId.setVideoFileSize(liveVideo.getFileSize());
+            byId.setVideoDuration(liveVideo.getDuration());
         }
         return byId;
     }

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

@@ -37,6 +37,8 @@ public class LiveVo {
     private String videoUrl;
     private Long videoId;
     private Integer videoType;
+    private Long videoFileSize;
+    private Long videoDuration;
 
     private String flvHlsUrl;