TdACardCouponsSMapper.xml 3.72 KB
<?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.zteits.pay.mapper.smapper.TdACardCouponsSMapper" >
  <resultMap id="BaseResultMap" type="com.zteits.pay.domain.TdACardCoupons" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="park_card_id" property="parkCardId" jdbcType="VARCHAR" />
    <result column="cust_id" property="custId" jdbcType="VARCHAR" />
    <result column="acct_id" property="acctId" jdbcType="VARCHAR" />
    <result column="card_big_type" property="cardBigType" jdbcType="INTEGER" />
    <result column="card_type" property="cardType" jdbcType="INTEGER" />
    <result column="card_balance" property="cardBalance" jdbcType="DECIMAL" />
    <result column="card_price" property="cardPrice" jdbcType="DECIMAL" />
    <result column="card_num" property="cardNum" jdbcType="INTEGER" />
    <result column="card_total_amount" property="cardTotalAmount" jdbcType="DECIMAL" />
    <result column="eff_date" property="effDate" jdbcType="TIMESTAMP" />
    <result column="exp_date" property="expDate" jdbcType="TIMESTAMP" />
    <result column="card_scope" property="cardScope" jdbcType="VARCHAR" />
    <result column="car_number" property="carNumber" jdbcType="VARCHAR" />
    <result column="remark" property="remark" jdbcType="VARCHAR" />
    <result column="push_state" property="pushState" jdbcType="INTEGER" />
    <result column="data_state" property="dataState" jdbcType="INTEGER" />
    <result column="create_empid" property="createEmpid" jdbcType="VARCHAR" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="modfiy_empid" property="modfiyEmpid" jdbcType="VARCHAR" />
    <result column="modfiy_date" property="modfiyDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, park_card_id, cust_id, acct_id, card_big_type, card_type, card_balance, card_price, 
    card_num, card_total_amount, eff_date, exp_date, card_scope, car_number, remark, 
    push_state, data_state, create_empid, create_date, modfiy_empid, modfiy_date
  </sql>
  <select id="queryCardCouponsByCustId" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from td_a_card_coupons
    where cust_id = #{custId,jdbcType=VARCHAR}
    and data_state  = 1
    and CURDATE() &gt;= eff_date
    and CURDATE() &lt;= exp_date
  </select>
  
  
    <select id="queryCardCouponsByparkCardId" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from td_a_card_coupons
    where park_card_id = #{parkardId,jdbcType=VARCHAR}
    and data_state  = 1
  </select>
  
   <select id="queryCardCouponsByCarNumbers" resultMap="BaseResultMap" >
    select 
    <include refid="Base_Column_List" />
    from td_a_card_coupons
    where car_number = #{carNumber}
    and data_state  = 1
     <![CDATA[and eff_date >= #{cardTime}]]>
    <![CDATA[and exp_date <= #{cardTime}]]>
  </select>
  
  <select id="queryPersonCardCouponsByCustId" resultType="java.util.HashMap">
	 SELECT
		t.id,
		t.park_card_id AS parkCardId,
		t.car_number AS carNumber,
		t.park_card_id AS parkCardId,
		t.card_price cardPrice,
		t.card_scope AS parkId,
		t.exp_date AS expDate,
		b.goods_type_remark cardTypeRemark,
		t.card_type cardType,
		CASE
	WHEN t.card_type IN ('20', '21') THEN
		'1'
	ELSE
		'0'
	END AS 'vipType',
	 CASE
	WHEN CURDATE() > t.exp_date THEN
		"0"
	ELSE
		"1"
	END AS "state"
	FROM
		td_a_card_coupons t,
		td_b_park_card_coupons b
	WHERE
		t.data_state = 1
	AND t.park_card_id = b.id
	AND t.cust_id = #{custId,jdbcType=VARCHAR}
	ORDER BY
		t.exp_date DESC
	
  </select>
</mapper>