123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <?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.platform.yijia.dao.CouponMapper">
- <!--优惠券-->
- <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.Coupon">
- <id column="id" jdbcType="INTEGER" property="couponId" />
- <result column="station_id" jdbcType="INTEGER" property="stationId" />
- <result column="coupon_name" jdbcType="VARCHAR" property="couponName" />
- <result column="coupon_type" jdbcType="VARCHAR" property="couponType" />
- <result column="coupon_threshold_amt" jdbcType="DECIMAL" property="couponThresholdAmt" />
- <result column="oil_type" jdbcType="VARCHAR" property="oilType" />
- <result column="coupon_amt" jdbcType="VARCHAR" property="couponAmt" />
- <result column="coupon_num" jdbcType="INTEGER" property="couponNum" />
- <result column="effective_time_type" jdbcType="VARCHAR" property="effectiveTimeType" />
- <result column="effective_time_start" jdbcType="TIMESTAMP" property="effectiveTimeStart" />
- <result column="effective_time_end" jdbcType="TIMESTAMP" property="effectiveTimeEnd" />
- <result column="effective_day_num" jdbcType="INTEGER" property="effectiveDayNum" />
- <result column="coupon_receive_num" jdbcType="INTEGER" property="couponReceiveNum" />
- <result column="open_platform" jdbcType="VARCHAR" property="openPlatform" />
- <result column="grant_status" jdbcType="VARCHAR" property="grantStatus" />
- <result column="status" jdbcType="VARCHAR" property="status" />
- </resultMap>
- <!--用户优惠券-->
- <resultMap id="UserCouponsBaseResultMap" type="com.platform.yijia.pojo.UserCoupon">
- <result column="coupon_id" jdbcType="INTEGER" property="couponId" />
- <result column="union_id" jdbcType="VARCHAR" property="unionId" />
- <result column="get_coupon_origin" jdbcType="VARCHAR" property="getCouponOrigin" />
- <result column="coupon_is_used" jdbcType="VARCHAR" property="couponIsUsed" />
- <result column="coupon_no" jdbcType="VARCHAR" property="couponNo" />
- <result column="coupon_is_effective" jdbcType="VARCHAR" property="couponIsEffective" />
- <result column="grant_coupon_shop" jdbcType="INTEGER" property="grantCouponShop" />
- <result column="get_coupon_time" jdbcType="TIMESTAMP" property="getCouponTime" />
- <result column="grant_coupon_person" jdbcType="INTEGER" property="grantCouponPerson" />
- <result column="station_id" jdbcType="INTEGER" property="stationId" />
- <result column="coupon_name" jdbcType="VARCHAR" property="couponName" />
- <result column="coupon_type" jdbcType="VARCHAR" property="couponType" />
- <result column="coupon_threshold_amt" jdbcType="DECIMAL" property="couponThresholdAmt" />
- <result column="oil_type" jdbcType="VARCHAR" property="oilType" />
- <result column="coupon_amt" jdbcType="VARCHAR" property="couponAmt" />
- <result column="coupon_num" jdbcType="INTEGER" property="couponNum" />
- <result column="effective_time_type" jdbcType="VARCHAR" property="effectiveTimeType" />
- <result column="effective_time_start" jdbcType="TIMESTAMP" property="effectiveTimeStart" />
- <result column="effective_time_end" jdbcType="TIMESTAMP" property="effectiveTimeEnd" />
- <result column="effective_day_num" jdbcType="INTEGER" property="effectiveDayNum" />
- <result column="coupon_receive_num" jdbcType="INTEGER" property="couponReceiveNum" />
- <result column="open_platform" jdbcType="VARCHAR" property="openPlatform" />
- <result column="grant_status" jdbcType="VARCHAR" property="grantStatus" />
- <result column="status" jdbcType="VARCHAR" property="status" />
- <result column="dept_name" jdbcType="VARCHAR" property="stationName" />
- </resultMap>
- <sql id="Base_Column_List">
- id, station_id, coupon_name, coupon_type, coupon_threshold_amt, oil_type, coupon_amt, coupon_num, effective_time_type,
- effective_time_start, effective_time_end, effective_day_num, coupon_receive_num, open_platform, grant_status, status
- </sql>
- <!--获取加油券信息-->
- <select id="selectCouponInfo" parameterType="com.platform.yijia.pojo.Coupon" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM
- coupon_info
- <where>
- <if test="id !=null">
- id = #{id}
- </if>
- </where>
- </select>
- <!--获取用户所拥有的加油券-->
- <select id="selectUserCoupons" parameterType="com.platform.yijia.pojo.UserCoupon" resultMap="UserCouponsBaseResultMap">
- SELECT
- T1.union_id,
- T1.coupon_id,
- T1.coupon_is_effective,
- T1.coupon_is_used,
- T1.grant_coupon_shop,
- T1.grant_coupon_person,
- T1.get_coupon_origin,
- T1.get_coupon_time,
- T3.dept_name,
- T2.station_id,
- T2.oil_type,
- T2.coupon_name,
- T2.coupon_threshold_amt,
- T2.coupon_amt,
- T2.effective_time_type,
- T2.effective_time_start,
- T2.effective_time_end,
- T2.effective_day_num,
- T2.status
- FROM coupon_user AS T1
- LEFT JOIN coupon_info AS T2 ON T1.coupon_id = T2.id
- LEFT JOIN sys_dept AS T3 ON T2.station_id = T3.dept_id
- <where>
- <if test="stationId !=null and stationId !=''">
- T1.station_id = #{stationId}
- </if>
- <if test="unionId !=null and unionId !=''">
- AND T1.union_id = #{unionId}
- </if>
- </where>
- </select>
- <!--用户获取优惠券-->
- <insert id="addUserCoupon" parameterType="com.platform.yijia.pojo.UserCoupon">
- INSERT INTO coupon_user
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="unionId !=null">
- union_id,
- </if>
- <if test="couponId !=null">
- coupon_id,
- </if>
- <if test="couponNo !=null">
- coupon_no,
- </if>
- <if test="getCouponOrigin !=null">
- get_coupon_origin,
- </if>
- <if test="couponIsUsed !=null">
- coupon_is_used,
- </if>
- <if test="couponIsEffective !=null">
- coupon_is_effective,
- </if>
- <if test="grantCouponShop !=null">
- grant_coupon_shop,
- </if>
- <if test="getCouponTime !=null">
- get_coupon_time,
- </if>
- <if test="grantCouponPerson !=null">
- grant_coupon_person,
- </if>
- <if test="stationId !=null">
- station_id,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="unionId !=null">
- #{unionId},
- </if>
- <if test="couponId !=null">
- #{couponId},
- </if>
- <if test="couponNo !=null">
- #{couponNo},
- </if>
- <if test="getCouponOrigin !=null">
- #{getCouponOrigin},
- </if>
- <if test="couponIsUsed !=null">
- #{couponIsUsed},
- </if>
- <if test="couponIsEffective !=null">
- #{couponIsEffective},
- </if>
- <if test="grantCouponShop !=null">
- #{grantCouponShop},
- </if>
- <if test="getCouponTime !=null">
- #{getCouponTime},
- </if>
- <if test="grantCouponPerson !=null">
- #{grantCouponPerson},
- </if>
- <if test="stationId !=null">
- #{stationId},
- </if>
- </trim>
- </insert>
- </mapper>
|