浏览代码

erp售后流程

xdd 4 周之前
父节点
当前提交
d563a8fe9f

+ 17 - 70
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.erp.constant.AfterSalesOrderStatusEnum;
 import com.fs.erp.constant.ErpQueryOrderStatusEnum;
 import com.fs.erp.constant.OrderStatusEnum;
 import com.fs.erp.constant.TaskStatusEnum;
@@ -28,6 +29,7 @@ import com.fs.hisStore.service.IFsStoreOrderScrmService;
 import com.fs.hisStore.service.IFsStoreProductScrmService;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.ObjectUtils;
 import org.apache.http.util.Asserts;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -52,9 +54,6 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
     @Autowired
     private IFsStoreOrderScrmService fsStoreOrderScrmService;
 
-    @Autowired
-    private FsJstAftersalePushMapper fsJstAftersalePushMapper;
-
     @Autowired
     private IFsStoreOrderItemService fsStoreOrderItemService;
     @Autowired
@@ -65,12 +64,6 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
     @Autowired
     private IFsStoreProductScrmService fsStoreProductScrmService;
 
-//    @Autowired
-//    private FsStoreDeliversMapper fsStoreDeliversMapper;
-
-    @Autowired
-    private FsStoreAfterSalesMapper fsStoreAfterSalesMapper;
-
     @Autowired
     private FsJstCodPushMapper fsJstCodPushMapper;
 
@@ -103,12 +96,7 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
         shopOrderDTO.setReceiverPhone(order.getReceiver_mobile());
         // 支付金额
         shopOrderDTO.setPayAmount(erpOrderPayment.getPayment());
-        // 运费 改
-//        if(ObjectUtil.isNull(fsStoreOrder.getPayPostage())) {
-//            shopOrderDTO.setFreight(Double.valueOf("0.00"));
-//        } else {
-//            shopOrderDTO.setFreight(fsStoreOrder.getPayPostage().doubleValue());
-//        }
+
         if (ObjectUtil.isNull(fsStoreOrder.getPayDelivery())) {
             shopOrderDTO.setFreight(Double.valueOf("0.00"));
         } else {
@@ -123,27 +111,6 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
 
         // 订单商品项列表
         List<OrderItemDTO> itemDTOList = new ArrayList<>();
-    // 改
-//        List<FsStoreOrderItemVO> fsStoreOrderItemVOS = fsStoreOrderItemService.selectFsStoreOrderItemListByOrderId(fsStoreOrder.getId());
-//        for (FsStoreOrderItemVO item : fsStoreOrderItemVOS) {
-//            OrderItemDTO orderItemDTO = new OrderItemDTO();
-//            JSONObject jsonObject = JSON.parseObject(item.getJsonInfo());
-//
-//            String barCode = jsonObject.getString("barCode");
-//            String productName = jsonObject.getString("productName");
-//
-//            orderItemDTO.setSkuId(barCode);
-//            orderItemDTO.setShopSkuId(barCode);
-//            orderItemDTO.setName(productName);
-//
-//            FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(item.getProductId());
-//
-//            orderItemDTO.setAmount(fsStoreProduct.getPrice());
-//
-//            orderItemDTO.setQty(item.getNum().intValue());
-//            orderItemDTO.setOuterOiId(String.format("%s%s",item.getOrderCode(),item.getItemId()));
-//            itemDTOList.add(orderItemDTO);
-//        }
 
         List<FsStoreOrderItem> fsStoreOrderItemVOS = fsStoreOrderItemService.selectFsStoreOrderItemListByOrderId(fsStoreOrder.getOrderId());
         for (FsStoreOrderItem item : fsStoreOrderItemVOS) {
@@ -182,7 +149,6 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
 
 
         // 如果是货到付款
-        log.info("订单支付方式: {},\"2\".equals(fsStoreOrder.getPayType()) || \"3\".equals(fsStoreOrder.getPayType()):{}",fsStoreOrder.getPayType(),fsStoreOrder.getPayType() == 2 || fsStoreOrder.getPayType() == 3);
         if(fsStoreOrder.getPayType() == 2 || fsStoreOrder.getPayType() == 3){
             shopOrderDTO.setIsCod(true);
             // 货到付款金额 = 物流代收金额-优惠金额
@@ -208,7 +174,6 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
             fsJstCodPush.setTaskStatus(TaskStatusEnum.PENDING.getCode());
             fsJstCodPushMapper.insert(fsJstCodPush);
 
-            //shopOrderDTO.setPay(paymentDTO);
         }
 
         ErpOrderResponseDTO upload = jstErpHttpService.upload(shopOrderDTO);
@@ -256,11 +221,6 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
         // 支付金额
         shopOrderDTO.setPayAmount(erpOrderPayment.getPayment());
         // 运费 改
-//        if(ObjectUtil.isNull(fsStoreOrder.getPayPostage())) {
-//            shopOrderDTO.setFreight(Double.valueOf("0.00"));
-//        } else {
-//            shopOrderDTO.setFreight(fsStoreOrder.getPayPostage().doubleValue());
-//        }
         if (ObjectUtil.isNull(fsStoreOrder.getPayDelivery())) {
             shopOrderDTO.setFreight(Double.valueOf("0.00"));
         } else {
@@ -274,27 +234,6 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
 
         // 订单商品项列表
         List<OrderItemDTO> itemDTOList = new ArrayList<>();
-        // 改
-//        List<FsStoreOrderItemVO> fsStoreOrderItemVOS = fsStoreOrderItemService.selectFsStoreOrderItemListByOrderId(fsStoreOrder.getId());
-//        for (FsStoreOrderItemVO item : fsStoreOrderItemVOS) {
-//            OrderItemDTO orderItemDTO = new OrderItemDTO();
-//            JSONObject jsonObject = JSON.parseObject(item.getJsonInfo());
-//
-//            String barCode = jsonObject.getString("barCode");
-//            String productName = jsonObject.getString("productName");
-//
-//            orderItemDTO.setSkuId(barCode);
-//            orderItemDTO.setShopSkuId(barCode);
-//            orderItemDTO.setName(productName);
-//
-//            FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(item.getProductId());
-//
-//            orderItemDTO.setAmount(fsStoreProduct.getPrice());
-//
-//            orderItemDTO.setQty(item.getNum().intValue());
-//            orderItemDTO.setOuterOiId(String.format("%s%s",item.getOrderCode(),item.getItemId()));
-//            itemDTOList.add(orderItemDTO);
-//        }
 
         List<FsStoreOrderItemVO> fsStoreOrderItemVOS = fsStoreOrderItemScrmService.selectFsStoreOrderItemListByOrderId(fsStoreOrder.getId());
         log.info("fsStoreOrderItemVOS==========>{}",fsStoreOrderItemVOS);
@@ -527,17 +466,25 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
         return baseResponse;
     }
 
+    @Autowired
+    private FsJstAftersalePushMapper fsJstAftersalePushMapper;
+
     @Override
     public BaseResponse refundUpdateScrm(ErpRefundUpdateRequest param) {
 
         FsStoreOrderScrm fsStoreOrder = fsStoreOrderScrmService.selectFsStoreOrderByOrderCode(param.getTid());
-        //todo 待合并
-//        FsStoreDelivers byOrderCode = fsStoreDeliversMapper.findByOrderCode(fsStoreOrder.getOrderCode());
-        //todo
         // 发货后退款
-//        if(ObjectUtil.isNotNull(byOrderCode)){
+        if(ObjectUtils.equals(fsStoreOrder.getStatus(),2)){
 
-//        } else {
+            FsJstAftersalePush fsJstAftersalePush = new FsJstAftersalePush();
+            fsJstAftersalePush.setOrderId(fsStoreOrder.getOrderCode());
+            fsJstAftersalePush.setTaskStatus(com.fs.hisStore.enums.TaskStatusEnum.PENDING.getCode());
+            fsJstAftersalePush.setType(String.valueOf(AfterSalesOrderStatusEnum.WAIT_SELLER_AGREE.getIndex()));
+            fsJstAftersalePush.setRetryCount(0);
+            fsJstAftersalePush.setAfterSaleId(String.valueOf(param.getStoreAfterSalesId()));
+            fsJstAftersalePushMapper.insert(fsJstAftersalePush);
+
+        } else {
         // 如果是发货前退款,直接走取消订单流程
         // 如果是发货后退款,走售后流程
         OrderCancelRequestDTO requestDTO = new OrderCancelRequestDTO();
@@ -546,7 +493,7 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
         requestDTO.setRemark("用户退款");
 
         jstErpHttpService.cancel(requestDTO);
-//        }
+        }
 
 
         BaseResponse baseResponse = new BaseResponse();

+ 1 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreAfterSalesScrmServiceImpl.java

@@ -379,6 +379,7 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
         request.setTid(order.getOrderCode());
         request.setOid(order.getOrderCode());
         request.setRefund_state(1);
+        request.setStoreAfterSalesId(storeAfterSales.getId());
         BaseResponse response=erpOrderService.refundUpdateScrm(request);
         if(response.getSuccess()){
             return R.ok();

+ 24 - 2
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -88,6 +88,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.WxPayService;
 import lombok.Synchronized;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.ObjectUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.aop.framework.AopContext;
@@ -1984,6 +1985,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         return fsStoreOrderMapper.selectFsStoreOrderListByDeliveryId(logisticCode);
     }
 
+    @Autowired
+    private IFsStoreAfterSalesScrmService fsStoreAfterSalesScrmService;
     @Override
     @Transactional
     public R refundOrderMoney(Long orderId) {
@@ -2012,8 +2015,27 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 //                return R.error(response.getErrorDesc());
 //            }
 
-            jSTOrderService.refundUpdateScrm(request);
-
+            if(ObjectUtils.equals(order.getStatus(),2)){
+                FsStoreAfterSalesParam fsStoreAfterSalesParam = new FsStoreAfterSalesParam();
+                fsStoreAfterSalesParam.setOrderCode(order.getOrderCode());
+                fsStoreAfterSalesParam.setRefundAmount(order.getRefundMoney());
+                fsStoreAfterSalesParam.setServiceType(1);
+                fsStoreAfterSalesParam.setReasons("后台手动退款流程");
+                fsStoreAfterSalesParam.setExplainImg(null);
+                List<FsStoreAfterSalesProductParam> productParams = new ArrayList<>();
+                List <FsStoreOrderItemScrm> items = fsStoreOrderMapper.selectOrderItem(order.getId());
+                for (FsStoreOrderItemScrm item : items){
+                    FsStoreAfterSalesProductParam param1 = new FsStoreAfterSalesProductParam();
+                    param1.setProductId(item.getProductId());
+                    param1.setNum(item.getNum());
+                    productParams.add(param1);
+                }
+                fsStoreAfterSalesParam.setProductList(productParams);
+
+                return fsStoreAfterSalesScrmService.applyForAfterSales(order.getUserId(),fsStoreAfterSalesParam);
+            } else{
+                jSTOrderService.refundUpdateScrm(request);
+            }
         }
         order.setStatus(-2);
         order.setRefundPrice(order.getPayMoney());