Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

ct 4 tygodni temu
rodzic
commit
2fc31a2991

+ 27 - 79
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,26 +466,35 @@ 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
+        log.info("订单号: {},发货状态: {},是否发货后: {}",fsStoreOrder.getOrderCode(),fsStoreOrder.getStatus(),ObjectUtils.equals(fsStoreOrder.getStatus(),2));
+
         // 发货后退款
-//        if(ObjectUtil.isNotNull(byOrderCode)){
+        if(ObjectUtils.equals(fsStoreOrder.getStatus(),2)){
 
-//        } else {
-        // 如果是发货前退款,直接走取消订单流程
-        // 如果是发货后退款,走售后流程
-        OrderCancelRequestDTO requestDTO = new OrderCancelRequestDTO();
-        requestDTO.setOIds(Collections.singletonList(Integer.valueOf(fsStoreOrder.getExtendOrderId())));
-        requestDTO.setCancelType("用户退款");
-        requestDTO.setRemark("用户退款");
-
-        jstErpHttpService.cancel(requestDTO);
-//        }
+            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();
+            requestDTO.setOIds(Collections.singletonList(Integer.valueOf(fsStoreOrder.getExtendOrderId())));
+            requestDTO.setCancelType("用户退款");
+            requestDTO.setRemark("用户退款");
+
+            jstErpHttpService.cancel(requestDTO);
+        }
 
 
         BaseResponse baseResponse = new BaseResponse();

+ 1 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java

@@ -318,7 +318,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
         }
 
         if (param.getType()==1) {
-            if (StringUtils.isBlank(user.getMaOpenId()) && !CloudHostUtils.hasCloudHostName("弘德堂")) {
+            if (StringUtils.isBlank(user.getMaOpenId()) && !CloudHostUtils.hasCloudHostName("弘德堂", "金牛明医", "木易华康")) {
                 return R.error("用户OPENID不存在");
             }
 

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

@@ -62,6 +62,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.google.gson.Gson;
 import lombok.Synchronized;
+import org.apache.commons.beanutils.BeanUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -71,6 +72,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.text.DecimalFormat;
@@ -320,7 +322,14 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
 //                totalPrice = NumberUtil.add(totalPrice, NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount));
                 item.setIsAfterSales(1);
                 FsStoreOrderItemScrm orderItem=new FsStoreOrderItemScrm();
-                BeanUtil.copyProperties(item, orderItem);
+//                BeanUtil.copyProperties(item, orderItem);
+                try {
+                    BeanUtils.copyProperties(orderItem,item);
+                } catch (IllegalAccessException e) {
+                    throw new RuntimeException(e);
+                } catch (InvocationTargetException e) {
+                    throw new RuntimeException(e);
+                }
                 orderItemService.updateFsStoreOrderItem(orderItem);
 
             }
@@ -379,6 +388,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());

+ 2 - 2
fs-user-app/src/main/java/com/fs/app/controller/InquiryOrderController.java

@@ -144,7 +144,7 @@ public class InquiryOrderController extends  AppBaseController {
         }
 
         if (param.getType() == 1) {
-            if (StringUtils.isBlank(user.getMaOpenId()) && !CloudHostUtils.hasCloudHostName("弘德堂")) {
+            if (StringUtils.isBlank(user.getMaOpenId()) && !CloudHostUtils.hasCloudHostName("弘德堂", "金牛明医", "木易华康")) {
                 return R.error("用户OPENID不存在");
             }
 
@@ -180,7 +180,7 @@ public class InquiryOrderController extends  AppBaseController {
         if(user!=null){
 
             // 红德堂特殊处理
-            if (!CloudHostUtils.hasCloudHostName("弘德堂") && StringUtils.isBlank(user.getMaOpenId())) {
+            if (!CloudHostUtils.hasCloudHostName("弘德堂", "金牛明医", "木易华康") && StringUtils.isBlank(user.getMaOpenId())) {
                 return R.error("用户OPENID不存在");
             }