123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572 |
- <?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.ElectronicMembershipCardMapper">
- <!--储蓄卡返回结果-->
- <resultMap id="CardBaseResultMap" type="com.platform.yijia.pojo.CustomerElectronicCard">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="union_id" jdbcType="VARCHAR" property="unionId" />
- <result column="blog_openid" jdbcType="VARCHAR" property="blogOpenid" />
- <result column="mina_openid" jdbcType="VARCHAR" property="minaOpenid" />
- <result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
- <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
- <result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone" />
- <result column="amt" jdbcType="DECIMAL" property="amt" />
- <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
- <result column="station_id" jdbcType="INTEGER" property="stationId" />
- <result column="station_name" jdbcType="VARCHAR" property="stationName" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="recently_time" jdbcType="TIMESTAMP" property="recentlyTime" />
- </resultMap>
- <!--储蓄卡使用记录返回结果-->
- <resultMap id="CardRecordBaseResultMap" type="com.platform.yijia.pojo.CustomerCardUseRecord">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
- <result column="union_id" jdbcType="VARCHAR" property="unionId" />
- <result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
- <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
- <result column="usage_type" jdbcType="VARCHAR" property="usageType" />
- <result column="pay_type" jdbcType="VARCHAR" property="payType" />
- <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
- <result column="amt" jdbcType="DECIMAL" property="amt" />
- <result column="present_amt" jdbcType="DECIMAL" property="presentAmt" />
- <result column="balance" jdbcType="DECIMAL" property="balance" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="station_id" jdbcType="INTEGER" property="stationId" />
- <result column="station_name" jdbcType="VARCHAR" property="stationName" />
- <result column="status" jdbcType="VARCHAR" property="status" />
- </resultMap>
- <!--储蓄卡充值规则返回结果-->
- <resultMap id="CardSettingBaseResultMap" type="com.platform.yijia.pojo.CustomerCardSetting">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
- <result column="discount_time_setting" jdbcType="VARCHAR" property="discountTimeSetting" />
- <result column="discount_time_type" jdbcType="VARCHAR" property="discountTimeType" />
- <result column="discount_time" jdbcType="VARCHAR" property="discountTime" />
- <result column="present_scale" jdbcType="VARCHAR" property="presentScale" />
- <result column="is_discount_coupon" jdbcType="VARCHAR" property="isDiscountCoupon" />
- <result column="enjoy_integral_multiple" jdbcType="DATE" property="enjoyIntegralMultiple" />
- <result column="station_id" jdbcType="INTEGER" property="stationId" />
- <result column="station_name" jdbcType="VARCHAR" property="stationName" />
- <result column="create_time" jdbcType="VARCHAR" property="createTime" />
- <collection property="customerCardSettingDetailList" resultMap="CardSettingDetailResultMap"/>
- </resultMap>
- <!--储蓄卡充值规则明细表-->
- <resultMap id="CardSettingDetailResultMap" type="com.platform.yijia.pojo.CustomerCardSettingDetail">
- <id column="cardSettingDetailId" jdbcType="INTEGER" property="cardSettingDetailId" />
- <result column="parent_id" jdbcType="INTEGER" property="parentId"/>
- <result column="setting_rule_type" jdbcType="VARCHAR" property="settingRuleType" />
- <result column="discount_amt_start" jdbcType="DECIMAL" property="discountAmtStart" />
- <result column="discount_amt_end" jdbcType="DECIMAL" property="discountAmtEnd" />
- <result column="present_amt" jdbcType="DECIMAL" property="presentAmt"/>
- <result column="oil_name" jdbcType="VARCHAR" property="oilName" />
- </resultMap>
- <!--查询油站电子会员卡(储蓄卡)充值设置规则-->
- <select id="getCardRechargeSettingList" parameterType="com.platform.yijia.pojo.CustomerCardSetting" resultMap="CardSettingBaseResultMap">
- SELECT
- T1.id,
- T1.card_oils_type,
- T1.discount_time_setting,
- T1.discount_time_type,
- T1.discount_time,
- T1.present_scale,
- T1.is_discount_coupon,
- T1.enjoy_integral_multiple,
- T1.station_id,
- T1.station_name,
- T1.create_time,
- T2.id AS cardSettingDetailId,
- T2.parent_id,
- T2.setting_rule_type,
- T2.discount_amt_start,
- T2.discount_amt_end,
- T2.present_amt,
- T2.oil_name
- FROM
- customer_card_setting AS T1 LEFT JOIN customer_card_setting_detail AS T2 ON T1.id = T2.parent_id
- <where>
- <if test="stationId !=null">
- T1.station_id = #{stationId}
- </if>
- <if test="cardOilsType !=null">
- AND FIND_IN_SET(#{cardOilsType}, T1.card_oils_type)
- </if>
- <if test="cardOilsType !=null">
- AND T2.oil_name = #{cardOilsType}
- </if>
- </where>
- <if test="orderBy !=null and orderBy !=''">
- ORDER BY T2.discount_amt_end ${orderBy}
- </if>
- </select>
- <!--查询客户充值的订单信息-->
- <select id="getCardRecordByOrderNo" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord" resultMap="CardRecordBaseResultMap">
- SELECT
- id,
- order_no,
- union_id,
- customer_name,
- usage_type,
- pay_type,
- card_oils_type,
- amt,
- present_amt,
- create_time,
- station_id,
- station_name,
- status
- FROM
- customer_card_use_record
- <where>
- <if test=" orderNo !=null and orderNo !=''">
- order_no = #{orderNo}
- </if>
- </where>
- </select>
- <!--根据订单号更新用户充值记录的状态-->
- <update id="updateCardRecordStatusByOrderNo" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
- UPDATE
- customer_card_use_record
- <set>
- <if test="status !=null">
- status = #{status}
- </if>
- </set>
- <where>
- <if test=" orderNo !=null and orderNo !=''">
- order_no = #{orderNo}
- </if>
- </where>
- </update>
- <!--插入用户电子会员卡的使用记录-->
- <insert id="insetCardUseRecord" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
- INSERT INTO
- customer_card_use_record
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="orderNo !=null">
- order_no,
- </if>
- <if test="unionId !=null">
- union_id,
- </if>
- <if test="customerNo !=null">
- customer_no,
- </if>
- <if test="customerName !=null">
- customer_name,
- </if>
- <if test="usageType !=null">
- usage_type,
- </if>
- <if test="payType !=null">
- pay_type,
- </if>
- <if test="cardOilsType !=null">
- card_oils_type,
- </if>
- <if test="amt !=null">
- amt,
- </if>
- <if test="presentAmt !=null">
- present_amt,
- </if>
- <if test="balance !=null">
- balance,
- </if>
- <if test="createTime !=null">
- create_time,
- </if>
- <if test="stationId !=null">
- station_id,
- </if>
- <if test="stationName !=null">
- station_name,
- </if>
- <if test="status !=null">
- status,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="orderNo !=null">
- #{orderNo},
- </if>
- <if test="unionId !=null">
- #{unionId},
- </if>
- <if test="customerNo !=null">
- #{customerNo},
- </if>
- <if test="customerName !=null">
- #{customerName},
- </if>
- <if test="usageType !=null">
- #{usageType},
- </if>
- <if test="payType !=null">
- #{payType},
- </if>
- <if test="cardOilsType !=null">
- #{cardOilsType},
- </if>
- <if test="amt !=null">
- #{amt},
- </if>
- <if test="presentAmt !=null">
- #{presentAmt},
- </if>
- <if test="balance !=null">
- #{balance},
- </if>
- <if test="createTime !=null">
- #{createTime},
- </if>
- <if test="stationId !=null">
- #{stationId},
- </if>
- <if test="stationName !=null">
- #{stationName},
- </if>
- <if test="status !=null">
- #{status},
- </if>
- </trim>
- </insert>
- <!--查询客户电子会员卡的使用记录-->
- <select id="getCardUseRecordList" resultMap="CardRecordBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
- SELECT
- id,
- order_no,
- union_id,
- customer_no,
- customer_name,
- usage_type,
- pay_type,
- card_oils_type,
- amt,
- present_amt,
- balance,
- create_time,
- station_id,
- station_name,
- status
- FROM
- customer_card_use_record
- <where>
- status ="1"
- <if test=" usageType !=null and usageType !=''">
- AND usage_type = #{usageType}
- </if>
- <if test="stationId !=null and stationId !=''">
- AND station_id = #{stationId}
- </if>
- <if test="unionId !=null and unionId !=''">
- AND union_id = #{unionId}
- </if>
- </where>
- ORDER BY create_time DESC
- </select>
- <!--查询用户所拥有的储蓄卡-->
- <select id="getElectronicCardList" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
- SELECT
- id,
- union_id,
- blog_openid,
- mina_openid,
- customer_no,
- customer_name,
- amt,
- card_oils_type,
- station_id,
- station_name,
- create_time,
- recently_time
- FROM
- customer_electronic_card
- <where>
- <if test="stationId !=null and stationId !=''">
- station_id = #{stationId}
- </if>
- <if test="unionId !=null and unionId !=''">
- AND union_id = #{unionId}
- </if>
- <if test="cardOilsType !=null and cardOilsType !=''">
- AND card_oils_type = #{cardOilsType}
- </if>
- </where>
- </select>
- <!--插入用户电子会员卡-->
- <insert id="insetElectronicCard" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
- INSERT INTO
- customer_electronic_card
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="unionId !=null">
- union_id,
- </if>
- <if test="blogOpenid !=null">
- blog_openid,
- </if>
- <if test="minaOpenid !=null">
- mina_openid,
- </if>
- <if test="customerNo !=null">
- customer_no,
- </if>
- <if test="customerName !=null">
- customer_name,
- </if>
- <if test="mobilePhone !=null">
- mobile_phone,
- </if>
- <if test="amt !=null">
- amt,
- </if>
- <if test="cardOilsType !=null">
- card_oils_type,
- </if>
- <if test="stationId !=null">
- station_id,
- </if>
- <if test="stationName !=null">
- station_name,
- </if>
- <if test="createTime !=null">
- create_time,
- </if>
- <if test="recentlyTime !=null">
- recently_time,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="unionId !=null">
- #{unionId},
- </if>
- <if test="blogOpenid !=null">
- #{blogOpenid},
- </if>
- <if test="minaOpenid !=null">
- #{minaOpenid},
- </if>
- <if test="customerNo !=null">
- #{customerNo},
- </if>
- <if test="customerName !=null">
- #{customerName},
- </if>
- <if test="mobilePhone !=null">
- #{mobilePhone},
- </if>
- <if test="amt !=null">
- #{amt},
- </if>
- <if test="cardOilsType !=null">
- #{cardOilsType},
- </if>
- <if test="stationId !=null">
- #{stationId},
- </if>
- <if test="stationName !=null">
- #{stationName},
- </if>
- <if test="createTime !=null">
- #{createTime},
- </if>
- <if test="recentlyTime !=null">
- #{recentlyTime},
- </if>
- </trim>
- </insert>
- <!--根据unionId获取用户用要充值电子会员卡(储蓄卡)信息-->
- <select id="getElectronicCardInfoByUnionId" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
- SELECT
- id,
- union_id,
- blog_openid,
- mina_openid,
- customer_no,
- customer_name,
- amt,
- card_oils_type,
- station_id,
- station_name,
- create_time,
- recently_time
- FROM
- customer_electronic_card
- <where>
- <if test="stationId !='' and stationId != null" >
- station_id = #{stationId}
- </if>
- <if test="unionId !=null and unionId !=''">
- AND union_id = #{unionId}
- </if>
- <!-- <if test="blogOpenid !=null and blogOpenid !=''">-->
- <!-- AND blog_openid = #{blogOpenid}-->
- <!-- </if>-->
- <!-- <if test="minaOpenid !=null and minaOpenid !=''">-->
- <!-- AND mina_openid = #{minaOpenid}-->
- <!-- </if>-->
- <if test="cardOilsType !=null and cardOilsType !=''">
- AND card_oils_type = #{cardOilsType}
- </if>
- </where>
- </select>
- <!--获取用户用要充值电子会员卡(储蓄卡)信息-->
- <select id="getElectronicCardInfo" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
- SELECT
- id,
- union_id,
- blog_openid,
- mina_openid,
- customer_no,
- customer_name,
- amt,
- card_oils_type,
- station_id,
- station_name,
- create_time,
- recently_time
- FROM
- customer_electronic_card
- <where>
- <if test="id !=null and id !=''">
- id = #{id}
- </if>
- </where>
- </select>
- <!--更新用户的电子会员卡的信息-->
- <update id="updateElectronicCardInfo" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
- UPDATE
- customer_electronic_card
- <set>
- <if test="amt !=null">
- amt = #{amt},
- </if>
- <if test="recentlyTime !=null">
- recently_time = #{recentlyTime}
- </if>
- </set>
- <where>
- <if test="id !=null and id != ''">
- id = #{id}
- </if>
- </where>
- </update>
- <!--根据unionId更新用户的电子会员卡的信息-->
- <update id="updateElectronicCardInfoByUnionId" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
- UPDATE customer_electronic_card
- <set>
- <if test="unionId !=null">
- union_id = #{unionId},
- </if>
- <if test="blogOpenid !=null">
- blog_openid = #{blogOpenid},
- </if>
- <if test="minaOpenid !=null">
- mina_openid = #{minaOpenid},
- </if>
- <if test="customerNo !=null">
- customer_no = #{customerNo},
- </if>
- <if test="customerName !=null">
- customer_name = #{customerName},
- </if>
- <if test="mobilePhone !=null">
- mobile_phone = #{mobilePhone},
- </if>
- <if test="amt !=null">
- amt = #{amt},
- </if>
- <if test="cardOilsType !=null">
- card_oils_type = #{cardOilsType},
- </if>
- <if test="stationId !=null">
- station_id = #{stationId},
- </if>
- <if test="stationName !=null">
- station_name = #{stationName},
- </if>
- <if test="createTime !=null">
- create_time = #{createTime},
- </if>
- <if test="recentlyTime !=null">
- recently_time = #{recentlyTime}
- </if>
- </set>
- <where>
- <if test="stationId !='' and stationId != null" >
- station_id = #{stationId}
- </if>
- <!-- <if test="blogOpenid !=null and blogOpenid !=''">-->
- <!-- AND blog_openid = #{blogOpenid}-->
- <!-- </if>-->
- <!-- <if test="minaOpenid !=null and minaOpenid !=''">-->
- <!-- AND mina_openid = #{minaOpenid}-->
- <!-- </if>-->
- <if test="unionId !=null and unionId != ''">
- AND union_id = #{unionId}
- </if>
- <if test="cardOilsType !='' and cardOilsType != null" >
- AND card_oils_type = #{cardOilsType}
- </if>
- </where>
- </update>
- <!--查询油站的会员卡启用标识 (1、启动 2,停用)-->
- <select id="getStationCardEnabledFlag" parameterType="Integer" resultType="String">
- SELECT
- card_enabled_flag AS cardEnabledFlag
- FROM
- station_pay
- <where>
- <if test="stationId !='' and stationId != null" >
- station_id = #{stationId}
- </if>
- </where>
- </select>
- <!--根据小程序用户openId查询客户电子会员卡信息-->
- <select id="getElectronicCardInfoByMinaOpenId" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
- SELECT
- id,
- union_id,
- blog_openid,
- mina_openid,
- customer_no,
- customer_name,
- amt,
- card_oils_type,
- station_id,
- station_name,
- create_time,
- recently_time
- FROM
- customer_electronic_card
- <where>
- <if test="stationId !='' and stationId != null" >
- station_id = #{stationId}
- </if>
- <if test="minaOpenid !='' and minaOpenid != null" >
- AND mina_openid = #{minaOpenid}
- </if>
- <if test="cardOilsType !='' and cardOilsType != null" >
- AND card_oils_type = #{cardOilsType}
- </if>
- </where>
- </select>
- </mapper>
|