优惠券重写
This commit is contained in:
@@ -4,11 +4,13 @@
|
||||
|
||||
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord" id="TbActivateOutRecordMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
||||
<result property="orderId" column="order_id" jdbcType="VARCHAR"/>
|
||||
<result property="giveId" column="give_id" jdbcType="INTEGER"/>
|
||||
<result property="proId" column="pro_id" jdbcType="INTEGER"/>
|
||||
<result property="vipUserId" column="vip_user_id" jdbcType="INTEGER"/>
|
||||
<result property="type" column="type" jdbcType="INTEGER"/>
|
||||
<result property="useNum" column="use_num" jdbcType="INTEGER"/>
|
||||
<result property="refNum" column="ref_num" jdbcType="INTEGER"/>
|
||||
<result property="orderId" column="order_id" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="status" jdbcType="VARCHAR"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
@@ -16,7 +18,7 @@
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
, give_id, pro_id, use_num, ref_num, order_id,status, create_time, update_time </sql>
|
||||
, shop_id, order_id, give_id, vip_user_id, type, use_num, ref_num, status, create_time, update_time </sql>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="TbActivateOutRecordMap">
|
||||
@@ -27,24 +29,28 @@
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryVipPro" resultType="com.chaozhanggui.system.cashierservice.entity.vo.UserCouponVo">
|
||||
SELECT tb_product.NAME AS detail,
|
||||
tb_activate_out_record.order_id as orderId,
|
||||
1 AS status,
|
||||
tb_activate_out_record.use_num AS num,
|
||||
<choose>
|
||||
<when test="shopName != null and shopName != ''">#{shopName}</when>
|
||||
<otherwise>''</otherwise>
|
||||
</choose>
|
||||
AS shopName,
|
||||
2 AS type
|
||||
FROM tb_activate_out_record
|
||||
LEFT JOIN tb_product ON tb_activate_out_record.pro_id = tb_product.id
|
||||
LEFT JOIN tb_activate_in_record ON tb_activate_in_record.id = tb_activate_out_record.give_id
|
||||
WHERE vip_user_id = #{vipUserId}
|
||||
AND tb_activate_in_record.shop_id = #{shopId}
|
||||
AND tb_activate_out_record.STATUS = 'closed'
|
||||
<select id="queryByVipIdAndShopId" resultType="com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo">
|
||||
SELECT
|
||||
CASE
|
||||
WHEN outRecord.type = 1 THEN inRecord.name
|
||||
WHEN outRecord.type = 2 THEN pro.NAME
|
||||
END AS `name`,
|
||||
outRecord.type,
|
||||
outRecord.use_num-outRecord.ref_num as num
|
||||
FROM
|
||||
tb_activate_out_record outRecord
|
||||
INNER JOIN tb_activate_in_record inRecord
|
||||
on outRecord.give_id = inRecord.id
|
||||
and inRecord.shop_id = #{shopId}
|
||||
and inRecord.vip_user_id = #{vipUserId}
|
||||
LEFT JOIN tb_product pro
|
||||
ON inRecord.pro_id = pro.id and pro.shop_id = #{shopId}
|
||||
WHERE
|
||||
outRecord.vip_user_id = #{vipUserId}
|
||||
and outRecord.shop_id = #{shopId}
|
||||
and outRecord.status = 'closed'
|
||||
and outRecord.use_num-outRecord.ref_num >0
|
||||
order by outRecord.create_time desc
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
@@ -57,11 +63,20 @@
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
and shop_id = #{shopId}
|
||||
</if>
|
||||
<if test="orderId != null and orderId != ''">
|
||||
and order_id = #{orderId}
|
||||
</if>
|
||||
<if test="giveId != null">
|
||||
and give_id = #{giveId}
|
||||
</if>
|
||||
<if test="proId != null">
|
||||
and pro_id = #{proId}
|
||||
<if test="vipUserId != null">
|
||||
and vip_user_id = #{vipUserId}
|
||||
</if>
|
||||
<if test="type != null">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="useNum != null">
|
||||
and use_num = #{useNum}
|
||||
@@ -69,9 +84,6 @@
|
||||
<if test="refNum != null">
|
||||
and ref_num = #{refNum}
|
||||
</if>
|
||||
<if test="orderId != null and orderId != ''">
|
||||
and order_id = #{orderId}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and status = #{status}
|
||||
</if>
|
||||
@@ -87,16 +99,19 @@
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_activate_out_record(give_id, pro_id, use_num, ref_num, order_id, status, create_time, update_time)
|
||||
values (#{giveId}, #{proId}, #{useNum}, #{refNum}, #{orderId}, #{status} #{createTime}, #{updateTime})
|
||||
insert into tb_activate_out_record(shop_id, order_id, give_id, vip_user_id, type, use_num, ref_num, status,
|
||||
create_time, update_time)
|
||||
values (#{shopId}, #{orderId}, #{giveId}, #{vipUserId}, #{type}, #{useNum}, #{refNum}, #{status}, #{createTime},
|
||||
#{updateTime})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_activate_out_record(give_id, pro_id, use_num, ref_num, order_id, status, create_time, update_time)
|
||||
insert into tb_activate_out_record(shop_id, order_id, give_id, vip_user_id, type, use_num, ref_num, status,
|
||||
create_time, update_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.giveId}, #{entity.proId}, #{entity.useNum}, #{entity.refNum}, #{entity.orderId},
|
||||
#{entity.status}, #{entity.createTime}, #{entity.updateTime})
|
||||
(#{entity.shopId}, #{entity.orderId}, #{entity.giveId}, #{entity.vipUserId}, #{entity.type},
|
||||
#{entity.useNum}, #{entity.refNum}, #{entity.status}, #{entity.createTime}, #{entity.updateTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
@@ -104,11 +119,20 @@
|
||||
<update id="update">
|
||||
update tb_activate_out_record
|
||||
<set>
|
||||
<if test="shopId != null">
|
||||
shop_id = #{shopId},
|
||||
</if>
|
||||
<if test="orderId != null and orderId != ''">
|
||||
order_id = #{orderId},
|
||||
</if>
|
||||
<if test="giveId != null">
|
||||
give_id = #{giveId},
|
||||
</if>
|
||||
<if test="proId != null">
|
||||
pro_id = #{proId},
|
||||
<if test="vipUserId != null">
|
||||
vip_user_id = #{vipUserId},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type = #{type},
|
||||
</if>
|
||||
<if test="useNum != null">
|
||||
use_num = #{useNum},
|
||||
@@ -116,9 +140,6 @@
|
||||
<if test="refNum != null">
|
||||
ref_num = #{refNum},
|
||||
</if>
|
||||
<if test="orderId != null and orderId != ''">
|
||||
order_id = #{orderId},
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
status = #{status},
|
||||
</if>
|
||||
@@ -131,13 +152,6 @@
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateByOrderIdAndStatus">
|
||||
update tb_activate_out_record
|
||||
set
|
||||
status = 'closed'
|
||||
where order_id = #{orderId}
|
||||
</update>
|
||||
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
|
||||
Reference in New Issue
Block a user