|
@@ -34,6 +34,7 @@ import com.fs.erp.domain.*;
|
|
|
import com.fs.erp.dto.*;
|
|
import com.fs.erp.dto.*;
|
|
|
import com.fs.erp.dto.df.*;
|
|
import com.fs.erp.dto.df.*;
|
|
|
import com.fs.erp.service.IErpOrderService;
|
|
import com.fs.erp.service.IErpOrderService;
|
|
|
|
|
+import com.fs.erp.utils.WeizouApiClient;
|
|
|
import com.fs.event.*;
|
|
import com.fs.event.*;
|
|
|
import com.fs.gtPush.service.uniPush2Service;
|
|
import com.fs.gtPush.service.uniPush2Service;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
import com.fs.his.config.FsSysConfig;
|
|
@@ -119,6 +120,7 @@ import java.sql.Timestamp;
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import static com.fs.his.utils.PhoneUtil.decryptPhone;
|
|
import static com.fs.his.utils.PhoneUtil.decryptPhone;
|
|
@@ -313,6 +315,8 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
private Map<Integer, IErpOrderService> erpServiceMap;
|
|
private Map<Integer, IErpOrderService> erpServiceMap;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsStoreOrderScrmService orderScrmService;
|
|
private IFsStoreOrderScrmService orderScrmService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IFsStoreProductService fsStoreProductService;
|
|
|
@PostConstruct
|
|
@PostConstruct
|
|
|
public void initErpServiceMap() {
|
|
public void initErpServiceMap() {
|
|
|
erpServiceMap = new HashMap<>();
|
|
erpServiceMap = new HashMap<>();
|
|
@@ -4543,4 +4547,123 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
return fsStoreOrderMapper.selectOutTimeOrderList(unPayTime);
|
|
return fsStoreOrderMapper.selectOutTimeOrderList(unPayTime);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void weizouPush(Long l) throws IOException {
|
|
|
|
|
+ FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderByOrderId(l);
|
|
|
|
|
+ if (order.getShippingType() != null && order.getShippingType() == 2)return;
|
|
|
|
|
+ WeizouApiPushOrderParam param = new WeizouApiPushOrderParam();
|
|
|
|
|
+ param.setPaid(order.getIsPay()).setRealName(order.getUserName()).setPhone(order.getUserPhone())
|
|
|
|
|
+ .setFreightPrice(order.getFreightPrice()).setExtendOrderId(order.getOrderId().toString())
|
|
|
|
|
+ .setPayType(order.getPayType()==1?"02":"04")
|
|
|
|
|
+ .setPaymentType(order.getPayType()==1?"01":"02").setDeliveryType("顺丰快递")
|
|
|
|
|
+ ;
|
|
|
|
|
+ //商品
|
|
|
|
|
+ FsStoreOrderItem itemMap = new FsStoreOrderItem();
|
|
|
|
|
+ itemMap.setOrderId(order.getOrderId());
|
|
|
|
|
+ List<FsStoreOrderItem> orderItems = storeOrderItemService.selectFsStoreOrderItemList(itemMap);//查订单商品
|
|
|
|
|
+ ArrayList<WeizouOrderEntry> orders = new ArrayList<>();
|
|
|
|
|
+ List<Long> productIds = orderItems.stream().map(FsStoreOrderItem::getProductId).collect(Collectors.toList());
|
|
|
|
|
+ List<FsStoreProduct> fsStoreProducts = fsStoreProductService.getStoreProductInProductIds(productIds);
|
|
|
|
|
+ Map<Long, FsStoreProduct> productMap = fsStoreProducts.stream().collect(Collectors.toMap(FsStoreProduct::getProductId,Function.identity()));
|
|
|
|
|
+ orderItems.forEach(item -> {
|
|
|
|
|
+ WeizouOrderEntry entry = new WeizouOrderEntry();
|
|
|
|
|
+ FsStoreProduct fsStoreProduct = productMap.get(item.getProductId());
|
|
|
|
|
+ entry.setSkuNumber(fsStoreProduct.getBarCode()).setRetailPrice(fsStoreProduct.getPrice())
|
|
|
|
|
+ .setTaxPrice(fsStoreProduct.getPrice()).setTaxTotalAmount(fsStoreProduct.getPrice().multiply(new BigDecimal(item.getNum())))
|
|
|
|
|
+ .setCount(Integer.parseInt(item.getNum().toString()));
|
|
|
|
|
+ orders.add(entry);
|
|
|
|
|
+ });
|
|
|
|
|
+ //设置地址-省市区
|
|
|
|
|
+ String[] address = order.getUserAddress().split(" ");
|
|
|
|
|
+ try{
|
|
|
|
|
+ if (address.length < 3) {
|
|
|
|
|
+ String kdnAddress = fsUserAddressService.getKdnAddress(order.getUserAddress());
|
|
|
|
|
+ Map<String, Object> addDAta = (Map<String, Object>) JSON.parse(kdnAddress);
|
|
|
|
|
+ Map<String, String> add = (Map<String, String>) addDAta.get("Data");
|
|
|
|
|
+ param.setProvince(add.get("ProvinceName")).setCity(add.get("CityName"))
|
|
|
|
|
+ .setDistrict(add.get("ExpAreaName"))
|
|
|
|
|
+ .setUserAddress(add.get("StreetName") + add.get("Address"));
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ param.setProvince(address[0]).setCity(address[1]).setDistrict(address[2]);
|
|
|
|
|
+ //处理地址多空隔问题
|
|
|
|
|
+ if (address.length > 3) {
|
|
|
|
|
+ StringBuffer addrs = new StringBuffer();
|
|
|
|
|
+ for (int i = 3; i < address.length; i++) {
|
|
|
|
|
+ addrs.append(address[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ param.setUserAddress(addrs.toString());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ param.setUserAddress(address[2]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ log.error("地址错误:{}",e);
|
|
|
|
|
+ throw new CustomException("地址格式不对请正确写入详细地址!!");
|
|
|
|
|
+ }
|
|
|
|
|
+ param.setEntryList(orders);
|
|
|
|
|
+ String s = WeizouApiClient.pushOrder(param);
|
|
|
|
|
+ log.info("微走推送结果:{}",s);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int sendGoodsWeizou(FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
+ FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderByOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ if (order == null) throw new CustomException("订单不存在");
|
|
|
|
|
+ if (order.getStatus() == 2){
|
|
|
|
|
+ FsStoreOrder o1 = new FsStoreOrder();
|
|
|
|
|
+ o1.setOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ o1.setStatus(3);
|
|
|
|
|
+ o1.setUpdateTime(new DateTime());
|
|
|
|
|
+ o1.setDeliveryCode(fsStoreOrder.getDeliveryCode());
|
|
|
|
|
+ o1.setDeliveryName(fsStoreOrder.getDeliveryName());
|
|
|
|
|
+ o1.setDeliverySn(fsStoreOrder.getDeliverySn());
|
|
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ String dateString = formatter.format(new Date());
|
|
|
|
|
+ o1.setDeliveryTime(dateString);
|
|
|
|
|
+ int i = fsStoreOrderMapper.updateFsStoreOrder(o1);
|
|
|
|
|
+ if (order.getCompanyId() != null) {
|
|
|
|
|
+ companyService.subtractCompanyMoney(order);
|
|
|
|
|
+ }
|
|
|
|
|
+ FsStoreOrderLogs Logs = new FsStoreOrderLogs();
|
|
|
|
|
+ Logs.setChangeMessage(opeName+" 订单发货");
|
|
|
|
|
+ Logs.setOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ Logs.setChangeTime(new DateTime());
|
|
|
|
|
+ Logs.setChangeType("delivery_goods");
|
|
|
|
|
+ Optional.ofNullable(fsStoreOrder.getOperator()).ifPresent(Logs::setOperator);
|
|
|
|
|
+ fsStoreOrderLogsMapper.insertFsStoreOrderLogs(Logs);
|
|
|
|
|
+ String lastFourNumber = "";
|
|
|
|
|
+ if (order.getDeliveryCode().equals(ShipperCodeEnum.SF.getValue())) {
|
|
|
|
|
+ lastFourNumber = order.getUserPhone();
|
|
|
|
|
+ if (lastFourNumber.length() == 11) {
|
|
|
|
|
+ lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ expressService.subscribeEspress(order.getOrderCode(), fsStoreOrder.getDeliveryCode(), fsStoreOrder.getDeliverySn(), lastFourNumber);
|
|
|
|
|
+ return i;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ log.info("微走修改快递单号",fsStoreOrder.getDeliverySn());
|
|
|
|
|
+ FsStoreOrder o1 = new FsStoreOrder();
|
|
|
|
|
+ o1.setOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ o1.setDeliveryCode(fsStoreOrder.getDeliveryCode());
|
|
|
|
|
+ int i = fsStoreOrderMapper.updateFsStoreOrder(o1);
|
|
|
|
|
+ FsStoreOrderLogs Logs = new FsStoreOrderLogs();
|
|
|
|
|
+ Logs.setChangeMessage(opeName+"订单单号更新");
|
|
|
|
|
+ Logs.setOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ Logs.setChangeTime(new DateTime());
|
|
|
|
|
+ Logs.setChangeType("delivery_goods");
|
|
|
|
|
+ Logs.setOperator("微走快递单号更新");
|
|
|
|
|
+ fsStoreOrderLogsMapper.insertFsStoreOrderLogs(Logs);
|
|
|
|
|
+ String lastFourNumber = "";
|
|
|
|
|
+ if (order.getDeliveryCode().equals(ShipperCodeEnum.SF.getValue())) {
|
|
|
|
|
+ lastFourNumber = order.getUserPhone();
|
|
|
|
|
+ if (lastFourNumber.length() == 11) {
|
|
|
|
|
+ lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ expressService.subscribeEspress(order.getOrderCode(), fsStoreOrder.getDeliveryCode(), fsStoreOrder.getDeliverySn(), lastFourNumber);
|
|
|
|
|
+ return i;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|