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

154 lines
6.5 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="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="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="selectOrderMaster">
SELECT id,
dept_id,
code,
customer_id,
address_id,
order_type,
order_status,
pay_type,
pay_status,
worker_id,
pay_time,
rev_time,
create_by,
create_time,
remark
FROM order_master
</sql>
<select id="selectOrderMasterList" parameterType="com.ghy.order.domain.OrderMaster" resultMap="OrderMasterResult">
<include refid="selectOrderMaster"/>
<where>
<if test="deptId != null and deptId != 0">
AND dept_id = #{deptId}
</if>
<if test="code != null and code != ''">
AND `code` LIKE concat('%', #{code}, '%')
</if>
<if test="customerId != null and customerId != 0">
AND customer_id = #{customerId}
</if>
<if test="orderType != null">
AND order_type = #{orderType}
</if>
<if test="orderStatus != null">
AND order_status = #{orderStatus}
</if>
<if test="payType != null">
AND pay_type = #{payType}
</if>
<if test="payStatus != null">
AND pay_status = #{payStatus}
</if>
<if test="workerId != null and workerId != 0">
AND worker_id = #{workerId}
</if>
</where>
order by create_time desc
</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="payTime != null">pay_time = #{payTime},</if>
<if test="revTime != null">rev_time = #{revTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = SYSDATE()
</set>
WHERE id = #{id}
</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="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>
<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="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>
<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>
</mapper>