| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?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.ylx.massage.mapper.CouponReceiveMapper">
- <resultMap id="CouponReceiveVoMap" type="com.ylx.massage.domain.vo.CouponReceiveVo">
- <result property="id" column="id" jdbcType="VARCHAR"/>
- <result property="openid" column="receive_open_id" jdbcType="VARCHAR"/>
- <result property="couponId" column="coupon_id" jdbcType="VARCHAR"/>
- <result property="couponName" column="coupon_name" jdbcType="VARCHAR"/>
- <result property="couponType" column="coupon_type" jdbcType="INTEGER"/>
- <result property="validityType" column="validity_type" jdbcType="INTEGER"/>
- <result property="validStartTime" column="valid_start_time" jdbcType="TIMESTAMP"/>
- <result property="expirationTime" column="expiration_time" jdbcType="TIMESTAMP"/>
- <result property="ruleMinSpendAmount" column="rule_min_spend_amount" jdbcType="DECIMAL"/>
- <result property="ruleDiscountRate" column="rule_discount_rate" jdbcType="DECIMAL"/>
- <result property="ruleDiscountCapAmount" column="rule_discount_cap_amount" jdbcType="DECIMAL"/>
- <result property="ruleReductionAmount" column="rule_reduction_amount" jdbcType="DECIMAL"/>
- </resultMap>
- <sql id="selectCouponReceiveVo">
- distinct a.id, a.receive_open_id, a.coupon_id, b.coupon_name,a.validity_type,a.valid_start_time,a.expiration_time,a.coupon_status,b.market_price,a.create_time, a.update_time, a.is_delete
- </sql>
- <!-- 批量插入 -->
- <insert id="insertBatch" keyProperty="id">
- insert into coupon_receive(id,openid,coupon_id,expiration_time,dept_id,dept_name)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.id},#{entity.openid},#{entity.couponId},#{entity.expirationTime},#{entity.deptId},#{entity.deptName})
- </foreach>
- </insert>
- <!-- 批量插入或按主键更新 -->
- <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
- insert into coupon_receive(openid,coupon_id,expiration_time,dept_id,dept_name,create_time,update_time,is_delete)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.openid},#{entity.couponId},#{entity.expirationTime},#{entity.deptId},#{entity.deptName},#{entity.createTime},#{entity.updateTime},#{entity.isDelete})
- </foreach>
- on duplicate key update
- openid = values(openid),
- coupon_id = values(coupon_id),
- expiration_time = values(expiration_time),
- dept_id = values(dept_id),
- dept_name = values(dept_name),
- create_time = values(create_time),
- update_time = values(update_time),
- is_delete = values(is_delete)
- </insert>
- <!-- 查询我的待使用的优惠券 -->
- <!--<select id="getByOpenId" resultMap="CouponReceiveVoMap">
- SELECT
- <include refid="selectCouponReceiveVo"/>
- FROM coupon_receive a
- LEFT JOIN coupon b ON a.coupon_id = b.id
- WHERE a.is_delete = 0
- AND b.is_delete = 0
- AND a.use_state = 0
- and a.expiration_time >= now()
- and a.openid = #{openid}
- </select>-->
- <select id="getByOpenId" resultMap="CouponReceiveVoMap">
- SELECT
- <include refid="selectCouponReceiveVo"/>
- FROM coupon_receive a
- LEFT JOIN user_coupon_relation b ON a.coupon_id = b.coupon_id
- WHERE a.is_delete = 0
- AND a.coupon_status = 0
- and a.receive_open_id = #{openid}
- </select>
- </mapper>
|