Zlpt-Cloud/zlpt-modules/zlpt-order/src/main/resources/mapper/OrderInfoMapper.xml

205 lines
11 KiB
XML
Raw Normal View History

2023-12-02 14:32:47 +08: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.bonus.zlpt.order.mapper.OrderInfoMapper">
2023-12-03 17:12:53 +08:00
<resultMap type="com.bonus.zlpt.common.core.domain.order.OrderInfo" id="OrderInfoResult">
2023-12-02 14:32:47 +08:00
<result property="orderId" column="order_id" />
<result property="pId" column="p_id" />
<result property="code" column="code" />
<result property="time" column="time" />
2023-12-07 11:05:51 +08:00
<result property="endTime" column="end_time" />
2023-12-02 14:32:47 +08:00
<result property="deposit" column="deposit" />
<result property="cost" column="cost" />
<result property="payType" column="pay_type" />
<result property="supplier" column="supplier" />
<result property="orderStatus" column="order_status" />
<result property="orderUser" column="order_user" />
<result property="orderCompany" column="order_company" />
</resultMap>
<sql id="selectOrderInfoVo">
2023-12-07 11:05:51 +08:00
select order_id, p_id, code, time, end_time, deposit, cost, pay_type, supplier, order_status, order_user, order_company from ma_order_info
2023-12-02 14:32:47 +08:00
</sql>
2023-12-05 10:13:26 +08:00
<select id="selectOrderInfoList" parameterType="com.bonus.zlpt.common.core.domain.order.vo.OrderInfoVo" resultType="com.bonus.zlpt.common.core.domain.order.vo.OrderInfoVo">
2023-12-05 10:56:30 +08:00
select o.*,d.phone as order_phone,d.ma_id,co.company_name as supplier_company
2023-12-05 10:13:26 +08:00
from ma_order_info o
2023-12-06 15:00:01 +08:00
left join ma_order_details d on o.order_id=d.order_id
2023-12-05 10:56:30 +08:00
left join bm_company_info co on o.supplier=co.company_id
2023-12-02 14:32:47 +08:00
<where>
2023-12-05 10:13:26 +08:00
<if test="orderId != null "> and o.order_id = #{orderId}</if>
<if test="pId != null "> and o.p_id = #{pId}</if>
<if test="code != null and code != ''"> and o.code = #{code}</if>
<if test="time != null and time != ''"> and o.time = #{time}</if>
<if test="deposit != null "> and o.deposit = #{deposit}</if>
<if test="cost != null "> and o.cost = #{cost}</if>
<if test="payType != null and payType != ''"> and o.pay_type = #{payType}</if>
<if test="supplier != null and supplier != ''"> and o.supplier = #{supplier}</if>
<if test="orderStatus != null and orderStatus != ''"> and o.order_status = #{orderStatus}</if>
<if test="orderUser != null "> and o.order_user = #{orderUser}</if>
<if test="orderCompany != null and orderCompany != ''"> and o.order_company = #{orderCompany}</if>
2023-12-02 14:32:47 +08:00
</where>
</select>
2023-12-06 19:33:32 +08:00
<select id="selectOrderInfoByOrderId" parameterType="Long" resultType="com.bonus.zlpt.common.core.domain.order.vo.OrderInfoVo">
2023-12-08 13:18:51 +08:00
select d.*,o.code,o.time as order_time,o.order_status
2023-12-06 19:33:32 +08:00
from ma_order_info o
2023-12-08 13:18:51 +08:00
left join ma_order_details d on d.order_id = o.order_id
where o.order_id = #{orderId}
2023-12-02 14:32:47 +08:00
</select>
2023-12-08 13:18:51 +08:00
<!-- select d.*,o.code,o.time as order_time,o.order_status,s.file_url as contract_url-->
<!-- from ma_order_info o-->
<!-- left join ma_order_details d on d.order_id = o.order_id-->
<!-- left join sys_file_info s on s.model_id = o.order_id-->
<!-- where o.order_id = #{orderId} and s.dic_id = 21-->
2023-12-02 14:32:47 +08:00
2023-12-06 19:57:07 +08:00
<insert id="insertOrderInfo" parameterType="com.bonus.zlpt.common.core.domain.order.vo.OrderInfoVo">
2023-12-02 14:32:47 +08:00
insert into ma_order_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">order_id,</if>
<if test="pId != null">p_id,</if>
<if test="code != null">code,</if>
<if test="time != null">time,</if>
2023-12-07 11:05:51 +08:00
<if test="endTime != null">end_time,</if>
2023-12-02 14:32:47 +08:00
<if test="deposit != null">deposit,</if>
<if test="cost != null">cost,</if>
<if test="payType != null">pay_type,</if>
<if test="supplier != null">supplier,</if>
<if test="orderStatus != null">order_status,</if>
<if test="orderUser != null">order_user,</if>
<if test="orderCompany != null">order_company,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if>
<if test="pId != null">#{pId},</if>
<if test="code != null">#{code},</if>
<if test="time != null">#{time},</if>
2023-12-07 11:05:51 +08:00
<if test="endTime != null">#{endTime},</if>
2023-12-02 14:32:47 +08:00
<if test="deposit != null">#{deposit},</if>
<if test="cost != null">#{cost},</if>
<if test="payType != null">#{payType},</if>
<if test="supplier != null">#{supplier},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="orderUser != null">#{orderUser},</if>
<if test="orderCompany != null">#{orderCompany},</if>
</trim>
</insert>
2023-12-06 19:57:07 +08:00
<insert id="insertOrderDetails" parameterType="com.bonus.zlpt.common.core.domain.order.vo.OrderInfoVo">
insert into ma_order_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">order_id,</if>
<if test="needCompany != null">need_company,</if>
<if test="planStartTime != null">plan_start_time,</if>
<if test="isMachinist != null">is_machinist,</if>
<if test="addressId != null">address_id,</if>
<if test="address != null">address,</if>
<if test="duration != null">duration,</if>
<if test="invoiceType != null">invoice_type,</if>
<if test="description != null">description,</if>
<if test="maId != null">ma_id,</if>
<if test="leaseType != null">lease_type,</if>
<if test="leasePrice != null">lease_price,</if>
<if test="machinistPrice != null">machinist_price,</if>
<if test="orderContract != null">order_contract,</if>
<if test="machinistName != null">machinist_name,</if>
<if test="phone != null">phone,</if>
<if test="logisticsPhone != null">logistics_phone,</if>
<if test="realStartTime != null">real_start_time,</if>
<if test="renterName != null">renter_name,</if>
<if test="tenantName != null">tenant_name,</if>
<if test="entryAttachment != null">entry_attachment,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if>
<if test="needCompany != null">#{needCompany},</if>
<if test="planStartTime != null">#{planStartTime},</if>
<if test="isMachinist != null">#{isMachinist},</if>
<if test="addressId != null">#{addressId},</if>
<if test="address != null">#{address},</if>
<if test="duration != null">#{duration},</if>
<if test="invoiceType != null">#{invoiceType},</if>
<if test="description != null">#{description},</if>
<if test="maId != null">#{maId},</if>
<if test="leaseType != null">#{leaseType},</if>
<if test="leasePrice != null">#{leasePrice},</if>
<if test="machinistPrice != null">#{machinistPrice},</if>
<if test="orderContract != null">#{orderContract},</if>
<if test="machinistName != null">#{machinistName},</if>
<if test="phone != null">#{phone},</if>
<if test="logisticsPhone != null">#{logisticsPhone},</if>
<if test="realStartTime != null">#{realStartTime},</if>
<if test="renterName != null">#{renterName},</if>
<if test="tenantName != null">#{tenantName},</if>
<if test="entryAttachment != null">#{entryAttachment},</if>
</trim>
</insert>
2023-12-06 20:32:10 +08:00
<update id="updateOrderInfo" parameterType="com.bonus.zlpt.common.core.domain.order.vo.OrderInfoVo">
2023-12-02 14:32:47 +08:00
update ma_order_info
<trim prefix="SET" suffixOverrides=",">
2023-12-08 13:12:44 +08:00
<if test="orderId != null">order_id = #{orderId},</if>
2023-12-02 14:32:47 +08:00
<if test="pId != null">p_id = #{pId},</if>
<if test="code != null">code = #{code},</if>
<if test="time != null">time = #{time},</if>
2023-12-07 11:05:51 +08:00
<if test="endTime != null">time = #{endTime},</if>
2023-12-02 14:32:47 +08:00
<if test="deposit != null">deposit = #{deposit},</if>
<if test="cost != null">cost = #{cost},</if>
<if test="payType != null">pay_type = #{payType},</if>
<if test="supplier != null">supplier = #{supplier},</if>
<if test="orderStatus != null">order_status = #{orderStatus},</if>
<if test="orderUser != null">order_user = #{orderUser},</if>
<if test="orderCompany != null">order_company = #{orderCompany},</if>
</trim>
where order_id = #{orderId}
</update>
2023-12-06 20:32:10 +08:00
<update id="updateOrderDetails" parameterType="com.bonus.zlpt.common.core.domain.order.vo.OrderInfoVo">
update ma_order_details
<trim prefix="SET" suffixOverrides=",">
<if test="orderId != null">order_id = #{orderId},</if>
<if test="needCompany != null">need_company = #{needCompany},</if>
<if test="planStartTime != null">plan_start_time = #{planStartTime},</if>
<if test="isMachinist != null">is_machinist = #{isMachinist},</if>
<if test="addressId != null">address_id = #{addressId},</if>
<if test="address != null">address = #{address},</if>
<if test="duration != null">duration = #{duration},</if>
<if test="invoiceType != null">invoice_type = #{invoiceType},</if>
<if test="description != null">description = #{description},</if>
<if test="maId != null">ma_id = #{maId},</if>
<if test="leaseType != null">lease_type = #{leaseType},</if>
<if test="leasePrice != null">lease_price = #{leasePrice},</if>
<if test="machinistPrice != null">machinist_price = #{machinistPrice},</if>
<if test="orderContract != null">order_contract = #{orderContract},</if>
<if test="machinistName != null">machinist_name = #{machinistName},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="logisticsPhone != null">logistics_phone = #{logisticsPhone},</if>
<if test="realStartTime != null">real_start_time = #{realStartTime},</if>
<if test="renterName != null">renter_name = #{renterName},</if>
<if test="tenantName != null">tenant_name = #{tenantName},</if>
<if test="entryAttachment != null">entry_attachment = #{entryAttachment},</if>
</trim>
where order_id = #{orderId}
</update>
2023-12-02 14:32:47 +08:00
<delete id="deleteOrderInfoByOrderId" parameterType="Long">
delete from ma_order_info where order_id = #{orderId}
</delete>
<delete id="deleteOrderInfoByOrderIds" parameterType="String">
delete from ma_order_info where order_id in
<foreach item="orderId" collection="array" open="(" separator="," close=")">
#{orderId}
</foreach>
</delete>
2023-12-06 20:20:48 +08:00
<select id="selectLastInsertId" resultType="Long">
SELECT LAST_INSERT_ID()
</select>
2023-12-07 13:53:04 +08:00
<select id="count" parameterType="Long" resultType="Long">
SELECT count(*) from ma_order_info where orderUser = #{userId}
</select>
2023-12-02 14:32:47 +08:00
</mapper>