Commit 4d951720 authored by zhengyi's avatar zhengyi

出货阶段的订单修改审批业务部分提交

parent 0c80de6a
...@@ -41,19 +41,27 @@ public interface OrderService extends IService<OrderDO> { ...@@ -41,19 +41,27 @@ public interface OrderService extends IService<OrderDO> {
OrderDO createOrder(OrderCreateReqVO createReqVO, MemberUserDO memberUserDO); OrderDO createOrder(OrderCreateReqVO createReqVO, MemberUserDO memberUserDO);
/** /**
* 更新订单 * 更新编辑下单或草稿订单
* *
* @param updateReqVO 更新信息 * @param updateReqVO 更新信息
*/ */
void updateOrder(@Valid OrderUpdateReqVO updateReqVO, MemberUserDO memberUserDO); void updateOrder(@Valid OrderUpdateReqVO updateReqVO, MemberUserDO memberUserDO);
/** /**
* 更新订单 * 更新入仓订单
* *
* @param updateReqVO 更新信息 * @param updateReqVO 更新信息
* @param memberUserDO 会员信息
*/ */
void updateOrderApply(@Valid OrderUpdateReqVO updateReqVO, MemberUserDO memberUserDO); void updateOrderApply(@Valid OrderUpdateReqVO updateReqVO, MemberUserDO memberUserDO);
/**
* 更新出货订单
*
* @param updateReqVO 更新信息
*/
void shipmentOrderApplyUpdate(@Valid OrderUpdateReqVO updateReqVO, MemberUserDO memberUserDO);
/** /**
* 订单入仓 * 订单入仓
......
...@@ -1072,7 +1072,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -1072,7 +1072,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.getOrderId())).findFirst().orElse(null); order.getOrderId())).findFirst().orElse(null);
CustomerDO customerDO = customerService.getById(order.getCustomerId()); CustomerDO customerDO = customerService.getById(order.getCustomerId());
if(Objects.nonNull(customerDO)) { if (Objects.nonNull(customerDO)) {
order.setIsInOpenSea(customerDO.getIsInOpenSea()); order.setIsInOpenSea(customerDO.getIsInOpenSea());
order.setYejiType(customerDO.getIsNew() ? 1 : 0); order.setYejiType(customerDO.getIsNew() ? 1 : 0);
} }
...@@ -1792,6 +1792,100 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -1792,6 +1792,100 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (!Objects.equals(updateReqVO.getTransportId(), logisticsInfoDto.getTransportId())) { if (!Objects.equals(updateReqVO.getTransportId(), logisticsInfoDto.getTransportId())) {
throw exception(TRANSPORT_AND_LINE_NOT_AGREEMENT); throw exception(TRANSPORT_AND_LINE_NOT_AGREEMENT);
} }
// 执行订单审批申请业务
this.orderAuditApplyUpdate(updateReqVO, vo, logisticsInfoDto);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void shipmentOrderApplyUpdate(OrderUpdateReqVO updateReqVO, MemberUserDO memberUserDO) {
OrderBackVO vo = orderQueryService.getOrder(updateReqVO.getOrderId());
if (Objects.isNull(vo)) {
throw exception(ORDER_NOT_EXISTS);
}
if (Objects.nonNull(vo.getParentOrderId()) && vo.getParentOrderId() > 0 && !vo.getSplitSeparateOrder()) {
// 如果是拆单订单,且未标记为独立订单,则不允许修改
throw exception(SPLIT_ORDER_REVOKE_CAN_UPDATE);
}
OrderApprovalDO orderApprovalDO = orderApprovalMapper.newItemInfo(null, vo.getOrderId(), ORDER_UPDATE.getValue());
if (Objects.nonNull(orderApprovalDO) && orderApprovalDO.getStatus() == 1) {
throw exception(YOUR_APPLY_PENDING);
}
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);
return;
}
if (Objects.equals(vo.getStatus(), OrderStatusEnum.IN_WAREHOUSE.getValue())) {
// 已入仓业务
this.updateOrderApply(updateReqVO, memberUserDO);
return;
}
/**
* 海运订单预装未装柜/空运订单分拣未出货
* ----跟现有的不便,锁定订单信息无法修改
* l 海运订单、拆单子单已装柜/空运已出货.
* A. 运输方式,始发城市,目的国字段锁定不允许修改
* B. 海外仓选择不允许修改,需要通过申请记录来变更
* C. 是否控货字段,当是否控货从是修改成否,需校验订单是否有放货记录状态≠已取消,有则弹出提示“订单已放货,无法修改为不控货”;当是否控货从否修改成是,校验订单是否有提货记录,有则弹出提示“订单已有提货记录,无法修改成控货”
* D. 当订单所在自编号已起运,无法修改报关方式
* E. 订单信息修改,需校验订单对应提单是否已审批通过,是需弹出提示“提单已制作,如需修改请联系客服”,仅做提示确认后允许提交,审批通过后需要同步更新自编号中订单信息。
* F. 订单修改通过后,插入的操作日志中需要注明当前的订单状态,如在航运中修改,在日志中备注订单状态:航运中
* 注:海运+拆单子单已装柜/空运+拆单子单已出货修改订单信息需单独按钮,支持权限配置,与现有的订单编辑按钮不共用;
* 订单修改审批流程跟现有的订单审批流程一致,订单信息修改后无需产生异常,不判断异常条件是否满足
* 海运订单、拆单子单已装柜/空运已出货,订单信息修改,不需要更新价格
*/
// 海运订单预装未装柜/空运订单分拣未出货, 锁定订单信息无法修改
if (vo.getShipmentState() == 0 || vo.getShipmentState() == 305 || vo.getShipmentState() == 307) {
// throw exception(ORDER_PRE_INSTALLATION_NOT_UPDATE);
}
// 不允许修改运输方式
if (updateReqVO.getTransportId() != vo.getTransportId()) {
// throw exception(NOT_UPDATE_TRANSPORT);
}
// TODO 这里需要优化查询,这里查询了后面调用不建议重复查询,后面做优化
LogisticsInfoDto logisticsInfoDto = warehouseLineMapper.getStartInfoAndDestInfoByLineId(updateReqVO.getLineId());
LogisticsInfoDto orgLogisticsInfoDto = warehouseLineMapper.getStartInfoAndDestInfoByLineId(vo.getLineId());
// 不允许修改始发地
if (!Objects.equals(logisticsInfoDto.getStartCityId(), updateReqVO.getDepartureId())) {
// throw exception(NOT_UPDATE_DEPARTURE);
}
// 不允许修改目的国
if (!Objects.equals(logisticsInfoDto.getDestCountryId(), orgLogisticsInfoDto.getDestCountryId())) {
// throw exception(NOT_UPDATE_DEST_COUNTRY);
}
// 海外仓业务变动申请
if (!vo.getType().contains("2") && updateReqVO.getType().contains("2")){
// TODO 订单如果转海外仓需要单独申请, 订单如果是海外仓改为非海外仓呢?
}
// 当控货订单取消控货时,需要校验是否有放货记录
if (vo.getIsCargoControl() && !updateReqVO.getIsCargoControl()){
// TODO 校验订单是否有放货记录
long count = orderCargoControlPickMapper.selectCount(new LambdaQueryWrapper<OrderCargoControlPickDO>()
.eq(OrderCargoControlPickDO::getOrderId, updateReqVO.getOrderId())
.in(OrderCargoControlPickDO::getStatus, 1,2,3,4,5,6));
if(count > 0){
// 订单存在放货记录,不能取消控货
// throw exception(ORDER_EXISTS_PICK_NOT_CANCEL_CARGO_CONTROL);
}
}
// 执行订单审批申请业务
this.orderAuditApplyUpdate(updateReqVO, vo, logisticsInfoDto);
}
/**
* 订单修改审批信息封装
*
* @param updateReqVO
* @param vo
* @param logisticsInfoDto
*/
private void orderAuditApplyUpdate(OrderUpdateReqVO updateReqVO, OrderBackVO vo, LogisticsInfoDto logisticsInfoDto) {
OrderApprovalDO orderApprovalDO;
OrderDO updateObj = OrderConvert.INSTANCE.convert(updateReqVO); OrderDO updateObj = OrderConvert.INSTANCE.convert(updateReqVO);
if (updateReqVO.getIsExternalWarehouse() && StringUtils.isNotBlank(updateReqVO.getType()) && updateReqVO.getType().contains("1")) { if (updateReqVO.getIsExternalWarehouse() && StringUtils.isNotBlank(updateReqVO.getType()) && updateReqVO.getType().contains("1")) {
throw exception(EXTERNAL_WAREHOUSE_AND_CONCENTRATE_TRANSPORT_NOT_PARALLEL); throw exception(EXTERNAL_WAREHOUSE_AND_CONCENTRATE_TRANSPORT_NOT_PARALLEL);
...@@ -5594,7 +5688,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -5594,7 +5688,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 强制重新定价, 则需要将特价属性都重置 // 强制重新定价, 则需要将特价属性都重置
orderBusinessService.costCalculation(String.valueOf(userId), orderDO, consignorDO.getCustomerId(), Objects.isNull(consigneeDO) ? 0L : consigneeDO.getCustomerId(), orderBusinessService.costCalculation(String.valueOf(userId), orderDO, consignorDO.getCustomerId(), Objects.isNull(consigneeDO) ? 0L : consigneeDO.getCustomerId(),
consignorDO.getCustomerContactsId(), Objects.isNull(consigneeDO) ? 0L : consigneeDO.getCustomerContactsId(), orderItemDOList, 10); consignorDO.getCustomerContactsId(), Objects.isNull(consigneeDO) ? 0L : consigneeDO.getCustomerContactsId(), orderItemDOList, 10);
}else if (orderBackVO.getIsCheckCoupon()){ } else if (orderBackVO.getIsCheckCoupon()) {
// 如果没有重新计价,这里就需要对订单优惠活动进行检查,是否需要重新匹配新的优惠 // 如果没有重新计价,这里就需要对订单优惠活动进行检查,是否需要重新匹配新的优惠
List<OrderItemDO> orderItemDOList = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>().eq(OrderItemDO::getOrderId, orderDO.getOrderId())); List<OrderItemDO> orderItemDOList = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>().eq(OrderItemDO::getOrderId, orderDO.getOrderId()));
// 是否需要检查优惠卷(如果满足当前优惠卷,则继续使用(即使过期也可以),如果不满足则匹配最新的优惠(排除过期)) // 是否需要检查优惠卷(如果满足当前优惠卷,则继续使用(即使过期也可以),如果不满足则匹配最新的优惠(排除过期))
...@@ -6182,7 +6276,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -6182,7 +6276,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
@Override @Override
public Long copyOrder(Long copyOrderId, MemberUserDO memberUserDO) { public Long copyOrder(Long copyOrderId, MemberUserDO memberUserDO) {
OrderDO orderDO = orderMapper.selectById(copyOrderId); OrderDO orderDO = orderMapper.selectById(copyOrderId);
if (Objects.isNull(orderDO)){ if (Objects.isNull(orderDO)) {
throw exception(ORDER_NOT_EXISTS); throw exception(ORDER_NOT_EXISTS);
} }
// 重新生成订单编号, 并重置订单中其他冗余信息 // 重新生成订单编号, 并重置订单中其他冗余信息
...@@ -6193,10 +6287,10 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -6193,10 +6287,10 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 生成草稿订单编号 // 生成草稿订单编号
String newOrderNo = "DRAFT-" + System.currentTimeMillis(); String newOrderNo = "DRAFT-" + System.currentTimeMillis();
newOrder.setOrderNo(newOrderNo); newOrder.setOrderNo(newOrderNo);
if (Objects.nonNull(memberUserDO)){ if (Objects.nonNull(memberUserDO)) {
// 会员端下单,需要保存会员id信息 // 会员端下单,需要保存会员id信息
newOrder.setUserId(memberUserDO.getId()); newOrder.setUserId(memberUserDO.getId());
}else { } else {
newOrder.setUserId(0L); newOrder.setUserId(0L);
} }
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
......
...@@ -268,7 +268,7 @@ public class OrderController { ...@@ -268,7 +268,7 @@ public class OrderController {
@ApiOperation("(新修改订单)订单修改审批申请") @ApiOperation("(新修改订单)订单修改审批申请")
// @PreAuthorize("@ss.hasPermission('ecw:order:update')") // @PreAuthorize("@ss.hasPermission('ecw:order:update')")
@Idempotent(timeout = 5) @Idempotent(timeout = 5)
public CommonResult<Boolean> specialApplyOrder(@Valid @RequestBody OrderUpdateReqVO updateReqVO) { public CommonResult<Boolean> orderUpdateApply(@Valid @RequestBody OrderUpdateReqVO updateReqVO) {
if (Objects.equals(TransportTypeShortEnum.AIR_FREIGHT_LINE.getValue(), updateReqVO.getTransportId()) if (Objects.equals(TransportTypeShortEnum.AIR_FREIGHT_LINE.getValue(), updateReqVO.getTransportId())
|| Objects.equals(TransportTypeShortEnum.AIR_SEA_COMBINED_TRANSPORT.getValue(), updateReqVO.getTransportId())) { || Objects.equals(TransportTypeShortEnum.AIR_SEA_COMBINED_TRANSPORT.getValue(), updateReqVO.getTransportId())) {
if (Objects.isNull(updateReqVO.getChannelId()) || 0 == updateReqVO.getChannelId()) { if (Objects.isNull(updateReqVO.getChannelId()) || 0 == updateReqVO.getChannelId()) {
...@@ -286,6 +286,27 @@ public class OrderController { ...@@ -286,6 +286,27 @@ public class OrderController {
return success(true); return success(true);
} }
@PutMapping("/shipment/update/apply")
@ApiOperation("(新修改订单)订单修改审批申请")
@Idempotent(timeout = 5)
public CommonResult<Boolean> shipmentOrderApplyUpdate(@Valid @RequestBody OrderUpdateReqVO updateReqVO) {
if (Objects.equals(TransportTypeShortEnum.AIR_FREIGHT_LINE.getValue(), updateReqVO.getTransportId())
|| Objects.equals(TransportTypeShortEnum.AIR_SEA_COMBINED_TRANSPORT.getValue(), updateReqVO.getTransportId())) {
if (Objects.isNull(updateReqVO.getChannelId()) || 0 == updateReqVO.getChannelId()) {
throw exception(ORDER_LINE_CHANNEL_NOT_NULL);
}
}
String redisKey = MessageFormat.format(ORDER_UPDATE_KEY, updateReqVO.getOrderId().toString());
Long count = redisHelper.incrBy(redisKey, 1);
if (count > 1) {
return error(ORDER_UPDATE_REPEAT_COMMIT);
}
redisHelper.expire(redisKey, 1, TimeUnit.MINUTES);
orderService.shipmentOrderApplyUpdate(updateReqVO, null);
redisHelper.delete(redisKey);
return success(true);
}
@GetMapping("update/info") @GetMapping("update/info")
@ApiOperation("获得订单修改申请详情") @ApiOperation("获得订单修改申请详情")
@ApiImplicitParam(name = "approveId", value = "审核ID", required = true, example = "1024", dataType = "Long") @ApiImplicitParam(name = "approveId", value = "审核ID", required = true, example = "1024", dataType = "Long")
......
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