|  | @@ -7,6 +7,9 @@ import cn.hutool.json.JSONObject;
 | 
											
												
													
														|  |  import cn.hutool.json.JSONUtil;
 |  |  import cn.hutool.json.JSONUtil;
 | 
											
												
													
														|  |  import com.alibaba.fastjson.JSON;
 |  |  import com.alibaba.fastjson.JSON;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 |  |  import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 | 
											
												
													
														|  | 
 |  | +import com.fs.common.event.TemplateBean;
 | 
											
												
													
														|  | 
 |  | +import com.fs.common.event.TemplateEvent;
 | 
											
												
													
														|  | 
 |  | +import com.fs.common.event.TemplateListenEnum;
 | 
											
												
													
														|  |  import com.fs.common.utils.DateUtils;
 |  |  import com.fs.common.utils.DateUtils;
 | 
											
												
													
														|  |  import com.fs.company.service.ICompanyService;
 |  |  import com.fs.company.service.ICompanyService;
 | 
											
												
													
														|  |  import com.fs.erp.domain.ErpDeliverys;
 |  |  import com.fs.erp.domain.ErpDeliverys;
 | 
											
										
											
												
													
														|  | @@ -27,12 +30,18 @@ import com.fs.his.service.IFsExpressService;
 | 
											
												
													
														|  |  import com.fs.his.service.IFsStoreOrderLogsService;
 |  |  import com.fs.his.service.IFsStoreOrderLogsService;
 | 
											
												
													
														|  |  import com.fs.his.service.IFsStoreOrderService;
 |  |  import com.fs.his.service.IFsStoreOrderService;
 | 
											
												
													
														|  |  import com.fs.his.utils.ConfigUtil;
 |  |  import com.fs.his.utils.ConfigUtil;
 | 
											
												
													
														|  | 
 |  | +import com.fs.hisStore.domain.FsExpressScrm;
 | 
											
												
													
														|  |  import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 |  |  import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 | 
											
												
													
														|  |  import com.fs.hisStore.domain.FsStoreOrderScrm;
 |  |  import com.fs.hisStore.domain.FsStoreOrderScrm;
 | 
											
												
													
														|  |  import com.fs.hisStore.domain.FsStoreProductScrm;
 |  |  import com.fs.hisStore.domain.FsStoreProductScrm;
 | 
											
												
													
														|  | 
 |  | +import com.fs.hisStore.enums.OrderInfoEnum;
 | 
											
												
													
														|  | 
 |  | +import com.fs.hisStore.enums.OrderLogEnum;
 | 
											
												
													
														|  | 
 |  | +import com.fs.hisStore.enums.ShipperCodeEnum;
 | 
											
												
													
														|  |  import com.fs.hisStore.mapper.FsStoreOrderItemScrmMapper;
 |  |  import com.fs.hisStore.mapper.FsStoreOrderItemScrmMapper;
 | 
											
												
													
														|  |  import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
 |  |  import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
 | 
											
												
													
														|  |  import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
 |  |  import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
 | 
											
												
													
														|  | 
 |  | +import com.fs.hisStore.service.IFsExpressScrmService;
 | 
											
												
													
														|  | 
 |  | +import com.fs.hisStore.service.IFsStoreOrderScrmService;
 | 
											
												
													
														|  |  import com.fs.hisStore.vo.FsStoreOrderItemVO;
 |  |  import com.fs.hisStore.vo.FsStoreOrderItemVO;
 | 
											
												
													
														|  |  import com.fs.system.domain.SysConfig;
 |  |  import com.fs.system.domain.SysConfig;
 | 
											
												
													
														|  |  import com.fs.system.mapper.SysConfigMapper;
 |  |  import com.fs.system.mapper.SysConfigMapper;
 | 
											
										
											
												
													
														|  | @@ -51,8 +60,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  @Service
 |  |  @Service
 | 
											
												
													
														|  |  @Slf4j
 |  |  @Slf4j
 | 
											
												
													
														|  | -public class DfOrderServiceImpl implements IErpOrderService
 |  | 
 | 
											
												
													
														|  | -{
 |  | 
 | 
											
												
													
														|  | 
 |  | +public class DfOrderServiceImpl implements IErpOrderService {
 | 
											
												
													
														|  |  //    @Autowired
 |  |  //    @Autowired
 | 
											
												
													
														|  |  //    ConfigUtil configUtil;
 |  |  //    ConfigUtil configUtil;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -89,6 +97,9 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private IFsStoreOrderLogsService fsStoreOrderLogsService;
 |  |      private IFsStoreOrderLogsService fsStoreOrderLogsService;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private IFsStoreOrderScrmService fsStoreOrderScrmLogsService;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private ICompanyService companyService;
 |  |      private ICompanyService companyService;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -97,6 +108,10 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private IFsExpressService expressService;
 |  |      private IFsExpressService expressService;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private IFsExpressScrmService expressScrmService;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private IFsStoreOrderService fsStoreOrderService;
 |  |      private IFsStoreOrderService fsStoreOrderService;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -126,7 +141,7 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |          String orderCode = order.getOrderCode();
 |  |          String orderCode = order.getOrderCode();
 | 
											
												
													
														|  |          FsStoreOrder fsStoreOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderCode(orderCode);
 |  |          FsStoreOrder fsStoreOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderCode(orderCode);
 | 
											
												
													
														|  |          FsStoreOrderDf df = fsStoreOrderDfMapper.selectFsStoreOrderDfByOrderId(fsStoreOrder.getOrderId());
 |  |          FsStoreOrderDf df = fsStoreOrderDfMapper.selectFsStoreOrderDfByOrderId(fsStoreOrder.getOrderId());
 | 
											
												
													
														|  | -        if (df == null){
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (df == null) {
 | 
											
												
													
														|  |              return null;
 |  |              return null;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          Long dfAccountId = getSFAccountIndex(fsStoreOrder.getOrderId());
 |  |          Long dfAccountId = getSFAccountIndex(fsStoreOrder.getOrderId());
 | 
											
										
											
												
													
														|  | @@ -240,7 +255,7 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |              if (order != null) {
 |  |              if (order != null) {
 | 
											
												
													
														|  |                  //获取下单账户
 |  |                  //获取下单账户
 | 
											
												
													
														|  |                  FsStoreOrderDf df = fsStoreOrderDfMapper.selectFsStoreOrderDfByOrderId(order.getOrderId());
 |  |                  FsStoreOrderDf df = fsStoreOrderDfMapper.selectFsStoreOrderDfByOrderId(order.getOrderId());
 | 
											
												
													
														|  | -                if(df == null){
 |  | 
 | 
											
												
													
														|  | 
 |  | +                if (df == null) {
 | 
											
												
													
														|  |                      return null;
 |  |                      return null;
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |                  Long dfAccountId = getSFAccountIndex(order.getOrderId());
 |  |                  Long dfAccountId = getSFAccountIndex(order.getOrderId());
 | 
											
										
											
												
													
														|  | @@ -261,7 +276,30 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public ErpOrderQueryResponse getScrmOrder(ErpOrderQueryRequert param) {
 |  |      public ErpOrderQueryResponse getScrmOrder(ErpOrderQueryRequert param) {
 | 
											
												
													
														|  | -        return null;
 |  | 
 | 
											
												
													
														|  | 
 |  | +        ErpOrderQueryResponse response = new ErpOrderQueryResponse();
 | 
											
												
													
														|  | 
 |  | +        String orderNumber = param.getCode();
 | 
											
												
													
														|  | 
 |  | +        if (StrUtil.isNotBlank(orderNumber)) {
 | 
											
												
													
														|  | 
 |  | +            FsStoreOrderScrm order = fsStoreOrderScrmMapper.selectFsStoreOrderByOrderCode(orderNumber);
 | 
											
												
													
														|  | 
 |  | +            if (order != null) {
 | 
											
												
													
														|  | 
 |  | +                //获取下单账户
 | 
											
												
													
														|  | 
 |  | +                FsStoreOrderDf df = fsStoreOrderDfMapper.selectFsStoreOrderDfByOrderId(order.getId());
 | 
											
												
													
														|  | 
 |  | +                if (df == null) {
 | 
											
												
													
														|  | 
 |  | +                    return null;
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +                Long dfAccountId = getSFAccountIndex(order.getId());
 | 
											
												
													
														|  | 
 |  | +                if (dfAccountId != null) {
 | 
											
												
													
														|  | 
 |  | +                    Map<String, Object> orderResultQueryParam = new HashMap<>();
 | 
											
												
													
														|  | 
 |  | +                    orderResultQueryParam.put("orderNumber", orderNumber);
 | 
											
												
													
														|  | 
 |  | +                    orderResultQueryParam.put("exInterfaceType", df.getStatus());
 | 
											
												
													
														|  | 
 |  | +                    getOrderScrmResult(orderResultQueryParam, dfAccountId);
 | 
											
												
													
														|  | 
 |  | +                    return response;
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            response.setErrorDesc("该订单不存在/顺丰账户不存在");
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            response.setErrorDesc("未获取到原始订单号");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return response;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
										
											
												
													
														|  | @@ -290,7 +328,7 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |          try {
 |  |          try {
 | 
											
												
													
														|  |              String response = client.execute(RequestUrlEnum.ORDER_DELIVERY_STATUS, map, dfAccountId);
 |  |              String response = client.execute(RequestUrlEnum.ORDER_DELIVERY_STATUS, map, dfAccountId);
 | 
											
												
													
														|  |              DFApiResponse dfApiResponse = JSON.parseObject(response, DFApiResponse.class);
 |  |              DFApiResponse dfApiResponse = JSON.parseObject(response, DFApiResponse.class);
 | 
											
												
													
														|  | -            if ("运单不存在".equals(dfApiResponse.getMsg())){
 |  | 
 | 
											
												
													
														|  | 
 |  | +            if ("运单不存在".equals(dfApiResponse.getMsg())) {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                  //查看原来物流状态
 |  |                  //查看原来物流状态
 | 
											
												
													
														|  |                  cancelOrder(order);
 |  |                  cancelOrder(order);
 | 
											
										
											
												
													
														|  | @@ -352,7 +390,7 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |                          Map<String, Object> config = (Map<String, Object>) JSON.parse(sysConfig.getConfigValue());
 |  |                          Map<String, Object> config = (Map<String, Object>) JSON.parse(sysConfig.getConfigValue());
 | 
											
												
													
														|  |                          Object isUpdateOrder = config.get("isUpdateOrder");
 |  |                          Object isUpdateOrder = config.get("isUpdateOrder");
 | 
											
												
													
														|  |                          if (isUpdateOrder == null || "1".equals(isUpdateOrder.toString())) {
 |  |                          if (isUpdateOrder == null || "1".equals(isUpdateOrder.toString())) {
 | 
											
												
													
														|  | -                            fsStoreOrderService.getGoods(order.getOrderId(),"物流自动");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                            fsStoreOrderService.getGoods(order.getOrderId(), "物流自动");
 | 
											
												
													
														|  |                          }
 |  |                          }
 | 
											
												
													
														|  |                          break;
 |  |                          break;
 | 
											
												
													
														|  |                      case 10:
 |  |                      case 10:
 | 
											
										
											
												
													
														|  | @@ -386,7 +424,7 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |              order.setDeliverySn("");
 |  |              order.setDeliverySn("");
 | 
											
												
													
														|  |              fsStoreOrderMapper.updateFsStoreOrder(order);
 |  |              fsStoreOrderMapper.updateFsStoreOrder(order);
 | 
											
												
													
														|  |              fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.UPDATE_ORDER_DF.getValue(),
 |  |              fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.UPDATE_ORDER_DF.getValue(),
 | 
											
												
													
														|  | -                    "运单不存在,"+FsStoreOrderLogEnum.UPDATE_ORDER_DF.getDesc());
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    "运单不存在," + FsStoreOrderLogEnum.UPDATE_ORDER_DF.getDesc());
 | 
											
												
													
														|  |          } else {
 |  |          } else {
 | 
											
												
													
														|  |              //有物流信息->售后处理
 |  |              //有物流信息->售后处理
 | 
											
												
													
														|  |              //取消订单
 |  |              //取消订单
 | 
											
										
											
												
													
														|  | @@ -396,7 +434,7 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |              afterSalesParam.setOperator("代服管家");
 |  |              afterSalesParam.setOperator("代服管家");
 | 
											
												
													
														|  |              fsStoreOrderService.afterSales(afterSalesParam);
 |  |              fsStoreOrderService.afterSales(afterSalesParam);
 | 
											
												
													
														|  |              fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.REFUND_ORDER_DF.getValue(),
 |  |              fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.REFUND_ORDER_DF.getValue(),
 | 
											
												
													
														|  | -                    "运单不存在,"+FsStoreOrderLogEnum.REFUND_ORDER_DF.getDesc());
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    "运单不存在," + FsStoreOrderLogEnum.REFUND_ORDER_DF.getDesc());
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          FsStoreOrderDf df = new FsStoreOrderDf();
 |  |          FsStoreOrderDf df = new FsStoreOrderDf();
 | 
											
												
													
														|  |          df.setOrderId(order.getOrderId());
 |  |          df.setOrderId(order.getOrderId());
 | 
											
										
											
												
													
														|  | @@ -404,6 +442,7 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |          df.setUpdateTime(new Date());
 |  |          df.setUpdateTime(new Date());
 | 
											
												
													
														|  |          fsStoreOrderDfMapper.updateFsStoreOrderDf(df);
 |  |          fsStoreOrderDfMapper.updateFsStoreOrderDf(df);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      /**
 |  |      /**
 | 
											
												
													
														|  |       * 获取erp推送参数
 |  |       * 获取erp推送参数
 | 
											
												
													
														|  |       *
 |  |       *
 | 
											
										
											
												
													
														|  | @@ -438,7 +477,7 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |                  orderResultQueryParam.put("orderNumber", order.getPlatform_code());
 |  |                  orderResultQueryParam.put("orderNumber", order.getPlatform_code());
 | 
											
												
													
														|  |                  orderResultQueryParam.put("exInterfaceType", df.getStatus());
 |  |                  orderResultQueryParam.put("exInterfaceType", df.getStatus());
 | 
											
												
													
														|  |                  try {
 |  |                  try {
 | 
											
												
													
														|  | -                    getOrderResult(orderResultQueryParam,dfAccountId);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    getOrderScrmResult(orderResultQueryParam, dfAccountId);
 | 
											
												
													
														|  |                  } catch (Exception e) {
 |  |                  } catch (Exception e) {
 | 
											
												
													
														|  |                      log.info("推送订单完成,查询订单问题{}", e.getMessage());
 |  |                      log.info("推送订单完成,查询订单问题{}", e.getMessage());
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
										
											
												
													
														|  | @@ -489,7 +528,7 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |                  orderResultQueryParam.put("orderNumber", order.getPlatform_code());
 |  |                  orderResultQueryParam.put("orderNumber", order.getPlatform_code());
 | 
											
												
													
														|  |                  orderResultQueryParam.put("exInterfaceType", df.getStatus());
 |  |                  orderResultQueryParam.put("exInterfaceType", df.getStatus());
 | 
											
												
													
														|  |                  try {
 |  |                  try {
 | 
											
												
													
														|  | -                    getOrderResult(orderResultQueryParam,dfAccountId);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    getOrderResult(orderResultQueryParam, dfAccountId);
 | 
											
												
													
														|  |                  } catch (Exception e) {
 |  |                  } catch (Exception e) {
 | 
											
												
													
														|  |                      log.info("推送订单完成,查询订单问题{}", e.getMessage());
 |  |                      log.info("推送订单完成,查询订单问题{}", e.getMessage());
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
										
											
												
													
														|  | @@ -636,7 +675,12 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |                  skuVo.setProductName(product.getProductName()); //商品名称
 |  |                  skuVo.setProductName(product.getProductName()); //商品名称
 | 
											
												
													
														|  |                  com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(item.getJsonInfo());
 |  |                  com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(item.getJsonInfo());
 | 
											
												
													
														|  |                  skuVo.setSkuCode(jsonObject.getString("sku")); //sku编码
 |  |                  skuVo.setSkuCode(jsonObject.getString("sku")); //sku编码
 | 
											
												
													
														|  | -                skuVo.setProductCode(jsonObject.getString("barCode")); //商品编号
 |  | 
 | 
											
												
													
														|  | 
 |  | +                String barCode = jsonObject.getString("barCode");
 | 
											
												
													
														|  | 
 |  | +                if (StringUtils.isNotBlank(barCode)) {
 | 
											
												
													
														|  | 
 |  | +                    skuVo.setProductCode(barCode); //商品编号
 | 
											
												
													
														|  | 
 |  | +                } else {
 | 
											
												
													
														|  | 
 |  | +                    skuVo.setProductCode(item.getProductId().toString()); //商品编号
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  |                  skuVo.setAttributeNames(jsonObject.getString("sku")); //商品规格,格式:颜色:红色,尺寸:L码....以此类推
 |  |                  skuVo.setAttributeNames(jsonObject.getString("sku")); //商品规格,格式:颜色:红色,尺寸:L码....以此类推
 | 
											
												
													
														|  |                  skuVo.setProductNumber(Math.toIntExact(item.getNum())); //商品预定数量
 |  |                  skuVo.setProductNumber(Math.toIntExact(item.getNum())); //商品预定数量
 | 
											
												
													
														|  |                  skuVo.setPrice(product.getPrice().doubleValue()); //商品单价
 |  |                  skuVo.setPrice(product.getPrice().doubleValue()); //商品单价
 | 
											
										
											
												
													
														|  | @@ -767,7 +811,6 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |      /**
 |  |      /**
 | 
											
												
													
														|  |       * 获取账户索引 后续添加规则
 |  |       * 获取账户索引 后续添加规则
 | 
											
												
													
														|  |       *
 |  |       *
 | 
											
										
											
												
													
														|  | @@ -814,12 +857,16 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |                          if (bspOrderResponse != null) {
 |  |                          if (bspOrderResponse != null) {
 | 
											
												
													
														|  |                              String failMsg = bspOrderResponse.getFailMsg();
 |  |                              String failMsg = bspOrderResponse.getFailMsg();
 | 
											
												
													
														|  |                              if (StringUtils.isNotBlank(failMsg)) {
 |  |                              if (StringUtils.isNotBlank(failMsg)) {
 | 
											
												
													
														|  | -                                if (failMsg.equals("暂未结果, 请稍后再查")){
 |  | 
 | 
											
												
													
														|  | 
 |  | +                                if (failMsg.equals("暂未结果, 请稍后再查")) {
 | 
											
												
													
														|  |                                      return;
 |  |                                      return;
 | 
											
												
													
														|  |                                  }
 |  |                                  }
 | 
											
												
													
														|  |                                  //下单失败 返回未推送状态
 |  |                                  //下单失败 返回未推送状态
 | 
											
												
													
														|  | -                                String  orderNumber = bspOrderResponse.getOrderNumber();
 |  | 
 | 
											
												
													
														|  | -                                rollBackOrder(orderNumber,failMsg);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                                String orderNumber = bspOrderResponse.getOrderNumber();
 | 
											
												
													
														|  | 
 |  | +                                try {
 | 
											
												
													
														|  | 
 |  | +                                    rollBackOrder(orderNumber, failMsg);
 | 
											
												
													
														|  | 
 |  | +                                } catch (Exception e) {
 | 
											
												
													
														|  | 
 |  | +                                    log.info("{}订单获取运单失败,订单状态回滚失败,失败原因:{},失败信息为:{}", orderNumber,e.getMessage(),failMsg);
 | 
											
												
													
														|  | 
 |  | +                                }
 | 
											
												
													
														|  |                              } else {
 |  |                              } else {
 | 
											
												
													
														|  |                                  setExpress(bspOrderResponse);
 |  |                                  setExpress(bspOrderResponse);
 | 
											
												
													
														|  |                              }
 |  |                              }
 | 
											
										
											
												
													
														|  | @@ -845,7 +892,60 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    private void rollBackOrder(String orderNumber,String failMsg) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private void getOrderScrmResult(Map<String, Object> map, Long dfAccountId) {
 | 
											
												
													
														|  | 
 |  | +        try {
 | 
											
												
													
														|  | 
 |  | +            String status = map.get("exInterfaceType").toString();
 | 
											
												
													
														|  | 
 |  | +            log.info("开始查询订单结果,参数为: {}", JSON.toJSONString(map));
 | 
											
												
													
														|  | 
 |  | +            String response = client.execute(RequestUrlEnum.ORDER_RESULT, map, dfAccountId);
 | 
											
												
													
														|  | 
 |  | +            DFApiResponse dfApiResponse = JSON.parseObject(response, DFApiResponse.class);
 | 
											
												
													
														|  | 
 |  | +            if (dfApiResponse != null && "ok".equals(dfApiResponse.getCode())) {
 | 
											
												
													
														|  | 
 |  | +                log.info("查询订单结果,结果: {}", JSON.toJSONString(dfApiResponse));
 | 
											
												
													
														|  | 
 |  | +                Object result = dfApiResponse.getResult();
 | 
											
												
													
														|  | 
 |  | +                if (result != null) {
 | 
											
												
													
														|  | 
 |  | +                    String jsonString = JSON.toJSONString(result);
 | 
											
												
													
														|  | 
 |  | +                    //下单
 | 
											
												
													
														|  | 
 |  | +                    if ("1".equals(status)) {
 | 
											
												
													
														|  | 
 |  | +                        //下单结果
 | 
											
												
													
														|  | 
 |  | +                        BspOrderResponseWrapper bspOrderResponse = JSONUtil.toBean(jsonString, BspOrderResponseWrapper.class);
 | 
											
												
													
														|  | 
 |  | +                        if (bspOrderResponse != null) {
 | 
											
												
													
														|  | 
 |  | +                            String failMsg = bspOrderResponse.getFailMsg();
 | 
											
												
													
														|  | 
 |  | +                            if (StringUtils.isNotBlank(failMsg)) {
 | 
											
												
													
														|  | 
 |  | +                                if (failMsg.equals("暂未结果, 请稍后再查")) {
 | 
											
												
													
														|  | 
 |  | +                                    return;
 | 
											
												
													
														|  | 
 |  | +                                }
 | 
											
												
													
														|  | 
 |  | +                                //下单失败 返回未推送状态
 | 
											
												
													
														|  | 
 |  | +                                String orderNumber = bspOrderResponse.getOrderNumber();
 | 
											
												
													
														|  | 
 |  | +                                try {
 | 
											
												
													
														|  | 
 |  | +                                    rollBackOrderScrm(orderNumber, failMsg);
 | 
											
												
													
														|  | 
 |  | +                                } catch (Exception e) {
 | 
											
												
													
														|  | 
 |  | +                                    log.info("{}订单获取运单失败,订单状态回滚失败,失败原因:{},失败信息为:{}", orderNumber,e.getMessage(),failMsg);
 | 
											
												
													
														|  | 
 |  | +                                }
 | 
											
												
													
														|  | 
 |  | +                            } else {
 | 
											
												
													
														|  | 
 |  | +                                setExpressScrm(bspOrderResponse);
 | 
											
												
													
														|  | 
 |  | +                            }
 | 
											
												
													
														|  | 
 |  | +                        }
 | 
											
												
													
														|  | 
 |  | +                    } else if ("2".equals(status)) {
 | 
											
												
													
														|  | 
 |  | +                        //取消订单
 | 
											
												
													
														|  | 
 |  | +                        DFCancelOrderResultResponse cancelResponse = JSONUtil.toBean(jsonString, DFCancelOrderResultResponse.class);
 | 
											
												
													
														|  | 
 |  | +                        if (cancelResponse != null) {
 | 
											
												
													
														|  | 
 |  | +                            if (cancelResponse.getIsCancelSuss() == 1) {
 | 
											
												
													
														|  | 
 |  | +                                log.info("查询订单取消成功,返回结果{}", JSON.toJSONString(cancelResponse));
 | 
											
												
													
														|  | 
 |  | +                            } else {
 | 
											
												
													
														|  | 
 |  | +                                log.info("查询订单取消失败,返回结果{}", JSON.toJSONString(cancelResponse));
 | 
											
												
													
														|  | 
 |  | +                            }
 | 
											
												
													
														|  | 
 |  | +                        }
 | 
											
												
													
														|  | 
 |  | +                    }
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                log.info(String.format("查询订单失败,原因: %s", dfApiResponse.getMsg()));
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +        } catch (IOException e) {
 | 
											
												
													
														|  | 
 |  | +            e.printStackTrace();
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private void rollBackOrder(String orderNumber, String failMsg) {
 | 
											
												
													
														|  |          FsStoreOrder fsStoreOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderCode(orderNumber);
 |  |          FsStoreOrder fsStoreOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderCode(orderNumber);
 | 
											
												
													
														|  |          FsStoreOrder tempOrder = new FsStoreOrder();
 |  |          FsStoreOrder tempOrder = new FsStoreOrder();
 | 
											
												
													
														|  |          tempOrder.setOrderId(fsStoreOrder.getOrderId());
 |  |          tempOrder.setOrderId(fsStoreOrder.getOrderId());
 | 
											
										
											
												
													
														|  | @@ -857,6 +957,24 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |          df.setFailMsg(failMsg); //失败消息
 |  |          df.setFailMsg(failMsg); //失败消息
 | 
											
												
													
														|  |          df.setUpdateTime(new Date());
 |  |          df.setUpdateTime(new Date());
 | 
											
												
													
														|  |          fsStoreOrderDfMapper.updateFsStoreOrderDf(df);
 |  |          fsStoreOrderDfMapper.updateFsStoreOrderDf(df);
 | 
											
												
													
														|  | 
 |  | +        log.info("{}订单获取运单失败,失败信息为:{}", orderNumber,failMsg);
 | 
											
												
													
														|  | 
 |  | +        //推送失败消息
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private void rollBackOrderScrm(String orderNumber, String failMsg) {
 | 
											
												
													
														|  | 
 |  | +        FsStoreOrderScrm fsStoreOrder = fsStoreOrderScrmMapper.selectFsStoreOrderByOrderCode(orderNumber);
 | 
											
												
													
														|  | 
 |  | +        FsStoreOrderScrm tempOrder = new FsStoreOrderScrm();
 | 
											
												
													
														|  | 
 |  | +        tempOrder.setId(fsStoreOrder.getId());
 | 
											
												
													
														|  | 
 |  | +        tempOrder.setExtendOrderId("");
 | 
											
												
													
														|  | 
 |  | +        tempOrder.setDeliveryId("");
 | 
											
												
													
														|  | 
 |  | +        fsStoreOrderScrmMapper.updateFsStoreOrder(tempOrder);
 | 
											
												
													
														|  | 
 |  | +        FsStoreOrderDf df = new FsStoreOrderDf();
 | 
											
												
													
														|  | 
 |  | +        df.setOrderId(fsStoreOrder.getId());
 | 
											
												
													
														|  | 
 |  | +        df.setStatus(OrderInfoEnum.STATUS_1.getValue()); //回到默认
 | 
											
												
													
														|  | 
 |  | +        df.setFailMsg(failMsg); //失败消息
 | 
											
												
													
														|  | 
 |  | +        df.setUpdateTime(new Date());
 | 
											
												
													
														|  | 
 |  | +        fsStoreOrderDfMapper.updateFsStoreOrderDf(df);
 | 
											
												
													
														|  | 
 |  | +        log.info("{}订单获取运单失败,失败信息为:{}", orderNumber,failMsg);
 | 
											
												
													
														|  |          //推送失败消息
 |  |          //推送失败消息
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -931,4 +1049,79 @@ public class DfOrderServiceImpl implements IErpOrderService
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    /**
 | 
											
												
													
														|  | 
 |  | +     * 顺丰会有自己的轨迹推送 不使用快递鸟(代服务管家设置推送地址)
 | 
											
												
													
														|  | 
 |  | +     *
 | 
											
												
													
														|  | 
 |  | +     * @param bspResponse
 | 
											
												
													
														|  | 
 |  | +     */
 | 
											
												
													
														|  | 
 |  | +    private void setExpressScrm(BspOrderResponseWrapper bspResponse) {
 | 
											
												
													
														|  | 
 |  | +        String orderNumber = bspResponse.getOrderNumber();
 | 
											
												
													
														|  | 
 |  | +        //快递单号
 | 
											
												
													
														|  | 
 |  | +        String mailNumber = bspResponse.getMailNumber();
 | 
											
												
													
														|  | 
 |  | +        //快递名字
 | 
											
												
													
														|  | 
 |  | +        BspOrderResponse bspOrderResponse = bspResponse.getBspResponse();
 | 
											
												
													
														|  | 
 |  | +        if (bspOrderResponse != null) {
 | 
											
												
													
														|  | 
 |  | +            AtomicBoolean flag = new AtomicBoolean(false);
 | 
											
												
													
														|  | 
 |  | +            List<OrderResponse> list = bspOrderResponse.getBody();
 | 
											
												
													
														|  | 
 |  | +            if (list != null && !list.isEmpty()) {
 | 
											
												
													
														|  | 
 |  | +                for (OrderResponse orderResponse : list) {
 | 
											
												
													
														|  | 
 |  | +                    List<RlsInfo> rlsInfo = orderResponse.getRlsInfo();
 | 
											
												
													
														|  | 
 |  | +                    if (rlsInfo != null && !rlsInfo.isEmpty()) {
 | 
											
												
													
														|  | 
 |  | +                        for (RlsInfo info : rlsInfo) {
 | 
											
												
													
														|  | 
 |  | +                            List<RlsDetail> rlsDetails = info.getRlsDetail();
 | 
											
												
													
														|  | 
 |  | +                            if (rlsDetails != null && !rlsDetails.isEmpty()) {
 | 
											
												
													
														|  | 
 |  | +                                for (RlsDetail rlsDetail : rlsDetails) {
 | 
											
												
													
														|  | 
 |  | +                                    String proCode = rlsDetail.getProCode();
 | 
											
												
													
														|  | 
 |  | +                                    if (StringUtils.isNotBlank(proCode)) {
 | 
											
												
													
														|  | 
 |  | +                                        FsStoreOrderScrm order = fsStoreOrderScrmMapper.selectFsStoreOrderByOrderCode(orderNumber);
 | 
											
												
													
														|  | 
 |  | +                                        if (order != null && order.getStatus() == OrderInfoEnum.STATUS_1.getValue()) {
 | 
											
												
													
														|  | 
 |  | +                                            FsExpressScrm express = expressScrmService.selectFsExpressByOmsCode(order.getDeliveryCode());
 | 
											
												
													
														|  | 
 |  | +                                            if (express != null) {
 | 
											
												
													
														|  | 
 |  | +                                                order.setDeliveryName(proCode);
 | 
											
												
													
														|  | 
 |  | +                                                order.setDeliverySn(express.getOmsCode());
 | 
											
												
													
														|  | 
 |  | +                                            }
 | 
											
												
													
														|  | 
 |  | +                                            order.setStatus(OrderInfoEnum.STATUS_2.getValue());
 | 
											
												
													
														|  | 
 |  | +                                            order.setDeliveryId(mailNumber);
 | 
											
												
													
														|  | 
 |  | +                                            order.setDeliverySendTime(new Date());
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                                            fsStoreOrderScrmMapper.updateFsStoreOrder(order);
 | 
											
												
													
														|  | 
 |  | +                                            fsStoreOrderScrmLogsService.create(order.getId(), FsStoreOrderLogEnum.DELIVERY_GOODS.getValue(), FsStoreOrderLogEnum.DELIVERY_GOODS.getDesc());
 | 
											
												
													
														|  | 
 |  | +                                            //订阅物流回调
 | 
											
												
													
														|  | 
 |  | +//                                            String lastFourNumber = "";
 | 
											
												
													
														|  | 
 |  | +//                                            if (order.getDeliverySn().equals(ShipperCodeEnum.SF.getValue())) {
 | 
											
												
													
														|  | 
 |  | +//                                                lastFourNumber = order.getUserPhone();
 | 
											
												
													
														|  | 
 |  | +//                                                if (lastFourNumber.length() == 11) {
 | 
											
												
													
														|  | 
 |  | +//                                                    lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
 | 
											
												
													
														|  | 
 |  | +//                                                }
 | 
											
												
													
														|  | 
 |  | +//                                            }
 | 
											
												
													
														|  | 
 |  | +//                                            expressService.subscribeEspress(order.getOrderCode(), order.getDeliverySn(), order.getDeliveryId(), lastFourNumber);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +//                                            TemplateBean templateBean = TemplateBean.builder()
 | 
											
												
													
														|  | 
 |  | +//                                                    .orderId(order.getId().toString())
 | 
											
												
													
														|  | 
 |  | +//                                                    .orderCode(order.getOrderCode().toString())
 | 
											
												
													
														|  | 
 |  | +//                                                    .deliveryId(order.getDeliveryId())
 | 
											
												
													
														|  | 
 |  | +//                                                    .deliveryName(order.getDeliveryName())
 | 
											
												
													
														|  | 
 |  | +//                                                    .userId(order.getUserId())
 | 
											
												
													
														|  | 
 |  | +//                                                    .templateType(TemplateListenEnum.TYPE_2.getValue())
 | 
											
												
													
														|  | 
 |  | +//                                                    .build();
 | 
											
												
													
														|  | 
 |  | +//                                            publisher.publishEvent(new TemplateEvent(this, templateBean));
 | 
											
												
													
														|  | 
 |  | +                                        }
 | 
											
												
													
														|  | 
 |  | +                                        flag.set(true);
 | 
											
												
													
														|  | 
 |  | +                                    }
 | 
											
												
													
														|  | 
 |  | +                                    break;
 | 
											
												
													
														|  | 
 |  | +                                }
 | 
											
												
													
														|  | 
 |  | +                            }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                        }
 | 
											
												
													
														|  | 
 |  | +                        if (flag.get()) {
 | 
											
												
													
														|  | 
 |  | +                            break;
 | 
											
												
													
														|  | 
 |  | +                        }
 | 
											
												
													
														|  | 
 |  | +                    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  }
 |  |  }
 |