392 lines
16 KiB
XML
392 lines
16 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.OrderMasterMapper">
|
|
|
|
<resultMap id="OrderMasterResult" type="com.ghy.order.domain.OrderMaster">
|
|
<id property="id" column="id"/>
|
|
<result property="deptId" column="dept_id"/>
|
|
<result property="code" column="code"/>
|
|
<result property="customerId" column="customer_id"/>
|
|
<result property="addressId" column="address_id"/>
|
|
<result property="orderType" column="order_type"/>
|
|
<result property="orderMode" column="order_mode"/>
|
|
<result property="orderStatus" column="order_status"/>
|
|
<result property="payType" column="pay_type"/>
|
|
<result property="payStatus" column="pay_status"/>
|
|
<result property="workerId" column="worker_id"/>
|
|
<result property="payTime" column="pay_time"/>
|
|
<result property="revTime" column="rev_time"/>
|
|
<result property="expectTimeStart" column="expect_time_start"/>
|
|
<result property="expectTimeEnd" column="expect_time_end"/>
|
|
<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"/>
|
|
<result property="goodsId" column="goods_id"/>
|
|
<result property="allSelfAssigned" column="all_self_assigned"/>
|
|
<result property="hasDispatchedAll" column="has_dispatched_all"/>
|
|
<result property="timeout" column="timeout_"/>
|
|
<result property="timeoutFineTimes" column="timeout_fine_times"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectOrderMaster">
|
|
SELECT id,
|
|
dept_id,
|
|
code,
|
|
customer_id,
|
|
address_id,
|
|
order_type,
|
|
order_mode,
|
|
order_status,
|
|
pay_type,
|
|
pay_status,
|
|
worker_id,
|
|
pay_time,
|
|
rev_time,
|
|
expect_time_start,
|
|
expect_time_end,
|
|
create_by,
|
|
create_time,
|
|
update_time,
|
|
remark,
|
|
all_self_assigned,
|
|
goods_id,
|
|
timeout_,
|
|
timeout_fine_times
|
|
FROM order_master
|
|
</sql>
|
|
<sql id="selectOrderMasterMoreInfo">
|
|
SELECT om.id,
|
|
om.dept_id,
|
|
om.code,
|
|
om.customer_id,
|
|
om.address_id,
|
|
om.order_type,
|
|
om.order_mode,
|
|
om.order_status,
|
|
om.pay_type,
|
|
om.pay_status,
|
|
om.worker_id,
|
|
om.pay_time,
|
|
om.rev_time,
|
|
om.expect_time_start,
|
|
om.expect_time_end,
|
|
om.create_by,
|
|
om.create_time,
|
|
om.update_time,
|
|
om.remark,
|
|
om.all_self_assigned,
|
|
om.goods_id,
|
|
om.timeout_,
|
|
om.timeout_fine_times
|
|
FROM order_master om
|
|
LEFT JOIN customer_address ca ON ca.customer_address_id = om.address_id
|
|
LEFT JOIN goods g ON g.goods_id = om.goods_id
|
|
LEFT JOIN financial_master fm ON om.id = fm.order_master_id
|
|
</sql>
|
|
|
|
<select id="selectOrderMasterList" parameterType="com.ghy.order.domain.OrderMaster" resultMap="OrderMasterResult">
|
|
<include refid="selectOrderMasterMoreInfo"></include>
|
|
<where>
|
|
<if test="isMonitoredOrder">
|
|
AND (om.all_self_assigned = 0 or om.all_self_assigned is null) AND om.order_status in (1,2,3,4)
|
|
</if>
|
|
<if test="allSelfAssigned != null">
|
|
AND all_self_assigned = #{allSelfAssigned}
|
|
</if>
|
|
<if test="deptId != null and deptId != 0">
|
|
AND om.dept_id = #{deptId}
|
|
</if>
|
|
<if test="code != null and code != ''">
|
|
AND om.code LIKE concat('%', #{code}, '%')
|
|
</if>
|
|
<if test="customerId != null and customerId != 0">
|
|
AND om.customer_id = #{customerId}
|
|
</if>
|
|
<if test="customerIds != null and customerIds.size > 0">
|
|
AND om.customer_id in
|
|
<foreach item="customerId" collection="customerIds" open="(" separator="," close=")">
|
|
#{customerId}
|
|
</foreach>
|
|
</if>
|
|
<if test="orderType != null">
|
|
AND om.order_type = #{orderType}
|
|
</if>
|
|
<if test="orderStatus != null">
|
|
AND om.order_status = #{orderStatus}
|
|
</if>
|
|
<if test="payType != null">
|
|
AND om.pay_type = #{payType}
|
|
</if>
|
|
<if test="payStatus != null">
|
|
AND om.pay_status = #{payStatus}
|
|
</if>
|
|
<if test="payStatusList != null">
|
|
AND om.pay_status in ( #{payStatusList} )
|
|
</if>
|
|
<if test="workerId != null and workerId > 0">
|
|
AND om.worker_id = #{workerId}
|
|
</if>
|
|
<if test="workerId == -1">
|
|
AND om.worker_id IS NULL
|
|
AND ( (om.order_mode in ('01','03','04'))
|
|
OR (om.order_mode = '02' and fm.pay_status = 1) )
|
|
</if>
|
|
<if test="sysPayStatus != null">
|
|
AND fm.pay_status = #{sysPayStatus}
|
|
</if>
|
|
<if test="orderMode != null and orderMode != ''">
|
|
AND om.order_mode = #{orderMode}
|
|
</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="exceptOrderStatus != null">
|
|
AND om.order_status != #{exceptOrderStatus}
|
|
</if>
|
|
<if test="createTimeStart != null">
|
|
AND om.create_time >= #{createTimeStart}
|
|
</if>
|
|
<if test="createTimeEnd != null">
|
|
AND om.create_time < #{createTimeEnd}
|
|
</if>
|
|
<if test="orderMasterIds != null and orderMasterIds != ''">
|
|
AND om.id in (${orderMasterIds})
|
|
</if>
|
|
<if test="orderStatuses != null and orderStatuses != ''">
|
|
AND om.order_status in (${orderStatuses})
|
|
</if>
|
|
<if test="hasDispatchedAll != null">
|
|
AND om.has_dispatched_all = #{hasDispatchedAll}
|
|
</if>
|
|
<if test="exceptOrderMasterIds != null and exceptOrderMasterIds.size > 0">
|
|
AND om.id not in
|
|
<foreach collection="exceptOrderMasterIds" item="id" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="timeout != null">
|
|
AND om.timeout_ = #{timeout}
|
|
</if>
|
|
</where>
|
|
order by om.create_time
|
|
<trim suffixOverrides=",">
|
|
<choose>
|
|
<when test="params.createTimeSort != null and params.createTimeSort != ''">
|
|
${params.createTimeSort}
|
|
</when>
|
|
<otherwise>
|
|
desc
|
|
</otherwise>
|
|
</choose>
|
|
</trim>
|
|
</select>
|
|
|
|
<select id="countOrderMasterList" parameterType="com.ghy.order.domain.OrderMaster" resultType="Long">
|
|
SELECT COUNT(*) FROM order_master om
|
|
<where>
|
|
<if test="isMonitoredOrder">
|
|
AND (om.all_self_assigned = 0 or om.all_self_assigned is null) AND om.order_status in (1,2,3,4)
|
|
</if>
|
|
<if test="deptId != null and deptId != 0">
|
|
AND om.dept_id = #{deptId}
|
|
</if>
|
|
<if test="code != null and code != ''">
|
|
AND om.code LIKE concat('%', #{code}, '%')
|
|
</if>
|
|
<if test="customerId != null and customerId != 0">
|
|
AND om.customer_id = #{customerId}
|
|
</if>
|
|
<if test="orderType != null">
|
|
AND om.order_type = #{orderType}
|
|
</if>
|
|
<if test="orderStatus != null">
|
|
AND om.order_status = #{orderStatus}
|
|
</if>
|
|
<if test="orderStatuses != null and orderStatuses != ''">
|
|
AND om.order_status in (${orderStatuses})
|
|
</if>
|
|
<if test="payType != null">
|
|
AND om.pay_type = #{payType}
|
|
</if>
|
|
<if test="payStatus != null">
|
|
AND om.pay_status = #{payStatus}
|
|
</if>
|
|
<if test="payStatusList != null">
|
|
AND om.pay_status in ( #{payStatusList} )
|
|
</if>
|
|
<if test="workerId != null and workerId > 0">
|
|
AND om.worker_id = #{workerId}
|
|
</if>
|
|
<if test="workerId == -1">
|
|
AND om.worker_id IS NULL
|
|
</if>
|
|
<if test="exceptOrderStatus != null">
|
|
AND om.order_status != #{exceptOrderStatus}
|
|
</if>
|
|
<if test="hasDispatchedAll != null">
|
|
AND om.has_dispatched_all = #{hasDispatchedAll}
|
|
</if>
|
|
<if test="orderMasterIds != null and orderMasterIds != ''">
|
|
AND om.id in (${orderMasterIds})
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectById" parameterType="long" resultMap="OrderMasterResult">
|
|
<include refid="selectOrderMaster"/>
|
|
<where>
|
|
<if test="orderMasterId != null and orderMasterId != 0">
|
|
AND id = #{orderMasterId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<delete id="deleteOrderMasterByIds" parameterType="Long">
|
|
DELETE FROM order_master WHERE id IN
|
|
<foreach collection="array" item="orderMasterId" open="(" separator="," close=")">
|
|
#{orderMasterId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<update id="updateOrderMaster" parameterType="com.ghy.order.domain.OrderMaster">
|
|
UPDATE order_master
|
|
<set>
|
|
<if test="code != null and code != ''">code = #{code},</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="payType != null">pay_type = #{payType},</if>
|
|
<if test="payStatus != null">pay_status = #{payStatus},</if>
|
|
<if test="workerId != null and workerId != 0">worker_id = #{workerId},</if>
|
|
<if test="workerId == -1">
|
|
worker_id = NULL,
|
|
</if>
|
|
<if test="payTime != null">pay_time = #{payTime},</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="useTimeNotRange">expect_time_end = null,</if>
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
<if test="allSelfAssigned != null">all_self_assigned = #{allSelfAssigned},</if>
|
|
<if test="resetAllSelfAssigned">all_self_assigned = null,</if>
|
|
<if test="hasDispatchedAll != null">has_dispatched_all = #{hasDispatchedAll},</if>
|
|
update_time = SYSDATE()
|
|
</set>
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<update id="updateStatus">
|
|
UPDATE order_master
|
|
SET order_status = #{orderStatus},
|
|
update_time = SYSDATE()
|
|
WHERE id = #{orderMasterId}
|
|
</update>
|
|
|
|
<update id="updatePayStatus">
|
|
UPDATE order_master
|
|
SET pay_status = #{payStatus},
|
|
update_time = SYSDATE()
|
|
WHERE id = #{orderMasterId}
|
|
</update>
|
|
|
|
<insert id="insertOrderMaster" parameterType="com.ghy.order.domain.OrderMaster" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO order_master(
|
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
|
<if test="code != null and code != ''">code,</if>
|
|
<if test="customerId != null and customerId != 0">customer_id,</if>
|
|
<if test="addressId != null and addressId != 0">address_id,</if>
|
|
<if test="goodsId != null and goodsId != 0">goods_id,</if>
|
|
<if test="orderType != null">order_type,</if>
|
|
<if test="orderMode != null">order_mode,</if>
|
|
<if test="orderStatus != null">order_status,</if>
|
|
<if test="payType != null">pay_type,</if>
|
|
<if test="payStatus != null">pay_status,</if>
|
|
<if test="workerId != null and workerId != 0">worker_id,</if>
|
|
<if test="payTime != null">pay_time,</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="createBy != null and createBy != ''">create_by,</if>
|
|
create_time
|
|
)VALUES(
|
|
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
|
<if test="code != null">#{code},</if>
|
|
<if test="customerId != null and customerId != 0">#{customerId},</if>
|
|
<if test="addressId != null and addressId != 0">#{addressId},</if>
|
|
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
|
|
<if test="orderType != null">#{orderType},</if>
|
|
<if test="orderMode != null">#{orderMode},</if>
|
|
<if test="orderStatus != null">#{orderStatus},</if>
|
|
<if test="payType != null">#{payType},</if>
|
|
<if test="payStatus != null">#{payStatus},</if>
|
|
<if test="workerId != null and workerId != 0">#{workerId},</if>
|
|
<if test="payTime != null">#{payTime},</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="createBy != null and createBy != ''">#{createBy},</if>
|
|
SYSDATE()
|
|
)
|
|
</insert>
|
|
|
|
<select id="checkOrderMasterCodeUnique" parameterType="String" resultMap="OrderMasterResult">
|
|
<include refid="selectOrderMaster"/>
|
|
WHERE `code` = #{orderMasterCode} LIMIT 1
|
|
</select>
|
|
|
|
<select id="selectByCode" parameterType="String" resultMap="OrderMasterResult">
|
|
<include refid="selectOrderMaster"/>
|
|
WHERE `code` = #{orderMasterCode}
|
|
</select>
|
|
|
|
<select id="selectByStatus" resultMap="OrderMasterResult">
|
|
<include refid="selectOrderMaster"/>
|
|
WHERE `order_status` IN
|
|
<foreach collection="list" item="orderStatus" open="(" separator="," close=")">
|
|
#{orderStatus}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="selectUnfinished" resultMap="OrderMasterResult">
|
|
<include refid="selectOrderMaster"/>
|
|
WHERE `order_status` < 5
|
|
</select>
|
|
|
|
|
|
<select id="selectByIds" resultMap="OrderMasterResult">
|
|
<include refid="selectOrderMaster"/>
|
|
<where>
|
|
AND id IN
|
|
<foreach item="item" index="orderMasterId" collection="orderMasterId" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</where>
|
|
</select>
|
|
|
|
<update id="updateTimeout">
|
|
UPDATE order_master
|
|
SET timeout_ = #{timeout}
|
|
<if test="timeoutFineTimes != null">,timeout_fine_times = #{timeoutFineTimes}</if>
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<update id="removeWorker">
|
|
UPDATE order_master
|
|
SET worker_id = NULL
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
</mapper>
|