feat: 订单

pull/1121/head
梁宇奇 2025-04-15 22:35:57 +08:00
parent d0530eddf0
commit 440f86d3fb
10 changed files with 508 additions and 23 deletions

View File

@ -37,11 +37,6 @@ public class CommonController {
private OSSProperties ossProperties;
@Autowired
private RedisCache redisCache;
/**
* STS()
*/
@Value("${sts_cache_duration:1800}")
private Integer stsCacheDuration;
@ApiOperation("获取OSS临时访问凭证")
@GetMapping("/oss/getCredentials")
@ -63,11 +58,11 @@ public class CommonController {
vo.setBucketName(ossProperties.getBucketName());
vo.setRegionId(ossProperties.getRegionId());
vo.setEndPoint(ossProperties.getEndPoint());
vo.setExpiredDuration(ossProperties.getExpiredDuration() - stsCacheDuration);
vo.setExpiredDuration(ossProperties.getExpiredDuration() - ossProperties.getStsCacheDuration());
vo.setHttpsFlag(ossProperties.isHttps());
//缓存
redisCache.setCacheObject(CacheConstants.USER_STS_KEY + currentUserId, JSONUtil.toJsonStr(vo),
stsCacheDuration, TimeUnit.SECONDS);
ossProperties.getStsCacheDuration(), TimeUnit.SECONDS);
return R.ok(vo);
}

View File

@ -5,6 +5,8 @@ import com.ruoyi.common.core.controller.XktBaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.web.controller.xkt.vo.express.ExpressRegionTreeNodeVO;
import com.ruoyi.xkt.dto.express.ExpressRegionTreeNodeDTO;
import com.ruoyi.xkt.manager.ExpressManager;
import com.ruoyi.xkt.manager.impl.ZtExpressManagerImpl;
import com.ruoyi.xkt.service.IExpressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,6 +29,10 @@ public class ExpressController extends XktBaseController {
@Autowired
private IExpressService expressService;
@Autowired
private List<ExpressManager> expressManagers;
@Autowired
private ZtExpressManagerImpl ztExpressManager;
@PreAuthorize("@ss.hasPermi('system:express:query')")
@ApiOperation("获取行政规划树")

View File

@ -22,6 +22,7 @@ oss:
roleArn: acs:ram::1919425406190533:role/sts-role
expiredDuration: 3600
tempDir: E:/temp/
stsCacheDuration: 1800
es:
#多个用","分割
hosts: 49.234.41.39:9222
@ -161,3 +162,27 @@ xss:
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# 物流配置
express:
default:
province: 510000
city: 510100
county: 510114
# 中通配置
zt:
appKey: 95dc4ecf72fce1a2fbe79
appSecret: 694ea7e3ea89e3b6aa21aea1a0285d25
gatewayUrl: https://japi-test.zto.com/
# 支付宝配置
alipay:
appId: 9021000144616672
privateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC3x52ARikELwpOPvPcpY9jj7aEWIPivfBwkf3YRyUKnM7L6mOTxD1v3b7QLcL1+l0QmvOPSGgt2O3Qbjtvq+5ih4T32TlAzHGe8VqGVqrEv7ANQicsXz600ze5LdxCDRgBZWhO/GroGJKfenHf7K+arN4KXWWmHyZHCYD5z85TEvZZoA9e9MTMskXeDS8+fwP6McuNf4fR07kVuzblks+wWm1PsWfxFM7qNwSYKXbmEoyDe7+M9vBr7cwuj2OB3PEtj/FZjKMxVnFyVm61KiFAGUf3oUqWmPASTPDkFboRCS/njv980hk3sPba/qMDfMEpjoMZrcLBVzoj747oEi/DAgMBAAECggEAcVoXlRSxG7l/278MXl1nUXtEkeCeh+2rLWN+dDV9bUxGaJOLE4sIccUNeg2foGPpnuJTs15vk0endtVmp3weLntz0gMTQxpWQjiPIyi1b2Djz2msC7w7SwCz7+2PWtYEpmfLrFwX/Eubs+2r6vdrYDWbRj1RAuNXkp0UBgDcO3P9AFeGln5gUWxni4biN6B9sGGdsSwcm1A9biBPRsH2zMSVVWkhLVq+S73smm2Sh7WTIVEyeAuWEDeMs5oI2jQjPHMlUKmWW6JZ3uD5xbRm3Nkvve/nvfJ4ZXx58ABTI9EWzcBlEuLYef4T+P9q4KHZQljpJ4UliIxUVIDSk3GNMQKBgQDevjYnLW2FBNDYQvPf6FkD2iNzKFe80cQYR0+/jiSBgkmtQhXZgyJ2ZqQ5t20MjgLpeY0WJL2twBlFcYGico6Vnv+JMiJDtIjTu1UozAqV2VPeJ34nX34nqJptGwehiPXJupAiulAWtvTqsiYWlFHsr3dMtj6z07M+gDV8PU7P/QKBgQDTOCGgdrS3XYD680eH9vGKbH1DpIOMr3JokLk6kv4yui9Jxk5DMCxcJWkEQRnCrw2UYM8PfX17FqXrwhccmR9hskSmmbLONYzk4SDB73fM2nPqBw+VLO6jbWctylUsGaYfVxDOLDWPQkktKUsHK8pQHLNQ4jwlP5SGQUoIM/OqvwKBgHfRrmPIxh9GBeovqeyKmke+Mk+iJgBGfsvooHeUyQJ5yZRP9lz5c7JpaHI7v4d/ZQWfA0wkG3y5115JvshaA2VtEF0HAPOWy/vJy/eUOyV8sObSK8SWU9CVm+yRG7vDZyRLHXnw62AsrvcJOf/vbVp60RwM9RHbEZLPePYKLLkpAoGADPMaDK56ceuHptsXfZyEPopcO7NwZUW0a/jDgnXUo+OKVqmTzsa7UYLxp1MeczMsT/aHe1mkQdGnpoalyBkTNXgqgVRXBBGAa9/plDpMTADwrl50dB7nGpnwg3wuMJ/58V3zJ9DKD9huiBhKA0yKANNhownbyiTVxE1oboxQ2h0CgYEAkV4hjGe4t6mu5rhqvuIZkDskjuSOwO0dZsGXBZ/sOZusKNmskxeNZht4BajnATN4EaPg265k8ytWnOEQH041J8Wac1M+jAQQp6D1nkQWZZlrclTu7xvM+p6ypVtqNFTseIQtEhtyPw+fcsYrXM4u8LHpGlAzlwQ30lFg+K/Q++Y=
alipayPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkiTTeQLIkyVHnYiNmRKEtsdlwKftUySN1SLkrhn6CgmHl5ovjPeYteweZEZmsf2kt6wRnaLkODVP7xUQiRVC2cu6StdJyvDzyiYI00u72PvSOvaWHcpzgKqTFpGiQseJQlHnI8U3ob4PxfJylBy8RDQHG9fZwNY1WOCsnSb3m2ufV1EQIjndzTq13yQE6jCz639rO8atlAG3PtJW/QRiGUzyGaOuKsS4HRzPbbpmVtsXoN76+x+WLWkeqlTBEu35X4Hdbkf1C36wp3b68sI5fVyLksF6elRv/It4aUzjXSXbO/Dx+zvMIN01FgwaFV6nLh++k3qlmo87p4I+hvsGiQIDAQAB
notifyUrl:
returnUrl:
signType: RSA2
charset: UTF-8
gatewayUrl: https://openapi-sandbox.dl.alipaydev.com/gateway.do

View File

@ -49,6 +49,11 @@ public class RedisCache
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
}
public <T> void setCacheObject(final String key, final T value, final Long timeout, final TimeUnit timeUnit)
{
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
}
/**
*
*

View File

@ -28,4 +28,6 @@ public class OSSProperties {
private Long expiredDuration;
private String tempDir;
private Long stsCacheDuration;
}

View File

@ -0,0 +1,271 @@
package com.ruoyi.xkt.dto.express.zt;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author liangyq
* @date 2025-04-15 19:20
*/
@Data
public class CreateOrderReqDTO {
/**
* 12
*/
private String partnerType;
/**
* partnerType1orderType1 2 partnerType2orderType1 2 3 4
*/
private String orderType;
/**
*
*/
private String partnerOrderCode;
/**
* ,AccountDto
*/
private AccountInfo accountInfo;
/**
*
*/
private String billCode;
/**
* ,SenderInfoInput
*/
private SenderInfo senderInfo;
/**
* ,ReceiveInfoInput
*/
private ReceiveInfo receiveInfo;
/**
*
*/
private List<OrderVas> orderVasList;
/**
* /partnerType1使
*/
private String hallCode;
/**
* codeorderVasList.vasTypereceiveReturnService
*/
private String siteCode;
/**
* orderVasList.vasTypereceiveReturnService
*/
private String siteName;
/**
* ,SummaryDto
*/
private SummaryInfo summaryInfo;
/**
*
*/
private String remark;
/**
*
*/
private List<OrderItem> orderItems;
/**
* ,ExpressCabinetDto
*/
private Cabinet cabinet;
@Data
public static class AccountInfo {
/**
* partnerType2orderType1,2,4
*/
private String accountId;
/**
* ZTO123
*/
private String accountPassword;
/**
* :1.74.1
*/
private Integer type;
/**
* partnerType1
*/
private String customerId;
}
@Data
public static class SenderInfo {
/**
* senderInfo
*/
private String senderId;
/**
*
*/
private String senderName;
/**
* senderMobile
*/
private String senderPhone;
/**
* senderPhone
*/
private String senderMobile;
/**
*
*/
private String senderProvince;
/**
*
*/
private String senderCity;
/**
*
*/
private String senderDistrict;
/**
*
*/
private String senderAddress;
}
@Data
public static class ReceiveInfo {
/**
*
*/
private String receiverName;
/**
* receiverMobile
*/
private String receiverPhone;
/**
* receiverPhone
*/
private String receiverMobile;
/**
*
*/
private String receiverProvince;
/**
*
*/
private String receiverCity;
/**
*
*/
private String receiverDistrict;
/**
*
*/
private String receiverAddress;
}
@Data
public static class OrderVas {
/**
* COD vip insured receiveReturnService twoHourstandardExpress
*/
private String vasType;
/**
* vasTypeCODinsured
*/
private Long vasAmount;
/**
*
*/
private Long vasPrice;
/**
*
*/
private String vasDetail;
/**
*
*/
private String accountNo;
}
@Data
public static class SummaryInfo {
/**
*
*/
private String size;
/**
*
*/
private Integer quantity;
/**
*
*/
private BigDecimal price;
/**
*
*/
private BigDecimal freight;
/**
*
*/
private BigDecimal premium;
/**
*
*/
private Date startTime;
/**
*
*/
private Date endTime;
}
@Data
public static class OrderItem {
/**
*
*/
private String name;
/**
*
*/
private String category;
/**
*
*/
private String material;
/**
* ,,(),
*/
private String size;
/**
* )
*/
private Long weight;
/**
* (:)
*/
private Integer unitprice;
/**
*
*/
private Integer quantity;
/**
*
*/
private String remark;
}
@Data
public static class Cabinet {
/**
*
*/
private String address;
/**
* ( 1 2 3
*/
private Integer specification;
/**
*
*/
private String code;
}
}

View File

@ -16,6 +16,7 @@ public enum EOrderAction {
DELETE(3, "删除"),
PAY(4, "支付"),
CANCEL(5, "取消"),
SHIP(6, "发货"),
;
private final Integer value;

View File

@ -3,6 +3,7 @@ package com.ruoyi.xkt.manager.impl;
import com.ruoyi.xkt.enums.EExpressChannel;
import com.ruoyi.xkt.manager.ExpressManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
@ -12,6 +13,20 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public class ZtExpressManagerImpl implements ExpressManager {
private static final String CREATE_ORDER_URI = "zto.open.createOrder";
private static final String STRUCTURE_ADDRESS_URI = "zto.innovate.structureNamePhoneAddress";
@Value("${zt.appKey:}")
private String appKey;
@Value("${zt.appSecret:}")
private String appSecret;
@Value("${zt.gatewayUrl:}")
private String gatewayUrl;
@Override
public EExpressChannel channel() {
return EExpressChannel.ZT;

View File

@ -90,7 +90,22 @@ public interface IStoreOrderService {
* @param storeOrderId
* @param storeOrderDetailIds
* @param expressId
* @param operatorId
* @return
*/
StoreOrderExt preparePlaceOrder(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId);
StoreOrderExt prepareShipOrderByPlatform(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId,
Long operatorId);
/**
*
*
* @param storeOrderId
* @param storeOrderDetailIds
* @param expressId
* @param expressWaybillNo
* @param operatorId
* @return
*/
StoreOrderExt shipOrderByStore(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId,
String expressWaybillNo, Long operatorId);
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.Page;
@ -19,6 +20,7 @@ import com.ruoyi.xkt.dto.express.ExpressRegionDTO;
import com.ruoyi.xkt.dto.order.*;
import com.ruoyi.xkt.dto.storeProductFile.StoreProdMainPicDTO;
import com.ruoyi.xkt.enums.*;
import com.ruoyi.xkt.manager.ExpressManager;
import com.ruoyi.xkt.manager.PaymentManager;
import com.ruoyi.xkt.mapper.*;
import com.ruoyi.xkt.service.IExpressService;
@ -71,6 +73,8 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
private IVoucherSequenceService voucherSequenceService;
@Autowired
private List<PaymentManager> paymentManagers;
@Autowired
private List<ExpressManager> expressManagers;
@Transactional(rollbackFor = Exception.class)
@Override
@ -210,10 +214,7 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
@Override
public StoreOrderExt modifyOrder(StoreOrderUpdateDTO storeOrderUpdateDTO) {
//原订单
StoreOrder order = storeOrderMapper.selectById(storeOrderUpdateDTO.getId());
if (!BeanValidators.exists(order)) {
throw new ServiceException("订单[" + storeOrderUpdateDTO.getId() + "]不存在");
}
StoreOrder order = getAndBaseCheck(storeOrderUpdateDTO.getId());
Long orderUserId = storeOrderUpdateDTO.getOrderUserId();
Long storeId = storeOrderUpdateDTO.getStoreId();
Long expressId = storeOrderUpdateDTO.getExpressId();
@ -441,12 +442,10 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
@Transactional(rollbackFor = Exception.class)
@Override
public StoreOrderExt preparePayOrder(Long storeOrderId, EPayChannel payChannel) {
Assert.notNull(storeOrderId);
Assert.notNull(payChannel);
StoreOrder order = storeOrderMapper.selectById(storeOrderId);
StoreOrder order = getAndBaseCheck(storeOrderId);
Assert.isTrue(EOrderType.SALES_ORDER.getValue().equals(order.getOrderType()),
"非销售订单无法发起支付");
Assert.isTrue(BeanValidators.exists(order), "订单不存在");
if (payChannel != EPayChannel.of(order.getPayChannel())) {
throw new ServiceException("订单支付渠道不允许修改");
}
@ -474,11 +473,9 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
@Transactional(rollbackFor = Exception.class)
@Override
public StoreOrderExt paySuccess(Long storeOrderId, BigDecimal totalAmount, BigDecimal realTotalAmount) {
Assert.notNull(storeOrderId);
StoreOrder order = storeOrderMapper.selectById(storeOrderId);
StoreOrder order = getAndBaseCheck(storeOrderId);
Assert.isTrue(EOrderType.SALES_ORDER.getValue().equals(order.getOrderType()),
"订单类型异常");
Assert.isTrue(BeanValidators.exists(order), "订单不存在");
if (!order.getPayStatus().equals(EPayStatus.PAYING.getValue())
|| !order.getOrderStatus().equals(EOrderStatus.PENDING_PAYMENT.getValue())) {
log.error("订单状态异常,更新支付结果失败: id = {}", storeOrderId);
@ -526,9 +523,7 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
@Transactional(rollbackFor = Exception.class)
@Override
public void cancelOrder(OrderOptDTO opt) {
Assert.notNull(opt.getStoreOrderId());
StoreOrder order = storeOrderMapper.selectById(opt.getStoreOrderId());
Assert.isTrue(BeanValidators.exists(order), "订单不存在");
StoreOrder order = getAndBaseCheck(opt.getStoreOrderId());
EOrderStatus oStatus = EOrderStatus.of(order.getOrderStatus());
EPayStatus pStatus = EPayStatus.of(order.getPayStatus());
if (EOrderStatus.PENDING_PAYMENT != oStatus) {
@ -567,9 +562,139 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
opt.getOperatorId(), new Date());
}
@Transactional(rollbackFor = Exception.class)
@Override
public StoreOrderExt preparePlaceOrder(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId) {
return null;
public StoreOrderExt prepareShipOrderByPlatform(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId,
Long operatorId) {
Assert.notEmpty(storeOrderDetailIds);
// ExpressManager expressManager = getExpressManager(expressId);
Express express = expressService.getById(expressId);
if (!BeanValidators.exists(express) || !express.getSystemDeliverAccess()) {
throw new ServiceException("快递[" + expressId + "]不可用");
}
StoreOrder order = getAndBaseCheck(storeOrderId);
if (!EOrderStatus.PENDING_SHIPMENT.getValue().equals(order.getOrderStatus())
&& !EOrderStatus.SHIPPED.getValue().equals(order.getOrderStatus())) {
throw new ServiceException("订单[" + order.getId() + "]当前状态无法发货");
}
List<StoreOrderDetail> containDetails = storeOrderDetailMapper.selectList(
Wrappers.lambdaQuery(StoreOrderDetail.class)
.eq(StoreOrderDetail::getStoreOrderId, order.getId())
.eq(SimpleEntity::getDelFlag, Constants.UNDELETED));
for (StoreOrderDetail containDetail : containDetails) {
if (EDeliveryType.SHIP_COMPLETE.getValue().equals(order.getDeliveryType())) {
//如果是货齐再发,此次发货需要包含所有明细
if (!storeOrderDetailIds.contains(containDetail.getId())) {
throw new ServiceException("订单[" + order.getId() + "]不可拆单发货");
}
}
if (EExpressType.STORE.getValue().equals(containDetail.getExpressType())) {
//已存在档口发货的明细
throw new ServiceException("订单[" + order.getId() + "]由档口物流发货!");
}
}
List<StoreOrderDetail> orderDetails = storeOrderDetailMapper.selectByIds(storeOrderDetailIds);
//订单->已发货
order.setOrderStatus(EOrderStatus.SHIPPED.getValue());
int orderSuccess = storeOrderMapper.updateById(order);
if (orderSuccess == 0) {
throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG);
}
//生成请求号
String expressReqNo = IdUtil.simpleUUID();
List<Long> orderDetailIdList = new ArrayList<>(orderDetails.size());
for (StoreOrderDetail orderDetail : orderDetails) {
if (!BeanValidators.exists(orderDetail)) {
throw new ServiceException("订单明细[" + orderDetail.getId() + "]不存在");
}
if (!order.getId().equals(orderDetail.getStoreOrderId())) {
throw new ServiceException("发货订单[" + order.getId() + "]与明细[" + orderDetail.getId() + "]不匹配");
}
if (!EOrderStatus.PENDING_SHIPMENT.getValue().equals(orderDetail.getDetailStatus())) {
throw new ServiceException("订单明细[" + order.getId() + "]当前状态无法发货");
}
//明细->已发货
orderDetail.setDetailStatus(EOrderStatus.SHIPPED.getValue());
orderDetail.setExpressId(expressId);
orderDetail.setExpressType(EExpressType.PLATFORM.getValue());
orderDetail.setExpressStatus(EExpressStatus.PLACING.getValue());
orderDetail.setExpressReqNo(expressReqNo);
int orderDetailSuccess = storeOrderDetailMapper.updateById(orderDetail);
if (orderDetailSuccess == 0) {
throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG);
}
orderDetailIdList.add(orderDetail.getId());
}
//操作记录
addOperationRecords(order.getId(), EOrderAction.SHIP, orderDetailIdList, EOrderAction.SHIP,
"平台物流发货", operatorId, new Date());
return new StoreOrderExt(order, orderDetails);
}
@Transactional(rollbackFor = Exception.class)
@Override
public StoreOrderExt shipOrderByStore(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId,
String expressWaybillNo, Long operatorId) {
Assert.notEmpty(storeOrderDetailIds);
Express express = expressService.getById(expressId);
if (!BeanValidators.exists(express) || !express.getStoreDeliverAccess()) {
throw new ServiceException("快递[" + expressId + "]不可用");
}
StoreOrder order = getAndBaseCheck(storeOrderId);
if (!EOrderStatus.PENDING_SHIPMENT.getValue().equals(order.getOrderStatus())
&& !EOrderStatus.SHIPPED.getValue().equals(order.getOrderStatus())) {
throw new ServiceException("订单[" + order.getId() + "]当前状态无法发货");
}
List<StoreOrderDetail> containDetails = storeOrderDetailMapper.selectList(
Wrappers.lambdaQuery(StoreOrderDetail.class)
.eq(StoreOrderDetail::getStoreOrderId, order.getId())
.eq(SimpleEntity::getDelFlag, Constants.UNDELETED));
for (StoreOrderDetail containDetail : containDetails) {
if (EDeliveryType.SHIP_COMPLETE.getValue().equals(order.getDeliveryType())) {
//如果是货齐再发,此次发货需要包含所有明细
if (!storeOrderDetailIds.contains(containDetail.getId())) {
throw new ServiceException("订单[" + order.getId() + "]不可拆单发货");
}
}
if (EExpressType.PLATFORM.getValue().equals(containDetail.getExpressType())) {
//已存在平台发货的明细
throw new ServiceException("订单[" + order.getId() + "]由平台物流发货!");
}
}
List<StoreOrderDetail> orderDetails = storeOrderDetailMapper.selectByIds(storeOrderDetailIds);
//订单->已发货
order.setOrderStatus(EOrderStatus.SHIPPED.getValue());
int orderSuccess = storeOrderMapper.updateById(order);
if (orderSuccess == 0) {
throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG);
}
List<Long> orderDetailIdList = new ArrayList<>(orderDetails.size());
for (StoreOrderDetail orderDetail : orderDetails) {
if (!BeanValidators.exists(orderDetail)) {
throw new ServiceException("订单明细[" + orderDetail.getId() + "]不存在");
}
if (!order.getId().equals(orderDetail.getStoreOrderId())) {
throw new ServiceException("发货订单[" + order.getId() + "]与明细[" + orderDetail.getId() + "]不匹配");
}
if (!EOrderStatus.PENDING_SHIPMENT.getValue().equals(orderDetail.getDetailStatus())) {
throw new ServiceException("订单明细[" + order.getId() + "]当前状态无法发货");
}
//明细->已发货
orderDetail.setDetailStatus(EOrderStatus.SHIPPED.getValue());
orderDetail.setExpressId(expressId);
orderDetail.setExpressType(EExpressType.STORE.getValue());
orderDetail.setExpressStatus(EExpressStatus.COMPLETED.getValue());
orderDetail.setExpressWaybillNo(expressWaybillNo);
int orderDetailSuccess = storeOrderDetailMapper.updateById(orderDetail);
if (orderDetailSuccess == 0) {
throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG);
}
orderDetailIdList.add(orderDetail.getId());
}
//操作记录
addOperationRecords(order.getId(), EOrderAction.SHIP, orderDetailIdList, EOrderAction.SHIP,
"档口物流发货", operatorId, new Date());
return new StoreOrderExt(order, orderDetails);
}
private void checkPreparePayStatus(Integer payStatus) {
@ -729,6 +854,15 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
return new OrderDetailCheckRtn(spcsMap, spMap, scMap);
}
private StoreOrder getAndBaseCheck(Long storeOrderId) {
Assert.notNull(storeOrderId);
StoreOrder order = storeOrderMapper.selectById(storeOrderId);
if (!BeanValidators.exists(order)) {
throw new ServiceException("订单[" + storeOrderId + "]不存在");
}
return order;
}
/**
*
*
@ -747,6 +881,22 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
throw new ServiceException("未知支付渠道");
}
/**
*
*
* @param expressId
* @return
*/
private ExpressManager getExpressManager(Long expressId) {
Assert.notNull(expressId);
for (ExpressManager expressManager : expressManagers) {
if (expressManager.channel().getExpressId().equals(expressId)) {
return expressManager;
}
}
throw new ServiceException("未知物流渠道");
}
@Data
@AllArgsConstructor
@NoArgsConstructor