|  | @@ -1,15 +1,5 @@
 | 
	
		
			
				|  |  |  package com.fs.store.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import java.lang.reflect.Field;
 | 
	
		
			
				|  |  | -import java.math.BigDecimal;
 | 
	
		
			
				|  |  | -import java.nio.charset.Charset;
 | 
	
		
			
				|  |  | -import java.sql.Timestamp;
 | 
	
		
			
				|  |  | -import java.text.ParseException;
 | 
	
		
			
				|  |  | -import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | -import java.util.*;
 | 
	
		
			
				|  |  | -import java.util.concurrent.TimeUnit;
 | 
	
		
			
				|  |  | -import java.util.stream.Collectors;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  import cn.hutool.core.net.URLDecoder;
 | 
	
		
			
				|  |  |  import cn.hutool.core.util.IdUtil;
 | 
	
		
			
				|  |  |  import cn.hutool.core.util.NumberUtil;
 | 
	
	
		
			
				|  | @@ -41,6 +31,7 @@ import com.fs.company.service.ICompanyService;
 | 
	
		
			
				|  |  |  import com.fs.company.service.ICompanyUserService;
 | 
	
		
			
				|  |  |  import com.fs.erp.domain.*;
 | 
	
		
			
				|  |  |  import com.fs.erp.dto.*;
 | 
	
		
			
				|  |  | +import com.fs.erp.mapper.FsErpFinishPushMapper;
 | 
	
		
			
				|  |  |  import com.fs.erp.service.IErpGoodsService;
 | 
	
		
			
				|  |  |  import com.fs.erp.service.IErpOrderService;
 | 
	
		
			
				|  |  |  import com.fs.his.config.FsErpConfig;
 | 
	
	
		
			
				|  | @@ -50,6 +41,7 @@ import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 | 
	
		
			
				|  |  |  import com.fs.huifuPay.service.HuiFuService;
 | 
	
		
			
				|  |  |  import com.fs.pay.pay.domain.RefundResult;
 | 
	
		
			
				|  |  |  import com.fs.pay.pay.service.PayService;
 | 
	
		
			
				|  |  | +import com.fs.pay.service.IPayService;
 | 
	
		
			
				|  |  |  import com.fs.store.config.StoreConfig;
 | 
	
		
			
				|  |  |  import com.fs.store.config.StoreIntegralConfig;
 | 
	
		
			
				|  |  |  import com.fs.store.constants.StoreConstants;
 | 
	
	
		
			
				|  | @@ -58,11 +50,11 @@ import com.fs.store.dto.*;
 | 
	
		
			
				|  |  |  import com.fs.store.enums.*;
 | 
	
		
			
				|  |  |  import com.fs.store.mapper.FsStoreCartMapper;
 | 
	
		
			
				|  |  |  import com.fs.store.mapper.FsStoreOrderItemMapper;
 | 
	
		
			
				|  |  | +import com.fs.store.mapper.FsStoreOrderMapper;
 | 
	
		
			
				|  |  |  import com.fs.store.mapper.FsUserAddressMapper;
 | 
	
		
			
				|  |  |  import com.fs.store.param.*;
 | 
	
		
			
				|  |  |  import com.fs.store.service.*;
 | 
	
		
			
				|  |  |  import com.fs.store.vo.*;
 | 
	
		
			
				|  |  | -import com.fs.pay.service.IPayService;
 | 
	
		
			
				|  |  |  import com.fs.system.service.ISysConfigService;
 | 
	
		
			
				|  |  |  import com.fs.wx.pay.config.WxPayProperties;
 | 
	
		
			
				|  |  |  import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
 | 
	
	
		
			
				|  | @@ -80,15 +72,24 @@ import org.springframework.aop.framework.AopContext;
 | 
	
		
			
				|  |  |  import org.springframework.beans.BeanUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Qualifier;
 | 
	
		
			
				|  |  | -import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  |  import org.springframework.context.ApplicationEventPublisher;
 | 
	
		
			
				|  |  |  import org.springframework.context.annotation.EnableAspectJAutoProxy;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | -import com.fs.store.mapper.FsStoreOrderMapper;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Propagation;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.interceptor.TransactionAspectSupport;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.lang.reflect.Field;
 | 
	
		
			
				|  |  | +import java.math.BigDecimal;
 | 
	
		
			
				|  |  | +import java.nio.charset.Charset;
 | 
	
		
			
				|  |  | +import java.sql.Timestamp;
 | 
	
		
			
				|  |  | +import java.text.ParseException;
 | 
	
		
			
				|  |  | +import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | +import java.time.LocalDateTime;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  | +import java.util.concurrent.TimeUnit;
 | 
	
		
			
				|  |  | +import java.util.stream.Collectors;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  import static com.fs.store.constants.StoreConstants.DELIVERY;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
	
		
			
				|  | @@ -196,6 +197,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private WxPayProperties wxPayProperties;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private FsErpFinishPushMapper fsErpFinishPushMapper;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      @Qualifier("erpOrderServiceImpl")
 | 
	
		
			
				|  |  |      private IErpOrderService gyOrderService;
 | 
	
	
		
			
				|  | @@ -207,6 +211,12 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      @Qualifier("k9OrderServiceImpl")
 | 
	
		
			
				|  |  |      private IErpOrderService k9OrderService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private IFsStoreOrderAuditService orderAuditService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private IFsStoreOrderAuditLogService orderAuditLogService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询订单
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -552,21 +562,34 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |                  storeOrder.setServiceFee(config.getServiceFee());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            //后台制单处理
 | 
	
		
			
				|  |  | +            if(param.getPayPrice()!=null&¶m.getPayPrice().compareTo(BigDecimal.ZERO)>0){
 | 
	
		
			
				|  |  | +                if (param.getPayPrice().compareTo(dto.getTotalPrice()) > 0) {
 | 
	
		
			
				|  |  | +                    return R.error("改价价格不能大于商品总价");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                storeOrder.setPayPrice(param.getPayPrice());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else{
 | 
	
		
			
				|  |  | +                storeOrder.setPayPrice(dto.getPayPrice());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            //付款方式
 | 
	
		
			
				|  |  |              if(param.getPayType().equals("1")){
 | 
	
		
			
				|  |  |                  //全款支付
 | 
	
		
			
				|  |  |                  storeOrder.setStatus(0);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              else if(param.getPayType().equals("2")){
 | 
	
		
			
				|  |  | -                //货到付款
 | 
	
		
			
				|  |  | +                //物流代收
 | 
	
		
			
				|  |  |                  storeOrder.setStatus(1);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            //后台制单处理
 | 
	
		
			
				|  |  | -            if(param.getPayPrice()!=null&¶m.getPayPrice().compareTo(BigDecimal.ZERO)>0){
 | 
	
		
			
				|  |  | -                storeOrder.setPayPrice(param.getPayPrice());
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else{
 | 
	
		
			
				|  |  | -                storeOrder.setPayPrice(dto.getPayPrice());
 | 
	
		
			
				|  |  | +            else if(param.getPayType().equals("3")){
 | 
	
		
			
				|  |  | +                //货到付款
 | 
	
		
			
				|  |  | +                storeOrder.setStatus(1);
 | 
	
		
			
				|  |  | +                BigDecimal amount = param.getAmount();  //货到付款 自定义代收金额
 | 
	
		
			
				|  |  | +                if (amount != null && amount.compareTo(BigDecimal.ZERO) > 0){
 | 
	
		
			
				|  |  | +                    storeOrder.setPayMoney(amount);
 | 
	
		
			
				|  |  | +                    storeOrder.setPayDelivery(storeOrder.getPayPrice().subtract(amount) );
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              storeOrder.setOrderCreateType(param.getOrderCreateType());
 | 
	
		
			
				|  |  |              Long prescribe = carts.stream().filter(item -> item.getProductType()!=null&&item.getProductType()==2).count();
 | 
	
	
		
			
				|  | @@ -575,6 +598,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  storeOrder.setIsPrescribe(0);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            if (storeOrder.getCustomerId() == null){
 | 
	
		
			
				|  |  | +                storeOrder.setCustomerId(param.getCustomerId());//6.13 添加客户id
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              Integer flag=fsStoreOrderMapper.insertFsStoreOrder(storeOrder);
 | 
	
		
			
				|  |  |              if (flag==0) {
 | 
	
		
			
				|  |  |                  return R.error("订单创建失败");
 | 
	
	
		
			
				|  | @@ -651,7 +677,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |              //添加支付到期时间
 | 
	
		
			
				|  |  |              Calendar calendar = Calendar.getInstance();
 | 
	
		
			
				|  |  |              calendar.setTime(storeOrder.getCreateTime());
 | 
	
		
			
				|  |  | -            calendar.add(Calendar.MINUTE,config.getUnPayTime());
 | 
	
		
			
				|  |  | +            if (config.getUnPayTime() != null){
 | 
	
		
			
				|  |  | +                calendar.add(Calendar.MINUTE,config.getUnPayTime());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  |              String payLimitTime = format.format(calendar.getTime() );
 | 
	
		
			
				|  |  |              //删除推荐订单KEY
 | 
	
	
		
			
				|  | @@ -977,6 +1005,8 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |              createParam.setCompanyUserId(param.getCompanyUserId());
 | 
	
		
			
				|  |  |              createParam.setPaymentId(param.getPaymentId());
 | 
	
		
			
				|  |  |              createParam.setPayPrice(param.getPayPrice());
 | 
	
		
			
				|  |  | +            createParam.setCustomerId(param.getCustomerId());
 | 
	
		
			
				|  |  | +            createParam.setAmount(param.getAmount());
 | 
	
		
			
				|  |  |              return this.createOrder(param.getUserId(),createParam);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          else{
 | 
	
	
		
			
				|  | @@ -1245,6 +1275,18 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//            // 同步订单完成状态到erp
 | 
	
		
			
				|  |  | +//            // 如果是线上支付
 | 
	
		
			
				|  |  | +//            if("1".equals(order.getPayType())){
 | 
	
		
			
				|  |  | +//                FsErpFinishPush fsErpFinishPush = new FsErpFinishPush();
 | 
	
		
			
				|  |  | +//                fsErpFinishPush.setOrderId(orderId);
 | 
	
		
			
				|  |  | +//                fsErpFinishPush.setTaskStatus(0);
 | 
	
		
			
				|  |  | +//                fsErpFinishPush.setRetryCount(0);
 | 
	
		
			
				|  |  | +//                fsErpFinishPush.setCreateTime(new Date());
 | 
	
		
			
				|  |  | +//                fsErpFinishPushMapper.insert(fsErpFinishPush);
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              //模板消息支付成功发布事件
 | 
	
		
			
				|  |  |              TemplateBean templateBean = TemplateBean.builder()
 | 
	
		
			
				|  |  |                      .orderId(order.getId().toString())
 | 
	
	
		
			
				|  | @@ -1323,6 +1365,12 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |              storeOrder.setStatus(OrderInfoEnum.STATUS_1.getValue());
 | 
	
		
			
				|  |  |              storeOrder.setPayTime(new Date());
 | 
	
		
			
				|  |  |              fsStoreOrderMapper.updateFsStoreOrder(storeOrder);
 | 
	
		
			
				|  |  | +            // 添加订单审核
 | 
	
		
			
				|  |  | +            addOrderAudit(order);
 | 
	
		
			
				|  |  | +            return "SUCCESS";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              //非处方直接提交OMS
 | 
	
		
			
				|  |  |  //            if(order.getIsPrescribe().equals(0)){
 | 
	
		
			
				|  |  |  //                createOmsOrder(order.getId());
 | 
	
	
		
			
				|  | @@ -1341,9 +1389,46 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |  //            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 | 
	
		
			
				|  |  |  //            return "";
 | 
	
		
			
				|  |  |  //        }
 | 
	
		
			
				|  |  | -        return "SUCCESS";
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 添加审核
 | 
	
		
			
				|  |  | +     * @param order 订单信息
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void addOrderAudit(FsStoreOrder order) {
 | 
	
		
			
				|  |  | +        if (!getAuditSwitch()) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        FsStoreOrderAudit orderAudit = new FsStoreOrderAudit();
 | 
	
		
			
				|  |  | +        orderAudit.setOrderId(order.getId());
 | 
	
		
			
				|  |  | +        orderAudit.setCompanyId(order.getCompanyId());
 | 
	
		
			
				|  |  | +        orderAudit.setCompanyUserId(order.getCompanyUserId());
 | 
	
		
			
				|  |  | +        orderAudit.setAuditStatus(OrderAuditStateEnum.COMPANY_PENDING.getValue());
 | 
	
		
			
				|  |  | +        orderAudit.setCreateTime(LocalDateTime.now());
 | 
	
		
			
				|  |  | +        orderAuditService.save(orderAudit);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        FsStoreOrderAuditLog auditLog = new FsStoreOrderAuditLog();
 | 
	
		
			
				|  |  | +        auditLog.setAuditId(orderAudit.getId());
 | 
	
		
			
				|  |  | +        auditLog.setOrderId(order.getId());
 | 
	
		
			
				|  |  | +        auditLog.setContent("系统:提交审核");
 | 
	
		
			
				|  |  | +        auditLog.setCreateTime(LocalDateTime.now());
 | 
	
		
			
				|  |  | +        orderAuditLogService.save(auditLog);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 获取是否需要订单审核
 | 
	
		
			
				|  |  | +     * @return boolean
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private boolean getAuditSwitch() {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            String json = configService.selectConfigByKey("store.config");
 | 
	
		
			
				|  |  | +            StoreConfig config = JSONUtil.toBean(json,StoreConfig.class);
 | 
	
		
			
				|  |  | +            return config.getAuditSwitch() == 1;
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            return false;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public  boolean containsAddress(String companyName) {
 | 
	
		
			
				|  |  |          String[] items= {"新疆","西藏","内蒙古","海南"};
 | 
	
	
		
			
				|  | @@ -1395,18 +1480,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |              erpOrder.setVip_code(order.getUserId().toString());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          erpOrder.setPlatform_code(order.getOrderCode());
 | 
	
		
			
				|  |  | -//        if(order.getStoreHouseCode()==null){
 | 
	
		
			
				|  |  | -//            erpOrder.setWarehouse_code("CQDS001");
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//        else{
 | 
	
		
			
				|  |  | -            erpOrder.setWarehouse_code(erpConfig.getErpWarehouseCode());
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//        if(order.getStoreHouseCode().equals("YDSP001")){
 | 
	
		
			
				|  |  | -//            erpOrder.setShop_code("RunDayWuHan");
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//        else{
 | 
	
		
			
				|  |  | -            erpOrder.setShop_code(erpConfig.getErpShopCode());
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | +        erpOrder.setWarehouse_code(erpConfig.getErpWarehouseCode());
 | 
	
		
			
				|  |  | +        erpOrder.setShop_code(erpConfig.getErpShopCode());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  //      erpOrder.setPost_fee(order.getTotalPostage().doubleValue());
 | 
	
		
			
				|  |  |          erpOrder.setSeller_memo(order.getMark());
 | 
	
		
			
				|  |  |          // order.setCurrency_code("JCZD");
 | 
	
	
		
			
				|  | @@ -1423,114 +1499,19 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |              payment.setPaytime(new Timestamp(timeLong));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          payments.add(payment);
 | 
	
		
			
				|  |  | -        //1.新疆、西藏、内蒙古、海南的订单(代收+非代收)全部发EMS
 | 
	
		
			
				|  |  | -        //2.全款订单选择中通,快递ID 452  ZTO 中通商城标快 ZTBK.17782167502
 | 
	
		
			
				|  |  | -        //3.新疆  西藏 内蒙古 海南  全款订单走顺丰丰云配  【非全款】的就根据公司配置那来 配的哪个走哪个快递
 | 
	
		
			
				|  |  | -        //4.把现在发中通的规则改成发顺丰风云配 SF.0235402855
 | 
	
		
			
				|  |  | -        //5.全款支付且应付金额小于等于100元,快递方式默认中通小件455 ZTO 中通小件 ZTPDD
 | 
	
		
			
				|  |  | -        if(order.getCompanyId()!=null&& order.getStoreHouseCode()!=null&& order.getStoreHouseCode().equals("WHSP001")){
 | 
	
		
			
				|  |  | -            //杭州家有仙妻实业有限公司 全部订单快递方式设置为商城德邦快递
 | 
	
		
			
				|  |  | -            FsExpress express=expressService.selectFsExpressByOmsCode("SF-WHC");
 | 
	
		
			
				|  |  | +        if(order.getCompanyId()!=null){
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            FsExpress  express=expressService.selectFsExpressByOmsCode("SF");
 | 
	
		
			
				|  |  |              erpOrder.setExpress_code(express.getOmsCode());
 | 
	
		
			
				|  |  |              order.setDeliveryName(express.getName());
 | 
	
		
			
				|  |  |              order.setDeliverySn(express.getCode());
 | 
	
		
			
				|  |  | -            if(order.getPayDelivery().compareTo(new BigDecimal(0))==0){
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else{
 | 
	
		
			
				|  |  | -                //物流代收金额
 | 
	
		
			
				|  |  | -                ErpOrderPayment codPayment=new ErpOrderPayment();
 | 
	
		
			
				|  |  | -                codPayment.setPay_type_code("cod");
 | 
	
		
			
				|  |  | -                codPayment.setPayment(order.getPayDelivery().doubleValue());
 | 
	
		
			
				|  |  | -                payments.add(codPayment);
 | 
	
		
			
				|  |  | -                erpOrder.setCod(true);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else if(order.getCompanyId()!=null){
 | 
	
		
			
				|  |  | -            Company company = companyService.selectCompanyById(order.getCompanyId());
 | 
	
		
			
				|  |  | -            if (order.getPayDelivery().compareTo(new BigDecimal(0)) == 0) {  //没有物流代收(全款订单)
 | 
	
		
			
				|  |  | -                FsExpress express = new FsExpress();
 | 
	
		
			
				|  |  | -                //express=expressService.selectFsExpressByOmsCode("SF.0235402855");
 | 
	
		
			
				|  |  | -                if(order.getPayPrice().compareTo(new BigDecimal(100))<=0){
 | 
	
		
			
				|  |  | -                    express=expressService.selectFsExpressByOmsCode("ZTPDD");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else{
 | 
	
		
			
				|  |  | -                    boolean found = containsAddress(order.getUserAddress());
 | 
	
		
			
				|  |  | -                    if(found){
 | 
	
		
			
				|  |  | -                        express=expressService.selectFsExpressByOmsCode("SF.0235402855");
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else{
 | 
	
		
			
				|  |  | -                        express=expressService.selectFsExpressByOmsCode("SF.0235402855");
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                erpOrder.setExpress_code(express.getOmsCode());
 | 
	
		
			
				|  |  | -                order.setDeliveryName(express.getName());
 | 
	
		
			
				|  |  | -                order.setDeliverySn(express.getCode());
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else {
 | 
	
		
			
				|  |  | -                FsExpress express = new FsExpress();
 | 
	
		
			
				|  |  | -                boolean found = containsAddress(order.getUserAddress());
 | 
	
		
			
				|  |  | -                if(found){
 | 
	
		
			
				|  |  | -                    if(StringUtils.isNotEmpty(company.getOmsCode())){
 | 
	
		
			
				|  |  | -                        express = expressService.selectFsExpressByOmsCode(company.getOmsCode());
 | 
	
		
			
				|  |  | -                    }else{
 | 
	
		
			
				|  |  | -                        express=expressService.selectFsExpressByOmsCode("EMS.1");
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else{
 | 
	
		
			
				|  |  | -                    if(StringUtils.isNotEmpty(company.getOmsCode())){
 | 
	
		
			
				|  |  | -                        express = expressService.selectFsExpressByOmsCode(company.getOmsCode());
 | 
	
		
			
				|  |  | -                    }else{
 | 
	
		
			
				|  |  | -                        express = expressService.selectFsExpressByOmsCode("SF.0235402855");
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                erpOrder.setExpress_code(express.getOmsCode());
 | 
	
		
			
				|  |  | -                order.setDeliveryName(express.getName());
 | 
	
		
			
				|  |  | -                order.setDeliverySn(express.getCode());
 | 
	
		
			
				|  |  | -                //物流代收金额
 | 
	
		
			
				|  |  | -                ErpOrderPayment codPayment = new ErpOrderPayment();
 | 
	
		
			
				|  |  | -                codPayment.setPay_type_code("cod");
 | 
	
		
			
				|  |  | -                codPayment.setPayment(order.getPayDelivery().doubleValue());
 | 
	
		
			
				|  |  | -                payments.add(codPayment);
 | 
	
		
			
				|  |  | -                erpOrder.setCod(true);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          else{
 | 
	
		
			
				|  |  | -            if(order.getPayDelivery().compareTo(new BigDecimal(0))==0){  //没有物流代收(全款订单)
 | 
	
		
			
				|  |  | -                FsExpress express=new FsExpress();
 | 
	
		
			
				|  |  | -                if(order.getPayPrice().compareTo(new BigDecimal(100))<=0){
 | 
	
		
			
				|  |  | -                    express=expressService.selectFsExpressByOmsCode("ZTPDD");
 | 
	
		
			
				|  |  | -                }else{
 | 
	
		
			
				|  |  | -                    boolean found = containsAddress(order.getUserAddress());
 | 
	
		
			
				|  |  | -                    if(found){
 | 
	
		
			
				|  |  | -                        express=expressService.selectFsExpressByOmsCode("SF.0235402855");
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else{
 | 
	
		
			
				|  |  | -                        express=expressService.selectFsExpressByOmsCode("SF.0235402855");
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                erpOrder.setExpress_code(express.getOmsCode());
 | 
	
		
			
				|  |  | -                order.setDeliveryName(express.getName());
 | 
	
		
			
				|  |  | -                order.setDeliverySn(express.getCode());
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else{
 | 
	
		
			
				|  |  | -                ErpOrderPayment codPayment=new ErpOrderPayment();
 | 
	
		
			
				|  |  | -                codPayment.setPay_type_code("cod");
 | 
	
		
			
				|  |  | -                codPayment.setPayment(order.getPayDelivery().doubleValue());
 | 
	
		
			
				|  |  | -                payments.add(codPayment);
 | 
	
		
			
				|  |  | -                erpOrder.setCod(true);
 | 
	
		
			
				|  |  | -                FsExpress express=new FsExpress();
 | 
	
		
			
				|  |  | -                boolean found = containsAddress(order.getUserAddress());
 | 
	
		
			
				|  |  | -                if(found){
 | 
	
		
			
				|  |  | -                    express=expressService.selectFsExpressByOmsCode("EMS.1");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else {
 | 
	
		
			
				|  |  | -                    express=expressService.selectFsExpressByOmsCode("SF.0235402855");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                erpOrder.setExpress_code(express.getOmsCode());
 | 
	
		
			
				|  |  | -                order.setDeliveryName(express.getName());
 | 
	
		
			
				|  |  | -                order.setDeliverySn(express.getCode());
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            FsExpress express=expressService.selectFsExpressByOmsCode("SF");
 | 
	
		
			
				|  |  | +            erpOrder.setExpress_code(express.getOmsCode());
 | 
	
		
			
				|  |  | +            order.setDeliveryName(express.getName());
 | 
	
		
			
				|  |  | +            order.setDeliverySn(express.getCode());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          erpOrder.setPayments(payments);
 | 
	
		
			
				|  |  |          if(order.getCompanyId()!=null){
 | 
	
	
		
			
				|  | @@ -1554,13 +1535,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if(order.getStoreHouseCode().equals("WHSP001")){
 | 
	
		
			
				|  |  | -            //武汉不备注快递史
 | 
	
		
			
				|  |  | -            //erpOrder.setSeller_memo(erpOrder.getSeller_memo()+"-"+order.getDeliveryName());
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else{
 | 
	
		
			
				|  |  | -            erpOrder.setSeller_memo(erpOrder.getSeller_memo()+"-"+ order.getDeliveryName());
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        erpOrder.setSeller_memo(erpOrder.getSeller_memo()+"-"+ order.getDeliveryName());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          ErpRemarkDTO remarkDTO=new ErpRemarkDTO();
 | 
	
		
			
				|  |  |          remarkDTO.setTotalPrice(order.getTotalPrice());
 | 
	
		
			
				|  |  |          remarkDTO.setPayPrice(order.getPayPrice());
 | 
	
	
		
			
				|  | @@ -1569,11 +1546,6 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |          remarkDTO.setCouponMoney(order.getCouponPrice());
 | 
	
		
			
				|  |  |          remarkDTO.setOrderId(order.getOrderCode());
 | 
	
		
			
				|  |  |          remarkDTO.setYdMoney(order.getPayPrice().subtract(order.getPayMoney().subtract(order.getPayDelivery())));
 | 
	
		
			
				|  |  | -//        //套餐标题也传过去
 | 
	
		
			
				|  |  | -//        if (order.getOrderCreateType() == 2){
 | 
	
		
			
				|  |  | -//            JSONObject jsonStr = JSONObject.parseObject(order.getPackageJson());
 | 
	
		
			
				|  |  | -//            remarkDTO.setPackageTitle(jsonStr.getString("title"));
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if(order.getPayTime()!=null){
 | 
	
		
			
				|  |  |              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
	
		
			
				|  | @@ -2037,9 +2009,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |          if(money==null){
 | 
	
		
			
				|  |  |              return R.error("请输入价格");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if(money.compareTo(BigDecimal.ZERO)<=0){
 | 
	
		
			
				|  |  | -            return R.error("价格应大于0");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +//        if(money.compareTo(BigDecimal.ZERO)<=0){
 | 
	
		
			
				|  |  | +//            return R.error("价格应大于0");
 | 
	
		
			
				|  |  | +//        }
 | 
	
		
			
				|  |  |          String key=redisCache.getCacheObject("createOrderKey:"+createOrderKey);
 | 
	
		
			
				|  |  |          if (StringUtils.isEmpty(key)) {
 | 
	
		
			
				|  |  |              throw new CustomException("订单已过期",501);
 | 
	
	
		
			
				|  | @@ -2150,6 +2122,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |          storeOrder.setIsPayRemain(1);
 | 
	
		
			
				|  |  |          fsStoreOrderMapper.updateFsStoreOrder(storeOrder);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        // 添加审核
 | 
	
		
			
				|  |  | +        addOrderAudit(order);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          return "SUCCESS";
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2242,6 +2217,21 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                          successNum++;
 | 
	
		
			
				|  |  |                          importSuccessMsg.append("<br/>" + successNum + "、快递单号 " +dto.getDeliveryId() + " 导入成功");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        // 同步订单完成状态到erp
 | 
	
		
			
				|  |  | +                        // 如果是物流代收 或者 货到付款
 | 
	
		
			
				|  |  | +//                        if("2".equals(order.getPayType()) || "3".equals(order.getPayType())){
 | 
	
		
			
				|  |  | +//                            // 已结算
 | 
	
		
			
				|  |  | +//                            if("1".equals(dto.getDeliveryPayStatus())){
 | 
	
		
			
				|  |  | +//                                FsErpFinishPush fsErpFinishPush = new FsErpFinishPush();
 | 
	
		
			
				|  |  | +//                                fsErpFinishPush.setOrderId(order.getId());
 | 
	
		
			
				|  |  | +//                                fsErpFinishPush.setTaskStatus(0);
 | 
	
		
			
				|  |  | +//                                fsErpFinishPush.setRetryCount(0);
 | 
	
		
			
				|  |  | +//                                fsErpFinishPush.setCreateTime(new Date());
 | 
	
		
			
				|  |  | +//                                fsErpFinishPushMapper.insert(fsErpFinishPush);
 | 
	
		
			
				|  |  | +//                            }
 | 
	
		
			
				|  |  | +//                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      else{
 | 
	
		
			
				|  |  |                          String msg = "<br/>" + failureNum + "、快递单号 " + dto.getDeliveryId() + " 未签收或已导入,不能导入";
 |