226 lines
9.7 KiB
XML
226 lines
9.7 KiB
XML
<?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"/>
|
|
<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,
|
|
order_master_id,
|
|
order_master_code,
|
|
customer_id,
|
|
order_type,
|
|
order_status,
|
|
worker_id,
|
|
rev_time,
|
|
expect_time_start,
|
|
expect_time_end,
|
|
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>
|
|
|
|
<select id="selectOrderDetailList" parameterType="com.ghy.order.domain.OrderDetail" resultMap="OrderDetailResult">
|
|
<include refid="selectOrderDetailMoreInfo"/>
|
|
<where>
|
|
<if test="code != null and code != ''">
|
|
AND od.code LIKE concat('%', #{code}, '%')
|
|
</if>
|
|
<if test="customerId != null and customerId != 0">
|
|
AND od.customer_id = #{customerId}
|
|
</if>
|
|
<if test="orderType != null">
|
|
AND od.order_type = #{orderType}
|
|
</if>
|
|
<if test="orderStatus != null">
|
|
AND od.order_status = #{orderStatus}
|
|
</if>
|
|
<if test="orderMasterCode != null and orderMasterCode != 0">
|
|
AND od.order_detail_code = #{orderMasterCode}
|
|
</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}
|
|
</if>
|
|
<if test="expectTimeStart != null">
|
|
AND od.expect_time_start >= #{expectTimeStart}
|
|
</if>
|
|
<if test="expectTimeEnd != null">
|
|
AND od.expect_time_end <= #{expectTimeEnd}
|
|
</if>
|
|
</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>
|
|
</select>
|
|
|
|
<select id="selectById" parameterType="long" resultMap="OrderDetailResult">
|
|
<include refid="selectOrderDetail"/> WHERE id = #{orderDetailId}
|
|
</select>
|
|
|
|
|
|
<select id="selectByOrderMasterId" parameterType="long" resultMap="OrderDetailResult">
|
|
<include refid="selectOrderDetail"/> WHERE order_master_id = #{orderMasterId}
|
|
</select>
|
|
|
|
<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>
|
|
<if test="orderMasterId != null and orderMasterId != 0">order_master_id = #{orderMasterId},</if>
|
|
<if test="orderMasterCode != null and orderMasterCode != ''">order_master_code = #{orderMasterCode},</if>
|
|
<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>
|
|
<if test="workBeginTime != null">work_begin_time = #{workBeginTime},</if>
|
|
<if test="workFinishTime != null">work_finish_time = #{workFinishTime},</if>
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
update_time = SYSDATE()
|
|
</set>
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<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>
|
|
|
|
<insert id="insertOrderDetail" parameterType="com.ghy.order.domain.OrderDetail" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO order_detail(
|
|
<if test="code != null and code != ''">code,</if>
|
|
<if test="orderMasterId != null and orderMasterId != 0">order_master_id,</if>
|
|
<if test="orderMasterCode != null and orderMasterCode != ''">order_master_code,</if>
|
|
<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>
|
|
<if test="workBeginTime != null">work_begin_time,</if>
|
|
<if test="workFinishTime != null">work_finish_time,</if>
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
create_time
|
|
)VALUES(
|
|
<if test="code != null and code != ''">#{code},</if>
|
|
<if test="orderMasterId != null and orderMasterId != 0">#{orderMasterId},</if>
|
|
<if test="orderMasterCode != null and orderMasterCode != ''">#{orderMasterCode},</if>
|
|
<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>
|
|
<if test="workBeginTime != null">#{workBeginTime},</if>
|
|
<if test="workFinishTime != null">#{workFinishTime},</if>
|
|
<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>
|
|
|
|
<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>
|