12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?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 type="com.ylx.massage.domain.CouponReceive" id="CouponReceiveMap">
- <result property="id" column="id" jdbcType="VARCHAR"/>
- <result property="openid" column="openid" jdbcType="VARCHAR"/>
- <result property="couponId" column="coupon_id" jdbcType="VARCHAR"/>
- <result property="expirationTime" column="expiration_time" jdbcType="TIMESTAMP"/>
- <result property="useState" column="use_state" jdbcType="INTEGER"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
- <result property="isDelete" column="is_delete" jdbcType="INTEGER"/>
- </resultMap>
- <resultMap type="com.ylx.massage.domain.vo.CouponReceiveVo" id="CouponReceiveVoMap">
- <result property="id" column="id" jdbcType="VARCHAR"/>
- <result property="openid" column="openid" jdbcType="VARCHAR"/>
- <result property="couponId" column="coupon_id" jdbcType="VARCHAR"/>
- <result property="expirationTime" column="expiration_time" jdbcType="TIMESTAMP"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
- <result property="isDelete" column="is_delete" jdbcType="INTEGER"/>
- <result property="name" column="name" jdbcType="VARCHAR"/>
- <result property="type" column="type" jdbcType="INTEGER"/>
- <result property="discountType" column="discount_type" jdbcType="INTEGER"/>
- <result property="discountValue" column="discount_value" jdbcType="NUMERIC"/>
- <result property="thresholdAmount" column="threshold_amount" jdbcType="NUMERIC"/>
- <result property="obtainWay" column="obtain_way" jdbcType="INTEGER"/>
- <result property="termDays" column="term_days" jdbcType="INTEGER"/>
- <result property="status" column="status" jdbcType="INTEGER"/>
- <result property="usedNum" column="used_num" jdbcType="INTEGER"/>
- <result property="userLimit" column="user_limit" jdbcType="INTEGER"/>
- <result property="extParam" column="ext_param" jdbcType="VARCHAR"/>
- <result property="rebValue" column="reb_value" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="selectCouponReceiveVo">
- a.id, a.openid, a.coupon_id, a.expiration_time, a.create_time, a.update_time, a.is_delete,a.use_state,
- b.name, b.type, b.discount_type, b.discount_value, b.threshold_amount, b.obtain_way, b.term_days, b.status, b.used_num, b.user_limit, b.ext_param,b.reb_value
- </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.expiration_time >= now()
- and a.openid = #{openid}
- </select>
- </mapper>
|