123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786 |
- <?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_remark" jdbcType="VARCHAR" property="couponRemark" />
- <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_name" jdbcType="VARCHAR" property="oilName" />
- <result column="oil_type" jdbcType="VARCHAR" property="oilType" />
- <result column="coupon_amt" jdbcType="DECIMAL" 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="coupon_hold_num" jdbcType="INTEGER" property="couponHoldNum" />
- <result column="coupon_cumulative_num" jdbcType="INTEGER" property="couponCumulativeNum" />
- <result column="coupon_use_num" jdbcType="INTEGER" property="couponUseNum" />
- <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="create_by" jdbcType="VARCHAR" property="createBy" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="del_flag" jdbcType="VARCHAR" property="delFlag" />
- <result column="coupon_details" jdbcType="VARCHAR" property="couponDetails" />
- <result column="verification" jdbcType="VARCHAR" property="verification" />
- <result column="is_card_flag" jdbcType="VARCHAR" property="isCardFlag" />
- <result column="is_grade_flag" jdbcType="VARCHAR" property="isGradeFlag" />
- <result column="is_market_flag" jdbcType="VARCHAR" property="isMarketFlag" />
- <result column="available_control" jdbcType="VARCHAR" property="availableControl" />
- <result column="appointed_days" jdbcType="VARCHAR" property="appointedDays" />
- <result column="cycle_days" jdbcType="VARCHAR" property="cycleDays" />
- <result column="coupon_issue_id" jdbcType="VARCHAR" property="couponIssueId" />
- <result column="show_id" jdbcType="INTEGER" property="showId" />
- <result column="issue_type" jdbcType="VARCHAR" property="issueType" />
- <result column="issue_name" jdbcType="VARCHAR" property="issueName" />
- <result column="discount_threshold_amt" jdbcType="DECIMAL" property="discountThresholdAmt" />
- <collection property="couponVerificationList" select="selectCouponVerificationInfo"
- column="{param_station_id = station_id, param_coupon_id = id}" ofType="com.platform.yijia.pojo.CouponVerification"/>
- </resultMap>
- <!--发放方式,优惠劵信息-->
- <resultMap id="CouponIssueBaseResultMap" type="com.platform.yijia.pojo.CouponIssue">
- <result column="coupon_issue_id" jdbcType="VARCHAR" property="couponIssueId" />
- <result column="issue_type" jdbcType="VARCHAR" property="issueType" />
- <result column="issue_name" jdbcType="VARCHAR" property="issueName" />
- <result column="discount_threshold_amt" jdbcType="DECIMAL" property="discountThresholdAmt" />
- <result column="status" jdbcType="VARCHAR" property="status" />
- <result column="station_id" jdbcType="INTEGER" property="stationId" />
- <result column="create_by" jdbcType="VARCHAR" property="createBy" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="show_id" jdbcType="VARCHAR" property="showId" />
- <result column="available_control" jdbcType="VARCHAR" property="availableControl" />
- <result column="appointed_days" jdbcType="TIMESTAMP" property="appointedDays" />
- <result column="cycle_days" jdbcType="VARCHAR" property="cycleDays" />
- <result column="give_limit" jdbcType="INTEGER" property="giveLimit" />
- <result column="give_count" jdbcType="INTEGER" property="giveCount" />
- </resultMap>
- <!--用户优惠券-->
- <resultMap id="UserCouponsBaseResultMap" type="com.platform.yijia.pojo.UserCoupon">
- <result column="id" jdbcType="VARCHAR" property="id" />
- <result column="coupon_id" jdbcType="VARCHAR" property="couponId" />
- <result column="union_id" jdbcType="VARCHAR" property="unionId" />
- <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="get_coupon_time" jdbcType="TIMESTAMP" property="getCouponTime" />
- <result column="coupon_effective_time" jdbcType="TIMESTAMP" property="couponEffectiveTime" />
- <result column="verification_time" jdbcType="TIMESTAMP" property="verificationTime" />
- <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_details" jdbcType="VARCHAR" property="couponDetails" />
- <result column="coupon_threshold_amt" jdbcType="DECIMAL" property="couponThresholdAmt" />
- <result column="oil_name" jdbcType="VARCHAR" property="oilName" />
- <result column="oil_type" jdbcType="VARCHAR" property="oilType" />
- <result column="coupon_remark" jdbcType="VARCHAR" property="couponRemark" />
- <result column="coupon_amt" jdbcType="DECIMAL" 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="coupon_cumulative_num" jdbcType="INTEGER" property="couponCumulativeNum" />
- <result column="coupon_use_num" jdbcType="INTEGER" property="couponUseNum" />
- <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="create_by" jdbcType="VARCHAR" property="createBy" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="del_flag" jdbcType="VARCHAR" property="delFlag" />
- <result column="coupon_details" jdbcType="VARCHAR" property="couponDetails" />
- <result column="verification" jdbcType="VARCHAR" property="verification" />
- <result column="is_card_flag" jdbcType="VARCHAR" property="isCardFlag" />
- <result column="is_grade_flag" jdbcType="VARCHAR" property="isGradeFlag" />
- <result column="is_market_flag" jdbcType="VARCHAR" property="isMarketFlag" />
- <result column="available_control" jdbcType="VARCHAR" property="availableControl" />
- <result column="appointed_days" jdbcType="VARCHAR" property="appointedDays" />
- <result column="cycle_days" jdbcType="VARCHAR" property="cycleDays" />
- <result column="issue_name" jdbcType="VARCHAR" property="issueName" />
- <result column="canUse" jdbcType="VARCHAR" property="canUse" />
- <collection property="couponVerificationList" select="selectCouponVerificationInfo"
- column="{param_station_id = station_id, param_coupon_id = coupon_id}" ofType="com.platform.yijia.pojo.CouponVerification"/>
- </resultMap>
- <!---->
- <resultMap id="CouponUserGiveCountBaseResultMap" type="com.platform.yijia.pojo.CouponUserGiveCount">
- <result column="id" jdbcType="INTEGER" property="id" />
- <result column="union_id" jdbcType="VARCHAR" property="unionId" />
- <result column="station_id" jdbcType="INTEGER" property="stationId" />
- <result column="coupon_issue_id" jdbcType="VARCHAR" property="couponIssueId" />
- <result column="issue_give_count" jdbcType="INTEGER" property="issueGiveCount" />
- <result column="crete_time" jdbcType="TIMESTAMP" property="creteTime" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="give_count" jdbcType="INTEGER" property="giveCount" />
- <result column="issueStatus" jdbcType="VARCHAR" property="issueStatus" />
- </resultMap>
- <!-- 核销站点-->
- <resultMap id="CouponVerificationBaseResultMap" type="com.platform.yijia.pojo.CouponVerification">
- <result column="dept_id" jdbcType="INTEGER" property="verification" />
- <result column="dept_name" jdbcType="VARCHAR" property="verificationName" />
- </resultMap>
- <sql id="UserCoupon_Base_Column_List">
- T1.id, T1.coupon_is_used, T1.coupon_no, T2.id AS coupon_id, T2.station_id, T2.coupon_name, T2.coupon_remark, T2.coupon_type, T2.coupon_threshold_amt, T2.oil_name, T2.oil_type, T2.coupon_amt, T2.effective_time_type,
- T2.effective_time_start, T2.effective_time_end, T2.effective_day_num, T2.coupon_cumulative_num, T2.coupon_use_num,
- T2.open_platform, T2.status, T2.create_by, T2.create_time, T2.update_by, T2.update_time, T2.del_flag, T2.coupon_details, T2.verification,
- T2.is_card_flag, T2.is_grade_flag, T2.is_market_flag, T2.edit_flag, T2.available_control, T2.appointed_days, T2.cycle_days
- </sql>
- <sql id="Coupon_Base_Column_List">
- T2.id, T2.station_id, T2.coupon_name, T2.coupon_type, T2.coupon_remark, T2.coupon_threshold_amt, T2.oil_name, T2.oil_type, T2.coupon_amt, T2.coupon_num, T2.effective_time_type,
- T2.effective_time_start, T2.effective_time_end, T2.effective_day_num, T2.coupon_receive_num, T2.coupon_hold_num, T2.coupon_cumulative_num, T2.coupon_use_num,
- T2.open_platform, T2.status, T2.create_by, T2.create_time, T2.update_by, T2.update_time, T2.del_flag, T2.coupon_details, T2.verification,
- T2.is_card_flag, T2.is_grade_flag, T2.is_market_flag, T2.edit_flag, T2.available_control, T2.appointed_days, T2.cycle_days
- </sql>
- <!--查询优惠券模板信息-->
- <select id="selectCouponTemplateInfo" parameterType="com.platform.yijia.pojo.Coupon" resultMap="BaseResultMap">
- SELECT
- <include refid="Coupon_Base_Column_List"/>
- FROM coupon_info AS T2
- <where>
- <if test="couponId !=null">
- T2.id = #{couponId}
- </if>
- </where>
- </select>
- <!--更新优惠券模板-->
- <update id="updateCouponInfo" parameterType="com.platform.yijia.pojo.Coupon">
- UPDATE coupon_info
- <set>
- <if test="couponCumulativeNum != null">
- coupon_cumulative_num = #{couponCumulativeNum},
- </if>
- <if test="couponUseNum != null">
- coupon_use_num = #{couponUseNum},
- </if>
- </set>
- <where>
- <if test="stationId !=null">
- AND station_id = #{stationId}
- </if>
- <if test="couponId !=null">
- AND id = #{couponId}
- </if>
- </where>
- </update>
- <!--查询领取方式信息-->
- <select id="selectCouponIssueList" parameterType="com.platform.yijia.pojo.CouponIssue" resultMap="CouponIssueBaseResultMap">
- SELECT
- id AS coupon_issue_id,
- issue_name,
- issue_type,
- discount_threshold_amt,
- status,
- station_id,
- create_by,
- create_time,
- update_by,
- update_time,
- show_id,
- available_control,
- appointed_days,
- cycle_days,
- give_count,
- give_limit
- FROM coupon_issue
- <where>
- <if test="stationId !=null ">
- station_id = #{stationId}
- </if>
- <if test="couponIssueId !=null ">
- AND id = #{couponIssueId}
- </if>
- <if test="issueType !=null ">
- AND issue_type = #{issueType}
- </if>
- <if test="status !=null ">
- AND status = #{status}
- </if>
- </where>
- </select>
- <!--获取油站所分发的加油券-->
- <select id="selectStaGrantCouponList" parameterType="com.platform.yijia.pojo.Coupon" resultMap="BaseResultMap">
- SELECT
- T2.id AS coupon_issue_id,
- T2.issue_name,
- T2.issue_type,
- T2.discount_threshold_amt,
- T2.station_id,
- T2.show_id,
- T3.id,
- T3.coupon_name,
- T3.coupon_amt,
- T3.coupon_threshold_amt,
- T3.coupon_type,
- T3.oil_name,
- T3.use_discount_type,
- T3.effective_time_type,
- T3.effective_time_start,
- T3.effective_time_end,
- T3.effective_day_num,
- T3.coupon_receive_num,
- T3.coupon_hold_num,
- T3.coupon_cumulative_num,
- T3.coupon_use_num,
- T3.coupon_remark,
- T3.open_platform,
- T3.coupon_details,
- T3.grant_status,
- T3.status,
- T3.create_time,
- T3.is_card_flag,
- T3.is_grade_flag,
- T3.is_market_flag,
- T3.available_control,
- T3.appointed_days,
- T3.edit_flag,
- T3.verification,
- T3.cycle_days
- FROM coupon_issue_relation AS T1
- LEFT JOIN coupon_issue AS T2 ON T1.issue_id = T2.id
- LEFT JOIN coupon_info AS T3 ON T1.coupon_id = T3.id
- <where>
- T2.status = "1"
- AND T3.del_flag = "0"
- AND T3.status = "1"
- <if test="stationId !=null">
- AND T2.station_id = #{stationId}
- AND T3.station_id = #{stationId}
- </if>
- <if test="couponIssueId !=null">
- AND T1.issue_id = #{couponIssueId}
- </if>
- <if test="issueType !=null">
- AND T2.issue_type = #{issueType}
- </if>
- </where>
- </select>
- <!--查询核销站点信息-->
- <select id="selectCouponVerificationInfo" parameterType="java.util.HashMap" resultMap="CouponVerificationBaseResultMap">
- SELECT
- T2.dept_id,
- T2.dept_name
- FROM
- coupon_info AS T1
- LEFT JOIN sys_dept AS T2 ON FIND_IN_SET(T2.dept_id, T1.verification)
- WHERE
- T1.station_id = #{param_station_id}
- AND T1.coupon_type = "3"
- AND T1.id = #{param_coupon_id}
- </select>
- <!--获取用户进入领取页面的次数-->
- <select id="selectCouponUserGiveCount" parameterType="com.platform.yijia.pojo.CouponUserGiveCount" resultMap="CouponUserGiveCountBaseResultMap">
- SELECT
- T1.id,
- T1.union_id,
- T1.station_id,
- T1.coupon_issue_id,
- T1.issue_give_count,
- T1.crete_time,
- T1.update_time,
- T2.give_count,
- T2.status AS issueId
- FROM
- coupon_user_give_count AS T1
- LEFT JOIN coupon_issue AS T2 ON T1.coupon_issue_id = T2.id
- <where>
- <if test="unionId !=null and unionId !=''">
- T1.union_id = #{unionId}
- </if>
- <if test="stationId !=null">
- AND T1.station_id = #{stationId}
- </if>
- <if test="couponIssueId !=null and couponIssueId !=''">
- AND T1.coupon_issue_id = #{couponIssueId}
- </if>
- <if test="id !=null">
- AND T1.id = #{id}
- </if>
- </where>
- </select>
- <!-- 更新用户进入页面次数-->
- <update id="updateCouponUserGiveCount" parameterType="com.platform.yijia.pojo.CouponUserGiveCount">
- UPDATE
- coupon_user_give_count
- <set>
- <if test="issueGiveCount != null">
- issue_give_count = #{issueGiveCount},
- </if>
- <if test="updateTime != null">
- update_time = #{updateTime},
- </if>
- </set>
- <where>
- <if test="unionId !=null and unionId !=''">
- union_id = #{unionId}
- </if>
- <if test="stationId !=null">
- AND station_id = #{stationId}
- </if>
- <if test="couponIssueId !=null and couponIssueId !=''">
- AND coupon_issue_id = #{couponIssueId}
- </if>
- <if test="id !=null">
- AND id = #{id}
- </if>
- </where>
- </update>
- <!-- 更新用户优惠券信息-->
- <update id="updateCouponUserInfo" parameterType="com.platform.yijia.pojo.UserCoupon">
- UPDATE coupon_user
- <set>
- <if test="updateTime != null">
- update_time = #{updateTime},
- </if>
- <if test="couponIsUsed != null">
- coupon_is_used = #{couponIsUsed},
- </if>
- <if test="verificationTime != null">
- verification_time = #{verificationTime},
- </if>
- </set>
- <where>
- <if test="unionId !=null and unionId !=''">
- union_id = #{unionId}
- </if>
- <if test="stationId !=null">
- AND station_id = #{stationId}
- </if>
- <if test="couponNo !=null and couponNo !=''">
- AND coupon_no = #{couponNo}
- </if>
- <if test="id !=null">
- AND id = #{id}
- </if>
- </where>
- </update>
- <!--核销记录-->
- <insert id="addCouponVerificationRecord" parameterType="com.platform.yijia.pojo.CouponVerification" >
- INSERT INTO coupon_verification_record
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="couponUserId !=null">
- coupon_user_id,
- </if>
- <if test="verification !=null">
- verification,
- </if>
- <if test="createTime !=null">
- create_time,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="couponUserId !=null">
- #{couponUserId},
- </if>
- <if test="verification !=null">
- #{verification},
- </if>
- <if test="createTime !=null">
- #{createTime},
- </if>
- </trim>
- </insert>
- <!-- 更新核销用户信息-->
- <update id="updateCouponVerificationUser" parameterType="com.platform.yijia.pojo.CouponVerificationUser">
- UPDATE coupon_verification_user
- <set>
- <if test="mobilePhone != null">
- mobile_phone = #{mobilePhone},
- </if>
- </set>
- <where>
- <if test="unionId !=null and unionId !=''">
- union_id = #{unionId}
- </if>
- </where>
- </update>
- <!--核销人员-->
- <insert id="addCouponVerificationUser" parameterType="com.platform.yijia.pojo.CouponVerificationUser" >
- INSERT INTO coupon_verification_user
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="unionId !=null">
- union_id,
- </if>
- <if test="mobilePhone !=null">
- mobile_phone,
- </if>
- <if test="createTime !=null">
- create_time,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="unionId !=null">
- #{unionId},
- </if>
- <if test="mobilePhone !=null">
- #{mobilePhone},
- </if>
- <if test="createTime !=null">
- #{createTime},
- </if>
- </trim>
- </insert>
- <!--查询核销站点信息-->
- <select id="selectCouponVerificationUserInfo" parameterType="com.platform.yijia.pojo.CouponVerificationUser" resultType="com.platform.yijia.pojo.CouponVerificationUser">
- SELECT
- T1.union_id AS unionId,
- T1.mobile_phone AS mobilePhone,
- T3.ji_bie AS jiBie,
- T2.dept_id AS stationId
- FROM coupon_verification_user AS T1
- LEFT JOIN sys_user AS T2 ON T1.mobile_phone = T2.phonenumber
- LEFT JOIN sys_dept AS T3 ON T2.dept_id = T3.dept_id
- <where>
- T3.ji_bie = "1" OR T3.ji_bie = "2"
- <if test="unionId !=null and unionId !=''">
- AND T1.union_id = #{unionId}
- </if>
- </where>
- </select>
- <!--新增用户进入领取页面的次数-->
- <insert id="addCouponUserGiveCount" parameterType="com.platform.yijia.pojo.CouponUserGiveCount" >
- INSERT INTO coupon_user_give_count
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="unionId !=null">
- union_id,
- </if>
- <if test="stationId !=null">
- station_id,
- </if>
- <if test="couponIssueId !=null">
- coupon_issue_id,
- </if>
- <if test="issueGiveCount !=null">
- issue_give_count,
- </if>
- <if test="creteTime !=null">
- crete_time,
- </if>
- <if test="updateTime !=null">
- update_time,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="unionId !=null">
- #{unionId},
- </if>
- <if test="stationId !=null">
- #{stationId},
- </if>
- <if test="couponIssueId !=null">
- #{couponIssueId},
- </if>
- <if test="issueGiveCount !=null">
- #{issueGiveCount},
- </if>
- <if test="creteTime !=null">
- #{creteTime},
- </if>
- <if test="updateTime !=null">
- #{updateTime},
- </if>
- </trim>
- </insert>
- <!--获取用户某个加油券信息-->
- <select id="selectUserCouponInfo" parameterType="com.platform.yijia.pojo.UserCoupon" resultMap="UserCouponsBaseResultMap">
- SELECT
- <include refid="UserCoupon_Base_Column_List"/>
- FROM coupon_user AS T1
- LEFT JOIN coupon_info AS T2 ON T1.coupon_id = T2.id
- <where>
- <if test="id !=null">
- T1.id = #{id}
- </if>
- <if test="couponNo !=null">
- AND T1.coupon_no = #{couponNo}
- </if>
- <if test="unionId !=null">
- AND T1.union_id = #{unionId}
- </if>
- </where>
- </select>
- <!--用户已领取的该优惠券数量-->
- <select id="selectUserCouponCount" parameterType="com.platform.yijia.pojo.UserCoupon" resultType="int">
- SELECT
- COUNT(*)
- FROM
- coupon_user
- <where>
- coupon_is_effective ="1"
- <if test="unionId !=null and unionId !=''">
- AND coupon_id = #{couponId}
- </if>
- <if test="unionId !=null and unionId !=''">
- AND union_id = #{unionId}
- </if>
- <if test="couponIsUsed !=null and couponIsUsed !=''">
- AND coupon_is_used = #{couponIsUsed}
- </if>
- <if test="stationId !=null and stationId !=''">
- AND station_id = #{stationId}
- </if>
- </where>
- </select>
- <!--获取用户所拥有的加油券-->
- <select id="selectUserCoupons" parameterType="com.platform.yijia.pojo.UserCoupon" resultMap="UserCouponsBaseResultMap">
- SELECT
- T1.id,
- T1.union_id,
- T1.coupon_id,
- T1.coupon_no,
- T1.coupon_is_effective,
- T1.coupon_is_used,
- T1.get_coupon_time,
- T1.coupon_effective_time,
- T3.issue_name,
- T2.station_id,
- T2.oil_name,
- T2.oil_type,
- T2.coupon_remark,
- T2.coupon_name,
- T2.coupon_threshold_amt,
- T2.coupon_amt,
- T2.coupon_type,
- T2.coupon_details,
- T2.effective_time_type,
- T2.effective_time_start,
- T2.effective_time_end,
- T2.effective_day_num,
- T2.status,
- T2.create_time,
- T2.is_card_flag,
- T2.is_grade_flag,
- T2.is_market_flag,
- T2.available_control,
- CASE
- WHEN T2.available_control ='0' THEN CASE WHEN ( NOW() - T1.coupon_effective_time <= 0) THEN 'true' ELSE 'false' END
- WHEN T2.available_control ='1' THEN CASE WHEN LOCATE(DATE_FORMAT(NOW(), '%w'), T2.cycle_days) THEN 'true' ELSE 'false' END
- WHEN T2.available_control ='2' THEN CASE WHEN LOCATE(DATE_FORMAT(NOW(), '%e')-1, T2.cycle_days) THEN 'true' ELSE 'false' END
- WHEN T2.available_control ='3' THEN CASE WHEN LOCATE(DATE_FORMAT(NOW(), '%Y-%d-%m'), T2.appointed_days) THEN 'true' ELSE 'false' END
- END AS canUse,
- T2.appointed_days,
- T2.edit_flag,
- T2.verification,
- T2.cycle_days
- FROM coupon_user AS T1
- LEFT JOIN coupon_info AS T2 ON T1.coupon_id = T2.id
- LEFT JOIN coupon_issue AS T3 ON T1.issue_id = T3.id
- <where>
- T2.status = "1"
- AND T2.del_flag = "0"
- <if test="stationId !=null and stationId !=''">
- AND T1.station_id = #{stationId}
- </if>
- <if test="noVerificationVerFlag !=null and noVerificationVerFlag =='0'.toString()">
- AND T2.coupon_type <> "3"
- </if>
- <if test="couponIsUsed !=null and couponIsUsed !=''">
- AND T1.coupon_is_used = #{couponIsUsed}
- </if>
- <if test="unionId !=null and unionId !=''">
- AND T1.union_id = #{unionId}
- </if>
- <if test="oilName !=null and oilName !=''">
- AND FIND_IN_SET(#{oilName}, T2.oil_name)
- </if>
- <choose>
- <when test="expireFlag !=null and expireFlag == '0'.toString()">
- AND T1.coupon_effective_time >= #{currentTime}
- </when>
- <when test="expireFlag !=null and expireFlag == '1'.toString()">
- AND T1.coupon_effective_time < #{currentTime}
- </when>
- </choose>
- </where>
- </select>
- <!--查询已核销的优惠券-->
- <select id="selectCouponVerificationList" parameterType="com.platform.yijia.pojo.UserCoupon" resultMap="UserCouponsBaseResultMap">
- SELECT
- T1.id,
- T1.union_id,
- T1.coupon_id,
- T1.coupon_no,
- T1.coupon_is_effective,
- T1.coupon_is_used,
- T1.get_coupon_time,
- T1.coupon_effective_time,
- T1.verification_time,
- T3.issue_name,
- T2.station_id,
- T2.oil_name,
- T2.oil_type,
- T2.coupon_name,
- T2.coupon_remark,
- T2.coupon_threshold_amt,
- T2.coupon_amt,
- T2.coupon_type,
- T2.coupon_details,
- T2.effective_time_type,
- T2.effective_time_start,
- T2.effective_time_end,
- T2.effective_day_num,
- T2.status,
- T2.create_time,
- T2.is_card_flag,
- T2.is_grade_flag,
- T2.is_market_flag,
- T2.available_control,
- CASE
- WHEN T2.available_control ='0' THEN CASE WHEN ( NOW() - T1.coupon_effective_time <= 0) THEN 'true' ELSE 'false' END
- WHEN T2.available_control ='1' THEN CASE WHEN LOCATE(DATE_FORMAT(NOW(), '%w'), T2.cycle_days) THEN 'true' ELSE 'false' END
- WHEN T2.available_control ='2' THEN CASE WHEN LOCATE(DATE_FORMAT(NOW(), '%e')-1, T2.cycle_days) THEN 'true' ELSE 'false' END
- WHEN T2.available_control ='3' THEN CASE WHEN LOCATE(DATE_FORMAT(NOW(), '%Y-%d-%m'), T2.appointed_days) THEN 'true' ELSE 'false' END
- END AS canUse,
- T2.appointed_days,
- T2.edit_flag,
- T2.verification,
- T2.cycle_days
- FROM coupon_user AS T1
- LEFT JOIN coupon_info AS T2 ON T1.coupon_id = T2.id
- LEFT JOIN coupon_issue AS T3 ON T1.issue_id = T3.id
- LEFT JOIN sys_dept AS T4 ON T1.station_id = T4.dept_id
- <where>
- <if test="stationId !=null and stationId !=''">
- AND T1.station_id = #{stationId} OR FIND_IN_SET(#{stationId}, T2.verification)
- </if>
- <if test="groupId !=null and groupId !=''">
- AND T4.parent_id = #{groupId}
- </if>
- <if test="couponType !=null and couponType !=''">
- AND T2.coupon_type = #{couponType}
- </if>
- <if test="couponIsUsed !=null and couponIsUsed !=''">
- AND T1.coupon_is_used = #{couponIsUsed}
- </if>
- <if test="unionId !=null and unionId !=''">
- AND T1.union_id = #{unionId}
- </if>
- <if test="oilName !=null and oilName !=''">
- AND FIND_IN_SET(#{oilName}, T2.oil_name)
- </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="issueId !=null">
- issue_id,
- </if>
- <if test="couponNo !=null">
- coupon_no,
- </if>
- <if test="couponIsUsed !=null">
- coupon_is_used,
- </if>
- <if test="couponIsEffective !=null">
- coupon_is_effective,
- </if>
- <if test="getCouponTime !=null">
- get_coupon_time,
- </if>
- <if test="stationId !=null">
- station_id,
- </if>
- <if test="couponEffectiveTime !=null">
- coupon_effective_time,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="unionId !=null">
- #{unionId},
- </if>
- <if test="couponId !=null">
- #{couponId},
- </if>
- <if test="issueId !=null">
- #{issueId},
- </if>
- <if test="couponNo !=null">
- #{couponNo},
- </if>
- <if test="couponIsUsed !=null">
- #{couponIsUsed},
- </if>
- <if test="couponIsEffective !=null">
- #{couponIsEffective},
- </if>
- <if test="getCouponTime !=null">
- #{getCouponTime},
- </if>
- <if test="stationId !=null">
- #{stationId},
- </if>
- <if test="couponEffectiveTime !=null">
- #{couponEffectiveTime},
- </if>
- </trim>
- </insert>
- </mapper>
|