Commit 3e71c660 authored by liuzeheng's avatar liuzeheng

二期申请延期掉入公海

parent aa361efc
......@@ -363,6 +363,9 @@ public class CustomerDO extends BaseDO {
*/
private Boolean noConsignee ;
@ApiModelProperty("延期申请次数")
private int delayApprovalNum ;
/**
* vip等级-中文
*/
......
......@@ -2,8 +2,10 @@ package cn.iocoder.yudao.module.customer.dal.mysql.customer;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO;
import cn.iocoder.yudao.module.customer.dto.CustomerOrderQueryDTO;
import cn.iocoder.yudao.module.customer.vo.customer.vo.CustomerDetailRespVO;
import cn.iocoder.yudao.module.customer.vo.customer.vo.CustomerSelectReqVO;
import cn.iocoder.yudao.module.customer.vo.customerDetail.CustomerOrderBackPageVO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
......@@ -175,4 +177,9 @@ public interface CustomerMapper extends BaseMapperX<CustomerDO> {
@Update("update ecw_customer set is_new = #{isNew} where deleted = 0 and is_new != #{isNew} and id = #{customerId}")
void updateCustomerNewOrOld(@Param("customerId") Long customerId, @Param("isNew") Boolean isNew);
@Update("update ecw_customer set delay_approval_num = #{delayApprovalNum} where deleted = 0 and id = #{customerId}")
void updateCustomerDelayApprovalNum(@Param("customerId") Long customerId,@Param("delayApprovalNum") int delayApprovalNum);
List<CustomerOrderBackPageVO> orderList(@Param("start") int start, @Param("size") int size, @Param("query") CustomerOrderQueryDTO query);
}
......@@ -47,6 +47,7 @@ import cn.iocoder.yudao.module.customer.dal.mysql.customerPublicCatchLog.Custome
import cn.iocoder.yudao.module.customer.dto.CustomerDelayApprovalInfoDto;
import cn.iocoder.yudao.module.customer.dto.CustomerHandoverApprovalInfoDto;
import cn.iocoder.yudao.module.customer.dto.CustomerHandoverDetailDto;
import cn.iocoder.yudao.module.customer.dto.CustomerOrderQueryDTO;
import cn.iocoder.yudao.module.customer.service.customerApproval.CustomerApprovalService;
import cn.iocoder.yudao.module.customer.service.customerContacts.CustomerContactsService;
import cn.iocoder.yudao.module.customer.service.customerOperateLog.CustomerOperateLogService;
......@@ -58,6 +59,7 @@ import cn.iocoder.yudao.module.customer.vo.customer.line.CustomerLineUpdateReqVO
import cn.iocoder.yudao.module.customer.vo.customer.vo.*;
import cn.iocoder.yudao.module.customer.vo.customerBank.CustomerBankCreateReqVO;
import cn.iocoder.yudao.module.customer.vo.customerBank.CustomerBankUpdateReqVO;
import cn.iocoder.yudao.module.customer.vo.customerDetail.CustomerOrderBackPageVO;
import cn.iocoder.yudao.module.customer.vo.customerOperateLog.CustomerOperateLogCreateReqVO;
import cn.iocoder.yudao.module.ecw.dal.dataobject.country.CountryDO;
import cn.iocoder.yudao.module.ecw.enums.CustomerOperateTypeEnum;
......@@ -303,6 +305,8 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
customer.setIsCustomerServiceConfirmed(false);
customer.setIsInOpenSea(false);
}
Date estimateEnterOpenSeaTime = DateUtil.offsetMonth(new Date(), 3).toJdkDate(); //改为3个月
customer.setEstimateEnterOpenSeaTime(estimateEnterOpenSeaTime);
}
......@@ -1781,6 +1785,9 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
if (Objects.isNull(customerDO)) {
throw exception(CUSTOMER_NOT_EXISTS);
}
if(customerDO.getDelayApprovalNum() >=1){
throw exception(CUSTOMER_DELAY_APPROVAL_MORE_THEN_ONE);
}
if (customerDO.getIsInOpenSea()) {
throw exception(CUSTOMER_HAS_IN_OPEN_SEA);
}
......@@ -1825,6 +1832,9 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
customerApprovalDO.setFormId(formId);
customerApprovalService.updateById(customerApprovalDO);
//记录延期申请审核次数
customerMapper.updateCustomerDelayApprovalNum(customerDO.getId(),customerDO.getDelayApprovalNum()+1) ;
//纪录日志
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
CustomerOperateLogCreateReqVO customerOperateLogCreateReqVO = new CustomerOperateLogCreateReqVO()
......@@ -2488,12 +2498,20 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
boolean isFcl = isFcl(customer);
//捞取后设置预计进入公海池时间
Date estimateEnterOpenSeaTime = isFcl ? null : DateUtil.offsetMonth(now, 1).toJdkDate();
if(!loginUserId.equals(customer.getCustomerService())){//如果捞取新旧客户经理不是同一个,
estimateEnterOpenSeaTime = isFcl ? null : DateUtil.offsetMonth(now, 3).toJdkDate();//改为3个月
}
if(loginUserId.equals(customer.getCustomerService())){//如果捞取新旧客户经理是同一个,且客户的最后一次成交订单归属当前客户经理,延期6个月
//Date estimateEnterOpenSeaTime = isFcl ? null : DateUtil.offsetMonth(now, 1).toJdkDate();
Date estimateEnterOpenSeaTime = isFcl ? null : DateUtil.offsetMonth(now, 3).toJdkDate();
if (!loginUserId.equals(customer.getCustomerService())) {//如果捞取新旧客户经理不是同一个,
estimateEnterOpenSeaTime = isFcl ? null : DateUtil.offsetMonth(now, 3).toJdkDate();//改为3个月
}
if (loginUserId.equals(customer.getCustomerService())) {//如果捞取新旧客户经理是同一个,且客户的最后一次成交订单归属当前客户经理,延期6个月
List<CustomerOrderBackPageVO> orderList = customerMapper.orderList(0, 10, new CustomerOrderQueryDTO().setCustomerId(customerId));
if (CollectionUtil.isNotEmpty(orderList) && orderList.size() > 0) {//客户成交的订单不为空
CustomerOrderBackPageVO orderBackPageVO = orderList.get(0);
if (loginUserId.equals(customer.getCustomerService()) && orderBackPageVO != null && orderBackPageVO.getSalesmanId().equals(loginUserId)) {//订单的客户经理和当前是同一个
estimateEnterOpenSeaTime = isFcl ? null : DateUtil.offsetMonth(now, 6).toJdkDate();//改为6个月
}
}
}
......
......@@ -201,6 +201,7 @@
</select>
<update id="moveToWaitAssigned">
UPDATE
......@@ -257,8 +258,512 @@
)
</update>
<sql id="orderQuery">
<if test="query.type != null and query.type != '' and query.type == 0 ">
AND (o.type is null or o.type = '' or o.type = '0')
</if>
<if test="query.type == 1 ">
AND FIND_IN_SET(1, o.type)
</if>
<if test="query.type == 2 ">
AND FIND_IN_SET(2, o.type)
</if>
<if test="query.pdaStartWareIds != null and query.pdaStartWareIds != '' ">
AND FIND_IN_SET(ew_start.`id`, #{query.pdaStartWareIds})
</if>
<if test="query.pdaDestWareIds != null and query.pdaDestWareIds != '' ">
AND FIND_IN_SET(ew_dest.`id`, #{query.pdaDestWareIds})
</if>
<if test="query.isExternalWarehouse != null">
AND o.`is_external_warehouse` = #{query.isExternalWarehouse}
</if>
<if test="query.status != null">
AND o.`status` = #{query.status}
</if>
<if test="query.abnormalState != null">
<choose>
<when test="query.abnormalState != 0">
<choose>
<when test="query.abnormalState != -1">
AND o.`abnormal_state` = #{query.abnormalState}
</when>
<otherwise>
AND o.`abnormal_state` != 0
</otherwise>
</choose>
</when>
<otherwise>
AND o.`abnormal_state` = 0
</otherwise>
</choose>
</if>
<if test="query.inWarehouseState != null">
AND o.`in_warehouse_state` = #{query.inWarehouseState}
</if>
<if test="query.shipmentState != null">
AND o.`shipment_State` = #{query.shipmentState}
</if>
<if test="query.auditType != null">
<choose>
<when test="query.auditType != 0">
<choose>
<when test="query.auditType != -1">
AND o.`audit_type` = #{query.auditType}
</when>
<otherwise>
AND o.`audit_type` != 0
</otherwise>
</choose>
</when>
<otherwise>
AND o.`audit_type` = 0
</otherwise>
</choose>
</if>
<if test="query.salesmanId != null ">
AND (o.`salesman_id` = #{query.salesmanId} or o.`customer_id` in(select cus.id from ecw_customer cus where cus.is_customer_service_confirmed = 1 and cus.customer_service = #{query.salesmanId} ))
</if>
<if test="query.customsType != null">
AND o.`customs_type` = #{query.customsType}
</if>
<if test="query.productRecord != null">
AND o.`product_record` = #{query.productRecord}
</if>
<if test="query.transportId != null">
AND o.`transport_id` = #{query.transportId}
</if>
<if test="query.channelId != null">
AND o.`channel_id` = #{query.channelId}
</if>
<if test="query.warehouseType != null">
AND o.`warehouse_type` = #{query.warehouseType}
</if>
<if test="query.number != null and query.number != '' ">
AND (o.`number` like concat("%",concat(#{query.number},"%")) or o.order_id in( select distinct oi.order_id
from ecw_order_item oi
where oi.deleted = 0 and
((oi.warehouse_in_info is null and oi.express_no like concat('%',concat(#{query.number},'%')))
or (oi.warehouse_in_info is not null and oi.warehouse_in_info ->> '$.expressNo' like concat("%",concat(#{query.number},"%"))))))
</if>
<if test="query.notNumber != null and query.notNumber != '' ">
AND o.`number` not like concat("%",concat(#{query.notNumber},"%"))
and
o.order_id not in
(select distinct oi.order_id from ecw_order_item oi
where oi.deleted = 0 and
((oi.warehouse_in_info is null and oi.express_no like concat("%",concat(#{query.notNumber},"%")))
or
(oi.warehouse_in_info is not null and oi.warehouse_in_info ->> '$.expressNo' like
concat("%",concat(#{query.notNumber},"%")))))
</if>
<if test="query.marks != null and query.marks != '' ">
AND o.`marks` like concat("%",concat(#{query.marks},"%"))
</if>
<if test="query.departureId != null ">
AND de.`departure_id` = #{query.departureId}
</if>
<if test="query.objectiveId != null ">
AND ob.`objective_id` = #{query.objectiveId}
</if>
<if test="query.destCountryId != null ">
AND ob.`objective_country_id` = #{query.destCountryId}
</if>
<if test="query.consignorId != null ">
AND nor.`customer_id` = #{query.consignorId}
</if>
<if test="query.consignorPhone != null and query.consignorPhone != '' ">
AND nor.`phone` = #{query.consignorPhone}
</if>
<if test="query.packageType != null and query.packageType != '' ">
AND CONCAT(',',o.package_type,',') REGEXP CONCAT(',',REPLACE(#{query.packageType},',',',|,'), ',')
</if>
<if test="query.consigneeId != null ">
AND nee.`customer_id` = #{query.consigneeId}
</if>
<if test="query.consigneePhone != null and query.consigneePhone != '' ">
AND nee.`phone` = #{query.consigneePhone}
</if>
<if test="query.isCargoControl != null ">
AND o.`is_cargo_control` = #{query.isCargoControl}
</if>
<if test="query.orderNo != null and query.orderNo != '' ">
AND o.`order_no` like concat("%",concat(#{query.orderNo},"%"))
</if>
<if test="query.orderIdList != null and query.orderIdList.size() != 0">
AND o.`order_id` in
<foreach item='orderId' index='index' collection='query.orderIdList' open='(' separator=',' close=')'>
#{orderId}
</foreach>
</if>
<if test="query.tidanNo != null and query.tidanNo != '' ">
AND o.`tidan_no` like concat("%",concat(#{query.tidanNo},"%"))
</if>
<if test="query.containerNumber != null and query.containerNumber != '' ">
AND o.`container_number` = #{query.containerNumber}
</if>
<if test="query.customerId != null">
AND o.`customer_id` = #{query.customerId}
</if>
<if test="query.beginRucangTime != null and query.endRucangTime != null ">
AND o.order_id in(select distinct wi.order_id from ecw_order_warehouse_in wi where wi.deleted = 0 and
wi.`in_time` between #{query.beginRucangTime} and #{query.endRucangTime})
</if>
<if test="query.beginQingguanTime != null and query.endQingguanTime != null ">
AND o.`qingguan_time` between #{query.beginQingguanTime} and #{query.endQingguanTime}
</if>
<if test="query.beginDaogangTime != null and query.endDaogangTime != null ">
AND o.`daogang_time` between #{query.beginDaogangTime} and #{query.endDaogangTime}
</if>
<if test="query.beginPreLoadTime != null and query.endPreLoadTime != null ">
AND o.`status` > 5 AND o.`pre_load_time` between #{query.beginPreLoadTime} and #{query.endPreLoadTime}
</if>
<if test="query.beginOutboundTime != null and query.endOutboundTime != null ">
AND o.`status` > 5 AND o.container_number in(select distinct b.self_no from ecw_box_air_checkout bc join ecw_box b ON bc.shipment_id = b.id
where b.deleted = 0 and bc.deleted = 0 and bc.`checkout_time` between #{query.beginOutboundTime} and #{query.endOutboundTime})
</if>
<if test="query.beginLoadTime != null and query.endLoadTime != null ">
AND o.`status` > 5 AND o.`load_time` between #{query.beginLoadTime} and #{query.endLoadTime}
</if>
<if test="query.beginUnloadTime != null and query.endUnloadTime != null ">
AND o.`status` > 5 AND o.`unload_time` between #{query.beginUnloadTime} and #{query.endUnloadTime}
</if>
<if test="query.beginTakeTime != null and query.endTakeTime != null ">
AND o.`status` > 19 AND o.`take_time` between #{query.beginTakeTime} and #{query.endTakeTime}
</if>
<if test="query.beginSplitTime != null and query.endSplitTime != null ">
AND o.`split_time` between #{query.beginSplitTime} and #{query.endSplitTime}
</if>
<if test="query.beginCreateTime != null and query.endCreateTime != null ">
AND o.`create_time` between #{query.beginCreateTime} and #{query.endCreateTime}
</if>
<if test="query.beginPickTime != null and query.endPickTime != null ">
AND o.order_id in(select distinct op.order_id from ecw_order_cargo_control_pick op where op.deleted = 0 and
op.status in(1,3) and op.`create_time` between #{query.beginPickTime} and #{query.endPickTime})
</if>
<if test="query.beginPickUpTime != null and query.endPickUpTime != null ">
AND o.order_no in(select distinct op.order_id from ecw_order_pickup op where op.deleted = 0 and
op.`create_time` between #{query.beginPickUpTime} and #{query.endPickUpTime})
</if>
<if test="query.beginWarehouseInTime != null and query.endWarehouseInTime != null ">
AND o.order_id in(select distinct wi.order_id from ecw_order_warehouse_in wi where wi.deleted = 0 and
wi.`update_time` between #{query.beginWarehouseInTime} and #{query.endWarehouseInTime})
</if>
<if test="query.creator != null and query.creator != '' ">
AND o.`creator` = #{query.creator} and (o.user_id is null or o.user_id = 0)
</if>
<if test = 'query.cargoControlStatus != null and query.cargoControlStatus != 3'>
AND o.`cargo_control_status` = #{query.cargoControlStatus}
</if>
<if test = 'query.cargoControlStatus != null and query.cargoControlStatus == 3'>
AND o.`cargo_control_status` = 1 AND (select count(1) from ecw_order_cargo_control_pick ccp2 where ccp2.order_id = o.order_id and ccp2.status = 1) > 0
</if>
<if test="query.searchKey != null and query.searchKey != '' ">
AND concat(IFNULL(o.`order_no`,''), IFNULL(o.`old_numbers`,'')
,IFNULL(o.`marks`,''),IFNULL(o.`tidan_no`,''),IFNULL(o.`container_number`,''),IFNULL(nee.`name`,''),IFNULL(nee.`phone`,'')) like
concat("%",concat(#{query.searchKey},"%"))
</if>
<if test="query.consignorKey != null and query.consignorKey != '' ">
AND (concat(IFNULL(nor.`name`,''),IFNULL(nor.`name_en`,''),IFNULL(nor.`phone`,'')) like
concat("%",concat(#{query.consignorKey},"%"))
OR nor.customer_id in (select c.id from ecw_customer c where c.number like
concat("%",concat(#{query.consignorKey},"%"))))
</if>
<if test="query.notConsignorKey != null and query.notConsignorKey != '' ">
AND (concat(IFNULL(nor.`name`,''),IFNULL(nor.`name_en`,''),IFNULL(nor.`phone`,'')) not like
concat("%",concat(#{query.notConsignorKey},"%"))
AND nor.customer_id not in (select c.id from ecw_customer c where c.number like
concat("%",concat(#{query.notConsignorKey},"%"))))
</if>
<if test="query.consigneeKey != null and query.consigneeKey != '' ">
AND (concat(IFNULL(nee.`name`,''),IFNULL(nee.`name_en`,''),IFNULL(nee.`phone`,'')) like
concat("%",concat(#{query.consigneeKey},"%"))
OR nee.customer_id in (select c.id from ecw_customer c where c.number like
concat("%",concat(#{query.consigneeKey},"%"))))
</if>
<if test="query.notConsigneeKey != null and query.notConsigneeKey != '' ">
AND (concat(IFNULL(nee.`name`,''),IFNULL(nee.`name_en`,''),IFNULL(nee.`phone`,'')) not like
concat("%",concat(#{query.notConsigneeKey},"%"))
AND nee.customer_id not in (select c.id from ecw_customer c where c.number like
concat("%",concat(#{query.notConsigneeKey},"%"))))
</if>
<if test="query.numberKey != null and query.numberKey != '' ">
AND concat(IFNULL(o.`order_no`,''), IFNULL(o.`old_numbers`,''), IFNULL(o.`parent_number`,''), IFNULL(o.`initial_parent_order_no`,'')
,IFNULL(o.`marks`,''),IFNULL(o.`tidan_no`,''),IFNULL(o.`container_number`,''),IFNULL(o.`no_charge_record`,'')) like
concat("%",concat(#{query.numberKey},"%"))
</if>
<if test="query.notNumberKey != null and query.notNumberKey != '' ">
AND concat(IFNULL(o.`order_no`,''), IFNULL(o.`old_numbers`,''), IFNULL(o.`parent_number`,''), IFNULL(o.`initial_parent_order_no`,'')
,IFNULL(o.`marks`,''),IFNULL(o.`tidan_no`,''),IFNULL(o.`container_number`,''),IFNULL(o.`no_charge_record`,'')) not like
concat("%",concat(#{query.notNumberKey},"%"))
</if>
<if test="query.eqNumberKey != null and query.eqNumberKey != '' ">
AND (o.`order_no` = #{query.eqNumberKey}
or (o.`old_numbers` is not null and o.`old_numbers` != '' and o.`old_numbers` = #{query.eqNumberKey})
or (o.`parent_number` is not null and o.`parent_number` != '' and o.`parent_number` = #{query.eqNumberKey})
or (o.`marks` is not null and o.`marks` != '' and o.`marks` = #{query.eqNumberKey})
or (o.`tidan_no` is not null and o.`tidan_no` != '' and o.`tidan_no` = #{query.eqNumberKey})
or (o.`container_number` is not null and o.`container_number` != '' and o.`container_number` = #{query.eqNumberKey})
or (o.`no_charge_record` is not null and o.`no_charge_record` != '' and o.`no_charge_record` = #{query.eqNumberKey})
or (o.`initial_parent_order_no` is not null and o.`initial_parent_order_no` != '' and o.`initial_parent_order_no` = #{query.eqNumberKey})
)
</if>
<if test="query.notEqNumberKey != null and query.notEqNumberKey != '' ">
AND o.`order_no` != #{query.notEqNumberKey}
AND (o.`old_numbers` is null or o.`old_numbers` != '' or o.`old_numbers` != #{query.notEqNumberKey})
AND (o.`parent_number` is null or o.`parent_number` != '' or o.`parent_number` != #{query.notEqNumberKey})
AND (o.`marks` is null or o.`marks` != '' or o.`marks` != #{query.notEqNumberKey})
AND (o.`tidan_no` is null or o.`tidan_no` != '' or o.`tidan_no` != #{query.notEqNumberKey})
AND (o.`container_number` is null or o.`container_number` != '' or o.`container_number` != #{query.notEqNumberKey})
AND (o.`no_charge_record` is null or o.`no_charge_record` != '' or o.`no_charge_record` != #{query.notEqNumberKey})
</if>
<if test="query.prodKey != null and query.prodKey != '' ">
and (o.order_id in(
select oi.order_id
from ecw_order_item oi
left join ecw_product p
on oi.prod_id = p.id
left join ecw_product_type pt
on pt.id = oi.prod_type
left join ecw_product_brank pb
on pb.id = oi.brand
where oi.deleted = 0 and
concat(IFNULL(oi.`prod_title_zh`,''),IFNULL(oi.`prod_title_en`,''),IFNULL(pt.`title_zh`,''),IFNULL(pt.`title_en`,''),
IFNULL(pb.`title_zh`,''),IFNULL(pb.`title_en`,''))
like concat("%",concat(#{query.prodKey},"%"))
))
</if>
<if test="query.notProdKey != null and query.notProdKey != '' ">
and (o.order_id not in(
select oi.order_id
from ecw_order_item oi
left join ecw_product p
on oi.prod_id = p.id
left join ecw_product_type pt
on pt.id = oi.prod_type
left join ecw_product_brank pb
on pb.id = oi.brand
where oi.deleted = 0 and
concat(IFNULL(oi.`prod_title_zh`,''),IFNULL(oi.`prod_title_en`,''),IFNULL(pt.`title_zh`,''),IFNULL(pt.`title_en`,''),
IFNULL(pb.`title_zh`,''),IFNULL(pb.`title_en`,''))
like concat("%",concat(#{query.notProdKey},"%"))
))
</if>
<if test="query.eqProdKey != null and query.eqProdKey != '' ">
and (o.order_id in(
select oi.order_id
from ecw_order_item oi
left join ecw_product p
on oi.prod_id = p.id
left join ecw_product_type pt
on pt.id = oi.prod_type
left join ecw_product_brank pb
on pb.id = oi.brand
where oi.deleted = 0 and (oi.`prod_title_zh` = #{query.eqProdKey} or oi.`prod_title_en` = #{query.eqProdKey}
or pt.`title_zh` = #{query.eqProdKey} or pt.`title_en` = #{query.eqProdKey}
or pb.`title_zh` = #{query.eqProdKey} or pb.`title_en` = #{query.eqProdKey})
))
</if>
<if test="query.notEqProdKey != null and query.notEqProdKey != '' ">
and (o.order_id not in(
select oi.order_id
from ecw_order_item oi
left join ecw_product p
on oi.prod_id = p.id
left join ecw_product_type pt
on pt.id = oi.prod_type
left join ecw_product_brank pb
on pb.id = oi.brand
where oi.deleted = 0 and (oi.`prod_title_zh` = #{query.notEqProdKey} or oi.`prod_title_en` = #{query.notEqProdKey}
or pt.`title_zh` = #{query.notEqProdKey} or pt.`title_en` = #{query.notEqProdKey}
or pb.`title_zh` = #{query.notEqProdKey} or pb.`title_en` = #{query.notEqProdKey})
))
</if>
<if test="query.startWarehouseId != null and query.destWarehouseId != null ">
and (o.line_id in(
select whl.id
from ecw_warehouse_line whl
where whl.start_warehouse_id = #{query.startWarehouseId} and whl.dest_warehouse_id =
#{query.destWarehouseId}
))
</if>
<if test="query.startWarehouseId != null and query.destWarehouseId == null ">
and (o.line_id in(
select whl.id
from ecw_warehouse_line whl
where whl.start_warehouse_id = #{query.startWarehouseId}
))
</if>
<if test="query.startWarehouseId == null and query.destWarehouseId != null ">
and (o.line_id in(
select whl.id
from ecw_warehouse_line whl
where whl.dest_warehouse_id = #{query.destWarehouseId}
))
</if>
<if test="query.isNeat == false ">
AND o.sum_num <![CDATA[ < ]]> o.cost->>'$.totalNum'
</if>
<if test="query.airShipment != null and query.airShipment == 1">
AND o.`status` = 5 AND o.air_shipment = 1 and abnormal_state = 0 and audit_type = 0
</if>
<if test="query.airShipment != null and query.airShipment == 2">
AND o.`status` = 5 AND o.air_shipment = 2
</if>
<if test="query.airShipment != null and query.airShipment == 3">
AND o.`status` = 5 AND o.air_shipment = 3
</if>
<if test="query.airShipment != null and query.airShipment == 4">
AND o.`status` = 5 AND o.air_shipment = 4
</if>
<if test="query.airShipment != null and query.airShipment == 10">
AND o.`status` = 5 AND o.air_shipment in(2,3,4)
</if>
<if test="query.airShipment != null and query.airShipment == 11">
AND o.`status` = 5 AND o.air_shipment in(1,2,3,4) and abnormal_state = 0 and audit_type = 0
</if>
<if test="query.airShipment != null and query.airShipment == 12">
AND o.`status` = 5 AND o.air_shipment in(2,3) and abnormal_state = 0 and audit_type = 0
</if>
<if test="query.airShipment != null and query.airShipment == 20">
AND o.`status` = 5 AND o.air_shipment in(0,2,3,4) and abnormal_state = 0 and audit_type = 0
</if>
<if test="query.isNeat == true ">
AND o.sum_num = o.cost->>'$.totalNum'
</if>
<if test="query.customerDetailId != null">
AND (o.`customer_id` = #{query.customerDetailId} or nor.`customer_id` = #{query.customerDetailId} or
nee.`customer_id` = #{query.customerDetailId})
</if>
<if test="query.userType == 2 ">
AND ((o.user_id is not null AND o.user_id > 0 AND o.`status` != 0) or o.user_id is null or o.user_id = 0)
</if>
</sql>
<select id="orderList"
resultType="cn.iocoder.yudao.module.customer.vo.customerDetail.CustomerOrderBackPageVO">
select o.order_id,
o.package_type as advance_type,
o.package_remarks,
o.number,
o.order_no,
o.tidan_no,
o.type,
o.order_type,
o.air_shipment,
IFNULL((select SUM(IF(it.charge_volume > it.min_metering_volume, it.charge_volume, it.min_metering_volume)) FROM
ecw_order_item it WHERE it.order_id = o.order_id and it.deleted = 0 and it.warehouse_in_info IS NOT NULL), 0) as
w_volume,
IFNULL((select SUM(IF( it.charge_weight > it.min_metering_weight, it.charge_weight, it.min_metering_weight))
FROM ecw_order_item it WHERE it.order_id = o.order_id and it.deleted = 0 and it.warehouse_in_info IS NOT NULL),
0) as v_weight,
o.customs_type,
if(#{query.customerDetailId} is not null and #{query.customerDetailId} > 0, (select min(owi.`in_time`) from
ecw_order_warehouse_in owi where owi.deleted = 0 and owi.order_id = o.order_id ), o.rucang_time ) as
rucang_time,
o.cost,
o.parent_number,
o.parent_order_id,
o.initial_parent_order_id,
if(#{query.lang} = 0, de.departure ->> '$.titleZh', de.departure ->> '$.titleEn') as departure_name,
if(#{query.lang} = 0, ob.objective ->> '$.titleZh', ob.objective ->> '$.titleEn') as objective_name,
de.departure_id,
ob.objective_id,
o.adjust_to_start_warehouse_id,
(SELECT IF(0 = 0, ew_start_adjust.title_zh, ew_start_adjust.title_en) FROM ecw_warehouse ew_start_adjust WHERE
ew_start_adjust.id = o.adjust_to_start_warehouse_id) AS adjust_to_start_warehouse_name,
o.adjust_to_dest_warehouse_id,
(SELECT IF(0 = 0, ew_dest_adjust.title_zh, ew_dest_adjust.title_en) FROM ecw_warehouse ew_dest_adjust WHERE
ew_dest_adjust.id = o.adjust_to_dest_warehouse_id) AS adjust_to_dest_warehouse_name,
o.dest_adjust_to_start_warehouse_id,
(SELECT IF(0 = 0, ew_start_adjust.title_zh, ew_start_adjust.title_en) FROM ecw_warehouse ew_start_adjust WHERE
ew_start_adjust.id = o.dest_adjust_to_start_warehouse_id) AS dest_adjust_to_start_warehouse_name,
o.dest_adjust_to_dest_warehouse_id,
(SELECT IF(0 = 0, ew_dest_adjust.title_zh, ew_dest_adjust.title_en) FROM ecw_warehouse ew_dest_adjust WHERE
ew_dest_adjust.id = o.dest_adjust_to_dest_warehouse_id) AS dest_adjust_to_dest_warehouse_name,
w.start_warehouse_name,
w.dst_warehouse_name,
w.start_warehouse_id,
w.dst_warehouse_id,
o.marks,
o.salesman_id,
o.status,
o.abnormal_state,
o.in_warehouse_state,
o.shipment_state,
o.audit_type,
o.audit_result,
o.guan_lian_order_status,
o.transport_id,
(select ifnull(sum(ccp.pick_num),0) from ecw_order_cargo_control_pick ccp where ccp.order_id = o.order_id and
ccp.status in(1,2,3,4) ) as release_num,
o.is_cargo_control,
o.cargo_control_status,
o.cost ->> '$.totalNum' as total_num,
o.sum_num,
o.sum_volume,
o.sum_weight,
o.sum_weight_finished_warehouse_in,
o.sum_volume_finished_warehouse_in,
o.packing_list_url,
o.is_external_warehouse,
o.exception_reason,
o.is_exception,
o.create_time,
o.load_time,
(select su.nickname from system_user su where su.deleted = 0 and su.id = o.salesman_id) as salesman_name,
(select min(wi.`in_time`) from ecw_order_warehouse_in wi where wi.deleted = 0 and wi.order_id = o.order_id ) as
in_time,
if(#{query.userType} = 1, 1, 2) as user_type,
nor.name as consignor_name,
nor.name_en as consignor_name_en,
nor.phone as consignor_phone,
nor.country_code as consignor_country_code,
nee.name as consignee_name,
nee.name_en as consignee_name_en,
nee.phone as consignee_phone,
nee.country_code as consignee_country_code,
if(#{query.lang} = 0, channel.name_zh, channel.name_en) as channel_name,
o.update_time,
#{query.lang} as lang
from ecw_order o
left join (
SELECT
ewl.id AS line_id,
ew_start.id AS start_warehouse_id,
ew_dest.id AS dst_warehouse_id,
ew_start.title_zh AS start_title_zh,
IF( #{query.lang} = 0, ew_dest.title_zh, ew_dest.title_en ) AS dst_warehouse_name,
IF( #{query.lang} = 0, ew_start.title_zh, ew_start.title_en ) AS start_warehouse_name
FROM
ecw_warehouse_line ewl
LEFT JOIN ecw_warehouse ew_start ON ewl.start_warehouse_id = ew_start.id
LEFT JOIN ecw_warehouse ew_dest ON ewl.dest_warehouse_id = ew_dest.id
) w ON w.line_id = o.line_id
left join ecw_order_departure de on de.order_id = o.order_id
left join ecw_order_objective ob on ob.order_id = o.order_id
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_channel channel on channel.channel_id = o.channel_id
where o.deleted = 0 and o.in_warehouse_state != 211 and o.in_warehouse_state != 208 and o.status != 10
<if test="query.deptId != null ">
AND o.dept_id = #{query.deptId}
</if>
<if test="query.deptIdList != null and query.deptIdList.size() > 0">
AND (o.dept_id IN
<foreach item="deptId" collection="query.deptIdList" open="(" close=")" separator=",">
#{deptId}
</foreach>
or
(SELECT u.dept_id FROM system_user u WHERE u.id = o.creator) IN
<foreach item="deptId" collection="query.deptIdList" open="(" close=")" separator=",">
#{deptId}
</foreach>
)
</if>
<include refid="orderQuery"/>
order by o.create_time desc
limit #{start}, #{size}
</select>
</mapper>
......@@ -85,6 +85,8 @@ public interface ErrorCodeConstants {
ErrorCode CUSTOMER_CONTACTS_USERID_ALREADY_BIND = new ErrorCode(1004002016, "customer.contact.already.binding.others");
ErrorCode MESSAGE_LEAVE_NOT_EXISTS = new ErrorCode(1004002020, "message.leave.not.exists");
ErrorCode COUNTRY_NOT_EXISTS = new ErrorCode(1004002025, "country.not.exists");
......@@ -173,6 +175,7 @@ public interface ErrorCodeConstants {
ErrorCode CUSTOMER_IS_NEW_OR_OLD_NO_CHANGE = new ErrorCode(1004006036, "customer.is.new.or.old.no.change");
ErrorCode CUSTOMER_DELAY_APPROVAL_MORE_THEN_ONE = new ErrorCode (1004006037,"customer.delay.approval.times.more.then.one") ;
}
......@@ -1913,7 +1913,9 @@
<if test="query.userType == 2 ">
AND ((o.user_id is not null AND o.user_id > 0 AND o.`status` != 0) or o.user_id is null or o.user_id = 0)
</if>
</sql><sql id="issuedOrderQuery">
</sql>
<sql id="issuedOrderQuery">
<if test="query.type != null and query.type != '' and query.type == 0 ">
AND (o.type is null or o.type = '' or o.type = '0')
</if>
......
......@@ -62,6 +62,7 @@ customer.contacts.already.bind=
customer.contacts.multi.default=
customer.contacts.no.default=
customer.not.exists=
customer.delay.approval.times.more.then.one=
zhong.pao.line.config.exists=
zhong.pao.not.exists=
currency.not.exists=
......
......@@ -997,4 +997,5 @@ case.num.in.merge.pkg=This box has been packed, please scan the packing box numb
order.already.in.merge.pkg=The order has been placed under the packaging box
customer.is.new.or.old.no.change=customer current business type is {}, it's no change
order.is.pre.installed=Order pre installed
customer.delay.approval.times.more.then.one=delay approval times more then one
......@@ -565,6 +565,7 @@ customer.contacts.already.bind=\u5BA2\u6237\u8054\u7CFB\u4EBA\u624B\u673A\u53F7{
customer.contacts.multi.default=\u5BA2\u6237\u8054\u7CFB\u4EBA\u53EA\u80FD\u8BBE\u7F6E\u4E00\u4E2A\u9ED8\u8BA4\u8054\u7CFB\u4EBA
customer.contacts.no.default=\u5BA2\u6237\u8054\u7CFB\u4EBA\u672A\u8BBE\u7F6E\u9ED8\u8BA4\u8054\u7CFB\u4EBA
customer.not.exists=\u5BA2\u6237\u4E0D\u5B58\u5728
customer.delay.approval.times.more.then.one=\u5DF2\u7ECF\u7533\u8BF7\u8FC71\u6B21\u5EF6\u671F\u4E0D\u80FD\u518D\u7533\u8BF7\u4E86
zhong.pao.line.config.exists=\u6B64\u7EBF\u8DEF\u7684\u91CD\u6CE1\u8D27\u914D\u7F6E\u5DF2\u5B58\u5728
zhong.pao.not.exists=\u91CD\u6CE1\u8D27\u914D\u7F6E\u4E0D\u5B58\u5728
currency.not.exists=\u8D27\u5E01\u5355\u4F4D\u4E0D\u5B58\u5728
......
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