javacodeadmin/ruoyi-system/src/main/resources/mapper/system/GoodsOrderMapper.xml

322 lines
17 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.ruoyi.system.mapper.GoodsOrderMapper">
<resultMap type="GoodsOrder" id="GoodsOrderResult">
<result property="id" column="id" />
<result property="type" column="type" />
<result property="mainOrderId" column="main_order_id" />
<result property="orderId" column="order_id" />
<result property="transactionId" column="transaction_id" />
<result property="uid" column="uid" />
<result property="couponId" column="coupon_id" />
<result property="productId" column="product_id" />
<result property="isforservice" column="isforservice" />
<result property="forserviceid" column="forserviceid" />
<result property="name" column="name" />
<result property="returnrealmoney" column="returnrealmoney" />
<result property="ismany" column="ismany" />
<result property="phone" column="phone" />
<result property="address" column="address" />
<result property="num" column="num" />
<result property="totalPrice" column="total_price" />
<result property="goodPrice" column="good_price" />
<result property="servicePrice" column="service_price" />
<result property="payPrice" column="pay_price" />
<result property="deduction" column="deduction" />
<result property="postage" column="postage" />
<result property="payTime" column="pay_time" />
<result property="status" column="status" />
<result property="deliveryId" column="delivery_id" />
<result property="deliveryNum" column="delivery_num" />
<result property="sendTime" column="send_time" />
<result property="mark" column="mark" />
<result property="addressId" column="address_id" />
<result property="sku" column="sku" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="deletedAt" column="deleted_at" />
<result property="returnshow" column="returnshow" />
<result property="returntime" column="returntime" />
<result property="returnmoney" column="returnmoney" />
<result property="returnfinshtime" column="returnfinshtime" />
<result property="returnstatus" column="returnstatus" />
<result property="returntype" column="returntype" />
<result property="returnreason" column="returnreason" />
<result property="returnfiledata" column="returnfiledata" />
<result property="returnlogistics" column="returnlogistics" />
<result property="returnlogisticscode" column="returnlogisticscode" />
<result property="returnjson" column="returnjson" />
<result property="isself" column="isself" />
<result property="shopadresssid" column="shopadresssid" />
</resultMap>
<sql id="selectGoodsOrderVo">
select id, type, main_order_id,returnshow,ismany,returnrealmoney, returnstatus,order_id,returntime,returnmoney,returnfinshtime,returntype,returnreason,returnfiledata,returnlogistics,returnlogisticscode,returnjson, transaction_id,forserviceid,isforservice,isself,coupon_id,shopadresssid, uid, product_id, name, phone, address, num, total_price, good_price, service_price, pay_price, deduction, postage, pay_time, status, delivery_id, delivery_num, send_time, mark, address_id, sku, created_at, updated_at, deleted_at from goods_order
</sql>
<select id="selectGoodsOrderList" parameterType="GoodsOrder" resultMap="GoodsOrderResult">
<include refid="selectGoodsOrderVo"/>
<where>
<if test="payPriceMin != null and payPriceMax != null">
and pay_price BETWEEN #{payPriceMin} AND #{payPriceMax}
</if>
<if test="startdate != null and enddate != null">
and created_at BETWEEN #{startdate} AND #{enddate}
</if>
<if test="paystartdate != null and payenddate != null">
and pay_time BETWEEN #{paystartdate} AND #{payenddate}
</if>
<if test="returnstatus != null and returnstatus != null">
and status in(20,21,22)
</if>
<if test="uid != null "> and uid = #{uid}</if>
<if test="status != null "> and status = #{status}</if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="orderId != null and orderId != ''"> and order_id like concat('%', #{orderId}, '%') </if>
<if test="mainOrderId != null and mainOrderId != ''"> and main_order_id like concat('%', #{mainOrderId}, '%') </if>
</where>
ORDER BY
CASE
WHEN (status = 2 OR returnstatus IN (1,4)) THEN 0
ELSE 1
END ASC,
updated_at DESC
</select>
<select id="selectGoodsOrdergrouBymAIDList" parameterType="GoodsOrder" resultMap="GoodsOrderResult">
<include refid="selectGoodsOrderVo"/>
<where>
<if test="payPriceMin != null and payPriceMax != null">
and pay_price BETWEEN #{payPriceMin} AND #{payPriceMax}
</if>
<if test="startdate != null and enddate != null">
and created_at BETWEEN #{startdate} AND #{enddate}
</if>
<if test="paystartdate != null and payenddate != null">
and pay_time BETWEEN #{paystartdate} AND #{payenddate}
</if>
<if test="returnstatus != null and returnstatus != null">
and status in(20,21,22)
</if>
<if test="uid != null "> and uid = #{uid}</if>
<if test="status != null "> and status = #{status}</if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="orderId != null and orderId != ''"> and order_id like concat('%', #{orderId}, '%') </if>
<if test="mainOrderId != null and mainOrderId != ''"> and main_order_id like concat('%', #{mainOrderId}, '%') </if>
</where>
GROUP BY
main_order_id
ORDER BY
CASE
WHEN (status = 2 OR returnstatus IN (1,4)) THEN 0
ELSE 1
END ASC,
updated_at DESC
</select>
<select id="selectGoodsOrderByorderId" parameterType="String" resultMap="GoodsOrderResult">
<include refid="selectGoodsOrderVo"/>
where order_id = #{orderId} limit 1
</select>
<select id="selectGoodsOrderById" parameterType="Long" resultMap="GoodsOrderResult">
<include refid="selectGoodsOrderVo"/>
where id = #{id}
</select>
<select id="selectCountGoodsOrderByUid" resultType="Integer">
select count(1) from goods_order where uid = #{uid} and status=#{status}
</select>
<select id="selectAllCountGoodsOrderByUid" resultType="Integer">
select count(1) from goods_order where uid = #{uid}
</select>
<select id="countGoodsOrderByUidAndStatus" resultType="Integer">
select count(1) from goods_order where uid = #{uid} and status = #{status}
</select>
<insert id="insertGoodsOrder" parameterType="GoodsOrder" useGeneratedKeys="true" keyProperty="id">
insert into goods_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="type != null">type,</if>
<if test="mainOrderId != null">main_order_id,</if>
<if test="orderId != null and orderId != ''">order_id,</if>
<if test="transactionId != null">transaction_id,</if>
<if test="uid != null">uid,</if>
<if test="couponId"> coupon_id,</if>
<if test="productId != null">product_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="address != null and address != ''">address,</if>
<if test="num != null">num,</if>
<if test="totalPrice != null">total_price,</if>
<if test="goodPrice != null">good_price,</if>
<if test="servicePrice != null">service_price,</if>
<if test="payPrice != null">pay_price,</if>
<if test="deduction != null">deduction,</if>
<if test="postage != null">postage,</if>
<if test="payTime != null">pay_time,</if>
<if test="status != null">status,</if>
<if test="deliveryId != null">delivery_id,</if>
<if test="deliveryNum != null">delivery_num,</if>
<if test="sendTime != null">send_time,</if>
<if test="mark != null">mark,</if>
<if test="addressId != null">address_id,</if>
<if test="sku != null">sku,</if>
<if test="isself != null">isself,</if>
<if test="shopadresssid != null">shopadresssid,</if>
<if test="isforservice != null">isforservice,</if>
<if test="forserviceid != null">forserviceid,</if>
<if test="returntype != null">returntype,</if>
<if test="returnreason != null">returnreason,</if>
<if test="returnfiledata != null">returnfiledata,</if>
<if test="returnlogistics != null">returnlogistics,</if>
<if test="returnlogisticscode != null">returnlogisticscode,</if>
<if test="returnjson != null">returnjson,</if>
<if test="returntime != null">returntime,</if>
<if test="returnmoney != null">returnmoney,</if>
<if test="returnfinshtime != null">returnfinshtime,</if>
<if test="returnstatus != null">returnstatus,</if>
<if test="returnshow != null">returnshow,</if>
<if test="returnrealmoney != null">returnrealmoney,</if>
<if test="ismany != null">ismany,</if>
created_at,
updated_at
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="type != null">#{type},</if>
<if test="mainOrderId != null">#{mainOrderId},</if>
<if test="orderId != null and orderId != ''">#{orderId},</if>
<if test="transactionId != null">#{transactionId},</if>
<if test="uid != null">#{uid},</if>
<if test="couponId != null">#{couponId},</if>
<if test="productId != null">#{productId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="address != null and address != ''">#{address},</if>
<if test="num != null">#{num},</if>
<if test="totalPrice != null">#{totalPrice},</if>
<if test="goodPrice != null">#{goodPrice},</if>
<if test="servicePrice != null">#{servicePrice},</if>
<if test="payPrice != null">#{payPrice},</if>
<if test="deduction != null">#{deduction},</if>
<if test="postage != null">#{postage},</if>
<if test="payTime != null">#{payTime},</if>
<if test="status != null">#{status},</if>
<if test="deliveryId != null">#{deliveryId},</if>
<if test="deliveryNum != null">#{deliveryNum},</if>
<if test="sendTime != null">#{sendTime},</if>
<if test="mark != null">#{mark},</if>
<if test="addressId != null">#{addressId},</if>
<if test="sku != null">#{sku},</if>
<if test="deletedAt != null">#{deletedAt},</if>
<if test="isself != null">#{isself},</if>
<if test="shopadresssid != null">#{shopadresssid},</if>
<if test="isforservice != null">#{isforservice},</if>
<if test="forserviceid != null">#{forserviceid},</if>
<if test="returntype != null">#{returntype},</if>
<if test="returnreason != null">#{returnreason},</if>
<if test="returnfiledata != null">#{returnfiledata},</if>
<if test="returnlogistics != null">#{returnlogistics},</if>
<if test="returnlogisticscode != null">#{returnlogisticscode},</if>
<if test="returnjson != null">#{returnjson},</if>
<if test="returntime != null">#{returntime},</if>
<if test="returnmoney != null">#{returnmoney},</if>
<if test="returnfinshtime != null">#{returnfinshtime},</if>
<if test="returnstatus != null">#{returnstatus},</if>
<if test="returnshow != null">#{returnshow},</if>
<if test="returnrealmoney != null">#{returnrealmoney},</if>
<if test="ismany != null">#{ismany},</if>
NOW(),
NOW()
</trim>
</insert>
<update id="updateGoodsOrder" parameterType="GoodsOrder">
update goods_order
<trim prefix="SET" suffixOverrides=",">
<if test="type != null">type = #{type},</if>
<if test="mainOrderId != null">main_order_id = #{mainOrderId},</if>
<if test="orderId != null and orderId != ''">order_id = #{orderId},</if>
<if test="transactionId != null">transaction_id = #{transactionId},</if>
<if test="uid != null">uid = #{uid},</if>
<if test="productId != null">product_id = #{productId},</if>
<if test="couponId != null">coupon_id = #{couponId},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="phone != null and phone != ''">phone = #{phone},</if>
<if test="address != null and address != ''">address = #{address},</if>
<if test="num != null">num = #{num},</if>
<if test="totalPrice != null">total_price = #{totalPrice},</if>
<if test="goodPrice != null">good_price = #{goodPrice},</if>
<if test="servicePrice != null">service_price = #{servicePrice},</if>
<if test="payPrice != null">pay_price = #{payPrice},</if>
<if test="deduction != null">deduction = #{deduction},</if>
<if test="postage != null">postage = #{postage},</if>
<if test="payTime != null">pay_time = #{payTime},</if>
<if test="status != null">status = #{status},</if>
<if test="deliveryId != null">delivery_id = #{deliveryId},</if>
<if test="deliveryNum != null">delivery_num = #{deliveryNum},</if>
<if test="sendTime != null">send_time = #{sendTime},</if>
<if test="mark != null">mark = #{mark},</if>
<if test="addressId != null">address_id = #{addressId},</if>
<if test="sku != null">sku = #{sku},</if>
<if test="deletedAt != null">deleted_at = #{deletedAt},</if>
<if test="isself != null">isself = #{isself},</if>
<if test="shopadresssid != null">shopadresssid = #{shopadresssid},</if>
<if test="isforservice != null">isforservice = #{isforservice},</if>
<if test="forserviceid != null">forserviceid = #{forserviceid},</if>
<if test="returntype != null">returntype = #{returntype},</if>
<if test="returnreason != null">returnreason = #{returnreason},</if>
<if test="returnfiledata != null">returnfiledata = #{returnfiledata},</if>
<if test="returnlogistics != null">returnlogistics = #{returnlogistics},</if>
<if test="returnlogisticscode != null">returnlogisticscode = #{returnlogisticscode},</if>
<if test="returnjson != null">returnjson = #{returnjson},</if>
<if test="returntime != null">returntime = #{returntime},</if>
<if test="returnmoney != null">returnmoney = #{returnmoney},</if>
<if test="returnfinshtime != null">returnfinshtime = #{returnfinshtime},</if>
<if test="returnstatus != null">returnstatus = #{returnstatus},</if>
<if test="returnshow != null">returnshow = #{returnshow},</if>
<if test="returnrealmoney != null">returnrealmoney = #{returnrealmoney},</if>
<if test="ismany != null">ismany = #{ismany},</if>
updated_at=NOW()
</trim>
where id = #{id}
</update>
<delete id="deleteGoodsOrderById" parameterType="Long">
delete from goods_order where id = #{id}
</delete>
<delete id="deleteGoodsOrderByIds" parameterType="String">
delete from goods_order where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>