|
@@ -59,9 +59,10 @@ import com.fs.his.service.*;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.utils.PhoneUtil;
|
|
import com.fs.his.utils.PhoneUtil;
|
|
|
import com.fs.his.vo.*;
|
|
import com.fs.his.vo.*;
|
|
|
|
|
+import com.fs.hisStore.domain.FsStoreOrderLogsScrm;
|
|
|
import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
|
-import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
|
|
|
-import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
|
|
|
|
|
|
|
+import com.fs.hisStore.domain.FsStoreProductScrm;
|
|
|
|
|
+import com.fs.hisStore.mapper.*;
|
|
|
import com.fs.hisStore.param.FsStoreOrderRefundByProductParam;
|
|
import com.fs.hisStore.param.FsStoreOrderRefundByProductParam;
|
|
|
import com.fs.hisStore.service.IFsStoreOrderLogsScrmService;
|
|
import com.fs.hisStore.service.IFsStoreOrderLogsScrmService;
|
|
|
import com.fs.hisStore.service.IFsStoreOrderScrmService;
|
|
import com.fs.hisStore.service.IFsStoreOrderScrmService;
|
|
@@ -131,6 +132,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -328,6 +330,21 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
private IFsStoreOrderScrmService orderScrmService;
|
|
private IFsStoreOrderScrmService orderScrmService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsStoreProductService fsStoreProductService;
|
|
private IFsStoreProductService fsStoreProductService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsIntegralOrderMapper fsIntegralOrderMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsIntegralGoodsMapper fsIntegralGoodsMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsStoreOrderScrmMapper fsStoreOrderScrmMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsStoreOrderItemScrmMapper fsStoreOrderItemScrmMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsStoreProductScrmMapper fsStoreProductScrmMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsIntegralOrderLogsMapper fsIntegralOrderLogsMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsStoreOrderLogsScrmMapper fsStoreOrderLogsScrmMapper;
|
|
|
|
|
+
|
|
|
@PostConstruct
|
|
@PostConstruct
|
|
|
public void initErpServiceMap() {
|
|
public void initErpServiceMap() {
|
|
|
erpServiceMap = new HashMap<>();
|
|
erpServiceMap = new HashMap<>();
|
|
@@ -4634,7 +4651,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
if (order.getShippingType() != null && order.getShippingType() == 2)return;
|
|
if (order.getShippingType() != null && order.getShippingType() == 2)return;
|
|
|
WeizouApiPushOrderParam param = new WeizouApiPushOrderParam();
|
|
WeizouApiPushOrderParam param = new WeizouApiPushOrderParam();
|
|
|
param.setRealName(order.getUserName()).setPhone(order.getUserPhone().length() > 11 ? decryptPhone(order.getUserPhone()) : order.getUserPhone())
|
|
param.setRealName(order.getUserName()).setPhone(order.getUserPhone().length() > 11 ? decryptPhone(order.getUserPhone()) : order.getUserPhone())
|
|
|
- .setFreightPrice(order.getFreightPrice()).setExtendOrderId(order.getOrderId().toString())
|
|
|
|
|
|
|
+ .setFreightPrice(order.getFreightPrice()).setExtendOrderId(order.getOrderCode())
|
|
|
;
|
|
;
|
|
|
//全款
|
|
//全款
|
|
|
if (order.getPayType().equals(1)) {
|
|
if (order.getPayType().equals(1)) {
|
|
@@ -4684,7 +4701,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
param.setProvince(address[0]).setCity(address[1]).setDistrict(address[2]);
|
|
param.setProvince(address[0]).setCity(address[1]).setDistrict(address[2]);
|
|
|
- //处理地址多空隔问题
|
|
|
|
|
|
|
+ //处理地址多空格问题
|
|
|
if (address.length > 3) {
|
|
if (address.length > 3) {
|
|
|
StringBuffer addrs = new StringBuffer();
|
|
StringBuffer addrs = new StringBuffer();
|
|
|
for (int i = 3; i < address.length; i++) {
|
|
for (int i = 3; i < address.length; i++) {
|
|
@@ -4717,13 +4734,23 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
// 1. 参数校验
|
|
// 1. 参数校验
|
|
|
// validateSendGoodsParams(fsStoreOrder, opeName);//controller处理了
|
|
// validateSendGoodsParams(fsStoreOrder, opeName);//controller处理了
|
|
|
|
|
|
|
|
- // 2. 查询原始订单
|
|
|
|
|
- FsStoreOrder originalOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Object originalOrder = findFirstNonNull(
|
|
|
|
|
+ CompletableFuture.supplyAsync(() ->
|
|
|
|
|
+ fsStoreOrderMapper.selectFsStoreOrderByOrderCode(fsStoreOrder.getOrderCode())
|
|
|
|
|
+ ),
|
|
|
|
|
+ CompletableFuture.supplyAsync(() ->
|
|
|
|
|
+ fsStoreOrderMapper.selectFsStoreOrderScrmByOrderCode(fsStoreOrder.getOrderCode())
|
|
|
|
|
+ ),
|
|
|
|
|
+ CompletableFuture.supplyAsync(() ->
|
|
|
|
|
+ fsIntegralOrderMapper.selectFsIntegralOrderByOrderCode(fsStoreOrder.getOrderCode())
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
if (originalOrder == null) {
|
|
if (originalOrder == null) {
|
|
|
throw new CustomException("订单不存在");
|
|
throw new CustomException("订单不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 3. 根据操作类型分发处理
|
|
|
|
|
if (OPERATOR_CANCEL.equals(fsStoreOrder.getOperator())) {
|
|
if (OPERATOR_CANCEL.equals(fsStoreOrder.getOperator())) {
|
|
|
return processCancelDelivery(originalOrder, fsStoreOrder, "微走取消订单");
|
|
return processCancelDelivery(originalOrder, fsStoreOrder, "微走取消订单");
|
|
|
}
|
|
}
|
|
@@ -4733,57 +4760,124 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
return processUpdateDelivery(originalOrder, fsStoreOrder, "微走订单更新"); }
|
|
return processUpdateDelivery(originalOrder, fsStoreOrder, "微走订单更新"); }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 处理订单状态更新//todo 到货后续业务逻辑需要对接
|
|
|
|
|
- */
|
|
|
|
|
- private int processUpdateDelivery(FsStoreOrder originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
- //微走有多个状态,需要分别记录
|
|
|
|
|
- if (originalOrder.getStatus() == STATUS_SHIPPED) {
|
|
|
|
|
- updateOrderToEvaluated(fsStoreOrder);
|
|
|
|
|
|
|
+ @SafeVarargs
|
|
|
|
|
+ private final <T> T findFirstNonNull(CompletableFuture<? extends T>... futures) {
|
|
|
|
|
+ CompletableFuture.allOf(futures).join();
|
|
|
|
|
+ for (CompletableFuture<? extends T> future : futures) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ T result = future.get();
|
|
|
|
|
+ if (result != null) {
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 记录日志
|
|
|
|
|
- log.info("微走快递送达, 订单号: {}",
|
|
|
|
|
- fsStoreOrder.getOrderId());
|
|
|
|
|
- return saveOrderLog(fsStoreOrder, WeizouOrderExpressEnum.getDescByCode(fsStoreOrder.getOperator()), opeName);
|
|
|
|
|
|
|
+ private int processUpdateDelivery(Object order, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
+ OrderLogSaver logSaver = dispatchUpdate(order, fsStoreOrder);
|
|
|
|
|
+ log.info("微走快递送达, 订单号: {}", fsStoreOrder.getOrderId());
|
|
|
|
|
+ return logSaver.save(fsStoreOrder, WeizouOrderExpressEnum.getDescByCode(fsStoreOrder.getOperator()), opeName);
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* 处理取消发货
|
|
* 处理取消发货
|
|
|
*/
|
|
*/
|
|
|
- private int processCancelDelivery(FsStoreOrder originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
- // 待发货状态才更新订单状态
|
|
|
|
|
- if (originalOrder.getStatus() == STATUS_PENDING_SHIPMENT) {
|
|
|
|
|
- updateOrderToCancelled(fsStoreOrder);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 调用退款服务
|
|
|
|
|
-// SpringUtils.getBean(IFsStoreOrderScrmService.class).refundOrder(fsStoreOrder.getOrderId());//todo 推给售后
|
|
|
|
|
-
|
|
|
|
|
- // 记录日志
|
|
|
|
|
- log.info("微走取消发货, 订单号: {}",
|
|
|
|
|
- fsStoreOrder.getOrderId());
|
|
|
|
|
-
|
|
|
|
|
- return saveOrderLog(fsStoreOrder, fsStoreOrder.getOperator(), opeName);
|
|
|
|
|
|
|
+ private int processCancelDelivery(Object order, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
+ OrderLogSaver logSaver = dispatchCancel(order, fsStoreOrder);
|
|
|
|
|
+ log.info("微走取消发货, 订单号: {}", fsStoreOrder.getOrderId());
|
|
|
|
|
+ return logSaver.save(fsStoreOrder, fsStoreOrder.getOperator(), opeName);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 处理正常发货/修改快递
|
|
* 处理正常发货/修改快递
|
|
|
*/
|
|
*/
|
|
|
- private int processNormalDelivery(FsStoreOrder originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
- int result;
|
|
|
|
|
|
|
+ private int processNormalDelivery(Object order, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
+ if (order instanceof FsStoreOrder) {
|
|
|
|
|
+ FsStoreOrder o = (FsStoreOrder) order;
|
|
|
|
|
+ fsStoreOrder.setOrderId(o.getOrderId());
|
|
|
|
|
+ if (o.getStatus() == STATUS_PENDING_SHIPMENT) {
|
|
|
|
|
+ executeShipOrder(o, fsStoreOrder, opeName);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ updateDeliveryInfo(o, fsStoreOrder, opeName);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }else
|
|
|
|
|
+ if (order instanceof FsStoreOrderScrm) {
|
|
|
|
|
+ FsStoreOrderScrm o = (FsStoreOrderScrm) order;
|
|
|
|
|
+ fsStoreOrder.setOrderId(o.getId());
|
|
|
|
|
+ if (o.getStatus() == STATUS_PENDING_SHIPMENT) {
|
|
|
|
|
+ executeShipOrderScrm(o, fsStoreOrder, opeName);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ updateDeliveryInfoScrm(o, fsStoreOrder, opeName);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }else{
|
|
|
|
|
+ FsIntegralOrder o = (FsIntegralOrder) order;
|
|
|
|
|
+ fsStoreOrder.setOrderId(o.getOrderId());
|
|
|
|
|
+ if (o.getStatus() == STATUS_PENDING_SHIPMENT) {
|
|
|
|
|
+ executeShipOrderIntegral(o, fsStoreOrder, opeName);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ updateDeliveryInfoIntegral(o, fsStoreOrder, opeName);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (originalOrder.getStatus() == STATUS_PENDING_SHIPMENT) {
|
|
|
|
|
- // 待发货状态:执行发货操作
|
|
|
|
|
- result = executeShipOrder(originalOrder, fsStoreOrder, opeName);
|
|
|
|
|
- } else {
|
|
|
|
|
- // 其他状态:只更新快递信息
|
|
|
|
|
- result = updateDeliveryInfo(originalOrder, fsStoreOrder, opeName);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ log.info("微走取消发货, 订单号: {}", fsStoreOrder.getOrderId());
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 订阅快递信息(两种场景都需要)
|
|
|
|
|
-// subscribeExpress(originalOrder, fsStoreOrder);//2026-3-20沟通后今正用微走接口调用的方式更新物流状态
|
|
|
|
|
|
|
+ @FunctionalInterface
|
|
|
|
|
+ private interface OrderLogSaver {
|
|
|
|
|
+ int save(FsStoreOrder order, String operator, String message);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return result;
|
|
|
|
|
|
|
+ private OrderLogSaver dispatchCancel(Object order, FsStoreOrder fsStoreOrder) {
|
|
|
|
|
+ if (order instanceof FsStoreOrder) {
|
|
|
|
|
+ FsStoreOrder o = (FsStoreOrder) order;
|
|
|
|
|
+ if (o.getStatus() == STATUS_PENDING_SHIPMENT) {
|
|
|
|
|
+ fsStoreOrder.setOrderId(o.getOrderId());
|
|
|
|
|
+ updateOrderToCancelled(fsStoreOrder);
|
|
|
|
|
+ }
|
|
|
|
|
+ return this::saveOrderLog;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (order instanceof FsStoreOrderScrm) {
|
|
|
|
|
+ FsStoreOrderScrm o = (FsStoreOrderScrm) order;
|
|
|
|
|
+ if (o.getStatus() == STATUS_PENDING_SHIPMENT) {
|
|
|
|
|
+ fsStoreOrder.setOrderId(o.getId());
|
|
|
|
|
+ updateOrderToCancelledScrm(fsStoreOrder);
|
|
|
|
|
+ }
|
|
|
|
|
+ return this::saveOrderLogScrm;
|
|
|
|
|
+ }
|
|
|
|
|
+ FsIntegralOrder o = (FsIntegralOrder) order;
|
|
|
|
|
+ if (o.getStatus() == STATUS_PENDING_SHIPMENT) {
|
|
|
|
|
+ fsStoreOrder.setOrderId(o.getOrderId());
|
|
|
|
|
+ updateOrderToCancelledIntegral(fsStoreOrder);
|
|
|
|
|
+ }
|
|
|
|
|
+ return this::saveOrderLogIntegral;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private OrderLogSaver dispatchUpdate(Object order, FsStoreOrder fsStoreOrder) {
|
|
|
|
|
+ if (order instanceof FsStoreOrder) {
|
|
|
|
|
+ FsStoreOrder o = (FsStoreOrder) order;
|
|
|
|
|
+ if (o.getStatus() == STATUS_SHIPPED) {
|
|
|
|
|
+ fsStoreOrder.setOrderId(o.getOrderId());
|
|
|
|
|
+ updateOrderToEvaluated(fsStoreOrder);
|
|
|
|
|
+ }
|
|
|
|
|
+ return this::saveOrderLog;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (order instanceof FsStoreOrderScrm) {
|
|
|
|
|
+ FsStoreOrderScrm o = (FsStoreOrderScrm) order;
|
|
|
|
|
+ if (o.getStatus() == STATUS_SHIPPED) {
|
|
|
|
|
+ fsStoreOrder.setOrderId(o.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ return this::saveOrderLogScrm;
|
|
|
|
|
+ }
|
|
|
|
|
+ FsIntegralOrder o = (FsIntegralOrder) order;
|
|
|
|
|
+ if (o.getStatus() == STATUS_SHIPPED) {
|
|
|
|
|
+ fsStoreOrder.setOrderId(o.getOrderId());
|
|
|
|
|
+ }
|
|
|
|
|
+ return this::saveOrderLogIntegral;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -4810,6 +4904,47 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+ private int executeShipOrderScrm(FsStoreOrderScrm originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
+ // 1. 更新订单为已发货
|
|
|
|
|
+ FsStoreOrderScrm updateOrder = new FsStoreOrderScrm();
|
|
|
|
|
+ updateOrder.setId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ updateOrder.setStatus(STATUS_PENDING_SHIPMENT);
|
|
|
|
|
+ updateOrder.setUpdateTime(new DateTime());
|
|
|
|
|
+ updateOrder.setDeliveryCode(fsStoreOrder.getDeliveryCode());
|
|
|
|
|
+ updateOrder.setDeliveryName(fsStoreOrder.getDeliveryName());
|
|
|
|
|
+ updateOrder.setDeliverySn(fsStoreOrder.getDeliverySn());
|
|
|
|
|
+ updateOrder.setDeliveryTime(getCurrentDateTimeString());
|
|
|
|
|
+ int result = fsStoreOrderScrmMapper.updateFsStoreOrder(updateOrder);
|
|
|
|
|
+ // 2. 处理公司扣款
|
|
|
|
|
+ if (originalOrder.getCompanyId() != null) {
|
|
|
|
|
+ companyService.subtractCompanyMoneyScrm(originalOrder);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 3. 记录日志
|
|
|
|
|
+ String logMessage = opeName + " 订单发货";
|
|
|
|
|
+ saveOrderLogScrm(fsStoreOrder, opeName, logMessage);
|
|
|
|
|
+ log.info("微走订单发货成功, 订单号: {}, 快递公司: {}, 快递单号: {}",
|
|
|
|
|
+ fsStoreOrder.getOrderId(),
|
|
|
|
|
+ fsStoreOrder.getDeliveryName(),
|
|
|
|
|
+ fsStoreOrder.getDeliverySn());
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ private int executeShipOrderIntegral(FsIntegralOrder originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
+ // 1. 更新订单为已发货
|
|
|
|
|
+ FsIntegralOrder updateOrder = buildShipOrderUpdateIntegral(fsStoreOrder);
|
|
|
|
|
+ int result = fsIntegralOrderMapper.updateFsIntegralOrder(updateOrder);
|
|
|
|
|
+ // 2. 处理公司扣款 //积分商品暂未找到
|
|
|
|
|
+// if (originalOrder.getCompanyId() != null) {
|
|
|
|
|
+// companyService.subtractCompanyMoney(originalOrder);
|
|
|
|
|
+// }
|
|
|
|
|
+ // 3. 记录日志
|
|
|
|
|
+ String logMessage = opeName + " 订单发货";
|
|
|
|
|
+ saveOrderLogIntegral(fsStoreOrder, opeName, logMessage);
|
|
|
|
|
+ log.info("微走订单发货成功, 订单号: {}, 快递公司: {}, 快递单号: {}",
|
|
|
|
|
+ fsStoreOrder.getOrderId(),
|
|
|
|
|
+ fsStoreOrder.getDeliveryName(),
|
|
|
|
|
+ fsStoreOrder.getDeliverySn());
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 更新快递信息
|
|
* 更新快递信息
|
|
@@ -4828,6 +4963,34 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+ private int updateDeliveryInfoScrm(FsStoreOrderScrm originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
+ // 1. 只更新快递相关信息
|
|
|
|
|
+ FsStoreOrderScrm updateOrder = buildDeliveryInfoUpdateScrm(fsStoreOrder);
|
|
|
|
|
+ int result = fsStoreOrderScrmMapper.updateFsStoreOrder(updateOrder);
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 记录日志
|
|
|
|
|
+ String logMessage = opeName + " 订单单号更新";
|
|
|
|
|
+ saveOrderLogScrm(fsStoreOrder, opeName, logMessage);
|
|
|
|
|
+
|
|
|
|
|
+ log.info("微走修改快递单号, 订单号: {}, 新快递单号: {}",
|
|
|
|
|
+ fsStoreOrder.getOrderId(), fsStoreOrder.getDeliverySn());
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ private int updateDeliveryInfoIntegral(FsIntegralOrder originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
|
|
+ // 1. 只更新快递相关信息
|
|
|
|
|
+ FsIntegralOrder updateOrder = buildDeliveryInfoUpdateIntegral(fsStoreOrder);
|
|
|
|
|
+ int result = fsIntegralOrderMapper.updateFsIntegralOrder(updateOrder);
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 记录日志
|
|
|
|
|
+ String logMessage = opeName + " 订单单号更新";
|
|
|
|
|
+ saveOrderLogIntegral(fsStoreOrder, opeName, logMessage);
|
|
|
|
|
+
|
|
|
|
|
+ log.info("微走修改快递单号, 订单号: {}, 新快递单号: {}",
|
|
|
|
|
+ fsStoreOrder.getOrderId(), fsStoreOrder.getDeliverySn());
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 更新订单为已取消状态
|
|
* 更新订单为已取消状态
|
|
@@ -4841,6 +5004,24 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
|
|
|
|
|
fsStoreOrderMapper.updateFsStoreOrder(updateOrder);
|
|
fsStoreOrderMapper.updateFsStoreOrder(updateOrder);
|
|
|
}
|
|
}
|
|
|
|
|
+ private void updateOrderToCancelledScrm(FsStoreOrder fsStoreOrder) {
|
|
|
|
|
+ FsStoreOrderScrm updateOrder = new FsStoreOrderScrm();
|
|
|
|
|
+ updateOrder.setId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ updateOrder.setStatus(STATUS_PENDING_SHIPMENT);//待发货
|
|
|
|
|
+ updateOrder.setUpdateTime(new DateTime());
|
|
|
|
|
+ updateOrder.setDeliveryTime(getCurrentDateTimeString());
|
|
|
|
|
+
|
|
|
|
|
+ fsStoreOrderScrmMapper.updateFsStoreOrder(updateOrder);
|
|
|
|
|
+ }
|
|
|
|
|
+ private void updateOrderToCancelledIntegral(FsStoreOrder fsStoreOrder) {
|
|
|
|
|
+ FsIntegralOrder updateOrder = new FsIntegralOrder();
|
|
|
|
|
+ updateOrder.setOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ updateOrder.setStatus(STATUS_PENDING_SHIPMENT);//待发货
|
|
|
|
|
+ updateOrder.setUpdateTime(new DateTime());
|
|
|
|
|
+ updateOrder.setDeliveryTime(new DateTime());
|
|
|
|
|
+
|
|
|
|
|
+ fsIntegralOrderMapper.updateFsIntegralOrder(updateOrder);
|
|
|
|
|
+ }
|
|
|
/**
|
|
/**
|
|
|
* 更新订单为待评价状态
|
|
* 更新订单为待评价状态
|
|
|
*/
|
|
*/
|
|
@@ -4869,6 +5050,19 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
|
|
|
|
|
return updateOrder;
|
|
return updateOrder;
|
|
|
}
|
|
}
|
|
|
|
|
+ private FsIntegralOrder buildShipOrderUpdateIntegral(FsStoreOrder fsStoreOrder) {
|
|
|
|
|
+ FsIntegralOrder updateOrder = new FsIntegralOrder();
|
|
|
|
|
+ updateOrder.setOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ updateOrder.setStatus(STATUS_PENDING_SHIPMENT);
|
|
|
|
|
+ updateOrder.setUpdateTime(new DateTime());
|
|
|
|
|
+ updateOrder.setDeliveryCode(fsStoreOrder.getDeliveryCode());
|
|
|
|
|
+ updateOrder.setDeliveryName(fsStoreOrder.getDeliveryName());
|
|
|
|
|
+ updateOrder.setDeliverySn(fsStoreOrder.getDeliverySn());
|
|
|
|
|
+ updateOrder.setDeliveryTime(new DateTime());
|
|
|
|
|
+
|
|
|
|
|
+ return updateOrder;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 构建快递信息更新对象
|
|
* 构建快递信息更新对象
|
|
@@ -4884,6 +5078,29 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
|
|
|
|
|
return updateOrder;
|
|
return updateOrder;
|
|
|
}
|
|
}
|
|
|
|
|
+ private FsStoreOrderScrm buildDeliveryInfoUpdateScrm(FsStoreOrder fsStoreOrder) {
|
|
|
|
|
+ FsStoreOrderScrm updateOrder = new FsStoreOrderScrm();
|
|
|
|
|
+ updateOrder.setId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ updateOrder.setDeliveryCode(fsStoreOrder.getDeliveryCode());
|
|
|
|
|
+ updateOrder.setDeliveryName(fsStoreOrder.getDeliveryName());
|
|
|
|
|
+ updateOrder.setDeliverySn(fsStoreOrder.getDeliverySn());
|
|
|
|
|
+ updateOrder.setUpdateTime(new DateTime());
|
|
|
|
|
+ // 注意:这里不更新状态和发货时间
|
|
|
|
|
+
|
|
|
|
|
+ return updateOrder;
|
|
|
|
|
+ }
|
|
|
|
|
+ private FsIntegralOrder buildDeliveryInfoUpdateIntegral(FsStoreOrder fsStoreOrder) {
|
|
|
|
|
+ FsIntegralOrder updateOrder = new FsIntegralOrder();
|
|
|
|
|
+ updateOrder.setOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ updateOrder.setDeliveryCode(fsStoreOrder.getDeliveryCode());
|
|
|
|
|
+ updateOrder.setDeliveryName(fsStoreOrder.getDeliveryName());
|
|
|
|
|
+ updateOrder.setDeliverySn(fsStoreOrder.getDeliverySn());
|
|
|
|
|
+ updateOrder.setUpdateTime(new DateTime());
|
|
|
|
|
+ // 注意:这里不更新状态和发货时间
|
|
|
|
|
+
|
|
|
|
|
+ return updateOrder;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 保存订单日志
|
|
* 保存订单日志
|
|
@@ -4898,7 +5115,26 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
|
|
|
|
|
return fsStoreOrderLogsMapper.insertFsStoreOrderLogs(logs);
|
|
return fsStoreOrderLogsMapper.insertFsStoreOrderLogs(logs);
|
|
|
}
|
|
}
|
|
|
|
|
+ private int saveOrderLogScrm(FsStoreOrder fsStoreOrder, String operator, String message) {
|
|
|
|
|
+ FsStoreOrderLogsScrm logs = new FsStoreOrderLogsScrm();
|
|
|
|
|
+ logs.setChangeMessage(message);
|
|
|
|
|
+ logs.setOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ logs.setChangeTime(new DateTime());
|
|
|
|
|
+ logs.setChangeType(LOG_TYPE_DELIVERY);
|
|
|
|
|
+ logs.setOperator(operator);
|
|
|
|
|
|
|
|
|
|
+ return fsStoreOrderLogsScrmMapper.insertFsStoreOrderLogs(logs);
|
|
|
|
|
+ }
|
|
|
|
|
+ private int saveOrderLogIntegral(FsStoreOrder fsStoreOrder, String operator, String message) {
|
|
|
|
|
+ FsIntegralOrderLogs logs = new FsIntegralOrderLogs();
|
|
|
|
|
+ logs.setChangeMessage(message);
|
|
|
|
|
+ logs.setOrderId(fsStoreOrder.getOrderId());
|
|
|
|
|
+ logs.setChangeTime(LocalDateTime.now());
|
|
|
|
|
+ logs.setChangeType(LOG_TYPE_DELIVERY);
|
|
|
|
|
+ logs.setOperator(operator);
|
|
|
|
|
+
|
|
|
|
|
+ return fsIntegralOrderLogsMapper.insertFsIntegralOrderLogs(logs);
|
|
|
|
|
+ }
|
|
|
/**
|
|
/**
|
|
|
* 订阅快递信息
|
|
* 订阅快递信息
|
|
|
*/
|
|
*/
|
|
@@ -4966,4 +5202,153 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
public BigDecimal selectPayPriceByYear(String userId){
|
|
public BigDecimal selectPayPriceByYear(String userId){
|
|
|
return fsStoreOrderItemMapper.selectPayPriceByYear(userId);
|
|
return fsStoreOrderItemMapper.selectPayPriceByYear(userId);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void weizouPushIntergral(Long l) {
|
|
|
|
|
+ FsIntegralOrder order = fsIntegralOrderMapper.selectFsIntegralOrderByOrderId(l);
|
|
|
|
|
+ WeizouApiPushOrderParam param = new WeizouApiPushOrderParam();
|
|
|
|
|
+ param.setRealName(order.getUserName()).setPhone(order.getUserPhone().length() > 11 ? decryptPhone(order.getUserPhone()) : order.getUserPhone())
|
|
|
|
|
+ .setExtendOrderId(order.getOrderCode())
|
|
|
|
|
+ ;
|
|
|
|
|
+ // 积分订单全款
|
|
|
|
|
+ param.setPaymentType("01").setPaid(1)
|
|
|
|
|
+ .setPayType("02").setDeliveryType("顺丰快递")
|
|
|
|
|
+// .setPayType("01").setDeliveryType("邮政快递")
|
|
|
|
|
+ ;
|
|
|
|
|
+ com.alibaba.fastjson.JSONArray goods = com.alibaba.fastjson.JSONArray.parseArray(order.getItemJson());
|
|
|
|
|
+ Set<Long> goodIds =
|
|
|
|
|
+ goods.stream().map(item -> ((com.alibaba.fastjson.JSONObject) item).getLong("goodsId")).collect(Collectors.toSet());
|
|
|
|
|
+ List<FsIntegralGoodsVo> fsIntegralGoodsVos = fsIntegralGoodsMapper.selectAllByGoodsIds(goodIds);
|
|
|
|
|
+ Map<Long, FsIntegralGoodsVo> goodsMap = fsIntegralGoodsVos.stream().collect(Collectors.toMap(FsIntegralGoodsVo::getGoodsId, Function.identity()));
|
|
|
|
|
+ //商品
|
|
|
|
|
+ ArrayList<WeizouOrderEntry> orders = new ArrayList<>();
|
|
|
|
|
+ goods.forEach(item -> {
|
|
|
|
|
+ WeizouOrderEntry entry = new WeizouOrderEntry();
|
|
|
|
|
+ FsIntegralGoodsVo good = goodsMap.get(((com.alibaba.fastjson.JSONObject) item).getLong("goodsId"));
|
|
|
|
|
+ entry.setSkuNumber(good.getBarCode()).setRetailPrice(good.getOtPrice())
|
|
|
|
|
+ .setTaxPrice(good.getCash()).setTaxTotalAmount(good.getCash().multiply(new BigDecimal(((com.alibaba.fastjson.JSONObject) item).getInteger("num"))))
|
|
|
|
|
+ .setCount(((com.alibaba.fastjson.JSONObject) item).getInteger("num"));
|
|
|
|
|
+ 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 ="";
|
|
|
|
|
+ try {
|
|
|
|
|
+ s = WeizouApiClient.pushOrder(param);
|
|
|
|
|
+
|
|
|
|
|
+ }catch (IOException e){
|
|
|
|
|
+ log.error("微走推送异常:{}",e);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("微走推送结果:{}",s);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void weizouPushScrm(Long l) {
|
|
|
|
|
+ FsStoreOrderScrm order = fsStoreOrderScrmMapper.selectFsStoreOrderById(l);
|
|
|
|
|
+ if (order.getShippingType() != null && order.getShippingType() == 2)return;
|
|
|
|
|
+ WeizouApiPushOrderParam param = new WeizouApiPushOrderParam();
|
|
|
|
|
+ param.setRealName(order.getRealName()).setPhone(order.getUserPhone().length() > 11 ? decryptPhone(order.getUserPhone()) : order.getUserPhone())
|
|
|
|
|
+ .setFreightPrice(order.getFreightPrice()).setExtendOrderId(order.getOrderCode())
|
|
|
|
|
+ ;
|
|
|
|
|
+ //全款
|
|
|
|
|
+ if (order.getPayType().equals(1)) {
|
|
|
|
|
+ param.setPaymentType("01").setPaid(1)
|
|
|
|
|
+ .setPayType("02").setDeliveryType("顺丰快递")
|
|
|
|
|
+// .setPayType("01").setDeliveryType("邮政快递")
|
|
|
|
|
+ ;
|
|
|
|
|
+ //部分支付
|
|
|
|
|
+ } else if (order.getPayType().equals(2)) {
|
|
|
|
|
+ param.setPaymentType("02").setPaid(2).setPrecollection(order.getPayPrice())
|
|
|
|
|
+ .setPayType("04").setDeliveryType("顺丰快递")
|
|
|
|
|
+// .setPayType("03").setDeliveryType("邮政快递")
|
|
|
|
|
+ ;
|
|
|
|
|
+ //未付款
|
|
|
|
|
+ } else if (order.getPayType().equals(3)) {
|
|
|
|
|
+ param.setPaymentType("02").setPaid(0)
|
|
|
|
|
+ .setPayType("04").setDeliveryType("顺丰快递")
|
|
|
|
|
+// .setPayType("03").setDeliveryType("邮政快递")
|
|
|
|
|
+ ;
|
|
|
|
|
+ }
|
|
|
|
|
+ //商品
|
|
|
|
|
+ List<com.fs.hisStore.vo.FsStoreOrderItemVO> items = fsStoreOrderItemScrmMapper.selectFsStoreOrderItemListByOrderId(order.getId());
|
|
|
|
|
+ ArrayList<WeizouOrderEntry> orders = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ items.forEach(item -> {
|
|
|
|
|
+ FsStoreProductScrm product = fsStoreProductScrmMapper.selectFsStoreProductById(item.getProductId());
|
|
|
|
|
+
|
|
|
|
|
+ WeizouOrderEntry entry = new WeizouOrderEntry();
|
|
|
|
|
+
|
|
|
|
|
+ entry.setSkuNumber(product.getBarCode()).setRetailPrice(product.getPrice())
|
|
|
|
|
+ .setTaxPrice(product.getPrice()).setTaxTotalAmount(product.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 ="";
|
|
|
|
|
+ try {
|
|
|
|
|
+ s = WeizouApiClient.pushOrder(param);
|
|
|
|
|
+
|
|
|
|
|
+ }catch (IOException e){
|
|
|
|
|
+ log.error("微走推送异常:{}",e);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("微走推送结果:{}",s);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|