支付
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,170 @@
|
||||
<?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.zhwl.coupon.mapper.ZdyCouponItemMapper">
|
||||
|
||||
<resultMap type="ZdyCouponItem" id="ZdyCouponItemResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="couponId" column="coupon_id"/>
|
||||
<result property="storeCategory" column="store_category"/>
|
||||
<result property="storeId" column="store_id"/>
|
||||
<result property="storeName" column="store_name"/>
|
||||
<result property="goodsId" column="goods_id"/>
|
||||
<result property="goodsName" column="goods_name"/>
|
||||
<result property="goodsPrice" column="goods_price"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectZdyCouponItemVo">
|
||||
select id,
|
||||
coupon_id,
|
||||
store_category,
|
||||
store_id,
|
||||
store_name,
|
||||
goods_id,
|
||||
goods_name,
|
||||
goods_price,
|
||||
create_time,
|
||||
create_by
|
||||
from zdy_coupon_item
|
||||
</sql>
|
||||
|
||||
<select id="selectZdyCouponItemList" parameterType="ZdyCouponItem" resultMap="ZdyCouponItemResult">
|
||||
<include refid="selectZdyCouponItemVo"/>
|
||||
<where>
|
||||
<if test="couponId != null ">
|
||||
and coupon_id = #{couponId}
|
||||
</if>
|
||||
<if test="storeCategory != null and storeCategory != ''">
|
||||
and store_category = #{storeCategory}
|
||||
</if>
|
||||
<if test="storeId != null ">
|
||||
and store_id = #{storeId}
|
||||
</if>
|
||||
<if test="storeName != null and storeName != ''">
|
||||
and store_name like concat('%', #{storeName}, '%')
|
||||
</if>
|
||||
<if test="goodsId != null ">
|
||||
and goods_id = #{goodsId}
|
||||
</if>
|
||||
<if test="goodsName != null and goodsName != ''">
|
||||
and goods_name like concat('%', #{goodsName}, '%')
|
||||
</if>
|
||||
<if test="goodsPrice != null ">
|
||||
and goods_price = #{goodsPrice}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectZdyCouponItemById" parameterType="Long"
|
||||
resultMap="ZdyCouponItemResult">
|
||||
<include refid="selectZdyCouponItemVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectItemListByCouponId" resultMap="ZdyCouponItemResult">
|
||||
<include refid="selectZdyCouponItemVo"/>
|
||||
where coupon_id = #{couponId}
|
||||
</select>
|
||||
|
||||
<insert id="insertZdyCouponItem" parameterType="ZdyCouponItem" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into zdy_coupon_item
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,
|
||||
</if>
|
||||
<if test="couponId != null">coupon_id,
|
||||
</if>
|
||||
<if test="storeCategory != null">store_category,
|
||||
</if>
|
||||
<if test="storeId != null">store_id,
|
||||
</if>
|
||||
<if test="storeName != null">store_name,
|
||||
</if>
|
||||
<if test="goodsId != null">goods_id,
|
||||
</if>
|
||||
<if test="goodsName != null">goods_name,
|
||||
</if>
|
||||
<if test="goodsPrice != null">goods_price,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
</if>
|
||||
<if test="createBy != null">create_by,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},
|
||||
</if>
|
||||
<if test="couponId != null">#{couponId},
|
||||
</if>
|
||||
<if test="storeCategory != null">#{storeCategory},
|
||||
</if>
|
||||
<if test="storeId != null">#{storeId},
|
||||
</if>
|
||||
<if test="storeName != null">#{storeName},
|
||||
</if>
|
||||
<if test="goodsId != null">#{goodsId},
|
||||
</if>
|
||||
<if test="goodsName != null">#{goodsName},
|
||||
</if>
|
||||
<if test="goodsPrice != null">#{goodsPrice},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">#{createBy},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateZdyCouponItem" parameterType="ZdyCouponItem">
|
||||
update zdy_coupon_item
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="couponId != null">coupon_id =
|
||||
#{couponId},
|
||||
</if>
|
||||
<if test="storeCategory != null">store_category =
|
||||
#{storeCategory},
|
||||
</if>
|
||||
<if test="storeId != null">store_id =
|
||||
#{storeId},
|
||||
</if>
|
||||
<if test="storeName != null">store_name =
|
||||
#{storeName},
|
||||
</if>
|
||||
<if test="goodsId != null">goods_id =
|
||||
#{goodsId},
|
||||
</if>
|
||||
<if test="goodsName != null">goods_name =
|
||||
#{goodsName},
|
||||
</if>
|
||||
<if test="goodsPrice != null">goods_price =
|
||||
#{goodsPrice},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">create_by =
|
||||
#{createBy},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteZdyCouponItemById" parameterType="Long">
|
||||
delete
|
||||
from zdy_coupon_item
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteZdyCouponItemByIds" parameterType="String">
|
||||
delete from zdy_coupon_item where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteZdyCouponItemByCouponId">
|
||||
delete
|
||||
from zdy_coupon_item
|
||||
where coupon_id = #{couponId}
|
||||
</delete>
|
||||
</mapper>
|
@@ -0,0 +1,452 @@
|
||||
<?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.zhwl.coupon.mapper.ZdyCouponMapper">
|
||||
|
||||
<resultMap type="ZdyCoupon" id="ZdyCouponResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="storeCategory" column="store_category"/>
|
||||
<result property="storeId" column="store_id"/>
|
||||
<result property="storeName" column="store_name"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="method" column="method"/>
|
||||
<result property="spendAmount" column="spend_amount"/>
|
||||
<result property="couponAmount" column="coupon_amount"/>
|
||||
<result property="startSaleTime" column="start_sale_time"/>
|
||||
<result property="endSaleTime" column="end_sale_time"/>
|
||||
<result property="startUseTime" column="start_use_time"/>
|
||||
<result property="endUseTime" column="end_use_time"/>
|
||||
<result property="inventory" column="inventory"/>
|
||||
<result property="stock" column="stock"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="userClaimLimit" column="user_claim_limit"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="descr" column="descr"/>
|
||||
<result property="memo" column="memo"/>
|
||||
<result property="applicability" column="applicability"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectZdyCouponVo">
|
||||
select id,
|
||||
type,
|
||||
store_category,
|
||||
store_id,
|
||||
store_name,
|
||||
name,
|
||||
method,
|
||||
spend_amount,
|
||||
coupon_amount,
|
||||
start_sale_time,
|
||||
end_sale_time,
|
||||
start_use_time,
|
||||
end_use_time,
|
||||
inventory,
|
||||
stock,
|
||||
status,
|
||||
user_claim_limit,
|
||||
create_time,
|
||||
create_by,
|
||||
update_time,
|
||||
update_by,
|
||||
descr,
|
||||
memo,
|
||||
applicability
|
||||
from zdy_coupon
|
||||
</sql>
|
||||
|
||||
<select id="selectZdyCouponList" parameterType="ZdyCoupon" resultMap="ZdyCouponResult">
|
||||
<include refid="selectZdyCouponVo"/>
|
||||
<where>
|
||||
<if test="type != null and type != ''">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="storeCategory != null and storeCategory != ''">
|
||||
and store_category = #{storeCategory}
|
||||
</if>
|
||||
<if test="storeId != null ">
|
||||
and store_id = #{storeId}
|
||||
</if>
|
||||
<if test="storeName != null ">
|
||||
and store_name = #{storeName}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="method != null and method != ''">
|
||||
and method = #{method}
|
||||
</if>
|
||||
<if test="spendAmount != null ">
|
||||
and spend_amount = #{spendAmount}
|
||||
</if>
|
||||
<if test="couponAmount != null ">
|
||||
and coupon_amount = #{couponAmount}
|
||||
</if>
|
||||
<if test="startSaleTime != null ">
|
||||
and start_sale_time = #{startSaleTime}
|
||||
</if>
|
||||
<if test="endSaleTime != null ">
|
||||
and end_sale_time = #{endSaleTime}
|
||||
</if>
|
||||
<if test="startUseTime != null ">
|
||||
and start_use_time = #{startUseTime}
|
||||
</if>
|
||||
<if test="endUseTime != null ">
|
||||
and end_use_time = #{endUseTime}
|
||||
</if>
|
||||
<if test="inventory != null ">
|
||||
and inventory = #{inventory}
|
||||
</if>
|
||||
<if test="stock != null ">
|
||||
and stock = #{stock}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="userClaimLimit != null ">
|
||||
and user_claim_limit = #{userClaimLimit}
|
||||
</if>
|
||||
<if test="descr != null and descr != ''">
|
||||
and descr = #{descr}
|
||||
</if>
|
||||
<if test="memo != null and memo != ''">
|
||||
and memo = #{memo}
|
||||
</if>
|
||||
<if test="applicability != null and applicability != ''">
|
||||
and applicability = #{applicability}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectZdyCouponById" parameterType="Long"
|
||||
resultMap="ZdyCouponResult">
|
||||
<include refid="selectZdyCouponVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<resultMap id="ZdyCouponVoResult" type="zdyCouponVo" extends="ZdyCouponResult">
|
||||
<result property="canGetNum" column="canGetNum"/>
|
||||
</resultMap>
|
||||
<select id="selectRedeemableList" resultMap="ZdyCouponVoResult">
|
||||
SELECT
|
||||
zc.*,
|
||||
(zc.user_claim_limit - IFNULL(cur.used_count, 0)) AS canGetNum
|
||||
FROM
|
||||
zdy_coupon zc
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
coupon_id,
|
||||
COUNT(1) AS used_count
|
||||
FROM
|
||||
zdy_coupon_use_record
|
||||
WHERE
|
||||
user_id = #{userId}
|
||||
GROUP BY
|
||||
coupon_id
|
||||
) cur ON zc.id = cur.coupon_id
|
||||
WHERE
|
||||
zc.end_sale_time >= #{currentDate} and #{currentDate} >= zc.start_sale_time
|
||||
AND zc.stock > 0
|
||||
AND zc.status IN ('1', '2')
|
||||
AND zc.user_claim_limit > IFNULL(cur.used_count, 0);
|
||||
</select>
|
||||
<select id="selectRedeemedList" resultMap="ZdyCouponResult">
|
||||
SELECT
|
||||
cur.id as id,
|
||||
cur.status,
|
||||
cp.type,
|
||||
cp.store_category,
|
||||
cp.store_id,
|
||||
cp.store_name,
|
||||
cp.name,
|
||||
cp.method,
|
||||
cp.spend_amount,
|
||||
cp.coupon_amount,
|
||||
cp.start_sale_time,
|
||||
cp.end_sale_time,
|
||||
cp.start_use_time,
|
||||
cp.end_use_time,
|
||||
cp.inventory,
|
||||
cp.stock,
|
||||
cp.user_claim_limit,
|
||||
cp.create_time,
|
||||
cp.create_by,
|
||||
cp.update_time,
|
||||
cp.update_by,
|
||||
cp.descr,
|
||||
cp.memo,
|
||||
cp.applicability
|
||||
FROM
|
||||
zdy_coupon cp
|
||||
LEFT JOIN zdy_coupon_use_record cur ON cp.id = cur.coupon_id
|
||||
WHERE
|
||||
cur.user_id =#{userId}
|
||||
<if test="status != null and status!=''">
|
||||
and cur.status = #{status}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
<resultMap id="UsableCouponResult" type="ZdyRedeemedCouponVo" extends="ZdyCouponResult">
|
||||
<result property="goodsIds" column="goodsIds"/>
|
||||
<result property="storeIds" column="storeIds"/>
|
||||
</resultMap>
|
||||
<select id="selectUsableList" resultMap="UsableCouponResult">
|
||||
SELECT
|
||||
cur.id AS id,
|
||||
cur.status,
|
||||
cp.type,
|
||||
cp.store_category,
|
||||
cp.store_id,
|
||||
cp.store_name,
|
||||
cp.name,
|
||||
cp.method,
|
||||
cp.spend_amount,
|
||||
cp.coupon_amount,
|
||||
cp.start_sale_time,
|
||||
cp.end_sale_time,
|
||||
cp.start_use_time,
|
||||
cp.end_use_time,
|
||||
cp.inventory,
|
||||
cp.stock,
|
||||
cp.user_claim_limit,
|
||||
cp.create_time,
|
||||
cp.create_by,
|
||||
cp.update_time,
|
||||
cp.update_by,
|
||||
cp.descr,
|
||||
cp.memo,
|
||||
cp.applicability,
|
||||
GROUP_CONCAT( DISTINCT ci.goods_id ) AS goodsIds,
|
||||
GROUP_CONCAT( DISTINCT ci.store_id ) AS storeIds
|
||||
FROM
|
||||
zdy_coupon_use_record cur
|
||||
LEFT JOIN zdy_coupon cp ON cp.id = cur.coupon_id
|
||||
LEFT JOIN zdy_coupon_item AS ci ON ci.coupon_id = cp.id
|
||||
WHERE cur.STATUS = 2 and #{currentDate} BETWEEN cur.start_use_time and cur.end_use_time and cur.user_id = #{userId}
|
||||
AND ( ISNULL( cp.store_category ) OR cp.store_category = #{storeCategory} )
|
||||
AND ( ISNULL( cp.store_id ) OR cp.store_id in
|
||||
<foreach collection="storeIds" item="storeId" open="(" close=")" separator=",">
|
||||
#{storeId}
|
||||
</foreach>)
|
||||
AND ( cp.applicability = 1 OR EXISTS (
|
||||
SELECT 1 FROM zdy_coupon_item ci WHERE ci.coupon_id = cur.coupon_id
|
||||
AND ( ci.goods_id in
|
||||
<foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
|
||||
#{goodsId}
|
||||
</foreach>
|
||||
OR ( ISNULL(ci.goods_id) AND ci.store_id in
|
||||
<foreach collection="storeIds" item="storeId" open="(" close=")" separator=",">
|
||||
#{storeId}
|
||||
</foreach>)
|
||||
)
|
||||
)
|
||||
)
|
||||
GROUP BY cur.id
|
||||
</select>
|
||||
<select id="selectZdyCouponByIdForUpdate" parameterType="Long"
|
||||
resultMap="ZdyCouponResult">
|
||||
<include refid="selectZdyCouponVo"/>
|
||||
where id = #{id} for update
|
||||
</select>
|
||||
|
||||
<insert id="insertZdyCoupon" parameterType="ZdyCouponAllDto" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into zdy_coupon
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="type != null">type,
|
||||
</if>
|
||||
<if test="storeCategory != null">store_category,
|
||||
</if>
|
||||
<if test="storeId != null">store_id,
|
||||
</if>
|
||||
<if test="storeName != null">store_name,
|
||||
</if>
|
||||
<if test="name != null">name,
|
||||
</if>
|
||||
<if test="method != null">method,
|
||||
</if>
|
||||
<if test="spendAmount != null">spend_amount,
|
||||
</if>
|
||||
<if test="couponAmount != null">coupon_amount,
|
||||
</if>
|
||||
<if test="startSaleTime != null">start_sale_time,
|
||||
</if>
|
||||
<if test="endSaleTime != null">end_sale_time,
|
||||
</if>
|
||||
<if test="startUseTime != null">start_use_time,
|
||||
</if>
|
||||
<if test="endUseTime != null">end_use_time,
|
||||
</if>
|
||||
<if test="inventory != null">inventory,
|
||||
</if>
|
||||
<if test="stock != null">stock,
|
||||
</if>
|
||||
<if test="status != null">status,
|
||||
</if>
|
||||
<if test="userClaimLimit != null">user_claim_limit,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
</if>
|
||||
<if test="createBy != null">create_by,
|
||||
</if>
|
||||
<if test="updateTime != null">update_time,
|
||||
</if>
|
||||
<if test="updateBy != null">update_by,
|
||||
</if>
|
||||
<if test="descr != null">descr,
|
||||
</if>
|
||||
<if test="memo != null">memo,
|
||||
</if>
|
||||
<if test="applicability != null">applicability,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="type != null">#{type},
|
||||
</if>
|
||||
<if test="storeCategory != null">#{storeCategory},
|
||||
</if>
|
||||
<if test="storeId != null">#{storeId},
|
||||
</if>
|
||||
<if test="storeName != null">#{storeName},
|
||||
</if>
|
||||
<if test="name != null">#{name},
|
||||
</if>
|
||||
<if test="method != null">#{method},
|
||||
</if>
|
||||
<if test="spendAmount != null">#{spendAmount},
|
||||
</if>
|
||||
<if test="couponAmount != null">#{couponAmount},
|
||||
</if>
|
||||
<if test="startSaleTime != null">#{startSaleTime},
|
||||
</if>
|
||||
<if test="endSaleTime != null">#{endSaleTime},
|
||||
</if>
|
||||
<if test="startUseTime != null">#{startUseTime},
|
||||
</if>
|
||||
<if test="endUseTime != null">#{endUseTime},
|
||||
</if>
|
||||
<if test="inventory != null">#{inventory},
|
||||
</if>
|
||||
<if test="stock != null">#{stock},
|
||||
</if>
|
||||
<if test="status != null">#{status},
|
||||
</if>
|
||||
<if test="userClaimLimit != null">#{userClaimLimit},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">#{createBy},
|
||||
</if>
|
||||
<if test="updateTime != null">#{updateTime},
|
||||
</if>
|
||||
<if test="updateBy != null">#{updateBy},
|
||||
</if>
|
||||
<if test="descr != null">#{descr},
|
||||
</if>
|
||||
<if test="memo != null">#{memo},
|
||||
</if>
|
||||
<if test="applicability != null">#{applicability},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateZdyCoupon" parameterType="ZdyCoupon">
|
||||
update zdy_coupon
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="type != null">type =
|
||||
#{type},
|
||||
</if>
|
||||
<if test="storeCategory != null">store_category =
|
||||
#{storeCategory},
|
||||
</if>
|
||||
<if test="storeId != null">store_id =
|
||||
#{storeId},
|
||||
</if>
|
||||
<if test="storeName != null">store_name =
|
||||
#{storeName},
|
||||
</if>
|
||||
<if test="name != null">name =
|
||||
#{name},
|
||||
</if>
|
||||
<if test="method != null">method =
|
||||
#{method},
|
||||
</if>
|
||||
<if test="spendAmount != null">spend_amount =
|
||||
#{spendAmount},
|
||||
</if>
|
||||
<if test="couponAmount != null">coupon_amount =
|
||||
#{couponAmount},
|
||||
</if>
|
||||
<if test="startSaleTime != null">start_sale_time =
|
||||
#{startSaleTime},
|
||||
</if>
|
||||
<if test="endSaleTime != null">end_sale_time =
|
||||
#{endSaleTime},
|
||||
</if>
|
||||
<if test="startUseTime != null">start_use_time =
|
||||
#{startUseTime},
|
||||
</if>
|
||||
<if test="endUseTime != null">end_use_time =
|
||||
#{endUseTime},
|
||||
</if>
|
||||
<if test="inventory != null">inventory =
|
||||
#{inventory},
|
||||
</if>
|
||||
<if test="stock != null">stock =
|
||||
#{stock},
|
||||
</if>
|
||||
<if test="status != null">status =
|
||||
#{status},
|
||||
</if>
|
||||
<if test="userClaimLimit != null">user_claim_limit =
|
||||
#{userClaimLimit},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">create_by =
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="updateTime != null">update_time =
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="updateBy != null">update_by =
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="descr != null">descr =
|
||||
#{descr},
|
||||
</if>
|
||||
<if test="memo != null">memo =
|
||||
#{memo},
|
||||
</if>
|
||||
<if test="applicability != null">applicability =
|
||||
#{applicability},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateZdyCouponStatus">
|
||||
UPDATE zdy_coupon
|
||||
SET STATUS = (CASE
|
||||
WHEN #{currentDate} > end_use_time THEN '3'
|
||||
WHEN #{currentDate} >= start_use_time THEN '2'
|
||||
ELSE STATUS END)
|
||||
WHERE STATUS IN ('1', '2');
|
||||
</update>
|
||||
|
||||
<delete id="deleteZdyCouponById" parameterType="Long">
|
||||
delete
|
||||
from zdy_coupon
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteZdyCouponByIds" parameterType="String">
|
||||
delete from zdy_coupon where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@@ -0,0 +1,306 @@
|
||||
<?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.zhwl.coupon.mapper.ZdyCouponUseRecordMapper">
|
||||
|
||||
<resultMap type="ZdyCouponUseRecord" id="ZdyCouponUseRecordResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="couponId" column="coupon_id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="couponMethod" column="coupon_method"/>
|
||||
<result property="couponName" column="coupon_name"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="spendAmount" column="spend_amount"/>
|
||||
<result property="couponAmount" column="coupon_amount"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="startUseTime" column="start_use_time"/>
|
||||
<result property="endUseTime" column="end_use_time"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="useTime" column="use_time"/>
|
||||
<result property="orderCode" column="order_code"/>
|
||||
<result property="orderId" column="order_id"/>
|
||||
<result property="payAmount" column="pay_amount"/>
|
||||
<result property="totalAmount" column="total_amount"/>
|
||||
<result property="useIds" column="use_ids"/>
|
||||
<result property="refundAmount" column="refund_amount"/>
|
||||
<result property="storeCategory" column="store_category"/>
|
||||
<result property="storeId" column="store_id"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectZdyCouponUseRecordVo">
|
||||
select id,
|
||||
user_id,
|
||||
coupon_id,
|
||||
coupon_method,
|
||||
coupon_name,
|
||||
type,
|
||||
spend_amount,
|
||||
coupon_amount,
|
||||
create_time,
|
||||
start_use_time,
|
||||
end_use_time,
|
||||
status,
|
||||
use_time,
|
||||
order_code,
|
||||
order_id,
|
||||
pay_amount,
|
||||
total_amount,
|
||||
use_ids,
|
||||
refund_amount,
|
||||
store_category,
|
||||
store_id
|
||||
from zdy_coupon_use_record
|
||||
</sql>
|
||||
|
||||
<select id="selectZdyCouponUseRecordList" parameterType="ZdyCouponUseRecord" resultMap="ZdyCouponUseRecordResult">
|
||||
<include refid="selectZdyCouponUseRecordVo"/>
|
||||
<where>
|
||||
<if test="userId != null ">
|
||||
and user_id = #{userId}
|
||||
</if>
|
||||
<if test="couponMethod != null and couponMethod != ''">
|
||||
and coupon_method = #{couponMethod}
|
||||
</if>
|
||||
<if test="couponId != null and couponId != ''">
|
||||
and coupon_id = #{couponId}
|
||||
</if>
|
||||
<if test="couponName != null and couponName != ''">
|
||||
and coupon_name like concat('%', #{couponName}, '%')
|
||||
</if>
|
||||
<if test="type!= null and type!= ''">
|
||||
and `type` = #{type}
|
||||
</if>
|
||||
<if test="startUseTime != null ">
|
||||
and start_use_time = #{startUseTime}
|
||||
</if>
|
||||
<if test="endUseTime != null ">
|
||||
and end_use_time = #{endUseTime}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="useTime != null ">
|
||||
and use_time = #{useTime}
|
||||
</if>
|
||||
<if test="orderCode != null and orderCode != ''">
|
||||
and order_code = #{orderCode}
|
||||
</if>
|
||||
<if test="useIds != null and useIds != ''">
|
||||
AND FIND_IN_SET( #{useIds}, use_ids)
|
||||
</if>
|
||||
<if test="storeCategory != null and storeCategory != ''">
|
||||
and store_category = #{storeCategory}
|
||||
</if>
|
||||
<if test="storeId!= null">
|
||||
and store_id = #{storeId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectZdyCouponUseRecordById" parameterType="Long"
|
||||
resultMap="ZdyCouponUseRecordResult">
|
||||
<include refid="selectZdyCouponUseRecordVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectZdyCouponUseRecordCount" resultType="java.lang.Integer">
|
||||
select count(1) from zdy_coupon_use_record
|
||||
<where>
|
||||
<if test="userId != null ">
|
||||
and user_id = #{userId}
|
||||
</if>
|
||||
<if test="couponId!= null and couponId!= ''">
|
||||
and coupon_id = #{couponId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectByOrderCode" resultMap="ZdyCouponUseRecordResult">
|
||||
<include refid="selectZdyCouponUseRecordVo"/>
|
||||
where order_code = #{orderCode} limit 1
|
||||
</select>
|
||||
<select id="selectByOrderCodeAndUseId" resultMap="ZdyCouponUseRecordResult">
|
||||
<include refid="selectZdyCouponUseRecordVo"/>
|
||||
where order_code = #{orderCode} AND FIND_IN_SET( #{useId}, use_ids) limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertZdyCouponUseRecord" parameterType="ZdyCouponUseRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into zdy_coupon_use_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,
|
||||
</if>
|
||||
<if test="couponId != null">coupon_id,
|
||||
</if>
|
||||
<if test="userId != null">user_id,
|
||||
</if>
|
||||
<if test="couponMethod != null">coupon_method,
|
||||
</if>
|
||||
<if test="couponName != null">coupon_name,
|
||||
</if>
|
||||
<if test="type != null">`type`,
|
||||
</if>
|
||||
<if test="spendAmount != null">spend_amount,
|
||||
</if>
|
||||
<if test="couponAmount != null">coupon_amount,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
</if>
|
||||
<if test="startUseTime != null">start_use_time,
|
||||
</if>
|
||||
<if test="endUseTime != null">end_use_time,
|
||||
</if>
|
||||
<if test="status != null">status,
|
||||
</if>
|
||||
<if test="useTime != null">use_time,
|
||||
</if>
|
||||
<if test="orderCode != null">order_code,
|
||||
</if>
|
||||
<if test="orderId != null">order_id,
|
||||
</if>
|
||||
<if test="useIds != null">use_ids,
|
||||
</if>
|
||||
<if test="refundAmount != null">refund_amount,
|
||||
</if>
|
||||
<if test="storeCategory!= null">store_category,
|
||||
</if>
|
||||
<if test="storeId!= null">store_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},
|
||||
</if>
|
||||
<if test="couponId != null">#{couponId},
|
||||
</if>
|
||||
<if test="userId != null">#{userId},
|
||||
</if>
|
||||
<if test="couponMethod != null">#{couponMethod},
|
||||
</if>
|
||||
<if test="couponName != null">#{couponName},
|
||||
</if>
|
||||
<if test="type != null">#{type},
|
||||
</if>
|
||||
<if test="spendAmount != null">#{spendAmount},
|
||||
</if>
|
||||
<if test="couponAmount != null">#{couponAmount},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
</if>
|
||||
<if test="startUseTime != null">#{startUseTime},
|
||||
</if>
|
||||
<if test="endUseTime != null">#{endUseTime},
|
||||
</if>
|
||||
<if test="status != null">#{status},
|
||||
</if>
|
||||
<if test="useTime != null">#{useTime},
|
||||
</if>
|
||||
<if test="orderCode != null">#{orderCode},
|
||||
</if>
|
||||
<if test="orderId != null">#{orderId},
|
||||
</if>
|
||||
<if test="useIds != null">#{useIds},
|
||||
</if>
|
||||
<if test="refundAmount != null">#{refundAmount},
|
||||
</if>
|
||||
<if test="storeCategory!= null">#{storeCategory},
|
||||
</if>
|
||||
<if test="storeId!= null">#{storeId},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateZdyCouponUseRecord" parameterType="ZdyCouponUseRecord">
|
||||
update zdy_coupon_use_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="couponId != null">coupon_id =
|
||||
#{couponId},
|
||||
</if>
|
||||
<if test="userId != null">user_id =
|
||||
#{userId},
|
||||
</if>
|
||||
<if test="couponMethod != null">coupon_method =
|
||||
#{couponMethod},
|
||||
</if>
|
||||
<if test="couponName != null">coupon_name =
|
||||
#{couponName},
|
||||
</if>
|
||||
<if test="type != null">`type` =
|
||||
#{type},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="startUseTime != null">start_use_time =
|
||||
#{startUseTime},
|
||||
</if>
|
||||
<if test="endUseTime != null">end_use_time =
|
||||
#{endUseTime},
|
||||
</if>
|
||||
<if test="status != null">status =
|
||||
#{status},
|
||||
</if>
|
||||
use_time = #{useTime},
|
||||
<if test="orderCode != null">order_code =
|
||||
#{orderCode},
|
||||
</if>
|
||||
<if test="orderId != null">order_id =
|
||||
#{orderId},
|
||||
</if>
|
||||
<if test="payAmount != null">pay_amount =
|
||||
#{payAmount},
|
||||
</if>
|
||||
<if test="totalAmount != null">total_amount =
|
||||
#{totalAmount},
|
||||
</if>
|
||||
<if test="useIds != null">use_ids =
|
||||
#{useIds},
|
||||
</if>
|
||||
<if test="refundAmount != null">refund_amount =
|
||||
#{refundAmount},
|
||||
</if>
|
||||
<if test="storeCategory!= null">store_category =
|
||||
#{storeCategory},
|
||||
</if>
|
||||
<if test="storeId!= null">store_id =
|
||||
#{storeId},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateUndoUse" parameterType="ZdyCouponUseRecord">
|
||||
update zdy_coupon_use_record
|
||||
set status = #{status},
|
||||
use_time = #{useTime},
|
||||
order_code = #{orderCode},
|
||||
pay_amount = #{payAmount},
|
||||
total_amount = #{totalAmount},
|
||||
use_ids = #{useIds},
|
||||
refund_amount = #{refundAmount},
|
||||
store_category = #{storeCategory}
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateStatus">
|
||||
update zdy_coupon_use_record
|
||||
SET STATUS = (CASE
|
||||
WHEN #{currentDate} > end_use_time THEN '4'
|
||||
WHEN #{currentDate} >= start_use_time THEN '2'
|
||||
ELSE STATUS END)
|
||||
WHERE STATUS IN ('1', '2');
|
||||
</update>
|
||||
<update id="updateInvalidatedByCouponId">
|
||||
update zdy_coupon_use_record
|
||||
set status = '5'
|
||||
where coupon_id = #{couponId} and status in ('1','2')
|
||||
</update>
|
||||
|
||||
<delete id="deleteZdyCouponUseRecordById" parameterType="Long">
|
||||
delete
|
||||
from zdy_coupon_use_record
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteZdyCouponUseRecordByIds" parameterType="String">
|
||||
delete from zdy_coupon_use_record where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Reference in New Issue
Block a user