Commit 6898f69f authored by zhengyi's avatar zhengyi

控货订单放货收货人限制业务

Signed-off-by: default avatarzhengyi <landuo321@aliyun.com>
parent 9597cb83
-- 2024-08-24 订单控货现在参数控货订单锁定天数
alter table `ecw_order`
add column `lock_consignee_time` datetime default NULL COMMENT '放货锁定收货人到期时间';
alter table `ecw_order`
add column `is_limit_update_consignee` bit default 0 COMMENT '是否限制修改收获人';
\ No newline at end of file
......@@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.order.dal.dataobject.orderDeparture.OrderDepartur
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderObjective.OrderObjectiveDO;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
......@@ -15,10 +16,13 @@ import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 订单 DO
*
......@@ -518,6 +522,15 @@ public class OrderDO extends BaseDO {
@ApiModelProperty(value = "是否有收货人,1-是,0-否")
private Boolean hasConsignee = true;
@ApiModelProperty(value = "是否限制修改收货人")
private Boolean isLimitUpdateConsignee;
@ApiModelProperty(value = "放货锁定收货人到期时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date lockConsigneeTime;
//
// @ApiModelProperty(value = "拆单子订单是否变更运输方式")
// private Boolean splitChangeTransport = false;
......
......@@ -97,6 +97,9 @@ public interface OrderCargoControlMapper extends AbstractMapper<OrderCargoContro
"o.sum_volume, ",
"o.sum_weight, ",
"o.create_time, ",
"o.unload_time, ",
"o.is_limit_update_consignee, ",
"o.lock_consignee_time, ",
"nee.name as consignee_name, ",
"nee.name_en as consignee_name_en, ",
"nee.phone as consignee_phone, ",
......@@ -108,7 +111,6 @@ public interface OrderCargoControlMapper extends AbstractMapper<OrderCargoContro
"occ.email, ",
"occ.dial_code ",
"from ecw_order o ",
// "left join ecw_order_consignor nor on nor.order_id = o.order_id ",
"left join ecw_order_consignee nee on nee.order_id = o.order_id ",
"left join ecw_order_cargo_control occ ",
"on occ.order_id = o.order_id and occ.is_actual = 1 and occ.deleted = 0",
......
......@@ -3,13 +3,18 @@ package cn.iocoder.yudao.module.order.dto;
import cn.iocoder.yudao.module.order.vo.approval.OrderApprovalBackVO;
import cn.iocoder.yudao.module.order.vo.orderCargoControlPick.OrderCargoControlPickBackVO;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
@ApiModel(value = "控货订单放货详情返回值")
public class OrderCargoControlReleaseInfoDto {
......@@ -106,6 +111,19 @@ public class OrderCargoControlReleaseInfoDto {
@ApiModelProperty(value = "收货人邮箱")
private String consigneeEmail;
@ApiModelProperty(value = "卸柜/到仓时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date unloadTime;
@ApiModelProperty(value = "是否限制修改收货人")
private Boolean isLimitUpdateConsignee;
@ApiModelProperty(value = "放货锁定收货人到期时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date lockConsigneeTime;
@ApiModelProperty(value = "放货详情记录列表")
private List<OrderCargoControlPickBackVO> cargoControlPickBackVOList;
......
......@@ -394,4 +394,6 @@ public interface ErrorCodeConstants {
ErrorCode ORDER_IS_PRE_INSTALLED = new ErrorCode(1004001153, "order.is.pre.installed");
ErrorCode ORDER_IS_NOT_PRE_INSTALLED = new ErrorCode(1004001154, "order.is.not.pre.installed");
ErrorCode ORDER_CARGO_CONTROL_LIMIT_UPDATE_CONSIGNEE_ERROR = new ErrorCode(1004001155, "order.cargo.control.limit.update.consignee.error");
ErrorCode ORDER_CARGO_CONTROL_LIMIT_UPDATE_CONSIGNEE_INFO = new ErrorCode(1004001156, "order.cargo.control.limit.update.consignee.info");
}
......@@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.apollo.core.event.*;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.util.bigDecimal.BigDecimalUtils;
import cn.iocoder.yudao.framework.common.util.code.CodeUtils;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
......@@ -1455,8 +1456,15 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
orderTimeDO.setRemarksZh(String.format(orderAirTimeEnum.getRemarksZh(), objective.getTitleZh()));
orderTimeDO.setRemarksEn(String.format(orderAirTimeEnum.getRemarksEn(), objective.getTitleEn()));
}
// TODO 这里更新订单卸柜/到仓时间,同时对控货订单的限制修改收货人锁定到期时间进行更新,当前默认使用14D处理,待仓库业务添加该时间配置在做处理
Date lockConsigneeTime = null;
if (orderDO.getIsCargoControl()){
// TODO 获取卸柜/到仓业务时间的锁定收货人时间当天的结束时间
lockConsigneeTime = DateUtil.endOfDay(DateUtil.offsetDay(businessTime, 14));
}
orderMapper.update(null, new LambdaUpdateWrapper<OrderDO>()
.set(OrderDO::getUnloadTime, businessTime)
.set(OrderDO::getLockConsigneeTime, lockConsigneeTime)
.eq(OrderDO::getOrderId, orderDO.getOrderId()));
// LogisticsInfoDto logisticsDestInfoDto = warehouseLineMapper.getStartInfoAndDestInfoByLineId(orderDO.getLineId());
// if (Objects.nonNull(logisticsDestInfoDto)) {
......@@ -1590,8 +1598,15 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
orderTimeDO.setRemarksZh(String.format(orderSeaTimeEnum.getRemarksZh(), objective.getTitleZh()));
orderTimeDO.setRemarksEn(String.format(orderSeaTimeEnum.getRemarksEn(), objective.getTitleEn()));
}
// TODO 这里更新订单卸柜/到仓时间,同时对控货订单的限制修改收货人锁定到期时间进行更新,当前默认使用14D处理,待仓库业务添加该时间配置在做处理
Date lockConsigneeTime = null;
if (orderDO.getIsCargoControl()){
// TODO 获取卸柜/到仓业务时间的锁定收货人时间当天的结束时间
lockConsigneeTime = DateUtil.endOfDay(DateUtil.offsetDay(businessTime, 14));
}
orderMapper.update(null, new LambdaUpdateWrapper<OrderDO>()
.set(OrderDO::getUnloadTime, businessTime)
.set(OrderDO::getLockConsigneeTime, lockConsigneeTime)
.eq(OrderDO::getOrderId, orderDO.getOrderId()));
// LogisticsInfoDto logisticsDestInfoDto = warehouseLineMapper.getStartInfoAndDestInfoByLineId(orderDO.getLineId());
// if (Objects.nonNull(logisticsDestInfoDto)) {
......
......@@ -588,7 +588,13 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
OrderConsigneeDO orderConsigneeDO = null;
// 当订单为控货订单,且发货人客户档案未设置控货无收货人,则需要校验收货人信息
if (order.getIsCargoControl() && !noConsignee) {
if (!order.getIsCargoControl() || !noConsignee) {
// 控货订单有收货人则限制修改收货人
if (order.getIsCargoControl()) {
order.setIsLimitUpdateConsignee(Boolean.TRUE);
}else {
order.setIsLimitUpdateConsignee(Boolean.FALSE);
}
orderConsigneeDO = new OrderConsigneeDO();
orderConsigneeDO.setOrderId(order.getOrderId());
orderConsigneeDO.setCreator(creator);
......@@ -668,6 +674,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
}
orderConsigneeService.save(orderConsigneeDO);
}else {
// 控货订单没有收货人则不限制修改收货人
order.setIsLimitUpdateConsignee(Boolean.FALSE);
}
if (!Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
//customerType 发货人-1 收货人 2
......@@ -795,7 +804,13 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderBusinessService.createOrderControlLog(orderCargoControlDO.getOrderId(), 1, "创建控货信息", msg, 0L);
}
OrderConsigneeDO orderConsigneeDO = null;
if (order.getIsCargoControl() && !noConsignee) {
if (!order.getIsCargoControl() || !noConsignee) {
// 控货订单有收货人则限制修改收货人
if (order.getIsCargoControl()) {
order.setIsLimitUpdateConsignee(Boolean.TRUE);
}else {
order.setIsLimitUpdateConsignee(Boolean.FALSE);
}
orderConsigneeDO = new OrderConsigneeDO();
orderConsigneeDO.setOrderId(order.getOrderId());
orderConsigneeDO.setCreator(creator);
......@@ -905,6 +920,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (StringUtils.isNotBlank(orderConsigneeDO.getPhone())) {
orderConsigneeService.save(orderConsigneeDO);
}
}else {
// 控货订单没有收货人则不限制修改收货人
order.setIsLimitUpdateConsignee(Boolean.FALSE);
}
if (!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
......@@ -3000,7 +3018,13 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
OrderConsigneeDO orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, updateObj.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
if (updateObj.getIsCargoControl() && !noConsignee) {
if (!updateObj.getIsCargoControl() || !noConsignee) {
// 控货订单有收货人则限制修改收货人
if (updateObj.getIsCargoControl()) {
updateObj.setIsLimitUpdateConsignee(Boolean.TRUE);
}else {
updateObj.setIsLimitUpdateConsignee(Boolean.FALSE);
}
if (Objects.isNull(orderConsigneeDO)) {
orderConsigneeDO = new OrderConsigneeDO();
}
......@@ -3072,6 +3096,8 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsigneeService.removeById(orderConsigneeDO.getId());
orderConsigneeDO = null;
}
// 控货订单没有收货人则不限制修改收货人
updateObj.setIsLimitUpdateConsignee(Boolean.FALSE);
}
if (!Objects.equals(updateReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
......@@ -3218,8 +3244,13 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
OrderConsigneeDO orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, updateObj.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
if (updateObj.getIsCargoControl() && !noConsignee) {
orderConsigneeDO = new OrderConsigneeDO();
if (!updateObj.getIsCargoControl() || !noConsignee) {
// 控货订单有收货人则限制修改收货人
if (updateObj.getIsCargoControl()) {
updateObj.setIsLimitUpdateConsignee(Boolean.TRUE);
}else {
updateObj.setIsLimitUpdateConsignee(Boolean.FALSE);
}
if (Objects.isNull(orderConsigneeDO)) {
orderConsigneeDO = new OrderConsigneeDO();
}
......@@ -3324,6 +3355,8 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsigneeDO = null;
}
consigneeDO = null;
// 控货订单没有收货人则不限制修改收货人
updateObj.setIsLimitUpdateConsignee(Boolean.FALSE);
}
if (!Objects.equals(updateReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
......@@ -5425,10 +5458,15 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorService.updateById(consignorDO);
OrderConsigneeDO consigneeDO = OrderConsigneeConvert.INSTANCE.convert(consigneeVO);
// 控货订单发货人无收货人属性变动,需要清空订单收货人信息
Boolean isLimitUpdateConsignee = Boolean.FALSE;
if (orderBackVO.getIsChargeNoConsignee()){
orderConsigneeService.removeById(consigneeDO.getId());
}else {
orderConsigneeService.updateById(consigneeDO);
if (orderBackVO.getIsCargoControl()){
// 控货订单有收货人则限制修改收货人
isLimitUpdateConsignee = Boolean.TRUE;
}
}
// 始发地目的地更新
OrderDepartureDO departureDO = OrderDepartureConvert.INSTANCE.convert(orderBackVO.getOrderDepartureVO());
......@@ -5440,6 +5478,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (orderBackVO.getIsException()) {
orderDO.setHandlerChannelAttrException(false);
}
orderDO.setIsLimitUpdateConsignee(isLimitUpdateConsignee);
orderDO.setOrderNo(oldOrder.getOrderNo());
String oldOrderNo = oldOrder.getOrderNo(); // 临时保存旧的订单编号
boolean isDisassociation = false;
......
......@@ -131,15 +131,10 @@ public class OrderCargoControlPickServiceImpl extends AbstractService<OrderCargo
if (StringUtils.equals(createReqVO.getConsigneeCountryCode(), "86")) {
throw exception(CONSIGNEE_PHONE_IS_NOT_CHINA);
}
// if (StringUtils.isNotBlank(createReqVO.getConsigneeCountryCode()) && StringUtils.isNotBlank(createReqVO.getConsigneePhone())) {
String mobileCode = createReqVO.getConsigneeCountryCode() +
StrUtil.COLON + createReqVO.getConsigneePhone();
paramValidatorApi.validatorMobile(mobileCode);
// String phone = PhoneUtil.formatPhone(mobileCode);
// if (StringUtils.isNotBlank(phone)) {
// createReqVO.setConsigneePhone(phone);
// }
// }
OrderDO orderDO = orderService.getById(createReqVO.getOrderId());
if (Objects.isNull(orderDO)) {
throw exception(ORDER_NOT_EXISTS);
......@@ -151,7 +146,21 @@ public class OrderCargoControlPickServiceImpl extends AbstractService<OrderCargo
if (createReqVO.getPickNum() > orderDO.getSumNum()) {
throw exception(ORDER_CARGO_CONTROL_NUM_GO_BEYOND);
}
// 如果控货订单限制修改收货人,则需要判断控货收货人限制修改时间是否到期,且当前放货操作的收货人电话是否有变动
if (orderDO.getIsLimitUpdateConsignee() && Objects.isNull(orderDO.getLockConsigneeTime())){
// 当前控货订单限制修改收货人,但是未到仓/卸柜,未查询到限制时间
throw exception(ORDER_CARGO_CONTROL_LIMIT_UPDATE_CONSIGNEE_ERROR);
}
if (orderDO.getIsLimitUpdateConsignee() && Objects.nonNull(orderDO.getLockConsigneeTime()) && orderDO.getLockConsigneeTime().compareTo(new Date()) >= 0){
// 控货收货人限制修改时间未到期,需要判断当前放货操作的收货人电话是否有变动
OrderCargoControlReleaseInfoDto releaseInfoDto = orderCargoControlMapper.getOrderCargoControlReleaseInfo(orderDO.getOrderId());
if (StringUtils.isBlank(releaseInfoDto.getConsigneeCountryCode()) || StringUtils.isBlank(releaseInfoDto.getConsigneePhone())){
throw exception(ORDER_CONSIGNEE_PHONE_INFO_NOT_COMPLETE);
}
if (!StringUtils.equals(releaseInfoDto.getConsigneeCountryCode()+releaseInfoDto.getConsigneePhone(), createReqVO.getConsigneeCountryCode() + createReqVO.getConsigneePhone())){
throw exception(ORDER_CARGO_CONTROL_LIMIT_UPDATE_CONSIGNEE_INFO);
}
}
int pickNum = 0;
int pickQuantity = 0;
BigDecimal pickVolume = BigDecimal.ZERO;
......
......@@ -262,3 +262,5 @@ order.already.in.merge.pkg=
customer.is.new.or.old.no.change=
order.is.pre.installed=
order.is.not.pre.installed=
order.cargo.control.limit.update.consignee.error=
order.cargo.control.limit.update.consignee.info=
......@@ -999,3 +999,5 @@ customer.is.new.or.old.no.change=customer current business type is {}, it's no c
order.is.pre.installed=Order pre installed
customer.delay.approval.times.more.then.one=delay approval times more then one
order.is.not.pre.installed =Order not pre installed, unable to package together
order.cargo.control.limit.update.consignee.error=The current control order restricts the modification of the consignee, and no restriction time was found
order.cargo.control.limit.update.consignee.info=The recipient restriction modification time for the controlled goods order has not expired, and the recipient information for the order cannot be modified
......@@ -1002,3 +1002,6 @@ order.already.in.merge.pkg=\u8BA2\u5355\u5DF2\u5728\u5408\u5305\u7BB1\u4E0B
customer.is.new.or.old.no.change=\u5BA2\u6237\u5F53\u524D\u4E1A\u7EE9\u7C7B\u578B\u662F{}\u5BA2\u6237\uFF0C\u4E0D\u9700\u8981\u66F4\u65B0
order.is.pre.installed=\u8BA2\u5355\u5DF2\u9884\u88C5
order.is.not.pre.installed =\u8ba2\u5355\u672a\u9884\u88c5\uff0c\u4e0d\u80fd\u5408\u5305
order.cargo.control.limit.update.consignee.error=\u5f53\u524d\u63a7\u8d27\u8ba2\u5355\u9650\u5236\u4fee\u6539\u6536\u8d27\u4eba\uff0c\u672a\u67e5\u8be2\u5230\u9650\u5236\u65f6\u95f4
order.cargo.control.limit.update.consignee.info=\u63a7\u8d27\u8ba2\u5355\u6536\u8d27\u4eba\u9650\u5236\u4fee\u6539\u65f6\u95f4\u672a\u5230\u671f\uff0c\u4e0d\u80fd\u4fee\u6539\u8ba2\u5355\u6536\u8d27\u4eba\u4fe1\u606f
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