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.OrderMasterMapper">
|
|
|
|
|
|
|
|
|
|
<resultMap id="OrderMasterResult" type="com.ghy.order.domain.OrderMaster">
|
|
|
|
|
<id property="id" column="id"/>
|
2022-05-24 22:26:26 +08:00
|
|
|
<result property="deptId" column="dept_id"/>
|
2022-04-25 17:06:55 +08:00
|
|
|
<result property="code" column="code"/>
|
|
|
|
|
<result property="customerId" column="customer_id"/>
|
2022-06-09 14:35:13 +08:00
|
|
|
<result property="addressId" column="address_id"/>
|
2022-04-25 17:06:55 +08:00
|
|
|
<result property="orderType" column="order_type"/>
|
|
|
|
|
<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"/>
|
2022-06-20 18:09:34 +08:00
|
|
|
<result property="expectTimeStart" column="expect_time_start"/>
|
|
|
|
|
<result property="expectTimeEnd" column="expect_time_end"/>
|
2022-04-25 17:06:55 +08:00
|
|
|
<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"/>
|
2022-07-04 22:35:02 +08:00
|
|
|
<result property="goodsId" column="goods_id"/>
|
2022-11-04 00:30:37 +08:00
|
|
|
<result property="allSelfAssigned" column="all_self_assigned"/>
|
2022-04-25 17:06:55 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectOrderMaster">
|
|
|
|
|
SELECT id,
|
2022-05-24 22:26:26 +08:00
|
|
|
dept_id,
|
2022-04-25 17:06:55 +08:00
|
|
|
code,
|
|
|
|
|
customer_id,
|
2022-06-09 14:35:13 +08:00
|
|
|
address_id,
|
2022-04-25 17:06:55 +08:00
|
|
|
order_type,
|
|
|
|
|
order_status,
|
|
|
|
|
pay_type,
|
|
|
|
|
pay_status,
|
|
|
|
|
worker_id,
|
|
|
|
|
pay_time,
|
|
|
|
|
rev_time,
|
2022-06-20 18:09:34 +08:00
|
|
|
expect_time_start,
|
|
|
|
|
expect_time_end,
|
2022-04-25 17:06:55 +08:00
|
|
|
create_by,
|
|
|
|
|
create_time,
|
2022-11-04 00:30:37 +08:00
|
|
|
remark,
|
|
|
|
|
all_self_assigned
|
2022-04-25 17:06:55 +08:00
|
|
|
FROM order_master
|
|
|
|
|
</sql>
|
2022-07-04 22:35:02 +08:00
|
|
|
<sql id="selectOrderMasterMoreInfo">
|
|
|
|
|
SELECT om.id,
|
|
|
|
|
om.dept_id,
|
|
|
|
|
om.code,
|
|
|
|
|
om.customer_id,
|
|
|
|
|
om.address_id,
|
|
|
|
|
om.order_type,
|
|
|
|
|
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.remark,
|
2022-11-04 00:30:37 +08:00
|
|
|
om.all_self_assigned,
|
2022-07-04 22:35:02 +08:00
|
|
|
om.goods_id
|
|
|
|
|
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
|
|
|
|
|
</sql>
|
2022-04-25 17:06:55 +08:00
|
|
|
|
|
|
|
|
<select id="selectOrderMasterList" parameterType="com.ghy.order.domain.OrderMaster" resultMap="OrderMasterResult">
|
2022-11-04 00:30:37 +08:00
|
|
|
<include refid="selectOrderMasterMoreInfo"></include>
|
2022-04-25 17:06:55 +08:00
|
|
|
<where>
|
2022-11-04 00:30:37 +08:00
|
|
|
<if test="isMonitoredOrder">
|
|
|
|
|
AND all_self_assigned = 0 AND om.order_status in (2,3,4,5)
|
2022-11-01 23:57:21 +08:00
|
|
|
</if>
|
2022-05-24 22:26:26 +08:00
|
|
|
<if test="deptId != null and deptId != 0">
|
2022-07-04 22:35:02 +08:00
|
|
|
AND om.dept_id = #{deptId}
|
2022-05-24 22:26:26 +08:00
|
|
|
</if>
|
2022-04-25 17:06:55 +08:00
|
|
|
<if test="code != null and code != ''">
|
2022-07-04 22:35:02 +08:00
|
|
|
AND om.code LIKE concat('%', #{code}, '%')
|
2022-04-25 17:06:55 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="customerId != null and customerId != 0">
|
2022-07-04 22:35:02 +08:00
|
|
|
AND om.customer_id = #{customerId}
|
2022-04-25 17:06:55 +08:00
|
|
|
</if>
|
2022-05-24 22:26:26 +08:00
|
|
|
<if test="orderType != null">
|
2022-07-04 22:35:02 +08:00
|
|
|
AND om.order_type = #{orderType}
|
2022-04-25 17:06:55 +08:00
|
|
|
</if>
|
2022-05-24 22:26:26 +08:00
|
|
|
<if test="orderStatus != null">
|
2022-07-04 22:35:02 +08:00
|
|
|
AND om.order_status = #{orderStatus}
|
2022-04-25 17:06:55 +08:00
|
|
|
</if>
|
2022-05-24 22:26:26 +08:00
|
|
|
<if test="payType != null">
|
2022-07-04 22:35:02 +08:00
|
|
|
AND om.pay_type = #{payType}
|
2022-04-25 17:06:55 +08:00
|
|
|
</if>
|
2022-05-24 22:26:26 +08:00
|
|
|
<if test="payStatus != null">
|
2022-07-04 22:35:02 +08:00
|
|
|
AND om.pay_status = #{payStatus}
|
2022-04-25 17:06:55 +08:00
|
|
|
</if>
|
2022-10-17 00:07:02 +08:00
|
|
|
<if test="payStatusList != null">
|
|
|
|
|
AND om.pay_status in ( #{payStatusList} )
|
|
|
|
|
</if>
|
2022-06-28 18:05:41 +08:00
|
|
|
<if test="workerId != null and workerId > 0">
|
2022-07-04 22:35:02 +08:00
|
|
|
AND om.worker_id = #{workerId}
|
2022-04-25 17:06:55 +08:00
|
|
|
</if>
|
2022-06-28 18:05:41 +08:00
|
|
|
<if test="workerId == -1">
|
2022-07-04 22:35:02 +08:00
|
|
|
AND om.worker_id IS NULL
|
|
|
|
|
</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-06-28 18:05:41 +08:00
|
|
|
</if>
|
2022-07-07 15:32:11 +08:00
|
|
|
<if test="exceptOrderStatus != null">
|
|
|
|
|
AND om.order_status != #{exceptOrderStatus}
|
|
|
|
|
</if>
|
2022-08-16 23:00:46 +08:00
|
|
|
<if test="createTimeStart != null">
|
|
|
|
|
AND om.create_time >= #{createTimeStart}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="createTimeEnd != null">
|
|
|
|
|
AND om.create_time < #{createTimeEnd}
|
|
|
|
|
</if>
|
2022-10-06 18:29:47 +08:00
|
|
|
<if test="orderMasterIds != null and orderMasterIds != ''">
|
2022-10-06 17:00:10 +08:00
|
|
|
AND om.id in (${orderMasterIds})
|
2022-09-25 22:46:05 +08:00
|
|
|
</if>
|
2022-10-06 18:29:47 +08:00
|
|
|
<if test="orderStatuses != null and orderStatuses != ''">
|
|
|
|
|
AND om.order_status in (${orderStatuses})
|
|
|
|
|
</if>
|
2022-04-25 17:06:55 +08:00
|
|
|
</where>
|
2022-07-05 14:09:52 +08:00
|
|
|
order by om.create_time
|
2022-07-04 22:35:02 +08:00
|
|
|
<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>
|
|
|
|
|
|
2022-07-13 11:11:04 +08:00
|
|
|
<select id="countOrderMasterList" parameterType="com.ghy.order.domain.OrderMaster" resultType="Long">
|
2022-11-04 00:30:37 +08:00
|
|
|
SELECT COUNT(*) FROM order_master om
|
2022-07-13 11:11:04 +08:00
|
|
|
<where>
|
2022-11-04 00:30:37 +08:00
|
|
|
<if test="isMonitoredOrder">
|
|
|
|
|
AND all_self_assigned = 0 AND om.order_status in (2,3,4,5)
|
2022-11-01 23:57:21 +08:00
|
|
|
</if>
|
2022-07-13 11:11:04 +08:00
|
|
|
<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>
|
2022-10-31 00:07:07 +08:00
|
|
|
<if test="orderStatuses != null and orderStatuses != ''">
|
|
|
|
|
AND om.order_status in (${orderStatuses})
|
|
|
|
|
</if>
|
2022-07-13 11:11:04 +08:00
|
|
|
<if test="payType != null">
|
|
|
|
|
AND om.pay_type = #{payType}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="payStatus != null">
|
|
|
|
|
AND om.pay_status = #{payStatus}
|
|
|
|
|
</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>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-04-25 17:06:55 +08:00
|
|
|
<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>
|
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="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>
|
2022-09-12 14:48:30 +08:00
|
|
|
<if test="workerId == -1">
|
|
|
|
|
worker_id = NULL,
|
|
|
|
|
</if>
|
2022-05-24 22:26:26 +08:00
|
|
|
<if test="payTime != null">pay_time = #{payTime},</if>
|
|
|
|
|
<if test="revTime != null">rev_time = #{revTime},</if>
|
2022-06-20 18:09:34 +08:00
|
|
|
<if test="expectTimeStart != null">expect_time_start = #{expectTimeStart},</if>
|
|
|
|
|
<if test="expectTimeEnd != null">expect_time_end = #{expectTimeEnd},</if>
|
2022-10-27 00:54:15 +08:00
|
|
|
<if test="useTimeNotRange">expect_time_end = null,</if>
|
2022-04-25 17:06:55 +08:00
|
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
2022-11-04 00:30:37 +08:00
|
|
|
<if test="allSelfAssigned != null">all_self_assigned = #{allSelfAssigned},</if>
|
2022-04-25 17:06:55 +08:00
|
|
|
update_time = SYSDATE()
|
|
|
|
|
</set>
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
2022-07-20 15:10:01 +08:00
|
|
|
<update id="updateStatus">
|
|
|
|
|
UPDATE order_master
|
|
|
|
|
SET order_status = #{orderStatus},
|
|
|
|
|
update_time = SYSDATE()
|
|
|
|
|
WHERE id = #{orderMasterId}
|
|
|
|
|
</update>
|
|
|
|
|
|
2022-04-25 17:06:55 +08:00
|
|
|
<insert id="insertOrderMaster" parameterType="com.ghy.order.domain.OrderMaster" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
INSERT INTO order_master(
|
2022-05-24 22:26:26 +08:00
|
|
|
<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>
|
2022-06-09 14:35:13 +08:00
|
|
|
<if test="addressId != null and addressId != 0">address_id,</if>
|
2022-07-04 22:35:02 +08:00
|
|
|
<if test="goodsId != null and goodsId != 0">goods_id,</if>
|
2022-05-24 22:26:26 +08:00
|
|
|
<if test="orderType != null">order_type,</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>
|
2022-06-30 17:48:25 +08:00
|
|
|
<if test="remark != null">remark,</if>
|
2022-06-20 18:09:34 +08:00
|
|
|
<if test="expectTimeStart != null">expect_time_start,</if>
|
|
|
|
|
<if test="expectTimeEnd != null">expect_time_end,</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="deptId != null and deptId != 0">#{deptId},</if>
|
2022-05-12 14:30:06 +08:00
|
|
|
<if test="code != null">#{code},</if>
|
2022-05-24 22:26:26 +08:00
|
|
|
<if test="customerId != null and customerId != 0">#{customerId},</if>
|
2022-06-20 10:07:44 +08:00
|
|
|
<if test="addressId != null and addressId != 0">#{addressId},</if>
|
2022-07-04 22:35:02 +08:00
|
|
|
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
|
2022-05-24 22:26:26 +08:00
|
|
|
<if test="orderType != null">#{orderType},</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>
|
2022-06-30 17:48:25 +08:00
|
|
|
<if test="remark != null">#{remark},</if>
|
2022-06-20 18:09:34 +08:00
|
|
|
<if test="expectTimeStart != null">#{expectTimeStart},</if>
|
|
|
|
|
<if test="expectTimeEnd != null">#{expectTimeEnd},</if>
|
2022-04-25 17:06:55 +08:00
|
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
|
|
|
SYSDATE()
|
|
|
|
|
)
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<select id="checkOrderMasterCodeUnique" parameterType="String" resultMap="OrderMasterResult">
|
|
|
|
|
<include refid="selectOrderMaster"/>
|
2022-08-24 23:47:51 +08:00
|
|
|
WHERE `code` = #{orderMasterCode} LIMIT 1
|
2022-04-25 17:06:55 +08:00
|
|
|
</select>
|
|
|
|
|
|
2022-05-29 17:52:49 +08:00
|
|
|
<select id="selectByCode" parameterType="String" resultMap="OrderMasterResult">
|
2022-05-11 20:10:00 +08:00
|
|
|
<include refid="selectOrderMaster"/>
|
|
|
|
|
WHERE `code` = #{orderMasterCode}
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-08-24 23:47:51 +08:00
|
|
|
<select id="selectByStatus" resultMap="OrderMasterResult">
|
2022-08-04 19:35:14 +08:00
|
|
|
<include refid="selectOrderMaster"/>
|
|
|
|
|
WHERE `order_status` IN
|
|
|
|
|
<foreach collection="list" item="orderStatus" open="(" separator="," close=")">
|
|
|
|
|
#{orderStatus}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-08-24 23:47:51 +08:00
|
|
|
<select id="selectUnfinished" resultMap="OrderMasterResult">
|
|
|
|
|
<include refid="selectOrderMaster"/>
|
|
|
|
|
WHERE `order_status` < 5
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-05-12 14:30:06 +08:00
|
|
|
</mapper>
|