Commit d0cf3625 authored by 332784038@qq.com's avatar 332784038@qq.com

Merge branch 'release-fix' into release

parents ed6f5ec1 a47c2b86
......@@ -94,7 +94,6 @@ import cn.iocoder.yudao.module.order.vo.orderItem.OrderItemInWarehouseVO;
import cn.iocoder.yudao.module.order.vo.orderObjective.OrderObjectiveBackVO;
import cn.iocoder.yudao.module.order.vo.orderSpecialNeed.OrderSpecialNeedCreateReqVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseIn.OrderWarehouseInSumBackVO;
import cn.iocoder.yudao.module.order.vo.targetLog.TargetOfferBackVO;
import cn.iocoder.yudao.module.product.dto.FeeDto;
import cn.iocoder.yudao.module.product.enums.FeeTypeEnum;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
......@@ -130,6 +129,7 @@ import static cn.iocoder.yudao.framework.apollo.core.constants.Constants.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.ORDER_UPDATE;
import static cn.iocoder.yudao.module.order.enums.OrderStatusEnum.DRAFT;
/**
* 订单 Service 实现类
......@@ -228,7 +228,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
throw exception(EXTERNAL_WAREHOUSE_AND_CONCENTRATE_TRANSPORT_NOT_PARALLEL);
}
if (createReqVO.getIsExternalWarehouse() != null &&
createReqVO.getIsExternalWarehouse() && !Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
createReqVO.getIsExternalWarehouse() && !Objects.equals(createReqVO.getStatus(), DRAFT.getValue())) {
// 校验外部仓信息是否为空
if (CollectionUtil.isEmpty(createReqVO.getExternalWarehouseDtoList())) {
throw exception(ORDER_EXTERNAL_WAREHOUSE_NOT_NULL);
......@@ -242,7 +242,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
} else {
if (Objects.isNull(createReqVO.getDeliveryDate()) &&
!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
DRAFT.getValue())) {
throw exception(ORDER_DELIVERY_DATE_NOT_NULL);
}
}
......@@ -272,7 +272,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (CollectionUtil.isNotEmpty(createReqVO.getCustomDraweeVOList())) {
order.setCustomDrawee(JSONObject.toJSONString(createReqVO.getCustomDraweeVOList()));
} else {
if (!Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (!Objects.equals(createReqVO.getStatus(), DRAFT.getValue())) {
throw exception(ORDER_CUSTOM_DRAWEE_INFO_NOT_NULL);
}
}
......@@ -294,7 +294,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
RegionDO objective = regionService.getRegion(createReqVO.getObjectiveId());
String newOrderNo;
if (Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (Objects.equals(createReqVO.getStatus(), DRAFT.getValue())) {
newOrderNo = "DRAFT-" + System.currentTimeMillis();
} else {
newOrderNo = orderBusinessService.saveOrUpdateOrderNo(objective,
......@@ -312,7 +312,6 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setUpdater(creator);
order.setCreateTime(now);
order.setUpdateTime(now);
orderMapper.insert(order);
//订单始发地信息
......@@ -440,7 +439,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
//非草稿状态下才更新客户状态及其他数据
if (!OrderStatusEnum.DRAFT.getValue().equals(order.getStatus())) {
if (!DRAFT.getValue().equals(order.getStatus())) {
Set<Long> idSet = Stream.of(createReqVO.getConsignorId(), createReqVO.getConsigneeId(), order.getCustomerId()).filter(Objects::nonNull).collect(Collectors.toSet());
for (Long id : idSet) {
customerService.updateCustomerByCreateOrder(id, order.getOrderId(), order.getOrderNo(), order.getCreateTime());
......@@ -683,11 +682,11 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 控货订单没有收货人则不限制修改收货人
order.setIsLimitUpdateConsignee(Boolean.FALSE);
}
if (!Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (!Objects.equals(createReqVO.getStatus(), DRAFT.getValue())) {
//customerType 发货人-1 收货人 2
int customerType = this.checkOrderSalesman(order, createReqVO.getOfferId(), null, null, orderConsignorDO, orderConsigneeDO);
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getIsChargeCustomer()) && order.getIsChargeCustomer()) {
if (!DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getIsChargeCustomer()) && order.getIsChargeCustomer()) {
addOrderCustomerService(order, customerType);
}
}
......@@ -737,7 +736,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorDO.setCustomerId(consignorContactsDO.getCustomerId());
} else {
if (!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
DRAFT.getValue())) {
if (StringUtils.isBlank(createReqVO.getConsignorPhone())) {
throw exception(CONSIGNOR_PHONE_NOT_NULL);
}
......@@ -751,7 +750,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorDO.setEmail(createReqVO.getConsignorEmail());
}
if (!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
DRAFT.getValue())) {
if (StringUtils.isBlank(orderConsignorDO.getPhone()) ||
StringUtils.isBlank(orderConsignorDO.getCountryCode())) {
throw exception(ORDER_CONSIGNOR_PHONE_INFO_NOT_COMPLETE);
......@@ -789,7 +788,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
if (order.getIsCargoControl() &&
!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
DRAFT.getValue())) {
// 控货订单 添加控货人信息 (当放货人为空时不添加 注:
// 当报价单赢单创建的草稿订单可能发货人为空)
......@@ -859,7 +858,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsigneeDO.setCustomerId(consigneeContactsDO.getCustomerId());
} else {
if (!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
DRAFT.getValue())) {
if (StringUtils.isBlank(createReqVO.getConsigneePhone())) {
throw exception(CONSIGNEE_PHONE_NOT_NULL);
......@@ -889,7 +888,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsigneeDO.setUpdateTime(now);
if (!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
DRAFT.getValue())) {
if (StringUtils.isBlank(orderConsigneeDO.getPhone()) ||
StringUtils.isBlank(orderConsigneeDO.getCountryCode())) {
......@@ -932,7 +931,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setIsLimitUpdateConsignee(Boolean.FALSE);
}
if (!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
DRAFT.getValue())) {
// 发货人 1 收货人 2
int customerType = this.checkOrderSalesman(order,
createReqVO.getOfferId(),
......@@ -941,7 +940,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorDO,
orderConsigneeDO);
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getIsChargeCustomer()) && order.getIsChargeCustomer()) {
if (!DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getIsChargeCustomer()) && order.getIsChargeCustomer()) {
addOrderCustomerService(order, customerType);
}
}
......@@ -1518,7 +1517,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
(StringUtils.isBlank(oldOrderDO.getType()) && StringUtils.isNotBlank(updateReqVO.getType()) && updateReqVO.getType().contains("1"))) {
isResetOrderNo = Boolean.TRUE;
}
if (null == updateReqVO.getStatus() || !Objects.equals(oldOrderDO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (null == updateReqVO.getStatus() || !Objects.equals(oldOrderDO.getStatus(), DRAFT.getValue())) {
updateObj.setStatus(oldOrderDO.getStatus());
}
List<OrderItemDO> oldOrderItemDOList = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>().eq(OrderItemDO::getOrderId, oldOrderDO.getOrderId()));
......@@ -1530,7 +1529,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 编辑时有对商品项进行删除
orderItemMapper.update(null, new LambdaUpdateWrapper<OrderItemDO>().set(OrderItemDO::getDeleted, 1).in(OrderItemDO::getOrderItemId, itemIds));
}
if (!Objects.equals(oldOrderDO.getStatus(), OrderStatusEnum.DRAFT.getValue()) && !Objects.equals(oldOrderDO.getStatus(), OrderStatusEnum.ORDER_PLACED.getValue()) && !Objects.equals(oldOrderDO.getStatus(), OrderStatusEnum.WAREHOUSING.getValue())) {
if (!Objects.equals(oldOrderDO.getStatus(), DRAFT.getValue()) && !Objects.equals(oldOrderDO.getStatus(), OrderStatusEnum.ORDER_PLACED.getValue()) && !Objects.equals(oldOrderDO.getStatus(), OrderStatusEnum.WAREHOUSING.getValue())) {
// 不是草稿、已下单、入仓中状态 走审批流程
throw exception(PLEASE_SUBMIT_ORDER_UPDATE_APPROVAL);
}
......@@ -1570,7 +1569,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
RegionDO oldObjective = JSONObject.parseObject(objectiveDO.getObjective(), RegionDO.class);
// 如果是空运订单,订单运输方式未变,目的地国家未变,则不用更新订单编号
if (updateReqVO.getTransportId() == 3 && Objects.equals(updateReqVO.getTransportId(), oldOrderDO.getTransportId()) && !oldOrderDO.getOrderNo().contains("DRAFT")
&& !Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
&& !Objects.equals(updateReqVO.getStatus(), DRAFT.getValue())) {
if (Objects.nonNull(objective) && Objects.nonNull(oldObjective)) {
String[] labelCodes = objective.getLabelCode().split(StrUtil.DASHED);
String[] oldLabelCodes = oldObjective.getLabelCode().split(StrUtil.DASHED);
......@@ -1583,7 +1582,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
if (Objects.equals(objectiveDO.getObjectiveId(), updateReqVO.getObjectiveId()) && updateReqVO.getTransportId() == 3
&& Objects.equals(updateReqVO.getTransportId(), oldOrderDO.getTransportId()) && !oldOrderDO.getOrderNo().contains("DRAFT")
&& !Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
&& !Objects.equals(updateReqVO.getStatus(), DRAFT.getValue())) {
isSaveOrUpdateOrderNo = false;
}
......@@ -1592,7 +1591,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (isSaveOrUpdateOrderNo) {
String newOrderNo;
if (Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (Objects.equals(updateReqVO.getStatus(), DRAFT.getValue())) {
newOrderNo = "DRAFT-" + System.currentTimeMillis();
} else {
newOrderNo = orderBusinessService.saveOrUpdateOrderNo(objective, updateReqVO.getTransportId(), updateReqVO.getIsExternalWarehouse(),
......@@ -1606,7 +1605,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 目的地未变,运输方式变更,重新生成订单号
RegionDO objective = JSONObject.parseObject(objectiveDO.getObjective(), RegionDO.class);
String newOrderNo;
if (Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (Objects.equals(updateReqVO.getStatus(), DRAFT.getValue())) {
newOrderNo = "DRAFT-" + System.currentTimeMillis();
} else {
newOrderNo = orderBusinessService.saveOrUpdateOrderNo(objective, updateReqVO.getTransportId(), updateObj.getIsExternalWarehouse(),
......@@ -1756,7 +1755,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (Objects.nonNull(orderApprovalDO) && orderApprovalDO.getStatus() == 1) {
throw exception(YOUR_APPLY_PENDING);
}
if (Objects.equals(vo.getStatus(), OrderStatusEnum.DRAFT.getValue())
if (Objects.equals(vo.getStatus(), DRAFT.getValue())
|| Objects.equals(vo.getStatus(), OrderStatusEnum.ORDER_PLACED.getValue()) || Objects.equals(vo.getStatus(), OrderStatusEnum.WAREHOUSING.getValue())) {
// 是草稿、已下单、入仓中状态 直接修改
this.updateOrder(updateReqVO, memberUserDO);
......@@ -2547,7 +2546,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
CustomerDO orgCustomerDO = customerService.getCustomer(vo.getCustomerId());
// TODO 客户归属变动时记录日志
if (!Objects.equals(vo.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (!Objects.equals(vo.getStatus(), DRAFT.getValue())) {
ApplyInfoVO infoVO = null;
int customerType = 0; // 无变动 0 发货人 1 收货人 2
if (StringUtils.isNotBlank(vo.getType()) && vo.getType().contains("2")) {
......@@ -3120,7 +3119,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
updateObj.setIsLimitUpdateConsignee(Boolean.FALSE);
}
if (!Objects.equals(updateReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
DRAFT.getValue())) {
//customerType 发货人 1 收货人 2
int customerType =
......@@ -3131,7 +3130,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorDO,
orderConsigneeDO);
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus())
if (!DRAFT.getValue().equals(updateObj.getStatus())
&& ((Objects.nonNull(updateObj.getIsChargeCustomer()) && updateObj.getIsChargeCustomer())
|| (Objects.nonNull(updateObj.getIsChargeDraft()) && updateObj.getIsChargeDraft()))) {
addOrderCustomerService(updateObj, customerType);
......@@ -3177,7 +3176,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorDO.setCustomerContactsId(consignorContactsDO.getId());
orderConsignorDO.setCustomerId(consignorContactsDO.getCustomerId());
} else {
if (!Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (!Objects.equals(updateReqVO.getStatus(), DRAFT.getValue())) {
if (StringUtils.isBlank(updateReqVO.getConsignorPhone())) {
throw exception(CONSIGNOR_PHONE_NOT_NULL);
}
......@@ -3198,7 +3197,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorDO.setRelationId(updateObj.getCustomerId());
orderConsignorDO.setUpdateTime(now);
if (!Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (!Objects.equals(updateReqVO.getStatus(), DRAFT.getValue())) {
if (StringUtils.isBlank(orderConsignorDO.getPhone()) || StringUtils.isBlank(orderConsignorDO.getCountryCode())) {
throw exception(ORDER_CONSIGNOR_PHONE_INFO_NOT_COMPLETE);
}
......@@ -3232,7 +3231,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (StringUtils.isNotBlank(orderConsignorDO.getPhone())) {
orderConsignorService.saveOrUpdate(orderConsignorDO);
}
if (updateObj.getIsCargoControl() && !Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (updateObj.getIsCargoControl() && !Objects.equals(updateReqVO.getStatus(), DRAFT.getValue())) {
OrderCargoControlDO orgOrderCargoControlDO = orderCargoControlMapper.selectOne(new LambdaQueryWrapper<OrderCargoControlDO>().eq(OrderCargoControlDO::getOrderId, updateObj.getOrderId()).eq(OrderCargoControlDO::getIsActual, Boolean.TRUE).last("limit 1"));
// 控货订单 添加控货人信息
OrderCargoControlDO orderCargoControlDO = new OrderCargoControlDO();
......@@ -3306,7 +3305,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsigneeDO.setCustomerContactsId(consigneeContactsDO.getId());
orderConsigneeDO.setCustomerId(consigneeContactsDO.getCustomerId());
} else {
if (!Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (!Objects.equals(updateReqVO.getStatus(), DRAFT.getValue())) {
if (StringUtils.isBlank(updateReqVO.getConsigneePhone())) {
throw exception(CONSIGNEE_PHONE_NOT_NULL);
}
......@@ -3338,7 +3337,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsigneeDO.setRelationId(updateReqVO.getCustomerId());
orderConsigneeDO.setUpdateTime(now);
if (!Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (!Objects.equals(updateReqVO.getStatus(), DRAFT.getValue())) {
if (StringUtils.isBlank(orderConsigneeDO.getPhone()) || StringUtils.isBlank(orderConsigneeDO.getCountryCode())) {
throw exception(ORDER_CONSIGNEE_PHONE_INFO_NOT_COMPLETE);
}
......@@ -3381,7 +3380,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
updateObj.setIsLimitUpdateConsignee(Boolean.FALSE);
}
if (!Objects.equals(updateReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
DRAFT.getValue())) {
//customerType 发货人 1 收货人 2
int customerType = this.checkOrderSalesman(updateObj,
updateReqVO.getOfferId(),
......@@ -3391,7 +3390,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsigneeDO);
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus())
if (!DRAFT.getValue().equals(updateObj.getStatus())
&& ((Objects.nonNull(updateObj.getIsChargeCustomer()) && updateObj.getIsChargeCustomer())
|| (Objects.nonNull(updateObj.getIsChargeDraft()) && updateObj.getIsChargeDraft()))) {
addOrderCustomerService(updateObj, customerType);
......@@ -6205,20 +6204,247 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
@Override
public Long copyOrder(Long copyOrderId, MemberUserDO memberUserDO) {
OrderDO orderDO = orderMapper.selectById(copyOrderId);
if (Objects.isNull(orderDO)){
throw exception(ORDER_NOT_EXISTS);
}
// 重新生成订单编号, 并重置订单中其他冗余信息
OrderDO newOrder = new OrderDO();
BeanUtils.copyProperties(orderDO, newOrder);
// 初始化订单信息
initializeOrderInfo(newOrder);
// 生成草稿订单编号
String newOrderNo = "DRAFT-" + System.currentTimeMillis();
newOrder.setOrderNo(newOrderNo);
if (Objects.nonNull(memberUserDO)){
// 会员端下单,需要保存会员id信息
newOrder.setUserId(memberUserDO.getId());
}
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
String creator = String.valueOf(loginUser != null ? loginUser.getId() : null);
Date now = new Date();
newOrder.setCreator(creator);
newOrder.setUpdater(creator);
newOrder.setCreateTime(now);
newOrder.setUpdateTime(now);
orderMapper.insert(newOrder);
Long newOrderId = newOrder.getOrderId();
// 始发地
OrderDepartureDO orderDepartureDO = orderDepartureService.getOne(new LambdaQueryWrapper<OrderDepartureDO>().eq(OrderDepartureDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderDepartureDO::getId).last("limit 1"));
OrderDepartureDO departureDO = new OrderDepartureDO();
BeanUtils.copyProperties(orderDepartureDO, departureDO);
departureDO.setId(null);
departureDO.setOrderId(newOrderId);
departureDO.setCreator(creator);
departureDO.setUpdater(creator);
departureDO.setCreateTime(now);
departureDO.setUpdateTime(now);
orderDepartureService.save(departureDO);
// 目的地
OrderObjectiveDO orderObjectiveDO = orderObjectiveService.getOne(new LambdaQueryWrapper<OrderObjectiveDO>().eq(OrderObjectiveDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderObjectiveDO::getId).last("limit 1"));
OrderObjectiveDO objectiveDO = new OrderObjectiveDO();
BeanUtils.copyProperties(orderObjectiveDO, objectiveDO);
objectiveDO.setId(null);
objectiveDO.setOrderId(newOrderId);
objectiveDO.setCreator(creator);
objectiveDO.setUpdater(creator);
objectiveDO.setCreateTime(now);
objectiveDO.setUpdateTime(now);
orderObjectiveService.save(objectiveDO);
// 发货人信息
OrderConsignorDO orderConsignorDO = orderConsignorService.getOne(new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1"));
OrderConsignorDO consignorDO = new OrderConsignorDO();
BeanUtils.copyProperties(orderConsignorDO, consignorDO);
consignorDO.setId(null);
consignorDO.setOrderId(newOrderId);
if (Objects.nonNull(memberUserDO)) {
consignorDO.setRelationId(memberUserDO.getId());
}
consignorDO.setCreator(creator);
consignorDO.setUpdater(creator);
consignorDO.setCreateTime(now);
consignorDO.setUpdateTime(now);
orderConsignorService.save(consignorDO);
// 收货人信息
OrderConsigneeDO orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
OrderConsigneeDO consigneeDO = null;
if (Objects.nonNull(orderConsigneeDO)) {
consigneeDO = new OrderConsigneeDO();
BeanUtils.copyProperties(orderConsigneeDO, consigneeDO);
consigneeDO.setId(null);
consigneeDO.setOrderId(newOrderId);
consigneeDO.setCreator(creator);
consigneeDO.setUpdater(creator);
consigneeDO.setCreateTime(now);
consigneeDO.setUpdateTime(now);
orderConsigneeService.save(consigneeDO);
}
if (newOrder.getIsCargoControl()) {
// 控货信息
OrderCargoControlDO orderCargoControlDO = orderCargoControlMapper.selectOne(new LambdaQueryWrapper<OrderCargoControlDO>().eq(OrderCargoControlDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderCargoControlDO::getId).last("limit 1"));
// 始发地
OrderDepartureDO orderDepartureDO = orderDepartureService.getOne(new LambdaQueryWrapper<OrderDepartureDO>().eq(OrderDepartureDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderDepartureDO::getId).last("limit 1"));
// 目的地
OrderObjectiveDO orderObjectiveDO = orderObjectiveService.getOne(new LambdaQueryWrapper<OrderObjectiveDO>().eq(OrderObjectiveDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderObjectiveDO::getId).last("limit 1"));
OrderCargoControlDO cargoControlDO = new OrderCargoControlDO();
BeanUtils.copyProperties(orderCargoControlDO, cargoControlDO);
cargoControlDO.setId(null);
cargoControlDO.setOrderId(newOrderId);
cargoControlDO.setCreator(creator);
cargoControlDO.setUpdater(creator);
cargoControlDO.setCreateTime(now);
cargoControlDO.setUpdateTime(now);
orderCargoControlMapper.insert(cargoControlDO);
}
// 当订单的包装类型不为空时,创建特需需要在订单业务执行完成后再进行,避免部分订单数据还未插入
if (StringUtils.isNotBlank(newOrder.getPackageType())) {
String[] packageTypes = newOrder.getPackageType().split(StrUtil.COMMA);
List<OrderSpecialNeedCreateReqVO> createReqVOList = new ArrayList<>();
for (String packageType : packageTypes) {
OrderSpecialNeedCreateReqVO reqVO =
new OrderSpecialNeedCreateReqVO();
reqVO.setOrderId(newOrderId);
reqVO.setAdvanceType(packageType);
reqVO.setTransFee(BigDecimal.ZERO);
reqVO.setTransCurrency(1);
reqVO.setTodoDetail(newOrder.getPackageRemarks());
createReqVOList.add(reqVO);
}
orderSpecialNeedService.createOrderSpecialNeed(createReqVOList, Boolean.FALSE);
}
// 商品信息
List<OrderItemDO> itemDOList = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>().eq(OrderItemDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderItemDO::getOrderItemId));
// TODO 这里是否需要重新判断业绩归属
// TODO 如果是web端复制的,发货人不是当前登陆会员,是否要改为当前登陆的会员管理客户信息
return 0L;
List<OrderItemDO> newItemDOList = itemDOList.stream().map(io -> copyNewOrderItem(io, newOrderId, newOrderNo, newOrder, now, creator)).collect(Collectors.toList());
// 插入订单商品项
orderBusinessService.costCalculation(creator,
newOrder, consignorDO.getCustomerId(),
Objects.isNull(consigneeDO) ? 0L : consigneeDO.getCustomerId(),
consignorDO.getCustomerContactsId(),
Objects.isNull(consigneeDO) ? 0L : consigneeDO.getCustomerContactsId(),
newItemDOList, 1);
try {
if (memberUserDO != null && Objects.nonNull(consigneeDO)) {
// app-web添加的订单
AdminClientCreateEvent adminClientCreateEvent =
new AdminClientCreateEvent();
//下单用户
adminClientCreateEvent.setUid(memberUserDO.getId());
//收货人信息
adminClientCreateEvent.setName(orderConsigneeDO.getName());
adminClientCreateEvent.setCompany(orderConsigneeDO.getCompany());
adminClientCreateEvent.setPhone(orderConsigneeDO.getPhone());
adminClientCreateEvent.setEmail(orderConsigneeDO.getEmail());
adminClientCreateEvent.setAddress(orderConsigneeDO.getAddress());
adminClientCreateEvent.setDialCode(Integer.parseInt(orderConsigneeDO.getCountryCode()));
adminClientCreateEvent.setMaitou(newOrder.getMarks());
adminClientCreateEvent.setDefaultContact(true);
indirectCustomerService.createIndirectCustomer(
adminClientCreateEvent);
}
} catch (Exception e) {
log.error("");
}
//发货人的信用日志
customerCreditLogService.sendPackageCreditLog(orderConsignorDO.getCustomerContactsId(), newOrderId, newOrderNo);
// 创建订单操作日志
orderBusinessService.addOrderOperateLog(newOrderId,
"新建订单", null);
// //在创建完订单号,计算订单业绩类型
// CalculateOrderYeJiTypeEvent even = new CalculateOrderYeJiTypeEvent();
// even.setOrderId(newOrderId);
// applicationContext.publishEvent(even);
return newOrderId;
}
@NotNull
private static OrderItemDO copyNewOrderItem(OrderItemDO io, Long newOrderId, String newOrderNo, OrderDO newOrder, Date now, String creator) {
OrderItemDO orderItemDO = new OrderItemDO();
orderItemDO.setOrderId(newOrderId);
orderItemDO.setOrderNo(newOrderNo);
orderItemDO.setTransportId(newOrder.getTransportId());
orderItemDO.setLineId(newOrder.getLineId());
orderItemDO.setChannelId(newOrder.getChannelId());
orderItemDO.setLink(io.getLink());
orderItemDO.setProdId(io.getProdId());
orderItemDO.setProdAttrIds(io.getProdAttrIds());
orderItemDO.setProdTitleEn(io.getProdTitleEn());
orderItemDO.setProdType(io.getProdType());
orderItemDO.setProdTitleZh(io.getProdTitleZh());
orderItemDO.setVolume(io.getVolume());
orderItemDO.setWeight(io.getWeight());
orderItemDO.setQuantity(io.getQuantity());
orderItemDO.setNum(io.getQuantity());
orderItemDO.setBoxGauge(io.getBoxGauge());
orderItemDO.setBrand(io.getBrand());
orderItemDO.setBrandType(io.getBrandType());
orderItemDO.setCreateTime(now);
orderItemDO.setCreator(creator);
return orderItemDO;
}
/**
* 初始化订单信息
*
* @param newOrder 需要初始化的订单信息
*/
private static void initializeOrderInfo(OrderDO newOrder) {
newOrder.setOrderId(null);
newOrder.setUserId(null);
newOrder.setSumNum(null);
newOrder.setSumQuantity(null);
newOrder.setSumVolume(null);
newOrder.setSumWeight(null);
newOrder.setPickleType(null);
newOrder.setPickRatio(null);
newOrder.setPickNum(null);
newOrder.setCost(null);
newOrder.setPackingListUrl(null);
newOrder.setCommissionPayable(null);
newOrder.setSpecialVWeight(null);
newOrder.setHandlerChannelAttrException(null);
newOrder.setWeightBeforePack(null);
newOrder.setWeightAfterPack(null);
newOrder.setStockOverWeightLimit(null);
newOrder.setFirstStockedTime(null);
newOrder.setHasConsignee(null);
newOrder.setIsLimitUpdateConsignee(null);
newOrder.setLockConsigneeDay(null);
newOrder.setLockConsigneeTime(null);
// newOrder.setDisplayBillLadingPrice(null);
// 状态重置
newOrder.setSplitSeparateOrder(null);
newOrder.setShipmentState(null);
newOrder.setStatus(DRAFT.getValue());// 默认草稿订单
newOrder.setAirShipment(null);
newOrder.setAbnormalState(null);
newOrder.setAuditType(null);
newOrder.setAuditResult(null);
newOrder.setPickState(null);
newOrder.setGuanLianOrderStatus(null);
// 时间重置
newOrder.setTakeTime(null);
newOrder.setUnloadTime(null);
newOrder.setRucangTime(null);
newOrder.setLoadTime(null);
newOrder.setPreLoadTime(null);
newOrder.setDeliveryDate(null);
newOrder.setDaogangTime(null);
newOrder.setQingguanTime(null);
newOrder.setSplitTime(null);
newOrder.setIsException(null);
newOrder.setExceptionReason(null);
newOrder.setExternalWarehouseJson(null);
newOrder.setHasConsignee(null);
newOrder.setHasExitAndEntry(null);
newOrder.setHasSendRucangSms(null);
newOrder.setHasSendWarehouseInNotice(null);
}
}
......@@ -160,6 +160,16 @@ public class OrderController {
}
@PostMapping("/copy/{copyOrderId}")
@ApiOperation("复制订单")
@DynamicRateLimiter(base = "#Headers['Authorization']", permits = 1)
@Idempotent(timeout = 5)
public CommonResult<Long> copyOrder(@PathVariable Long copyOrderId) {
Long orderId = orderService.copyOrder(copyOrderId, null);
return success(orderId);
}
@PutMapping("/update")
@ApiOperation("更新订单")
@Idempotent(timeout = 5)
......
......@@ -158,6 +158,28 @@ public class MyOrderController {
return success(orderService.createOrder(createReqVO, memberUserDO).getOrderId());
}
@PostMapping("/copy/{copyOrderId}")
@DynamicRateLimiter(base = "#Headers['Authorization']", permits = 1)
@ApiOperation(value = "复制订单", notes = "发货人只取当前用户信息,收货人取当前用户的客户信息")
@Idempotent(timeout = 15)
@PreAuthenticated
public CommonResult<Long> copyOrder(@PathVariable Long copyOrderId) {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Integer userType = loginUser.getUserType();
if (userType != 1){
return error(UNAUTHORIZED);
}
Long userId = loginUser.getId();
MemberUserDO memberUserDO = memberUserService.info(userId);
if (Objects.isNull(memberUserDO) ||
memberUserDO.getStatus() == 1 ||
memberUserDO.getDeleted()) {
return error(MEMBER_NOT_EXISTS);
}
Long orderId = orderService.copyOrder(copyOrderId, memberUserDO);
return success(orderId);
}
@PostMapping("/checkKycStatus")
@ApiOperation("检查kyc状态")
public CommonResult<Boolean> checkKycStatus(OrderKycReqVO kycReqVO) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment