|
|
@@ -20,7 +20,10 @@ import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.exception.ServiceException;
|
|
|
import com.fs.common.utils.*;
|
|
|
import com.fs.common.utils.ip.IpUtils;
|
|
|
-import com.fs.company.domain.*;
|
|
|
+import com.fs.company.domain.Company;
|
|
|
+import com.fs.company.domain.CompanyDept;
|
|
|
+import com.fs.company.domain.CompanyMoneyLogs;
|
|
|
+import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyDivItemMapper;
|
|
|
import com.fs.company.mapper.CompanyMapper;
|
|
|
import com.fs.company.mapper.CompanyMoneyLogsMapper;
|
|
|
@@ -36,13 +39,15 @@ import com.fs.core.config.WxPayProperties;
|
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
+import com.fs.enums.WeizouOrderExpressEnum;
|
|
|
import com.fs.erp.domain.*;
|
|
|
import com.fs.erp.dto.*;
|
|
|
import com.fs.erp.dto.df.*;
|
|
|
import com.fs.erp.service.IErpOrderService;
|
|
|
import com.fs.erp.utils.WeizouApiClient;
|
|
|
-import com.fs.event.*;
|
|
|
-import com.fs.gtPush.service.uniPush2Service;
|
|
|
+import com.fs.event.TemplateBean;
|
|
|
+import com.fs.event.TemplateEvent;
|
|
|
+import com.fs.event.TemplateListenEnum;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
import com.fs.his.config.StoreConfig;
|
|
|
import com.fs.his.domain.*;
|
|
|
@@ -54,9 +59,7 @@ import com.fs.his.service.*;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.utils.PhoneUtil;
|
|
|
import com.fs.his.vo.*;
|
|
|
-import com.fs.hisStore.domain.FsPayConfigScrm;
|
|
|
import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
|
-import com.fs.hisStore.domain.FsStorePaymentScrm;
|
|
|
import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
|
import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
|
|
|
import com.fs.hisStore.param.FsStoreOrderRefundByProductParam;
|
|
|
@@ -66,8 +69,8 @@ import com.fs.hisapi.domain.ApiResponse;
|
|
|
import com.fs.hisapi.param.CreateOrderParam;
|
|
|
import com.fs.hisapi.param.RecipeDetailParam;
|
|
|
import com.fs.hisapi.service.HisApiService;
|
|
|
-import com.fs.huifuPay.domain.*;
|
|
|
-import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentDelaytransConfirmRequest;
|
|
|
+import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
+import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
|
import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
import com.fs.im.dto.*;
|
|
|
@@ -78,15 +81,15 @@ import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.fs.qw.service.impl.QwUserServiceImpl;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
|
+import com.fs.system.mapper.SysConfigMapper;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
+import com.fs.tzBankPay.TzBankService.TzBankService;
|
|
|
import com.fs.tzBankPay.doman.*;
|
|
|
import com.fs.ybPay.domain.CreateWxOrderResult;
|
|
|
import com.fs.ybPay.domain.OrderResult;
|
|
|
import com.fs.ybPay.dto.OrderQueryDTO;
|
|
|
import com.fs.ybPay.dto.WxJspayDTO;
|
|
|
import com.fs.ybPay.service.IPayService;
|
|
|
-import com.fs.system.mapper.SysConfigMapper;
|
|
|
-import com.fs.system.service.ISysConfigService;
|
|
|
-import com.fs.tzBankPay.TzBankService.TzBankService;
|
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
|
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
|
@@ -125,6 +128,8 @@ import java.nio.charset.Charset;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -380,11 +385,12 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
//推送修改的互联网医院订单地址到聚水潭ERP
|
|
|
try {
|
|
|
pushOrderAddressToErp(fsStoreOrder);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("修改互联网医院订单地址推送到聚水潭ERP失败,orderId: {}", fsStoreOrder.getOrderId(), e);
|
|
|
}
|
|
|
return fsStoreOrderMapper.updateFsStoreOrder(fsStoreOrder);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 推送修改订单的最新地址到 ERP
|
|
|
*
|
|
|
@@ -1660,7 +1666,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class, propagation = Propagation.REQUIRED)
|
|
|
- public R payConfirm(String orderCode, String payCode, String tradeNo, String payType, Integer type,String bankTransactionId,String bankSerialNo){
|
|
|
+ public R payConfirm(String orderCode, String payCode, String tradeNo, String payType, Integer type, String bankTransactionId, String bankSerialNo) {
|
|
|
try {
|
|
|
FsStoreOrder order = null;
|
|
|
if (type.equals(1)) {
|
|
|
@@ -3255,12 +3261,12 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
} else {
|
|
|
appId = merchantAppConfig.getAppId();
|
|
|
openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
- if (StringUtils.isBlank(openId)){
|
|
|
+ if (StringUtils.isBlank(openId)) {
|
|
|
Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
.eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
.eq(FsUserWx::getAppId, appId);
|
|
|
FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
- if (Objects.nonNull(fsUserWx)){
|
|
|
+ if (Objects.nonNull(fsUserWx)) {
|
|
|
openId = fsUserWx.getOpenId();
|
|
|
}
|
|
|
}
|
|
|
@@ -4627,11 +4633,28 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
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())
|
|
|
+ param.setRealName(order.getUserName()).setPhone(order.getUserPhone().length() > 11 ? decryptPhone(order.getUserPhone()) : order.getUserPhone())
|
|
|
.setFreightPrice(order.getFreightPrice()).setExtendOrderId(order.getOrderId().toString())
|
|
|
- .setPayType(order.getPayType()==1?"02":"04")
|
|
|
- .setPaymentType(order.getPayType()==1?"01":"02").setDeliveryType("顺丰快递")
|
|
|
;
|
|
|
+ //全款
|
|
|
+ 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("邮政快递")
|
|
|
+ ;
|
|
|
+ }
|
|
|
//商品
|
|
|
FsStoreOrderItem itemMap = new FsStoreOrderItem();
|
|
|
itemMap.setOrderId(order.getOrderId());
|
|
|
@@ -4680,66 +4703,263 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
String s = WeizouApiClient.pushOrder(param);
|
|
|
log.info("微走推送结果:{}",s);
|
|
|
}
|
|
|
+ private static final int STATUS_PENDING_SHIPMENT = 2;
|
|
|
+ private static final int STATUS_SHIPPED = 3;
|
|
|
+ private static final int STATUS_TO_EVALUATED = 4;
|
|
|
+ private static final String OPERATOR_CANCEL = "0";
|
|
|
+ private static final String OPERATOR_UPDATE = "1";
|
|
|
+ private static final String LOG_TYPE_DELIVERY = "delivery_goods";
|
|
|
+ private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
|
|
|
@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;
|
|
|
+ public Integer sendGoodsWeizou(FsStoreOrder fsStoreOrder) {
|
|
|
+ // 1. 参数校验
|
|
|
+// validateSendGoodsParams(fsStoreOrder, opeName);//controller处理了
|
|
|
+
|
|
|
+ // 2. 查询原始订单
|
|
|
+ FsStoreOrder originalOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderId(fsStoreOrder.getOrderId());
|
|
|
+ if (originalOrder == null) {
|
|
|
+ throw new CustomException("订单不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 根据操作类型分发处理
|
|
|
+ if (OPERATOR_CANCEL.equals(fsStoreOrder.getOperator())) {
|
|
|
+ return processCancelDelivery(originalOrder, fsStoreOrder, "微走取消订单");
|
|
|
+ }
|
|
|
+ else if (WeizouOrderExpressEnum.SEND_ORDER.getCode().equals(fsStoreOrder.getOperator())){
|
|
|
+ return processNormalDelivery(originalOrder, fsStoreOrder, "微走发货同步订单单号更新");
|
|
|
}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);
|
|
|
+ return processUpdateDelivery(originalOrder, fsStoreOrder, "微走订单更新"); }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理订单状态更新//todo 到货后续业务逻辑需要对接
|
|
|
+ */
|
|
|
+ private int processUpdateDelivery(FsStoreOrder originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
+ //微走有多个状态,需要分别记录
|
|
|
+ if (originalOrder.getStatus() == STATUS_SHIPPED) {
|
|
|
+ updateOrderToEvaluated(fsStoreOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 记录日志
|
|
|
+ log.info("微走快递送达, 订单号: {}",
|
|
|
+ fsStoreOrder.getOrderId());
|
|
|
+ return saveOrderLog(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 processNormalDelivery(FsStoreOrder originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
+ int result;
|
|
|
+
|
|
|
+ if (originalOrder.getStatus() == STATUS_PENDING_SHIPMENT) {
|
|
|
+ // 待发货状态:执行发货操作
|
|
|
+ result = executeShipOrder(originalOrder, fsStoreOrder, opeName);
|
|
|
+ } else {
|
|
|
+ // 其他状态:只更新快递信息
|
|
|
+ result = updateDeliveryInfo(originalOrder, fsStoreOrder, opeName);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 订阅快递信息(两种场景都需要)
|
|
|
+// subscribeExpress(originalOrder, fsStoreOrder);//2026-3-20沟通后今正用微走接口调用的方式更新物流状态
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 执行发货操作
|
|
|
+ */
|
|
|
+ private int executeShipOrder(FsStoreOrder originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
+ // 1. 更新订单为已发货
|
|
|
+ FsStoreOrder updateOrder = buildShipOrderUpdate(fsStoreOrder);
|
|
|
+ int result = fsStoreOrderMapper.updateFsStoreOrder(updateOrder);
|
|
|
+
|
|
|
+ // 2. 处理公司扣款
|
|
|
+ if (originalOrder.getCompanyId() != null) {
|
|
|
+ companyService.subtractCompanyMoney(originalOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 记录日志
|
|
|
+ String logMessage = opeName + " 订单发货";
|
|
|
+ saveOrderLog(fsStoreOrder, opeName, logMessage);
|
|
|
+
|
|
|
+ log.info("微走订单发货成功, 订单号: {}, 快递公司: {}, 快递单号: {}",
|
|
|
+ fsStoreOrder.getOrderId(),
|
|
|
+ fsStoreOrder.getDeliveryName(),
|
|
|
+ fsStoreOrder.getDeliverySn());
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新快递信息
|
|
|
+ */
|
|
|
+ private int updateDeliveryInfo(FsStoreOrder originalOrder, FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
+ // 1. 只更新快递相关信息
|
|
|
+ FsStoreOrder updateOrder = buildDeliveryInfoUpdate(fsStoreOrder);
|
|
|
+ int result = fsStoreOrderMapper.updateFsStoreOrder(updateOrder);
|
|
|
+
|
|
|
+ // 2. 记录日志
|
|
|
+ String logMessage = opeName + " 订单单号更新";
|
|
|
+ saveOrderLog(fsStoreOrder, opeName, logMessage);
|
|
|
+
|
|
|
+ log.info("微走修改快递单号, 订单号: {}, 新快递单号: {}",
|
|
|
+ fsStoreOrder.getOrderId(), fsStoreOrder.getDeliverySn());
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新订单为已取消状态
|
|
|
+ */
|
|
|
+ private void updateOrderToCancelled(FsStoreOrder fsStoreOrder) {
|
|
|
+ FsStoreOrder updateOrder = new FsStoreOrder();
|
|
|
+ updateOrder.setOrderId(fsStoreOrder.getOrderId());
|
|
|
+ updateOrder.setStatus(STATUS_SHIPPED);
|
|
|
+ updateOrder.setUpdateTime(new DateTime());
|
|
|
+ updateOrder.setDeliveryTime(getCurrentDateTimeString());
|
|
|
+
|
|
|
+ fsStoreOrderMapper.updateFsStoreOrder(updateOrder);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 更新订单为待评价状态
|
|
|
+ */
|
|
|
+ private void updateOrderToEvaluated(FsStoreOrder fsStoreOrder) {
|
|
|
+ FsStoreOrder updateOrder = new FsStoreOrder();
|
|
|
+ updateOrder.setOrderId(fsStoreOrder.getOrderId());
|
|
|
+ updateOrder.setStatus(STATUS_TO_EVALUATED);
|
|
|
+ updateOrder.setUpdateTime(new DateTime());
|
|
|
+ updateOrder.setDeliveryTime(getCurrentDateTimeString());
|
|
|
+
|
|
|
+ fsStoreOrderMapper.updateFsStoreOrder(updateOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建发货订单更新对象
|
|
|
+ */
|
|
|
+ private FsStoreOrder buildShipOrderUpdate(FsStoreOrder fsStoreOrder) {
|
|
|
+ FsStoreOrder updateOrder = new FsStoreOrder();
|
|
|
+ updateOrder.setOrderId(fsStoreOrder.getOrderId());
|
|
|
+ updateOrder.setStatus(STATUS_SHIPPED);
|
|
|
+ updateOrder.setUpdateTime(new DateTime());
|
|
|
+ updateOrder.setDeliveryCode(fsStoreOrder.getDeliveryCode());
|
|
|
+ updateOrder.setDeliveryName(fsStoreOrder.getDeliveryName());
|
|
|
+ updateOrder.setDeliverySn(fsStoreOrder.getDeliverySn());
|
|
|
+ updateOrder.setDeliveryTime(getCurrentDateTimeString());
|
|
|
+
|
|
|
+ return updateOrder;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建快递信息更新对象
|
|
|
+ */
|
|
|
+ private FsStoreOrder buildDeliveryInfoUpdate(FsStoreOrder fsStoreOrder) {
|
|
|
+ FsStoreOrder updateOrder = new FsStoreOrder();
|
|
|
+ updateOrder.setOrderId(fsStoreOrder.getOrderId());
|
|
|
+ updateOrder.setDeliveryCode(fsStoreOrder.getDeliveryCode());
|
|
|
+ updateOrder.setDeliveryName(fsStoreOrder.getDeliveryName());
|
|
|
+ updateOrder.setDeliverySn(fsStoreOrder.getDeliverySn());
|
|
|
+ updateOrder.setUpdateTime(new DateTime());
|
|
|
+ // 注意:这里不更新状态和发货时间
|
|
|
+
|
|
|
+ return updateOrder;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存订单日志
|
|
|
+ */
|
|
|
+ private int saveOrderLog(FsStoreOrder fsStoreOrder, String operator, String message) {
|
|
|
+ FsStoreOrderLogs logs = new FsStoreOrderLogs();
|
|
|
+ logs.setChangeMessage(message);
|
|
|
+ logs.setOrderId(fsStoreOrder.getOrderId());
|
|
|
+ logs.setChangeTime(new DateTime());
|
|
|
+ logs.setChangeType(LOG_TYPE_DELIVERY);
|
|
|
+ logs.setOperator(operator);
|
|
|
+
|
|
|
+ return fsStoreOrderLogsMapper.insertFsStoreOrderLogs(logs);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订阅快递信息
|
|
|
+ */
|
|
|
+ private void subscribeExpress(FsStoreOrder originalOrder, FsStoreOrder fsStoreOrder) {
|
|
|
+ String lastFourNumber = "";
|
|
|
+
|
|
|
+ // 顺丰需要手机号后四位
|
|
|
+ if (ShipperCodeEnum.SF.getValue().equals(fsStoreOrder.getDeliveryCode())) {
|
|
|
+ lastFourNumber = getLastFourPhoneNumber(originalOrder.getUserPhone());
|
|
|
+ }
|
|
|
+
|
|
|
+ expressService.subscribeEspress(
|
|
|
+ originalOrder.getOrderCode(),
|
|
|
+ fsStoreOrder.getDeliveryCode(),
|
|
|
+ fsStoreOrder.getDeliverySn(),
|
|
|
+ lastFourNumber
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取手机号后四位
|
|
|
+ */
|
|
|
+ private String getLastFourPhoneNumber(String phone) {
|
|
|
+ if (phone != null && phone.length() == 11) {
|
|
|
+ return phone.substring(7); // 索引7开始取后4位
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前时间字符串
|
|
|
+ */
|
|
|
+ private String getCurrentDateTimeString() {
|
|
|
+ return LocalDateTime.now().format(DATE_TIME_FORMATTER);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 参数校验
|
|
|
+ */
|
|
|
+ private void validateSendGoodsParams(FsStoreOrder fsStoreOrder, String opeName) {
|
|
|
+ if (fsStoreOrder == null) {
|
|
|
+ throw new IllegalArgumentException("订单参数不能为空");
|
|
|
+ }
|
|
|
+ if (fsStoreOrder.getOrderId() == null) {
|
|
|
+ throw new IllegalArgumentException("订单ID不能为空");
|
|
|
+ }
|
|
|
+ if (opeName == null) {
|
|
|
+ throw new IllegalArgumentException("备注不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 非取消操作需要校验快递信息
|
|
|
+ if (!OPERATOR_CANCEL.equals(fsStoreOrder.getOperator()) ) {
|
|
|
+ if (!OPERATOR_UPDATE.equals(fsStoreOrder.getOperator())){
|
|
|
+ if (fsStoreOrder.getDeliveryCode() == null) {
|
|
|
+ throw new IllegalArgumentException("快递公司编码不能为空");
|
|
|
}
|
|
|
}
|
|
|
- expressService.subscribeEspress(order.getOrderCode(), fsStoreOrder.getDeliveryCode(), fsStoreOrder.getDeliverySn(), lastFourNumber);
|
|
|
- return i;
|
|
|
+ if (fsStoreOrder.getDeliverySn() == null) {
|
|
|
+ throw new IllegalArgumentException("快递单号不能为空");
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|