|  | @@ -103,6 +103,7 @@ import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
 | 
	
		
			
				|  |  |  import com.github.binarywang.wxpay.config.WxPayConfig;
 | 
	
		
			
				|  |  |  import com.github.binarywang.wxpay.exception.WxPayException;
 | 
	
		
			
				|  |  |  import com.github.binarywang.wxpay.service.WxPayService;
 | 
	
		
			
				|  |  | +import jodd.util.StringUtil;
 | 
	
		
			
				|  |  |  import lombok.Synchronized;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  |  import me.chanjar.weixin.common.error.WxErrorException;
 | 
	
	
		
			
				|  | @@ -394,11 +395,14 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public int updateFsStoreOrder(FsStoreOrderScrm fsStoreOrder) {
 | 
	
		
			
				|  |  |          fsStoreOrder.setUpdateTime(DateUtils.getNowDate());
 | 
	
		
			
				|  |  | -        //推送修改的商城订单地址到聚水潭ERP
 | 
	
		
			
				|  |  | -        try {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        FsStoreOrderScrm order = fsStoreOrderMapper.selectFsStoreOrderById(fsStoreOrder.getId());
 | 
	
		
			
				|  |  | +        if(ObjectUtil.isNull(order)) {
 | 
	
		
			
				|  |  | +            throw new IllegalArgumentException("ERP单号不存在!");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //推送修改的商城订单地址到聚水潭ERP 如果地址变化
 | 
	
		
			
				|  |  | +        if(!StringUtil.equals(fsStoreOrder.getUserAddress(),order.getUserAddress())){
 | 
	
		
			
				|  |  |              pushOrderAddressToErp(fsStoreOrder);
 | 
	
		
			
				|  |  | -        }catch (Exception e){
 | 
	
		
			
				|  |  | -            log.error("修改商城订单地址推送到聚水潭ERP失败,orderId: {}", fsStoreOrder.getId(), e);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return fsStoreOrderMapper.updateFsStoreOrder(fsStoreOrder);
 | 
	
	
		
			
				|  | @@ -410,8 +414,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public void pushOrderAddressToErp(FsStoreOrderScrm partialOrder) {
 | 
	
		
			
				|  |  |          if (partialOrder == null || partialOrder.getId() == null) {
 | 
	
		
			
				|  |  | -            log.info("传入订单为空或ID缺失,跳过ERP同步");
 | 
	
		
			
				|  |  | -            return;
 | 
	
		
			
				|  |  | +            log.error("传入订单为空或ID缺失,跳过ERP同步");
 | 
	
		
			
				|  |  | +            throw new IllegalArgumentException("传入订单为空或ID缺失!");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 1. 检查 ERP 是否开启
 | 
	
	
		
			
				|  | @@ -423,12 +427,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          Integer erpType = sysConfig.getErpType();
 | 
	
		
			
				|  |  |          if (erpType == null || !erpServiceMap.containsKey(erpType)) {
 | 
	
		
			
				|  |  | -            log.info("ERP类型配置无效: {}", erpType);
 | 
	
		
			
				|  |  | -            return;
 | 
	
		
			
				|  |  | +            log.error("ERP类型配置无效: {}", erpType);
 | 
	
		
			
				|  |  | +            throw new IllegalArgumentException(String.format("ERP类型配置无效: %d", erpType));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //目前只针对聚水潭ERP推送最新的修改地址
 | 
	
		
			
				|  |  |          if (erpType != 5){
 | 
	
		
			
				|  |  | -            return;
 | 
	
		
			
				|  |  | +            throw new IllegalArgumentException("目前只支持JST ERP 请联系管理员!");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // 2. 从数据库获取完整订单(用于补全必要字段;当前是修改商城订单接口,查询fs_store_order_scrm表)
 | 
	
		
			
				|  |  |          FsStoreOrderScrm dbOrder = fsStoreOrderMapper.selectFsStoreOrderById(partialOrder.getId());
 | 
	
	
		
			
				|  | @@ -439,12 +443,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 | 
	
		
			
				|  |  |          //判断当前是否满足推送条件(erp订单号不为空且订单状态为待发货时可推送)
 | 
	
		
			
				|  |  |          if (StringUtils.isBlank(dbOrder.getExtendOrderId()) || dbOrder.getStatus() != 1) {
 | 
	
		
			
				|  |  |              log.info("不满足修改订单地址推送到ERP条件: extendOrderId={}, status={}", dbOrder.getExtendOrderId(), dbOrder.getStatus());
 | 
	
		
			
				|  |  | -            return;
 | 
	
		
			
				|  |  | +            throw new RuntimeException("只支持待发货修改地址!");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // 3. 构造用于ERP推送的订单对象:订单地址用传入的新值
 | 
	
		
			
				|  |  |          if (StrUtil.isBlank(partialOrder.getUserAddress())){
 | 
	
		
			
				|  |  |              log.error("修改商城订单地址为空,orderId: {}", partialOrder.getId());
 | 
	
		
			
				|  |  | -            return;
 | 
	
		
			
				|  |  | +            throw new IllegalArgumentException("修改商城订单地址为空!");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          dbOrder.setUserAddress(partialOrder.getUserAddress());
 | 
	
		
			
				|  |  |          try {
 | 
	
	
		
			
				|  | @@ -459,6 +463,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 | 
	
		
			
				|  |  |                      dbOrder.getOrderCode(), erpType, response.getSuccess(), response.getCode());
 | 
	
		
			
				|  |  |          } catch (Exception e) {
 | 
	
		
			
				|  |  |              log.error("修改商城订单地址推送到ERP失败,orderId: {}", partialOrder.getId(), e);
 | 
	
		
			
				|  |  | +            throw new RuntimeException("修改地址失败!",e);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |