ghy-all/ghy-order/src/main/resources/mapper/order/OrderDetailMapper.xml

226 lines
9.7 KiB
XML
Raw Normal View History

2022-04-25 17:06:55 +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.ghy.order.mapper.OrderDetailMapper">
<resultMap id="OrderDetailResult" type="com.ghy.order.domain.OrderDetail">
<id property="id" column="id"/>
<result property="code" column="code"/>
<result property="orderMasterId" column="order_master_id"/>
<result property="orderMasterCode" column="order_master_code"/>
<result property="customerId" column="customer_id"/>
<result property="orderType" column="order_type"/>
<result property="orderStatus" column="order_status"/>
<result property="workerId" column="worker_id"/>
<result property="revTime" column="rev_time"/>
<result property="expectTimeStart" column="expect_time_start"/>
<result property="expectTimeEnd" column="expect_time_end"/>
2022-04-25 17:06:55 +08:00
<result property="workBeginTime" column="work_begin_time"/>
<result property="workFinishTime" column="work_finish_time"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectOrderDetail">
SELECT id,
code,
2022-05-24 22:26:26 +08:00
order_master_id,
2022-04-25 17:06:55 +08:00
order_master_code,
customer_id,
order_type,
order_status,
worker_id,
rev_time,
expect_time_start,
expect_time_end,
2022-04-25 17:06:55 +08:00
work_begin_time,
work_finish_time,
create_by,
create_time,
remark
FROM order_detail
</sql>
<sql id="selectOrderDetailMoreInfo">
SELECT od.id,
od.code,
od.order_master_id,
od.order_master_code,
od.customer_id,
od.order_type,
od.order_status,
od.worker_id,
od.rev_time,
od.expect_time_start,
od.expect_time_end,
od.work_begin_time,
od.work_finish_time,
od.create_by,
od.create_time,
od.remark
FROM order_detail od
LEFT JOIN order_master om ON om.id = od.order_master_id
LEFT JOIN customer_address ca ON ca.customer_address_id = om.address_id
LEFT JOIN goods g ON g.goods_id = om.goods_id
</sql>
2022-04-25 17:06:55 +08:00
<select id="selectOrderDetailList" parameterType="com.ghy.order.domain.OrderDetail" resultMap="OrderDetailResult">
<include refid="selectOrderDetailMoreInfo"/>
2022-04-25 17:06:55 +08:00
<where>
<if test="code != null and code != ''">
AND od.code LIKE concat('%', #{code}, '%')
2022-04-25 17:06:55 +08:00
</if>
<if test="customerId != null and customerId != 0">
AND od.customer_id = #{customerId}
2022-04-25 17:06:55 +08:00
</if>
2022-05-24 22:26:26 +08:00
<if test="orderType != null">
AND od.order_type = #{orderType}
2022-04-25 17:06:55 +08:00
</if>
2022-05-24 22:26:26 +08:00
<if test="orderStatus != null">
AND od.order_status = #{orderStatus}
2022-04-25 17:06:55 +08:00
</if>
<if test="orderMasterCode != null and orderMasterCode != 0">
AND od.order_detail_code = #{orderMasterCode}
2022-04-25 17:06:55 +08:00
</if>
<if test="workerId != null and workerId != 0">
AND od.worker_id = #{workerId}
</if>
<if test="goodsCategoryId != null">
AND g.dept_goods_category_id = #{goodsCategoryId}
</if>
<if test="goodsName != null and goodsName != ''">
AND g.goods_name like concat('%', #{goodsName}, '%')
</if>
<if test="countryId != null">
AND ca.country_id = #{countryId}
2022-04-25 17:06:55 +08:00
</if>
<if test="expectTimeStart != null">
AND od.expect_time_start &gt;= #{expectTimeStart}
</if>
<if test="expectTimeEnd != null">
AND od.expect_time_end &lt;= #{expectTimeEnd}
</if>
2022-04-25 17:06:55 +08:00
</where>
order by od.create_time
<trim suffixOverrides=",">
<choose>
<when test="params.createTimeSort != null and params.createTimeSort != ''">
${params.createTimeSort}
</when>
<otherwise>
desc
</otherwise>
</choose>
</trim>
2022-04-25 17:06:55 +08:00
</select>
<select id="selectById" parameterType="long" resultMap="OrderDetailResult">
2022-05-24 22:26:26 +08:00
<include refid="selectOrderDetail"/> WHERE id = #{orderDetailId}
2022-04-25 17:06:55 +08:00
</select>
<select id="selectByOrderMasterId" parameterType="long" resultMap="OrderDetailResult">
<include refid="selectOrderDetail"/> WHERE order_master_id = #{orderMasterId}
</select>
2022-04-25 17:06:55 +08:00
<delete id="deleteOrderDetailByIds" parameterType="Long">
DELETE FROM order_detail WHERE id IN
<foreach collection="array" item="orderDetailId" open="(" separator="," close=")">
#{orderDetailId}
</foreach>
</delete>
<update id="updateOrderDetail" parameterType="com.ghy.order.domain.OrderDetail">
UPDATE order_detail
<set>
<if test="code != null and code != ''">code = #{code},</if>
2022-05-24 22:26:26 +08:00
<if test="orderMasterId != null and orderMasterId != 0">order_master_id = #{orderMasterId},</if>
2022-04-25 17:06:55 +08:00
<if test="orderMasterCode != null and orderMasterCode != ''">order_master_code = #{orderMasterCode},</if>
2022-05-24 22:26:26 +08:00
<if test="customerId != null and customerId != 0">customer_id = #{customerId},</if>
<if test="orderType != null">order_type = #{orderType},</if>
<if test="orderStatus != null">order_status = #{orderStatus},</if>
<if test="workerId != null and workerId != 0">worker_id = #{workerId},</if>
<if test="revTime != null">rev_time = #{revTime},</if>
<if test="expectTimeStart != null">expect_time_start = #{expectTimeStart},</if>
<if test="expectTimeEnd != null">expect_time_end = #{expectTimeEnd},</if>
2022-05-24 22:26:26 +08:00
<if test="workBeginTime != null">work_begin_time = #{workBeginTime},</if>
<if test="workFinishTime != null">work_finish_time = #{workFinishTime},</if>
2022-04-25 17:06:55 +08:00
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = SYSDATE()
</set>
WHERE id = #{id}
</update>
2022-07-22 22:25:44 +08:00
<update id="updateStatus">
UPDATE order_detail
SET order_status = #{orderStatus},
update_time = SYSDATE()
WHERE id = #{id}
</update>
<update id="updateByOrderMasterId">
UPDATE order_detail
<set>
<if test="orderStatus != null">order_status = #{orderStatus},</if>
update_time = SYSDATE()
</set>
WHERE order_master_id = #{orderMasterId}
</update>
2022-04-25 17:06:55 +08:00
<insert id="insertOrderDetail" parameterType="com.ghy.order.domain.OrderDetail" useGeneratedKeys="true" keyProperty="id">
INSERT INTO order_detail(
2022-05-24 22:26:26 +08:00
<if test="code != null and code != ''">code,</if>
<if test="orderMasterId != null and orderMasterId != 0">order_master_id,</if>
2022-04-25 17:06:55 +08:00
<if test="orderMasterCode != null and orderMasterCode != ''">order_master_code,</if>
2022-05-24 22:26:26 +08:00
<if test="customerId != null and customerId != 0">customer_id,</if>
<if test="orderType != null">order_type,</if>
<if test="orderStatus != null">order_status,</if>
<if test="workerId != null and workerId != 0">worker_id,</if>
<if test="revTime != null">rev_time,</if>
<if test="remark != null">remark,</if>
<if test="expectTimeStart != null">expect_time_start,</if>
<if test="expectTimeEnd != null">expect_time_end,</if>
2022-05-24 22:26:26 +08:00
<if test="workBeginTime != null">work_begin_time,</if>
<if test="workFinishTime != null">work_finish_time,</if>
2022-04-25 17:06:55 +08:00
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)VALUES(
2022-05-24 22:26:26 +08:00
<if test="code != null and code != ''">#{code},</if>
2022-06-10 18:20:58 +08:00
<if test="orderMasterId != null and orderMasterId != 0">#{orderMasterId},</if>
2022-04-25 17:06:55 +08:00
<if test="orderMasterCode != null and orderMasterCode != ''">#{orderMasterCode},</if>
2022-05-24 22:26:26 +08:00
<if test="customerId != null and customerId != 0">#{customerId},</if>
<if test="orderType != null">#{orderType},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="workerId != null and workerId != 0">#{workerId},</if>
<if test="revTime != null">#{revTime},</if>
<if test="remark != null">#{remark},</if>
<if test="expectTimeStart != null">#{expectTimeStart},</if>
<if test="expectTimeEnd != null">#{expectTimeEnd},</if>
2022-05-24 22:26:26 +08:00
<if test="workBeginTime != null">#{workBeginTime},</if>
<if test="workFinishTime != null">#{workFinishTime},</if>
2022-04-25 17:06:55 +08:00
<if test="createBy != null and createBy != ''">#{createBy},</if>
SYSDATE()
)
</insert>
<select id="checkOrderDetailCodeUnique" parameterType="String" resultMap="OrderDetailResult">
<include refid="selectOrderDetail"/>
WHERE `code` =#{orderDetailCode} LIMIT 1
</select>
2022-06-01 14:50:58 +08:00
<select id="getByOrderIdList" resultMap="OrderDetailResult">
<include refid="selectOrderDetail" />
<where>
and order_master_id in
<foreach item="item" index="orderIdList" collection="orderIdList" open="(" separator="," close=")">
#{item}
</foreach>
</where>
</select>
</mapper>