2025-05-30 08:27:52 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
< !DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace= "com.ruoyi.sip.mapper.ProjectOrderInfoMapper" >
<resultMap type= "ProjectOrderInfo" id= "ProjectOrderInfoResult" >
<result property= "id" column= "id" />
<result property= "projectId" column= "project_id" />
<result property= "city" column= "city" />
<result property= "businessPerson" column= "business_person" />
<result property= "businessEmail" column= "business_email" />
<result property= "businessPhone" column= "business_phone" />
<result property= "orderCode" column= "order_code" />
<result property= "currencyType" column= "currencyType" />
<result property= "shipmentAmount" column= "shipment_amount" />
<result property= "actualPurchaseAmount" column= "actual_purchase_amount" />
<result property= "orderEndTime" column= "order_end_time" />
<result property= "deliveryTime" column= "delivery_time" />
<result property= "companyDelivery" column= "company_delivery" />
<result property= "notifier" column= "notifier" />
2025-07-31 01:30:32 +00:00
<result property= "notifierAddress" column= "notifier_address" />
2025-05-30 08:27:52 +00:00
<result property= "notifierEmail" column= "notifier_email" />
<result property= "notifierPhone" column= "notifier_phone" />
<result property= "duty" column= "duty" />
<result property= "dutyEmail" column= "duty_email" />
<result property= "dutyPhone" column= "duty_phone" />
<result property= "orderChannel" column= "order_channel" />
<result property= "partnerCode" column= "partner_code" />
<result property= "supplier" column= "supplier" />
<result property= "remark" column= "remark" />
<result property= "orderStatus" column= "order_status" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
2025-09-18 02:15:08 +00:00
<result property= "paymentMethod" column= "payment_method" />
<result property= "paymentRatio" column= "payment_ratio" />
<result property= "paymentDescription" column= "payment_description" />
2026-03-20 08:49:46 +00:00
<result property= "operationVersion" column= "operation_version" />
2026-05-21 02:28:15 +00:00
<result property= "orderStockingStatus" column= "order_stocking_status" />
2025-05-30 08:27:52 +00:00
</resultMap>
<sql id= "selectProjectOrderInfoVo" >
2025-06-04 03:25:20 +00:00
select id, project_id,province, city, business_person, business_email, business_phone, order_code, currencyType,
2025-10-28 07:08:30 +00:00
shipment_amount, actual_purchase_amount, order_end_time, delivery_time, company_delivery, notifier,finance_status,
2025-07-31 01:30:32 +00:00
notifier_email, notifier_phone, duty, duty_email, duty_phone, order_channel, partner_code, supplier,notifier_address,
2026-05-21 02:28:15 +00:00
remark, order_status, create_by, create_time, update_by, update_time,version_code,process_type,process_template,discount_fold,order_stocking_status,
2026-03-20 08:49:46 +00:00
delivery_status,sign_status,outer_status,approve_time,payment_method,payment_ratio,payment_description,order_type,operation_version
2025-08-08 10:05:13 +00:00
from project_order_info t1
2025-05-30 08:27:52 +00:00
</sql>
<sql id= "selectProjectOrderInfoRelationVo" >
2025-06-04 03:25:20 +00:00
select t1.id, t1.project_id,t1.province, t1.city, t1.business_person, t1.business_email, t1.business_phone, t1.order_code, t1.currencyType,
2025-12-09 01:10:05 +00:00
t1.shipment_amount, t1.actual_purchase_amount, t1.order_end_time, t1.delivery_time, t1.company_delivery, t1.notifier,t1.order_type,
2025-05-30 08:27:52 +00:00
t1.notifier_email, t1.notifier_phone, t1.duty, t1.duty_email, t1.duty_phone, t1.order_channel, t1.partner_code, t1.supplier,
2025-06-19 02:22:36 +00:00
t1.remark, t1.order_status, t1.create_by, t1.create_time, t1.update_by, t1.update_time,t1.partner_user_name,t1.partner_email
2025-10-28 07:08:30 +00:00
,t1.partner_phone,t1.version_code,t1.process_type,t1.process_template,t1.discount_fold,t1.notifier_address,t1.finance_status,
2026-05-21 02:28:15 +00:00
t1.delivery_status,t1.sign_status,t1.outer_status,t1.approve_time,t1.payment_method,t1.payment_ratio,t1.payment_description,t1.operation_version,t1.order_stocking_status
2025-07-03 09:17:23 +00:00
,t2.project_code,t2.project_name,t2.province,t2.customer_name,t2.customer_code,t2.industry_type,t2.bg_property,t2.agent_code,t2.estimated_order_time
2025-08-08 10:05:13 +00:00
,t2.customer_phone,t2.customer_user_name,t2.agent_code,t2.customer_code,t2.partner_name project_partner_name
2025-09-22 08:37:59 +00:00
,t3.partner_name,t3.level,t3.system_user_id,t3.address partner_address
2025-06-09 01:37:11 +00:00
,t4.agent_name
,t5.user_name as duty_name
2025-12-31 09:08:12 +00:00
,t6.charge_status,t6.biz_charge_date,t6.finance_charge_date
2025-05-30 08:27:52 +00:00
from project_order_info t1
left join project_info t2 on t1.project_id = t2.id
2025-07-03 09:17:23 +00:00
2025-05-30 08:27:52 +00:00
left join partner_info t3 on t1.partner_code=t3.partner_code
2025-06-09 01:37:11 +00:00
left join agent_info t4 on t2.agent_code=t4.agent_code
left join sys_user t5 on t1.duty=t5.user_id
2025-12-31 09:08:12 +00:00
left join oms_finance_charge t6 on t1.order_code=t6.order_code
2025-05-30 08:27:52 +00:00
</sql>
<select id= "selectProjectOrderInfoList" parameterType= "ProjectOrderInfo" resultMap= "ProjectOrderInfoResult" >
<include refid= "selectProjectOrderInfoRelationVo" />
2025-09-10 01:12:07 +00:00
where 1=1
2026-04-28 11:52:01 +00:00
<if test= "ids != null and ids != ''" > and find_in_set(t1.id, #{ids})</if>
2025-09-10 01:12:07 +00:00
<if test= "projectId != null " > and t1.project_id = #{projectId}</if>
<if test= "projectCode != null and projectCode!='' " > and t2.project_code like
concat('%',#{projectCode},'%')
</if>
<if test= "projectName != null and projectName!=''" > and t2.project_name like concat('%',
#{projectName},'%')
</if>
<if test= "customerName != null and customerName!=''" > and t2.customer_name like
concat('%',#{customerName},'%')
</if>
<if test= "agentName != null and agentName!=''" > and t4.agent_name like concat('%',#{agentName},'%')</if>
2025-10-28 07:08:30 +00:00
<if test= "financeStatus != null and financeStatus!=''" > and t1.finance_status =#{financeStatus}</if>
2025-09-10 01:12:07 +00:00
<if test= "province != null and province != ''" > and t1.province = #{province}</if>
<if test= "city != null and city != ''" > and t1.city = #{city}</if>
<if test= "businessPerson != null and businessPerson != ''" > and t1.business_person = #{businessPerson}</if>
<if test= "businessEmail != null and businessEmail != ''" > and t1.business_email = #{businessEmail}</if>
<if test= "businessPhone != null and businessPhone != ''" > and t1.business_phone = #{businessPhone}</if>
<if test= "orderCode != null and orderCode != ''" > and t1.order_code = #{orderCode}</if>
<if test= "currencyType != null and currencyType != ''" > and t1.currencyType = #{currencyType}</if>
<if test= "shipmentAmount != null " > and t1.shipment_amount = #{shipmentAmount}</if>
<if test= "actualPurchaseAmount != null " > and t1.actual_purchase_amount = #{actualPurchaseAmount}</if>
<if test= "orderEndTime != null " > and t1.order_end_time = #{orderEndTime}</if>
<if test= "deliveryTime != null " > and t1.delivery_time = #{deliveryTime}</if>
<if test= "companyDelivery != null and companyDelivery != ''" > and t1.company_delivery = #{companyDelivery}
</if>
<if test= "notifier != null and notifier != ''" > and t1.notifier = #{notifier}</if>
<if test= "notifierEmail != null and notifierEmail != ''" > and t1.notifier_email = #{notifierEmail}</if>
<if test= "notifierPhone != null and notifierPhone != ''" > and t1.notifier_phone = #{notifierPhone}</if>
<if test= "notifierAddress != null and notifierAddress != ''" > and t1.notifier_address = #{notifierAddress}
</if>
<if test= "duty != null and duty != ''" > and t1.duty = #{duty}</if>
2025-12-15 03:03:16 +00:00
<if test= "vendorCode != null and vendorCode != ''" > and t1.project_id in (
select ppi.project_id from product_info pi
left join project_product_info ppi on ppi.product_bom_code=pi.product_code
where pi.vendor_code=#{vendorCode}
) </if>
2025-09-10 01:12:07 +00:00
<if test= "dutyName != null and dutyName != ''" > and t5.user_name like concat('%', #{dutyName}, '%')</if>
<if test= "dutyEmail != null and dutyEmail != ''" > and t1.duty_email = #{dutyEmail}</if>
<if test= "dutyPhone != null and dutyPhone != ''" > and t1.duty_phone = #{dutyPhone}</if>
<if test= "orderChannel != null and orderChannel != ''" > and t1.order_channel = #{orderChannel}</if>
<if test= "partnerCode != null and partnerCode != ''" > and t1.partner_code = #{partnerCode}</if>
<if test= "partnerName != null and partnerName != ''" > and t3.partner_name like concat('%', #{partnerName},
'%')
</if>
<if test= "supplier != null and supplier != ''" > and t1.supplier = #{supplier}</if>
<if test= "supplier != null and supplier != ''" > and t1.supplier = #{supplier}</if>
<if test= "orderStatus != null and orderStatus != ''" > and t1.order_status = #{orderStatus}</if>
2026-05-21 02:28:15 +00:00
<if test= "orderStockingStatus != null and orderStockingStatus != ''" > and t1.order_stocking_status = #{orderStockingStatus}</if>
2025-09-10 01:12:07 +00:00
<if test= "deliveryStatus != null and deliveryStatus != ''" > and t1.delivery_status = #{deliveryStatus}</if>
<if test= "outerStatus != null and outerStatus != ''" > and t1.outer_status = #{outerStatus}</if>
<if test= "signStatus != null and signStatus != ''" > and t1.sign_status = #{signStatus}</if>
<if test= "keyword != null and keyword != ''" > and (t1.order_code like concat('%',#{keyword},'%') or
t2.project_name like concat('%',#{keyword},'%') or t2.customer_name like concat('%',#{keyword},'%'))
</if>
2026-03-20 03:24:23 +00:00
<if test= "createTimeStart != null or createTimeEnd != null" >
<choose >
<when test= "createTimeStart != null and createTimeEnd != null" >
and t1.create_time between #{createTimeStart} and #{createTimeEnd}
</when>
<when test= "createTimeStart != null" >
and t1.create_time <![CDATA[ >= ]]> #{createTimeStart}
</when>
<when test= "createTimeEnd != null" >
and t1.create_time <![CDATA[ <= ]]> #{createTimeEnd}
</when>
</choose>
</if>
2025-09-10 01:12:07 +00:00
<if test= "deliveryTimeStart != null or deliveryTimeEnd != null" >
<choose >
<when test= "deliveryTimeStart != null and deliveryTimeEnd != null" >
and t1.delivery_time between date_format(#{deliveryTimeStart}, '%Y-%m-%d 00:00:00') and
date_format(#{deliveryTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
<when test= "deliveryTimeStart != null" >
and t1.delivery_time <![CDATA[ >= ]]> date_format(#{deliveryTimeStart}, '%Y-%m-%d 00:00:00')
</when>
<when test= "deliveryTimeEnd != null" >
and t1.delivery_time <![CDATA[ <= ]]> date_format(#{deliveryTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
2025-06-12 03:26:43 +00:00
2025-09-10 01:12:07 +00:00
</choose>
</if>
2026-01-05 09:02:26 +00:00
<if test= "params.beginDeliveryTime != null or params.endDeliveryTime != null" >
<choose >
<when test= "params.beginDeliveryTime != null and params.endDeliveryTime != null" >
and t1.delivery_time between date_format(#{params.beginDeliveryTime}, '%Y-%m-%d 00:00:00') and
date_format(#{params.endDeliveryTime}, '%Y-%m-%d 23:59:59')
</when>
<when test= "params.beginDeliveryTime != null" >
and t1.delivery_time <![CDATA[ >= ]]> date_format(#{params.beginDeliveryTime}, '%Y-%m-%d 00:00:00')
</when>
<when test= "params.endDeliveryTime != null" >
and t1.delivery_time <![CDATA[ <= ]]> date_format(#{params.endDeliveryTime}, '%Y-%m-%d 23:59:59')
</when>
2026-04-07 15:30:06 +00:00
</choose>
</if>
<if test= "params.beginApproveTime != null or params.endApproveTime != null" >
<choose >
<when test= "params.beginApproveTime != null and params.endApproveTime != null" >
and t1.approve_time between date_format(#{params.beginApproveTime}, '%Y-%m-%d 00:00:00') and
date_format(#{params.endApproveTime}, '%Y-%m-%d 23:59:59')
</when>
<when test= "params.beginApproveTime != null" >
and t1.approve_time <![CDATA[ >= ]]> date_format(#{params.beginApproveTime}, '%Y-%m-%d 00:00:00')
</when>
<when test= "params.endApproveTime != null" >
and t1.approve_time <![CDATA[ <= ]]> date_format(#{params.endApproveTime}, '%Y-%m-%d 23:59:59')
</when>
2026-01-05 09:02:26 +00:00
</choose>
</if>
2025-09-10 01:12:07 +00:00
<if test= "updateTimeStart != null or updateTimeEnd != null" >
<choose >
<when test= "updateTimeStart != null and updateTimeEnd != null" >
and t1.update_time between date_format(#{updateTimeStart}, '%Y-%m-%d 00:00:00') and
date_format(#{updateTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
<when test= "updateTimeStart != null" >
and t1.update_time <![CDATA[ >= ]]> date_format(#{updateTimeStart}, '%Y-%m-%d 00:00:00')
</when>
<when test= "updateTimeEnd != null" >
and t1.update_time <![CDATA[ <= ]]> date_format(#{updateTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
2025-08-15 10:00:53 +00:00
2025-09-10 01:12:07 +00:00
</choose>
</if>
<if test= "approveTimeStart != null or approveTimeEnd != null" >
<choose >
<when test= "approveTimeStart != null and approveTimeEnd != null" >
and t1.approve_time between date_format(#{approveTimeStart}, '%Y-%m-%d 00:00:00') and
date_format(#{approveTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
2025-10-28 07:08:30 +00:00
<when test= "approveTimeStart != null" >
2025-09-10 01:12:07 +00:00
and t1.approve_time <![CDATA[ >= ]]> date_format(#{approveTimeStart}, '%Y-%m-%d 00:00:00')
</when>
<when test= "approveTimeEnd != null" >
and t1.approve_time <![CDATA[ <= ]]> date_format(#{approveTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
2025-08-08 10:05:13 +00:00
2025-09-10 01:12:07 +00:00
</choose>
</if>
<if test= "estimatedOrderTimeStart != null or estimatedOrderTimeEnd != null" >
<choose >
<when test= "estimatedOrderTimeStart != null and estimatedOrderTimeEnd != null" >
and t2.estimated_order_time between date_format(#{estimatedOrderTimeStart}, '%Y-%m-%d 00:00:00')
and date_format(#{estimatedOrderTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
<when test= "estimatedOrderTimeStart != null" >
and t2.estimated_order_time <![CDATA[ >= ]]> date_format(#{estimatedOrderTimeStart}, '%Y-%m-%d
00:00:00')
</when>
<when test= "estimatedOrderTimeEnd != null" >
and t2.estimated_order_time <![CDATA[ <= ]]> date_format(#{estimatedOrderTimeEnd}, '%Y-%m-%d
23:59:59')
</when>
2025-06-12 03:26:43 +00:00
2025-09-10 01:12:07 +00:00
</choose>
</if>
2026-01-05 09:02:26 +00:00
<if test= "params.beginEstimatedOrderTime != null or params.endEstimatedOrderTime != null" >
<choose >
<when test= "params.beginEstimatedOrderTime != null and params.endEstimatedOrderTime != null" >
and t2.estimated_order_time between date_format(#{params.beginEstimatedOrderTime}, '%Y-%m-%d 00:00:00')
and date_format(#{params.endEstimatedOrderTime}, '%Y-%m-%d 23:59:59')
</when>
<when test= "params.beginEstimatedOrderTime != null" >
and t2.estimated_order_time <![CDATA[ >= ]]> date_format(#{params.beginEstimatedOrderTime}, '%Y-%m-%d
00:00:00')
</when>
<when test= "params.endEstimatedOrderTime != null" >
and t2.estimated_order_time <![CDATA[ <= ]]> date_format(#{params.endEstimatedOrderTime}, '%Y-%m-%d
23:59:59')
</when>
</choose>
</if>
2025-09-10 01:12:07 +00:00
<if test= "orderEndTimeStart != null or orderEndTimeEnd != null" >
<choose >
<when test= "orderEndTimeStart != null and orderEndTimeEnd != null" >
and t1.order_end_time between date_format(#{orderEndTimeStart}, '%Y-%m-%d 00:00:00') and
date_format(#{orderEndTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
<when test= "orderEndTimeStart != null" >
and t1.order_end_time <![CDATA[ >= ]]> date_format(#{orderEndTimeStart}, '%Y-%m-%d 00:00:00')
</when>
<when test= "orderEndTimeEnd != null" >
and t1.order_end_time <![CDATA[ <= ]]> date_format(#{orderEndTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
</choose>
</if>
2026-01-05 09:02:26 +00:00
<if test= "params.beginOrderEndTime != null or params.endOrderEndTime != null" >
<choose >
<when test= "params.beginOrderEndTime != null and params.endOrderEndTime != null" >
and t1.order_end_time between date_format(#{params.beginOrderEndTime}, '%Y-%m-%d 00:00:00') and
date_format(#{params.endOrderEndTime}, '%Y-%m-%d 23:59:59')
</when>
<when test= "params.beginOrderEndTime != null" >
and t1.order_end_time <![CDATA[ >= ]]> date_format(#{params.beginOrderEndTime}, '%Y-%m-%d 00:00:00')
</when>
<when test= "params.endOrderEndTime != null" >
and t1.order_end_time <![CDATA[ <= ]]> date_format(#{params.endOrderEndTime}, '%Y-%m-%d 23:59:59')
</when>
</choose>
</if>
2025-09-10 01:12:07 +00:00
<if test= "approve!=null and approve!=''" > and t1.order_code in (select business_key from bu_todo where
process_key in ('order_approve_online','order_approve_offline') and approve_user = #{approve} and
task_name != '售前')
</if>
2025-11-21 02:47:00 +00:00
<if test= "approveLog!=null and approveLog!=''" > and t1.order_code in (select business_key from bu_todo_completed where
process_key in ('order_approve_online','order_approve_offline') and approve_user = #{approveLog} and
task_name != '售前')
</if>
2025-09-10 01:12:07 +00:00
<if test= "productCodeList!=null and productCodeList.size>0" >
and t1.project_id in (select distinct t2.project_id from project_product_info t2 where t2.product_bom_code
in
<foreach item= "item" collection= "productCodeList" separator= "," open= "(" close= ")" >
#{item}
</foreach>
)
</if>
2026-01-26 09:48:19 +00:00
<if test= "productCode!=null and productCode!=''" >
and t1.project_id in (select distinct t2.project_id from project_product_info t2 where t2.product_bom_code
like concat('%',#{productCode},'%')
)
</if>
<if test= "productModel!=null and productModel!=''" >
and t1.project_id in (select distinct t2.project_id from project_product_info t2 where t2.model like
concat('%',#{productModel},'%'))
</if>
2025-09-10 01:12:07 +00:00
${params.authSql}
2025-10-16 01:05:01 +00:00
${params.dataScope}
2025-05-30 08:27:52 +00:00
</select>
<select id= "selectProjectOrderInfoById" parameterType= "Long" resultMap= "ProjectOrderInfoResult" >
<include refid= "selectProjectOrderInfoRelationVo" />
where t1.id = #{id}
</select>
<select id= "selectProjectOrderInfoByProjectId" resultType= "com.ruoyi.sip.domain.ProjectOrderInfo" >
2025-07-01 09:13:10 +00:00
<include refid= "selectProjectOrderInfoRelationVo" />
2025-05-30 08:27:52 +00:00
where t1.project_id in (
<foreach item= "item" collection= "list" separator= "," >
#{item}
</foreach>
)
2025-06-04 03:25:20 +00:00
</select>
<select id= "selectMaxOrderCode" resultType= "java.lang.Integer" >
2025-06-06 09:47:34 +00:00
select ifnull( max(SUBSTR( order_code FROM LENGTH(#{province})+1 FOR 3 )), 0 )
2025-06-04 03:25:20 +00:00
from project_order_info
where order_code like concat(#{province}, '%')
2025-06-06 06:33:33 +00:00
</select>
<select id= "selectAgentProvinceByProjectId" resultType= "java.lang.String" >
select t2.province
from project_info t1
inner join agent_info t2 on t1.agent_code = t2.agent_code
where t1.id = #{projectId}
limit 1
2025-05-30 08:27:52 +00:00
</select>
2025-06-18 06:12:27 +00:00
<select id= "listHomePageData" resultType= "com.ruoyi.sip.dto.StatisticsDetailDto" >
2025-10-20 02:33:03 +00:00
select count(1) value,date_format(create_time,'%Y-%m-%d') statistics_str from project_order_info t1
2025-06-18 06:12:27 +00:00
where create_time >=DATE_SUB(CURDATE(), INTERVAL ${day} DAY)
2025-10-20 02:33:03 +00:00
${authSql}
2025-06-18 06:12:27 +00:00
group by date_format(create_time,'%Y-%m-%d')
</select>
2025-07-31 01:30:32 +00:00
<select id= "selectProjectOrderInfoByCode" resultType= "com.ruoyi.sip.domain.ProjectOrderInfo" >
<include refid= "selectProjectOrderInfoRelationVo" />
where t1.order_code = #{orderCode}
</select>
2025-08-15 10:00:53 +00:00
<select id= "listOrderInfoVo" resultType= "com.ruoyi.sip.vo.OrderInfoVo" >
SELECT
t1.order_code,
t2.project_name AS 'order_name',
2026-03-26 06:40:01 +00:00
CAST(ifnull(t1.version_code,0) + ifnull(t1.operation_version,0) AS SIGNED) AS version_code,
2026-04-02 06:43:33 +00:00
t1.version_code as order_version_code,
2025-08-15 10:00:53 +00:00
t3.contact_person AS 'sale_name',
t3.contact_email AS 'sale_email' ,
t4.customer_name as 'customer_name',
t4.contact_person,
t4.contact_email,
t4.contact_phone,
t1.update_time as 'last_update_time'
FROM
project_order_info t1
LEFT JOIN project_info t2 ON t1.project_id = t2.id
LEFT JOIN agent_info t3 ON t2.agent_code = t3.agent_code
LEFT JOIN customer_info t4 ON t2.customer_code = t4.customer_code
2026-04-14 10:06:42 +00:00
where (
2026-04-16 04:50:04 +00:00
(CAST(ifnull(t1.version_code,0) + ifnull(t1.operation_version,0) AS SIGNED) > 1 and t1.order_status = '2') or
2026-04-14 10:06:42 +00:00
t1.order_code in ( select DISTINCT order_code from oms_inventory_outer where outer_code in (SELECT outer_code from oms_inventory_delivery where delivery_status=1))
)
2025-11-18 12:52:05 +00:00
<choose >
<when test= "updateTimeStart!=null and updateTimeEnd!=null" >
and t1.update_time between #{updateTimeStart} and #{updateTimeEnd}
</when>
<when test= "updateTimeStart!=null" >
and t1.update_time <![CDATA[ >= ]]> #{updateTimeStart}
</when>
<when test= "updateTimeEnd!=null" >
and t1.update_time <![CDATA[ <= ]]> #{updateTimeEnd}
</when>
</choose>
2026-04-09 07:23:35 +00:00
<choose >
<when test= "productSnList != null and productSnList.size > 0" >
and t1.order_code in (
select distinct order_code
from oms_inventory_outer
where outer_code in (
select outer_code
from oms_inventory_info
where product_sn in
<foreach item= "item" collection= "productSnList" open= "(" separator= "," close= ")" >
#{item}
</foreach>
)
)
</when>
<when test= "productSn!=null and productSn!=''" >
and t1.order_code in (select DISTINCT order_code from oms_inventory_outer where outer_code in (select outer_code from oms_inventory_info where product_sn=#{productSn} ) )
</when>
</choose>
2025-08-15 10:00:53 +00:00
</select>
2025-09-26 07:29:01 +00:00
<select id= "listByCodeList" resultType= "com.ruoyi.sip.domain.ProjectOrderInfo" >
<include refid= "selectProjectOrderInfoRelationVo" />
where t1.order_code in (
<foreach item= "item" collection= "list" separator= "," >
#{item}
</foreach>
)
</select>
2025-12-01 08:17:20 +00:00
<select id= "listLog" resultType= "com.ruoyi.sip.domain.ProjectOrderInfo" >
select t1.id, t1.project_id,t1.province, t1.city, t1.business_person, t1.business_email, t1.business_phone, t1.order_code, t1.currencyType,
t1.shipment_amount, t1.actual_purchase_amount, t1.order_end_time, t1.delivery_time, t1.company_delivery, t1.notifier,
t1.notifier_email, t1.notifier_phone, t1.duty, t1.duty_email, t1.duty_phone, t1.order_channel, t1.partner_code, t1.supplier,
t1.remark, t1.order_status, t1.create_by, t1.create_time, t1.update_by, t1.update_time,t1.partner_user_name,t1.partner_email
,t1.partner_phone,t1.version_code,t1.process_type,t1.process_template,t1.discount_fold,t1.notifier_address,t1.finance_status,
2026-05-21 02:28:15 +00:00
t1.delivery_status,t1.sign_status,t1.outer_status,t1.approve_time,t1.payment_method,t1.payment_ratio,t1.payment_description,t1.operation_version,t1.order_stocking_status
2025-12-01 08:17:20 +00:00
,t2.project_code,t2.project_name,t2.province,t2.customer_name,t2.customer_code,t2.industry_type,t2.bg_property,t2.agent_code,t2.estimated_order_time
,t2.customer_phone,t2.customer_user_name,t2.agent_code,t2.customer_code,t2.partner_name project_partner_name
,t3.partner_name,t3.level,t3.system_user_id,t3.address partner_address
,t4.agent_name
,t5.user_name as duty_name
from project_order_info t1
left join project_info t2 on t1.project_id = t2.id
left join partner_info t3 on t1.partner_code=t3.partner_code
left join agent_info t4 on t2.agent_code=t4.agent_code
left join sys_user t5 on t1.duty=t5.user_id
inner join
(
SELECT
business_key,
max(btc.approve_time) todo_approve_time
FROM
bu_todo_completed btc
WHERE
btc.process_key IN ( 'order_approve_online', 'order_approve_offline' )
AND btc.approve_user = #{approveLog}
AND btc.task_name != '售前'
GROUP BY business_key
) t7 ON t7.business_key = t1.order_code
where 1=1
<if test= "projectId != null " > and t1.project_id = #{projectId}</if>
<if test= "projectCode != null and projectCode!='' " > and t2.project_code like
concat('%',#{projectCode},'%')
</if>
<if test= "projectName != null and projectName!=''" > and t2.project_name like concat('%',
#{projectName},'%')
</if>
<if test= "customerName != null and customerName!=''" > and t2.customer_name like
concat('%',#{customerName},'%')
</if>
<if test= "agentName != null and agentName!=''" > and t4.agent_name like concat('%',#{agentName},'%')</if>
<if test= "financeStatus != null and financeStatus!=''" > and t1.finance_status =#{financeStatus}</if>
<if test= "province != null and province != ''" > and t1.province = #{province}</if>
<if test= "city != null and city != ''" > and t1.city = #{city}</if>
<if test= "businessPerson != null and businessPerson != ''" > and t1.business_person = #{businessPerson}</if>
<if test= "businessEmail != null and businessEmail != ''" > and t1.business_email = #{businessEmail}</if>
<if test= "businessPhone != null and businessPhone != ''" > and t1.business_phone = #{businessPhone}</if>
<if test= "orderCode != null and orderCode != ''" > and t1.order_code = #{orderCode}</if>
<if test= "currencyType != null and currencyType != ''" > and t1.currencyType = #{currencyType}</if>
<if test= "shipmentAmount != null " > and t1.shipment_amount = #{shipmentAmount}</if>
<if test= "actualPurchaseAmount != null " > and t1.actual_purchase_amount = #{actualPurchaseAmount}</if>
<if test= "orderEndTime != null " > and t1.order_end_time = #{orderEndTime}</if>
<if test= "deliveryTime != null " > and t1.delivery_time = #{deliveryTime}</if>
<if test= "companyDelivery != null and companyDelivery != ''" > and t1.company_delivery = #{companyDelivery}
</if>
<if test= "notifier != null and notifier != ''" > and t1.notifier = #{notifier}</if>
<if test= "notifierEmail != null and notifierEmail != ''" > and t1.notifier_email = #{notifierEmail}</if>
<if test= "notifierPhone != null and notifierPhone != ''" > and t1.notifier_phone = #{notifierPhone}</if>
<if test= "notifierAddress != null and notifierAddress != ''" > and t1.notifier_address = #{notifierAddress}
</if>
<if test= "duty != null and duty != ''" > and t1.duty = #{duty}</if>
<if test= "dutyName != null and dutyName != ''" > and t5.user_name like concat('%', #{dutyName}, '%')</if>
<if test= "dutyEmail != null and dutyEmail != ''" > and t1.duty_email = #{dutyEmail}</if>
<if test= "dutyPhone != null and dutyPhone != ''" > and t1.duty_phone = #{dutyPhone}</if>
<if test= "orderChannel != null and orderChannel != ''" > and t1.order_channel = #{orderChannel}</if>
<if test= "partnerCode != null and partnerCode != ''" > and t1.partner_code = #{partnerCode}</if>
<if test= "partnerName != null and partnerName != ''" > and t3.partner_name like concat('%', #{partnerName},
'%')
</if>
<if test= "supplier != null and supplier != ''" > and t1.supplier = #{supplier}</if>
<if test= "supplier != null and supplier != ''" > and t1.supplier = #{supplier}</if>
<if test= "orderStatus != null and orderStatus != ''" > and t1.order_status = #{orderStatus}</if>
2026-05-21 02:28:15 +00:00
<if test= "orderStockingStatus != null and orderStockingStatus != ''" > and t1.order_stocking_status = #{orderStockingStatus}</if>
2025-12-01 08:17:20 +00:00
<if test= "deliveryStatus != null and deliveryStatus != ''" > and t1.delivery_status = #{deliveryStatus}</if>
<if test= "outerStatus != null and outerStatus != ''" > and t1.outer_status = #{outerStatus}</if>
<if test= "signStatus != null and signStatus != ''" > and t1.sign_status = #{signStatus}</if>
<if test= "keyword != null and keyword != ''" > and (t1.order_code like concat('%',#{keyword},'%') or
t2.project_name like concat('%',#{keyword},'%') or t2.customer_name like concat('%',#{keyword},'%'))
</if>
<if test= "deliveryTimeStart != null or deliveryTimeEnd != null" >
<choose >
<when test= "deliveryTimeStart != null and deliveryTimeEnd != null" >
and t1.delivery_time between date_format(#{deliveryTimeStart}, '%Y-%m-%d 00:00:00') and
date_format(#{deliveryTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
<when test= "deliveryTimeStart != null" >
and t1.delivery_time <![CDATA[ >= ]]> date_format(#{deliveryTimeStart}, '%Y-%m-%d 00:00:00')
</when>
<when test= "deliveryTimeEnd != null" >
and t1.delivery_time <![CDATA[ <= ]]> date_format(#{deliveryTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
</choose>
</if>
<if test= "updateTimeStart != null or updateTimeEnd != null" >
<choose >
<when test= "updateTimeStart != null and updateTimeEnd != null" >
and t1.update_time between date_format(#{updateTimeStart}, '%Y-%m-%d 00:00:00') and
date_format(#{updateTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
<when test= "updateTimeStart != null" >
and t1.update_time <![CDATA[ >= ]]> date_format(#{updateTimeStart}, '%Y-%m-%d 00:00:00')
</when>
<when test= "updateTimeEnd != null" >
and t1.update_time <![CDATA[ <= ]]> date_format(#{updateTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
</choose>
</if>
<if test= "approveTimeStart != null or approveTimeEnd != null" >
<choose >
<when test= "approveTimeStart != null and approveTimeEnd != null" >
and t1.approve_time between date_format(#{approveTimeStart}, '%Y-%m-%d 00:00:00') and
date_format(#{approveTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
<when test= "approveTimeStart != null" >
and t1.approve_time <![CDATA[ >= ]]> date_format(#{approveTimeStart}, '%Y-%m-%d 00:00:00')
</when>
<when test= "approveTimeEnd != null" >
and t1.approve_time <![CDATA[ <= ]]> date_format(#{approveTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
</choose>
</if>
<if test= "estimatedOrderTimeStart != null or estimatedOrderTimeEnd != null" >
<choose >
<when test= "estimatedOrderTimeStart != null and estimatedOrderTimeEnd != null" >
and t2.estimated_order_time between date_format(#{estimatedOrderTimeStart}, '%Y-%m-%d 00:00:00')
and date_format(#{estimatedOrderTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
<when test= "estimatedOrderTimeStart != null" >
and t2.estimated_order_time <![CDATA[ >= ]]> date_format(#{estimatedOrderTimeStart}, '%Y-%m-%d
00:00:00')
</when>
<when test= "estimatedOrderTimeEnd != null" >
and t2.estimated_order_time <![CDATA[ <= ]]> date_format(#{estimatedOrderTimeEnd}, '%Y-%m-%d
23:59:59')
</when>
</choose>
</if>
<if test= "orderEndTimeStart != null or orderEndTimeEnd != null" >
<choose >
<when test= "orderEndTimeStart != null and orderEndTimeEnd != null" >
and t1.order_end_time between date_format(#{orderEndTimeStart}, '%Y-%m-%d 00:00:00') and
date_format(#{orderEndTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
<when test= "orderEndTimeStart != null" >
and t1.order_end_time <![CDATA[ >= ]]> date_format(#{orderEndTimeStart}, '%Y-%m-%d 00:00:00')
</when>
<when test= "orderEndTimeEnd != null" >
and t1.order_end_time <![CDATA[ <= ]]> date_format(#{orderEndTimeEnd}, '%Y-%m-%d 23:59:59')
</when>
</choose>
</if>
<if test= "approve!=null and approve!=''" > and t1.order_code in (select business_key from bu_todo where
process_key in ('order_approve_online','order_approve_offline') and approve_user = #{approve} and
task_name != '售前')
</if>
<if test= "productCodeList!=null and productCodeList.size>0" >
and t1.project_id in (select distinct t2.project_id from project_product_info t2 where t2.product_bom_code
in
<foreach item= "item" collection= "productCodeList" separator= "," open= "(" close= ")" >
#{item}
</foreach>
)
</if>
2026-01-26 09:48:19 +00:00
<if test= "productCode!=null and productCode!=''" >
and t1.project_id in (select distinct t2.project_id from project_product_info t2 where t2.product_bom_code
like concat('%',#{productCode},'%')
)
</if>
<if test= "productModel!=null and productModel!=''" >
and t1.project_id in (select distinct t2.project_id from project_product_info t2 where t2.model like
concat('%',#{productModel},'%'))
</if>
2025-12-01 08:17:20 +00:00
${params.authSql}
${params.dataScope}
</select>
2025-08-15 10:00:53 +00:00
2025-05-30 08:27:52 +00:00
<insert id= "insertProjectOrderInfo" parameterType= "ProjectOrderInfo" useGeneratedKeys= "true" keyProperty= "id" >
insert into project_order_info
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > project_id,</if>
2025-06-04 03:25:20 +00:00
<if test= "province != null" > province,</if>
2025-05-30 08:27:52 +00:00
<if test= "city != null" > city,</if>
<if test= "businessPerson != null" > business_person,</if>
<if test= "businessEmail != null" > business_email,</if>
<if test= "businessPhone != null" > business_phone,</if>
<if test= "orderCode != null" > order_code,</if>
2025-06-19 02:22:36 +00:00
<if test= "versionCode != null" > version_code,</if>
2025-05-30 08:27:52 +00:00
<if test= "currencyType != null" > currencyType,</if>
<if test= "shipmentAmount != null" > shipment_amount,</if>
<if test= "actualPurchaseAmount != null" > actual_purchase_amount,</if>
<if test= "orderEndTime != null" > order_end_time,</if>
<if test= "deliveryTime != null" > delivery_time,</if>
<if test= "companyDelivery != null" > company_delivery,</if>
<if test= "notifier != null" > notifier,</if>
<if test= "notifierEmail != null" > notifier_email,</if>
<if test= "notifierPhone != null" > notifier_phone,</if>
2025-07-31 01:30:32 +00:00
<if test= "notifierAddress != null" > notifier_address,</if>
2025-05-30 08:27:52 +00:00
<if test= "duty != null" > duty,</if>
2025-12-08 09:40:15 +00:00
<if test= "orderType != null and orderType!=''" > order_type,</if>
2025-05-30 08:27:52 +00:00
<if test= "dutyEmail != null" > duty_email,</if>
<if test= "dutyPhone != null" > duty_phone,</if>
<if test= "orderChannel != null" > order_channel,</if>
<if test= "partnerCode != null" > partner_code,</if>
2025-06-09 01:37:11 +00:00
<if test= "partnerEmail != null" > partner_email,</if>
<if test= "partnerUserName != null" > partner_user_name,</if>
<if test= "partnerPhone != null" > partner_phone,</if>
2025-05-30 08:27:52 +00:00
<if test= "supplier != null" > supplier,</if>
<if test= "remark != null" > remark,</if>
<if test= "orderStatus != null" > order_status,</if>
2026-05-21 02:28:15 +00:00
<if test= "orderStockingStatus != null and orderStockingStatus != ''" > order_stocking_status,</if>
2025-05-30 08:27:52 +00:00
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
2025-07-21 09:50:52 +00:00
<if test= "processType != null and processType!=''" > process_type,</if>
<if test= "processTemplate != null and processTemplate!=''" > process_template,</if>
<if test= "discountFold != null and discountFold!=''" > discount_fold,</if>
2025-09-18 02:15:08 +00:00
<if test= "paymentMethod != null and paymentMethod != ''" > payment_method,</if>
<if test= "paymentRatio != null" > payment_ratio,</if>
<if test= "paymentDescription != null and paymentDescription != ''" > payment_description,</if>
2026-03-20 08:49:46 +00:00
<if test= "operationVersion != null" > operation_version,</if>
2025-05-30 08:27:52 +00:00
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > #{projectId},</if>
2025-06-04 03:25:20 +00:00
<if test= "province != null" > #{province},</if>
2025-05-30 08:27:52 +00:00
<if test= "city != null" > #{city},</if>
<if test= "businessPerson != null" > #{businessPerson},</if>
<if test= "businessEmail != null" > #{businessEmail},</if>
<if test= "businessPhone != null" > #{businessPhone},</if>
<if test= "orderCode != null" > #{orderCode},</if>
2025-06-19 02:22:36 +00:00
<if test= "versionCode != null" > #{versionCode},</if>
2025-05-30 08:27:52 +00:00
<if test= "currencyType != null" > #{currencyType},</if>
<if test= "shipmentAmount != null" > #{shipmentAmount},</if>
<if test= "actualPurchaseAmount != null" > #{actualPurchaseAmount},</if>
<if test= "orderEndTime != null" > #{orderEndTime},</if>
<if test= "deliveryTime != null" > #{deliveryTime},</if>
<if test= "companyDelivery != null" > #{companyDelivery},</if>
<if test= "notifier != null" > #{notifier},</if>
<if test= "notifierEmail != null" > #{notifierEmail},</if>
<if test= "notifierPhone != null" > #{notifierPhone},</if>
2025-07-31 01:30:32 +00:00
<if test= "notifierAddress != null" > #{notifierAddress},</if>
2025-05-30 08:27:52 +00:00
<if test= "duty != null" > #{duty},</if>
2025-12-08 09:40:15 +00:00
<if test= "orderType != null and orderType!=''" > #{orderType},</if>
2025-05-30 08:27:52 +00:00
<if test= "dutyEmail != null" > #{dutyEmail},</if>
<if test= "dutyPhone != null" > #{dutyPhone},</if>
<if test= "orderChannel != null" > #{orderChannel},</if>
<if test= "partnerCode != null" > #{partnerCode},</if>
2025-06-09 01:37:11 +00:00
<if test= "partnerEmail != null" > #{partnerEmail},</if>
<if test= "partnerUserName != null" > #{partnerUserName},</if>
<if test= "partnerPhone != null" > #{partnerPhone},</if>
2025-05-30 08:27:52 +00:00
<if test= "supplier != null" > #{supplier},</if>
<if test= "remark != null" > #{remark},</if>
<if test= "orderStatus != null" > #{orderStatus},</if>
2026-05-21 02:28:15 +00:00
<if test= "orderStockingStatus != null and orderStockingStatus != ''" > #{orderStockingStatus},</if>
2025-05-30 08:27:52 +00:00
<if test= "createBy != null" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
2025-07-21 09:50:52 +00:00
<if test= "processType != null and processType!=''" > #{processType},</if>
<if test= "processTemplate != null and processTemplate!=''" > #{processTemplate},</if>
<if test= "discountFold != null and discountFold!=''" > #{discountFold},</if>
2025-09-18 02:15:08 +00:00
<if test= "paymentMethod != null and paymentMethod != ''" > #{paymentMethod},</if>
<if test= "paymentRatio != null" > #{paymentRatio},</if>
<if test= "paymentDescription != null and paymentDescription != ''" > #{paymentDescription},</if>
2026-03-20 08:49:46 +00:00
<if test= "operationVersion != null" > #{operationVersion},</if>
2025-05-30 08:27:52 +00:00
</trim>
</insert>
2025-07-21 09:50:52 +00:00
<insert id= "bakData" >
2025-08-15 01:08:33 +00:00
insert into project_order_info_log(id,
project_id,
province,
city,
business_person,
business_email,
business_phone,
version_code,
order_code,
currencyType,
shipment_amount,
actual_purchase_amount,
order_end_time,
delivery_time,
company_delivery,
notifier,
notifier_email,
notifier_phone,
notifier_address,
duty,
duty_email,
duty_phone,
order_channel,
partner_user_name,
partner_phone,
partner_email,
partner_code,
supplier,
remark,
delivery_status,
sign_status,
outer_status,
approve_time,
order_status,
create_by,
create_time,
update_by,
update_time,
process_type,
process_template,
2025-12-08 09:40:15 +00:00
order_type,
2026-03-20 08:49:46 +00:00
discount_fold,
operation_version)
2025-08-15 01:08:33 +00:00
select id,
project_id,
province,
city,
business_person,
business_email,
business_phone,
version_code,
order_code,
currencyType,
shipment_amount,
actual_purchase_amount,
order_end_time,
delivery_time,
company_delivery,
notifier,
notifier_email,
notifier_phone,
notifier_address,
duty,
duty_email,
duty_phone,
order_channel,
partner_user_name,
partner_phone,
partner_email,
partner_code,
supplier,
remark,
delivery_status,
sign_status,
outer_status,
approve_time,
order_status,
create_by,
create_time,
update_by,
update_time,
process_type,
process_template,
2025-12-08 09:40:15 +00:00
order_type,
2026-03-20 08:49:46 +00:00
discount_fold,
operation_version
2025-08-15 01:08:33 +00:00
from project_order_info
where order_code = #{orderCode}
2025-07-21 09:50:52 +00:00
</insert>
2025-05-30 08:27:52 +00:00
<update id= "updateProjectOrderInfo" parameterType= "ProjectOrderInfo" >
update project_order_info
<trim prefix= "SET" suffixOverrides= "," >
<if test= "projectId != null" > project_id = #{projectId},</if>
2025-06-04 03:25:20 +00:00
<if test= "province != null" > province = #{province},</if>
2025-05-30 08:27:52 +00:00
<if test= "city != null" > city = #{city},</if>
2025-12-08 09:40:15 +00:00
<if test= "orderType != null and orderType!=''" > order_type=#{orderType},</if>
2025-05-30 08:27:52 +00:00
<if test= "businessPerson != null" > business_person = #{businessPerson},</if>
<if test= "businessEmail != null" > business_email = #{businessEmail},</if>
<if test= "businessPhone != null" > business_phone = #{businessPhone},</if>
<if test= "orderCode != null" > order_code = #{orderCode},</if>
2025-06-19 02:22:36 +00:00
<if test= "versionCode != null" > version_code=#{versionCode},</if>
2025-05-30 08:27:52 +00:00
<if test= "currencyType != null" > currencyType = #{currencyType},</if>
<if test= "shipmentAmount != null" > shipment_amount = #{shipmentAmount},</if>
<if test= "actualPurchaseAmount != null" > actual_purchase_amount = #{actualPurchaseAmount},</if>
<if test= "orderEndTime != null" > order_end_time = #{orderEndTime},</if>
<if test= "deliveryTime != null" > delivery_time = #{deliveryTime},</if>
<if test= "companyDelivery != null" > company_delivery = #{companyDelivery},</if>
<if test= "notifier != null" > notifier = #{notifier},</if>
<if test= "notifierEmail != null" > notifier_email = #{notifierEmail},</if>
<if test= "notifierPhone != null" > notifier_phone = #{notifierPhone},</if>
2025-07-31 01:30:32 +00:00
<if test= "notifierAddress != null" > notifier_address = #{notifierAddress},</if>
2025-05-30 08:27:52 +00:00
<if test= "duty != null" > duty = #{duty},</if>
<if test= "dutyEmail != null" > duty_email = #{dutyEmail},</if>
<if test= "dutyPhone != null" > duty_phone = #{dutyPhone},</if>
<if test= "orderChannel != null" > order_channel = #{orderChannel},</if>
<if test= "partnerCode != null" > partner_code = #{partnerCode},</if>
2025-06-09 01:37:11 +00:00
<if test= "partnerEmail != null" > partner_email=#{partnerEmail},</if>
2025-07-21 09:50:52 +00:00
<if test= "processType != null and processType!=''" > process_type=#{processType},</if>
<if test= "processTemplate != null and processTemplate!=''" > process_template=#{processTemplate},</if>
<if test= "discountFold != null and discountFold!=''" > discount_fold=#{discountFold},</if>
2025-06-09 01:37:11 +00:00
<if test= "partnerUserName != null" > partner_user_name=#{partnerUserName},</if>
<if test= "partnerPhone != null" > partner_phone=#{partnerPhone},</if>
2025-05-30 08:27:52 +00:00
<if test= "supplier != null" > supplier = #{supplier},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "orderStatus != null" > order_status = #{orderStatus},</if>
2026-05-21 02:28:15 +00:00
<if test= "orderStockingStatus != null and orderStockingStatus != ''" > order_stocking_status = #{orderStockingStatus},</if>
2025-08-15 01:08:33 +00:00
<if test= "outerStatus != null" > outer_status = #{outerStatus},</if>
<if test= "deliveryStatus != null" > delivery_status = #{deliveryStatus},</if>
<if test= "signStatus != null" > sign_status = #{signStatus},</if>
2025-05-30 08:27:52 +00:00
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
2025-08-08 10:05:13 +00:00
<if test= "approveTime != null" > approve_time = #{approveTime},</if>
2025-09-18 02:15:08 +00:00
<if test= "paymentMethod != null and paymentMethod != ''" > payment_method = #{paymentMethod},</if>
<if test= "paymentRatio != null" > payment_ratio = #{paymentRatio},</if>
<if test= "paymentDescription != null and paymentDescription != ''" > payment_description = #{paymentDescription},</if>
2025-10-28 07:08:30 +00:00
<if test= "financeStatus != null and financeStatus != ''" > finance_status = #{financeStatus},</if>
2026-03-20 08:49:46 +00:00
<if test= "operationVersion != null" > operation_version = #{operationVersion},</if>
2025-05-30 08:27:52 +00:00
</trim>
where id = #{id}
</update>
2025-07-21 09:50:52 +00:00
<update id= "updateProjectOrderInfoByCode" parameterType= "ProjectOrderInfo" >
update project_order_info
<trim prefix= "SET" suffixOverrides= "," >
<if test= "projectId != null" > project_id = #{projectId},</if>
<if test= "province != null" > province = #{province},</if>
<if test= "city != null" > city = #{city},</if>
<if test= "businessPerson != null" > business_person = #{businessPerson},</if>
<if test= "businessEmail != null" > business_email = #{businessEmail},</if>
<if test= "businessPhone != null" > business_phone = #{businessPhone},</if>
2025-08-08 10:05:13 +00:00
<if test= "approveTime != null" > approve_time = #{approveTime},</if>
2025-09-18 02:15:08 +00:00
<if test= "paymentMethod != null and paymentMethod != ''" > payment_method = #{paymentMethod},</if>
<if test= "paymentRatio != null" > payment_ratio = #{paymentRatio},</if>
<if test= "paymentDescription != null and paymentDescription != ''" > payment_description = #{paymentDescription},</if>
2026-03-20 08:49:46 +00:00
<if test= "operationVersion != null" > operation_version = #{operationVersion},</if>
2025-07-21 09:50:52 +00:00
<if test= "versionCode != null" >
<choose >
2025-09-19 11:15:28 +00:00
<when test= "versionCode == 'add'.toString()" > version_code = cast(version_code as UNSIGNED) +1,</when>
2025-09-15 06:39:56 +00:00
<otherwise > version_code = #{versionCode},</otherwise>
2025-07-21 09:50:52 +00:00
</choose>
</if>
<if test= "processType != null and processType!=''" > process_type=${processType},</if>
<if test= "processTemplate != null and processTemplate!=''" > process_template=${processTemplate},</if>
<if test= "discountFold != null and discountFold!=''" > discount_fold=${discountFold},</if>
<if test= "currencyType != null" > currencyType = #{currencyType},</if>
<if test= "shipmentAmount != null" > shipment_amount = #{shipmentAmount},</if>
<if test= "actualPurchaseAmount != null" > actual_purchase_amount = #{actualPurchaseAmount},</if>
<if test= "orderEndTime != null" > order_end_time = #{orderEndTime},</if>
<if test= "deliveryTime != null" > delivery_time = #{deliveryTime},</if>
<if test= "companyDelivery != null" > company_delivery = #{companyDelivery},</if>
<if test= "notifier != null" > notifier = #{notifier},</if>
<if test= "notifierEmail != null" > notifier_email = #{notifierEmail},</if>
<if test= "notifierPhone != null" > notifier_phone = #{notifierPhone},</if>
2025-07-31 01:30:32 +00:00
<if test= "notifierAddress != null" > notifier_address = #{notifierAddress},</if>
2025-07-21 09:50:52 +00:00
<if test= "duty != null" > duty = #{duty},</if>
<if test= "dutyEmail != null" > duty_email = #{dutyEmail},</if>
<if test= "dutyPhone != null" > duty_phone = #{dutyPhone},</if>
<if test= "orderChannel != null" > order_channel = #{orderChannel},</if>
<if test= "partnerCode != null" > partner_code = #{partnerCode},</if>
<if test= "partnerEmail != null" > partner_email=#{partnerEmail},</if>
<if test= "partnerUserName != null" > partner_user_name=#{partnerUserName},</if>
<if test= "partnerPhone != null" > partner_phone=#{partnerPhone},</if>
<if test= "supplier != null" > supplier = #{supplier},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "orderStatus != null" > order_status = #{orderStatus},</if>
2026-05-21 02:28:15 +00:00
<if test= "orderStockingStatus != null and orderStockingStatus != ''" > order_stocking_status = #{orderStockingStatus},</if>
2025-08-13 07:20:04 +00:00
<if test= "outerStatus != null" > outer_status = #{outerStatus},</if>
<if test= "deliveryStatus != null" > delivery_status = #{deliveryStatus},</if>
<if test= "signStatus != null" > sign_status = #{signStatus},</if>
2025-07-21 09:50:52 +00:00
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
</trim>
where order_code = #{orderCode}
</update>
2025-09-29 12:24:52 +00:00
<update id= "updatePartnerCodeByCode" >
update project_order_info set partner_code = #{newValue} where partner_code = #{oldValue}
</update>
2026-05-21 02:28:15 +00:00
<update id= "updateOrderStockingStatusByCode" >
update project_order_info
set order_stocking_status = #{orderStockingStatus},
update_time = now()
where order_code = #{orderCode}
</update>
2025-05-30 08:27:52 +00:00
2026-04-27 03:07:04 +00:00
<update id= "updateDutyByProjectIds" >
update project_order_info
set duty = #{duty},
duty_email = #{dutyEmail},
duty_phone = #{dutyPhone},
update_time = now()
where project_id in
<foreach collection= "projectIds" item= "projectId" open= "(" separator= "," close= ")" >
#{projectId}
</foreach>
</update>
2025-05-30 08:27:52 +00:00
<delete id= "deleteProjectOrderInfoById" parameterType= "Long" >
delete from project_order_info where id = #{id}
</delete>
<delete id= "deleteProjectOrderInfoByIds" parameterType= "String" >
2025-09-11 07:50:16 +00:00
delete from project_order_info where id in
2025-05-30 08:27:52 +00:00
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
2026-03-20 08:49:46 +00:00
<select id= "selectInentoryDeliveryByProjectOrderInfoId" resultType= "com.ruoyi.sip.domain.InventoryDelivery" >
select t3.*
from project_order_info as t1
inner join oms_inventory_outer as t2
on t1.order_code = t2.order_code
inner join oms_inventory_delivery as t3
on t2.outer_code = t3.outer_code
where t1.id = #{id}
</select>
2026-05-21 02:28:15 +00:00
<select id= "selectProductMatchList" resultType= "com.ruoyi.sip.dto.OrderProductMatchDto" >
select
t3.product_code as product_code,
t3.model,
2026-05-31 17:02:48 +00:00
t3.type as product_type,
t7.vendor_code,
t7.vendor_name,
2026-05-21 02:28:15 +00:00
t1.quantity as order_num,
sum(ifnull(t5.bind_num, 0)) as ph_num,
2026-05-31 17:02:48 +00:00
ifnull(t6.bh_num,0) as bh_num,
sum(ifnull(t5.bind_num, 0) * t4.price) as sum_cost
2026-05-21 02:28:15 +00:00
from project_product_info as t1
2026-05-31 17:02:48 +00:00
inner join project_order_info as t2 on t1.project_id = t2.project_id
inner join product_info as t3 on t1.product_bom_code = t3.product_code
left join oms_purchase_order_item as t4 on t3.product_code = t4.product_code
2026-06-01 06:40:36 +00:00
left join oms_purchase_order_map as t5 on t2.id = t5.order_id and t4.purchase_id = t5.purchase_id and t5.product_code = t4.product_code
2026-05-31 17:02:48 +00:00
left join (
select count(1) bh_num, product_code
from oms_inventory_info
where order_code = #{orderCode}
2026-06-01 06:40:36 +00:00
group by product_code
2026-05-31 17:02:48 +00:00
) t6 on t3.product_code = t6.product_code
left join oms_vendor_info as t7 on t3.vendor_code = t7.vendor_code
2026-05-21 02:28:15 +00:00
where t2.order_code = #{orderCode}
2026-05-31 17:02:48 +00:00
group by t3.product_code, t3.model
order by t3.type, t3.product_code
2026-05-21 02:28:15 +00:00
</select>
<select id= "selectProductMatchBindList" resultType= "com.ruoyi.sip.dto.OrderProductMatchBindDto" >
select
t3.product_code,
t3.model,
t6.id as purchase_id,
t6.purchase_no,
(select vendor_address from oms_vendor_info as tt where tt.vendor_id = t6.vendor_id) as vendor_address,
2026-05-31 17:02:48 +00:00
max(t4.price) as price,
2026-05-21 02:28:15 +00:00
t4.quantity as cg_num,
2026-05-31 18:30:13 +00:00
t4.quantity - ifnull((select sum(bind_num) from oms_purchase_order_map as tt
2026-06-04 09:24:59 +00:00
where tt.purchase_id = t4.purchase_id and tt.product_code = t4.product_code), 0) as ky_num,
2026-05-21 02:28:15 +00:00
t5.bind_num as ph_num,
t6.status,
(
select count(1) from oms_inventory_info as tt1
inner join oms_inventory_inner as tt2
on tt1.inner_code = tt2.inner_code
where t2.order_code = tt1.order_code
and t3.product_code = tt1.product_code
and tt2.purchase_no = t6.purchase_no
) as bh_num
from project_product_info as t1
inner join project_order_info as t2
on t1.project_id = t2.project_id
inner join product_info as t3
on t1.product_bom_code = t3.product_code
inner join oms_purchase_order_item as t4
on t3.product_code = t4.product_code
left join oms_purchase_order_map as t5
2026-06-01 06:40:36 +00:00
on t2.id = t5.order_id and t4.purchase_id = t5.purchase_id and t4.product_code = t5.product_code
2026-05-21 02:28:15 +00:00
inner join oms_purchase_order as t6
on t6.id = t4.purchase_id
where t2.order_code = #{orderCode}
2026-05-21 11:57:36 +00:00
<if test= "productCode != null and productCode!=''" >
2026-05-21 02:28:15 +00:00
and t3.product_code = #{productCode}
2026-05-21 11:57:36 +00:00
</if>
2026-05-21 02:28:15 +00:00
and t6.approve_status = 2 and t6.confirm_status = 1
group by t6.purchase_no
</select>
<select id= "selectProductMatchSnCountlList" resultType= "java.lang.Integer" >
select
count(1)
from oms_inventory_info as t1
inner join oms_inventory_inner as t2
on t1.inner_code = t2.inner_code
left join oms_warehouse_info as t3
on t2.warehouse_id = t3.id
2026-06-01 06:40:36 +00:00
where t2.purchase_no = #{purchaseNo}
2026-05-21 02:28:15 +00:00
</select>
<select id= "selectPurchaseOrderMapBindNum" resultType= "java.lang.Integer" >
select
ifnull(t3.bind_num, 0)
from oms_purchase_order as t1
inner join project_order_info as t2
on t2.order_code = #{orderCode}
left join oms_purchase_order_map as t3
2026-06-01 06:40:36 +00:00
on t2.id = t3.order_id and t1.id = t3.purchase_id and t3.product_code = #{productCode}
2026-05-21 02:28:15 +00:00
where t1.purchase_no = #{purchaseNo}
limit 1
</select>
<select id= "selectProductMatchSnDetailList" resultType= "com.ruoyi.sip.dto.OrderProductMatchSnDetailDto" >
select
t1.product_sn,
t3.warehouse_name,
t1.order_code,
t1.outer_code
from oms_inventory_info as t1
2026-06-03 10:03:27 +00:00
inner join oms_inventory_inner as t2 on t1.inner_code = t2.inner_code
left join oms_warehouse_info as t3 on t2.warehouse_id = t3.id
2026-05-31 17:02:48 +00:00
where t2.purchase_no = #{purchaseNo}
2026-05-31 18:30:13 +00:00
and t1.product_code = #{productCode}
2026-05-21 02:28:15 +00:00
order by t1.product_sn
</select>
2026-06-03 10:03:27 +00:00
<select id= "selectOrderProductBindAmount" resultType= "com.ruoyi.sip.dto.OrderProductBindAmountDto" >
select
product_code,
sum(cost_with_tax) as cost_with_tax,
sum(cost_without_tax) as cost_without_tax,
sum(amount_without_tax) as amount_without_tax,
sum(amount_without_tax) - sum(cost_without_tax) as gross_profit,
cast((sum(amount_without_tax) - sum(t.cost_without_tax)) / sum(amount_without_tax) * 100 as decimal(10,2)) as gross_profit_rate,
(case when sum(bind_num) >= max(quantity) then true else false end) as order_stocking_status
from (
select
t1.project_id,
t2.product_code,
t2.bind_num * t4.price as cost_with_tax,
cast(t2.bind_num * t4.price / (1 + t4.tax_rate) as decimal(10,2)) as cost_without_tax,
cast(t2.bind_num * t5.price / (1 + t5.tax_rate / 100) as decimal(10,2)) as amount_without_tax,
t2.bind_num,
t5.quantity
from project_order_info as t1
inner join oms_purchase_order_map as t2 on t1.id = t2.order_id
inner join oms_purchase_order as t3 on t2.purchase_id = t3.id
inner join oms_purchase_order_item as t4 on t3.id = t4.purchase_id and t2.product_code = t4.product_code
inner join project_product_info as t5 on t1.project_id = t5.project_id and t2.product_code = t5.product_bom_code
where t2.bind_num > 0
and t1.order_code = #{orderCode}
and t2.product_code = #{productCode}
) as t
group by product_code
</select>
<select id= "selectUnboundPurchaseOrderProductList" resultType= "com.ruoyi.sip.dto.UnboundPurchaseOrderProductDto" >
select
2026-06-04 01:20:57 +00:00
t5.project_code,
t5.project_name,
t2.id as order_id,
2026-06-03 10:03:27 +00:00
t1.order_code,
t1.product_code,
2026-06-04 01:20:57 +00:00
t1.inner_code,
t3.price,
cast(t3.price * count(1) as decimal(10,2)) as all_price,
count(1) as quantity,
2026-06-08 17:28:30 +00:00
ifnull(t3.tax_rate,13) / 100 as tax_rate,
cast(cast(t3.price * count(1) as decimal(10,2)) - cast(t3.price * count(1) as decimal(10,2)) / (1 + ifnull(t3.tax_rate,13) / 100) as decimal(10,2)) as tax_total,
2026-06-04 01:20:57 +00:00
t4.type,
t3.model,
t3.product_desc,
t6.user_id,
t6.user_name,
t6.email,
t6.phonenumber,
t7.vendor_id,
t1.warehouse_id
2026-06-03 10:03:27 +00:00
from oms_inventory_info as t1
2026-06-04 01:20:57 +00:00
inner join project_order_info as t2 on t1.order_code = t2.order_code
inner join project_product_info as t3 on t2.project_id = t3.project_id and t1.product_code = t3.product_bom_code
inner join product_info as t4 on t1.product_code = t4.product_code
inner join project_info as t5 on t2.project_id = t5.id
left join sys_user as t6 on t2.duty = t6.user_id
left join oms_vendor_info as t7 on t7.vendor_code = t4.vendor_code
where not exists (select order_id from oms_purchase_order_map as tt where tt.order_id = t2.id and tt.product_code = t1.product_code)
2026-06-03 10:03:27 +00:00
group by t1.order_code, t1.product_code, t1.inner_code
</select>
2026-06-04 01:20:57 +00:00
<insert id= "insertUnboundPurchaseOrderProductMap" >
insert into oms_purchase_order_map(order_id,purchase_id,product_code,bind_num) values(${orderId},${purchaseId},#{productCode},${quantity})
</insert>
<update id= "updateInventoryInnerPurchaseNo" >
update oms_inventory_inner set purchase_no = #{purchaseNo} where inner_code = #{innerCode}
</update>
2026-06-08 17:28:30 +00:00
<select id= "selectUnboundPurchaseOrderServerProductList" resultType= "com.ruoyi.sip.dto.UnboundPurchaseOrderProductDto" >
select
t5.project_code,
t5.project_name,
t2.id as order_id,
t2.order_code,
t4.product_code,
0 as price,
0 as all_price,
count(1) as quantity,
ifnull(t3.tax_rate,13) / 100 as tax_rate,
cast(0 - 0 / (1 + ifnull(t3.tax_rate,13) / 100) as decimal(10,2)) as tax_total,
t4.type,
t3.model,
t3.product_desc,
t6.user_id,
t6.user_name,
t6.email,
t6.phonenumber,
t7.vendor_id
from project_order_info as t2
inner join project_product_info as t3 on t2.project_id = t3.project_id
inner join product_info as t4 on t3.product_bom_code = t4.product_code
inner join project_info as t5 on t2.project_id = t5.id
left join sys_user as t6 on t2.duty = t6.user_id
left join oms_vendor_info as t7 on t7.vendor_code = t4.vendor_code
where t4.type not in (1,2)
and not exists (select order_id from oms_purchase_order_map as tt where tt.order_id = t2.id and tt.product_code = t4.product_code)
and t2.id in (
select order_id from (
select t1.id as order_id, t1.order_code, t2.product_bom_code, sum(t2.quantity) = sum(t4.bind_num) as bh
from project_order_info as t1
inner join project_product_info as t2 on t1.project_id = t2.project_id
inner join product_info as t3 on t2.product_bom_code = t3.product_code
inner join oms_purchase_order_map as t4 on t1.id = t4.order_id and t2.product_bom_code = t4.product_code
where t1.order_status = 2 and t3.type in (1,2)
group by t1.id, t2.product_bom_code
) as t group by order_id having count(1) = sum(bh)
)
group by t2.order_code, t4.product_code
</select>
2026-03-20 03:24:23 +00:00
</mapper>