2025-11-27 03:39:47 +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.OmsPurchaseOrderMapper" >
<resultMap type= "OmsPurchaseOrder" id= "OmsPurchaseOrderResult" >
<result property= "id" column= "id" />
<result property= "purchaseNo" column= "purchase_no" />
<result property= "buyerName" column= "buyer_name" />
<result property= "buyerAddress" column= "buyer_address" />
<result property= "vendorId" column= "vendor_id" />
<result property= "currency" column= "currency" />
<result property= "purchaserId" column= "purchaser_id" />
<result property= "purchaserName" column= "purchaser_name" />
<result property= "purchaserMobile" column= "purchaser_mobile" />
<result property= "purchaserEmail" column= "purchaser_email" />
<result property= "warehouseId" column= "warehouse_id" />
<result property= "payMethod" column= "pay_method" />
<result property= "ownerId" column= "owner_id" />
<result property= "ownerName" column= "owner_name" />
<result property= "remark" column= "remark" />
<result property= "totalAmount" column= "total_amount" />
<result property= "status" column= "status" />
<result property= "approveStatus" column= "approve_status" />
<result property= "approveTime" column= "approve_time" />
<result property= "approveNode" column= "approve_node" />
<result property= "confirmStatus" column= "confirm_status" />
<result property= "createTime" column= "create_time" />
<result property= "updateTime" column= "update_time" />
<result property= "delFlag" column= "del_flag" />
</resultMap>
<resultMap type= "OmsPurchaseOrderItem" id= "OmsPurchaseOrderItemResult" >
<result property= "id" column= "id" />
<result property= "purchaseId" column= "purchase_id" />
<result property= "productCode" column= "product_code" />
<result property= "innerStatus" column= "inner_status" />
<result property= "quantity" column= "quantity" />
<result property= "price" column= "price" />
<result property= "taxRate" column= "tax_rate" />
<result property= "taxTotal" column= "tax_total" />
<result property= "amountTotal" column= "amount_total" />
</resultMap>
<sql id= "selectOmsPurchaseOrderVo" >
select t1.id, t1.purchase_no, t1.buyer_name, t1.buyer_address, t1.vendor_id, t1.currency, t1.purchaser_id, t1.purchaser_name
, t1.purchaser_mobile, t1.purchaser_email, t1.warehouse_id, t1.pay_method, t1.owner_id, t1.owner_name, t1.remark, t1.total_amount
2025-11-28 01:08:26 +00:00
, t1.status, t1.approve_status, t1.approve_time, t1.approve_node, t1.confirm_status, t1.create_time, t1.update_time, t1.del_flag,t1.version,t1.flow_type
2025-11-27 03:39:47 +00:00
from oms_purchase_order t1
</sql>
<sql id= "selectOmsPurchaseOrderItemVo" >
SELECT
t1.id,
t1.purchase_id,
t1.product_code,
t1.quantity,
t1.price,
t1.tax_rate,
t1.tax_total,
t1.amount_total,
t1.inner_status,
t1.delivery_date,
t2.type as product_type,t2.model as product_model,t2.description as product_description
FROM
oms_purchase_order_item t1 left join product_info t2 on t1.product_code = t2.product_code
</sql>
<sql id= "selectOmsPurchaseOrderRelationVo" >
select t1.id, t1.purchase_no, t1.buyer_name, t1.buyer_address, t1.vendor_id, t1.currency, t1.purchaser_id, t1.purchaser_name
2025-11-28 01:08:26 +00:00
, t1.purchaser_mobile, t1.purchaser_email, t1.warehouse_id, t1.pay_method, t1.owner_id, t1.owner_name, t1.remark, t1.total_amount,t1.flow_type
2025-11-27 03:39:47 +00:00
, t1.status, t1.approve_status, t1.approve_time, t1.approve_node, t1.confirm_status, t1.create_time, t1.update_time, t1.del_flag,t1.version
,t2.vendor_name,t2.vendor_user,t2.vendor_phone
from oms_purchase_order t1
left join oms_vendor_info t2 on t1.vendor_id = t2.vendor_id
</sql>
<select id= "selectOmsPurchaseOrderList" parameterType= "OmsPurchaseOrder" resultMap= "OmsPurchaseOrderResult" >
<include refid= "selectOmsPurchaseOrderRelationVo" />
<where >
2025-11-28 03:29:56 +00:00
<if test= "purchaseNo != null and purchaseNo != ''" > and t1.purchase_no = #{purchaseNo}</if>
<if test= "buyerName != null and buyerName != ''" > and t1.buyer_name = #{buyerName}</if>
<if test= "vendorId != null " > and t1.vendor_id = #{vendorId}</if>
<if test= "status != null " > and t1.status = #{status}</if>
<if test= "confirmStatus != null " > and t1.confirm_status = #{confirmStatus}</if>
<if test= "approveStatus != null " > and t1.approve_status = #{approveStatus}</if>
<if test= "flowType != null " > and t1.flow_type = #{flowType}</if>
<if test= "vendorName != null " > and t2.vendor_name = #{vendorName}</if>
<if test= "ownerName != null " > and t1.owner_name = #{ownerName}</if>
2025-11-27 03:39:47 +00:00
</where>
</select>
<select id= "selectOmsPurchaseOrderById" parameterType= "Long" resultMap= "OmsPurchaseOrderResult" >
<include refid= "selectOmsPurchaseOrderRelationVo" />
where t1.id = #{id}
</select>
<select id= "selectMaxOrderCode" resultType= "java.lang.Integer" >
select ifnull( max(SUBSTR( purchase_no FROM LENGTH(#{province})+1 FOR 3 )), 0 )
from oms_purchase_order
where purchase_no like concat(#{province}, '%')
</select>
<select id= "listItemByPurchaseId" resultMap= "OmsPurchaseOrderItemResult" >
<include refid= "selectOmsPurchaseOrderItemVo" />
where purchase_id = #{purchaseId}
</select>
<select id= "listApprove" resultType= "com.ruoyi.sip.domain.OmsPurchaseOrder" >
select t1.id, t1.purchase_no, t1.buyer_name, t1.buyer_address, t1.vendor_id, t1.currency, t1.purchaser_id, t1.purchaser_name
2025-11-28 01:08:26 +00:00
, t1.purchaser_mobile, t1.purchaser_email, t1.warehouse_id, t1.pay_method, t1.owner_id, t1.owner_name, t1.remark, t1.total_amount,t1.flow_type
2025-11-27 03:39:47 +00:00
, t1.status, t1.approve_status, t1.approve_time, t1.approve_node, t1.confirm_status, t1.create_time, t1.update_time, t1.del_flag,t1.version
,t2.vendor_name,t2.vendor_user,t2.vendor_phone
2025-11-28 01:08:26 +00:00
,t3.apply_time,t3.process_key,t3.todo_id,t3.task_id
<if test= "'bu_todo_completed'.equals(tableName)" >
,t3.approve_time as todo_approve_time
</if>
2025-11-27 03:39:47 +00:00
from oms_purchase_order t1
left join oms_vendor_info t2 on t1.vendor_id = t2.vendor_id
2025-11-27 08:42:20 +00:00
inner join ${tableName} t3 on (t3.process_key in ('purchase_order_online') and t3.approve_user=#{entity.approveUser} and t3.task_name!='商务' and t3.business_key=t1.purchase_no)
2025-11-27 03:39:47 +00:00
<where >
2025-11-27 08:42:20 +00:00
<if test= "entity.purchaseNo != null and entity.purchaseNo != ''" > and t1.purchase_no = #{entity.purchaseNo}</if>
<if test= "entity.vendorName != null " > and t2.vendor_name = #{entity.vendorName}</if>
<if test= "entity.ownerName != null " > and t1.owner_name = #{entity.ownerName}</if>
<if test= "entity.approveUser != null " > and t3.approve_user = #{entity.approveUser}</if>
<if test= "entity.params.applyTimeStart != null and entity.params.applyTimeEnd != ''" >
2025-11-27 03:39:47 +00:00
<choose >
2025-11-28 03:29:56 +00:00
<when test= "entity.params.applyTimeStart != null and entity.params.applyTimeEnd != null" >
2025-11-27 08:42:20 +00:00
and t3.apply_time between date_format(#{entity.params.applyTimeStart}, '%Y-%m-%d 00:00:00') and
date_format(#{entity.params.applyTimeEnd}, '%Y-%m-%d 23:59:59')
2025-11-27 03:39:47 +00:00
</when>
2025-11-27 08:42:20 +00:00
<when test= "entity.params.applyTimeStart != null" >
and t3.apply_time <![CDATA[ >= ]]> date_format(#{entity.params.applyTimeStart}, '%Y-%m-%d 00:00:00')
2025-11-27 03:39:47 +00:00
</when>
2025-11-27 08:42:20 +00:00
<when test= "entity.params.applyTimeEnd != null" >
and t3.apply_time <![CDATA[ <= ]]> date_format(#{entity.params.applyTimeEnd}, '%Y-%m-%d 23:59:59')
2025-11-27 03:39:47 +00:00
</when>
</choose>
</if>
</where>
</select>
<select id= "selectByNo" resultType= "com.ruoyi.sip.domain.OmsPurchaseOrder" >
<include refid= "selectOmsPurchaseOrderRelationVo" />
where t1.purchase_no = #{businessKey}
</select>
<select id= "listByCodeList" resultType= "com.ruoyi.sip.domain.OmsPurchaseOrder" >
<include refid= "selectOmsPurchaseOrderRelationVo" />
where t1.purchase_no in
<foreach item= "item" collection= "list" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</select>
2025-11-28 09:07:15 +00:00
<select id= "listItem" resultType= "com.ruoyi.sip.dto.inventory.OmsPurchaseOrderItemDto" >
SELECT
2025-11-28 09:29:15 +00:00
t2.purchase_no,
t2.buyer_name,
t4.vendor_code,
t4.vendor_name,
t4.vendor_user,
t4.vendor_phone,
t2.create_time,
t2.owner_name,
t3.type as product_type,
t1.product_code,
t3.model as product_model,
t1.inner_quantity,
t1.quantity,
t1.price,
t1.amount_total,
t2.warehouse_id,
t3.description as product_desc
2025-11-28 09:07:15 +00:00
FROM
2025-11-28 09:29:15 +00:00
oms_purchase_order_item t1
LEFT JOIN oms_purchase_order t2 ON t1.purchase_id = t2.id
left join product_info t3 on t1.product_code=t3.product_code
left join oms_vendor_info t4 on t2.vendor_id=t4.vendor_id
2025-11-28 09:07:15 +00:00
<where >
<if test= "purchaseNo != null and purchaseNo != ''" > and t2.purchase_no = #{purchaseNo}</if>
<if test= "productCode != null and productCode != '' " > and t1.product_code = #{productCode}</if>
<if test= "productType != null" > and t3.type = #{productType}</if>
<if test= "vendorName != null and vendorName != ''" > and t4.vendor_name = #{vendorName}</if>
2025-11-28 09:29:15 +00:00
<if test= "approveStatus != null and approveStatus != ''" > and t2.approve_status = #{approveStatus}</if>
<if test= "confirmStatus != null and confirmStatus != ''" > and t2.confirm_status = #{confirmStatus}</if>
<if test= "productTypeList != null and productTypeList.size>0" > and t3.type in
<foreach item= "item" collection= "productTypeList" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
2025-11-28 09:07:15 +00:00
</where>
</select>
2025-11-27 03:39:47 +00:00
<insert id= "insertOmsPurchaseOrder" parameterType= "OmsPurchaseOrder" useGeneratedKeys= "true" keyProperty= "id" >
insert into oms_purchase_order
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "purchaseNo != null" > purchase_no,</if>
<if test= "buyerName != null" > buyer_name,</if>
<if test= "buyerAddress != null" > buyer_address,</if>
<if test= "vendorId != null" > vendor_id,</if>
<if test= "currency != null" > currency,</if>
<if test= "purchaserId != null" > purchaser_id,</if>
<if test= "purchaserName != null" > purchaser_name,</if>
<if test= "purchaserMobile != null" > purchaser_mobile,</if>
<if test= "purchaserEmail != null" > purchaser_email,</if>
<if test= "warehouseId != null" > warehouse_id,</if>
<if test= "payMethod != null" > pay_method,</if>
<if test= "ownerId != null" > owner_id,</if>
<if test= "ownerName != null" > owner_name,</if>
<if test= "remark != null" > remark,</if>
<if test= "totalAmount != null" > total_amount,</if>
<if test= "status != null" > status,</if>
<if test= "approveStatus != null" > approve_status,</if>
<if test= "approveTime != null" > approve_time,</if>
<if test= "approveNode != null" > approve_node,</if>
<if test= "confirmStatus != null" > confirm_status,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateTime != null" > update_time,</if>
<if test= "delFlag != null" > del_flag,</if>
<if test= "version != null" > version,</if>
2025-11-28 01:08:26 +00:00
<if test= "flowType != null" > flow_type,</if>
2025-11-27 03:39:47 +00:00
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "purchaseNo != null" > #{purchaseNo},</if>
<if test= "buyerName != null" > #{buyerName},</if>
<if test= "buyerAddress != null" > #{buyerAddress},</if>
<if test= "vendorId != null" > #{vendorId},</if>
<if test= "currency != null" > #{currency},</if>
<if test= "purchaserId != null" > #{purchaserId},</if>
<if test= "purchaserName != null" > #{purchaserName},</if>
<if test= "purchaserMobile != null" > #{purchaserMobile},</if>
<if test= "purchaserEmail != null" > #{purchaserEmail},</if>
<if test= "warehouseId != null" > #{warehouseId},</if>
<if test= "payMethod != null" > #{payMethod},</if>
<if test= "ownerId != null" > #{ownerId},</if>
<if test= "ownerName != null" > #{ownerName},</if>
<if test= "remark != null" > #{remark},</if>
<if test= "totalAmount != null" > #{totalAmount},</if>
<if test= "status != null" > #{status},</if>
<if test= "approveStatus != null" > #{approveStatus},</if>
<if test= "approveTime != null" > #{approveTime},</if>
<if test= "approveNode != null" > #{approveNode},</if>
<if test= "confirmStatus != null" > #{confirmStatus},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateTime != null" > #{updateTime},</if>
<if test= "delFlag != null" > #{delFlag},</if>
<if test= "version != null" > #{version},</if>
2025-11-28 01:08:26 +00:00
<if test= "flowType != null" > #{flowType},</if>
2025-11-27 03:39:47 +00:00
</trim>
</insert>
<update id= "updateOmsPurchaseOrder" parameterType= "OmsPurchaseOrder" >
update oms_purchase_order
<trim prefix= "SET" suffixOverrides= "," >
<if test= "purchaseNo != null" > purchase_no = #{purchaseNo},</if>
<if test= "buyerName != null" > buyer_name = #{buyerName},</if>
<if test= "buyerAddress != null" > buyer_address = #{buyerAddress},</if>
<if test= "vendorId != null" > vendor_id = #{vendorId},</if>
<if test= "currency != null" > currency = #{currency},</if>
<if test= "purchaserId != null" > purchaser_id = #{purchaserId},</if>
<if test= "purchaserName != null" > purchaser_name = #{purchaserName},</if>
<if test= "purchaserMobile != null" > purchaser_mobile = #{purchaserMobile},</if>
<if test= "purchaserEmail != null" > purchaser_email = #{purchaserEmail},</if>
<if test= "warehouseId != null" > warehouse_id = #{warehouseId},</if>
<if test= "payMethod != null" > pay_method = #{payMethod},</if>
<if test= "ownerId != null" > owner_id = #{ownerId},</if>
<if test= "ownerName != null" > owner_name = #{ownerName},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "totalAmount != null" > total_amount = #{totalAmount},</if>
<if test= "status != null" > status = #{status},</if>
<if test= "approveStatus != null" > approve_status = #{approveStatus},</if>
<if test= "approveTime != null" > approve_time = #{approveTime},</if>
<if test= "approveNode != null" > approve_node = #{approveNode},</if>
<if test= "confirmStatus != null" > confirm_status = #{confirmStatus},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "delFlag != null" > del_flag = #{delFlag},</if>
<if test= "version != null" > version = #{version},</if>
2025-11-28 01:08:26 +00:00
<if test= "flowType != null" > flow_type=#{flowType},</if>
2025-11-27 03:39:47 +00:00
</trim>
where id = #{id}
</update>
<update id= "updateOmsPurchaseOrderStatus" parameterType= "OmsPurchaseOrder" >
update oms_purchase_order
<trim prefix= "SET" suffixOverrides= "," >
<if test= "buyerName != null" > buyer_name = #{buyerName},</if>
<if test= "buyerAddress != null" > buyer_address = #{buyerAddress},</if>
<if test= "vendorId != null" > vendor_id = #{vendorId},</if>
<if test= "currency != null" > currency = #{currency},</if>
<if test= "purchaserId != null" > purchaser_id = #{purchaserId},</if>
<if test= "purchaserName != null" > purchaser_name = #{purchaserName},</if>
<if test= "purchaserMobile != null" > purchaser_mobile = #{purchaserMobile},</if>
<if test= "purchaserEmail != null" > purchaser_email = #{purchaserEmail},</if>
<if test= "warehouseId != null" > warehouse_id = #{warehouseId},</if>
<if test= "payMethod != null" > pay_method = #{payMethod},</if>
<if test= "ownerId != null" > owner_id = #{ownerId},</if>
<if test= "ownerName != null" > owner_name = #{ownerName},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "totalAmount != null" > total_amount = #{totalAmount},</if>
<if test= "status != null" > status = #{status},</if>
<if test= "approveStatus != null" > approve_status = #{approveStatus},</if>
<if test= "approveTime != null" > approve_time = #{approveTime},</if>
<if test= "approveNode != null" > approve_node = #{approveNode},</if>
<if test= "confirmStatus != null" > confirm_status = #{confirmStatus},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "delFlag != null" > del_flag = #{delFlag},</if>
<if test= "version != null" > version = #{version},</if>
2025-11-28 01:08:26 +00:00
<if test= "flowType != null" > flow_type=#{flowType},</if>
2025-11-27 03:39:47 +00:00
</trim>
where purchase_no = #{purchaseNo}
</update>
<update id= "updateOmsPurchaseOrderByCode" >
update oms_purchase_order
2025-11-28 09:29:15 +00:00
<trim prefix= "SET" suffixOverrides= "," >
<if test= "purchaseNo != null" > purchase_no = #{purchaseNo},</if>
<if test= "buyerName != null" > buyer_name = #{buyerName},</if>
<if test= "buyerAddress != null" > buyer_address = #{buyerAddress},</if>
<if test= "vendorId != null" > vendor_id = #{vendorId},</if>
<if test= "currency != null" > currency = #{currency},</if>
<if test= "purchaserId != null" > purchaser_id = #{purchaserId},</if>
<if test= "purchaserName != null" > purchaser_name = #{purchaserName},</if>
<if test= "purchaserMobile != null" > purchaser_mobile = #{purchaserMobile},</if>
<if test= "purchaserEmail != null" > purchaser_email = #{purchaserEmail},</if>
<if test= "warehouseId != null" > warehouse_id = #{warehouseId},</if>
<if test= "payMethod != null" > pay_method = #{payMethod},</if>
<if test= "ownerId != null" > owner_id = #{ownerId},</if>
<if test= "ownerName != null" > owner_name = #{ownerName},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "totalAmount != null" > total_amount = #{totalAmount},</if>
<if test= "status != null" > status = #{status},</if>
<if test= "approveStatus != null" > approve_status = #{approveStatus},</if>
<if test= "approveTime != null" > approve_time = #{approveTime},</if>
<if test= "approveNode != null" > approve_node = #{approveNode},</if>
<if test= "confirmStatus != null" > confirm_status = #{confirmStatus},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "delFlag != null" > del_flag = #{delFlag},</if>
<if test= "version != null" > version = #{version},</if>
<if test= "flowType != null" > flow_type=#{flowType},</if>
</trim>
2025-11-27 03:39:47 +00:00
where purchase_no = #{purchaseNo}
</update>
<delete id= "deleteOmsPurchaseOrderById" parameterType= "Long" >
delete from oms_purchase_order where id = #{id}
</delete>
<delete id= "deleteOmsPurchaseOrderByIds" parameterType= "String" >
delete from oms_purchase_order where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
<delete id= "deleteOmsPurchaseOrderItemByPurchaseIds" parameterType= "String" >
delete from oms_purchase_order_item where purchase_id in
<foreach item= "purchaseId" collection= "array" open= "(" separator= "," close= ")" >
#{purchaseId}
</foreach>
</delete>
<delete id= "deleteOmsPurchaseOrderItemByPurchaseId" parameterType= "Long" >
delete from oms_purchase_order_item where purchase_id = #{purchaseId}
</delete>
<insert id= "batchOmsPurchaseOrderItem" >
insert into oms_purchase_order_item( purchase_id, product_code, inner_status, quantity, price, tax_rate, tax_total, amount_total,delivery_date) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.purchaseId}, #{item.productCode}, #{item.innerStatus}, #{item.quantity},
#{item.price}, #{item.taxRate}, #{item.taxTotal}, #{item.amountTotal}, #{item.deliveryDate})
</foreach>
</insert>
</mapper>