TActivityDiscountRuleSmapper.xml 9.79 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.bill.mapper.smapper.TActivityDiscountRuleSmapper">
  <resultMap id="BaseResultMap" type="com.zteits.bill.domain.TActivityDiscountRule">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="disc_no" jdbcType="VARCHAR" property="discNo" />
    <result column="disc_rule_no" jdbcType="VARCHAR" property="discRuleNo" />
    <result column="disc_rule_name" jdbcType="VARCHAR" property="discRuleName" />
    <result column="disc_terminal_res" jdbcType="INTEGER" property="discTerminalRes" />
    <result column="disc_pay_type" jdbcType="INTEGER" property="discPayType" />
    <result column="dis_car_type" jdbcType="INTEGER" property="disCarType" />
    <result column="disc_value" jdbcType="VARCHAR" property="discValue" />
    <result column="is_t_limit" jdbcType="INTEGER" property="isTLimit" />
    <result column="eff_date" jdbcType="TIME" property="effDate" />
    <result column="exp_date" jdbcType="TIME" property="expDate" />
    <result column="special_day_type" jdbcType="INTEGER" property="specialDayType" />
    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
    <result column="data_state" jdbcType="INTEGER" property="dataState" />
    <result column="create_empid" jdbcType="VARCHAR" property="createEmpid" />
    <result column="create_name" jdbcType="VARCHAR" property="createName" />
    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
    <result column="modify_empid" jdbcType="VARCHAR" property="modifyEmpid" />
    <result column="modify_name" jdbcType="VARCHAR" property="modifyName" />
    <result column="modify_date" jdbcType="TIMESTAMP" property="modifyDate" />
  </resultMap>
  <sql id="Base_Column_List">
    id, disc_no, disc_rule_no, disc_rule_name, disc_terminal_res, disc_pay_type, dis_car_type, 
    disc_value, is_t_limit, eff_date, exp_date, special_day_type, remarks, data_state, 
    create_empid, create_name, create_date, modify_empid, modify_name, modify_date
  </sql>
 
 	<!-- 根据折扣规则编码查询折扣价格 -->
 	<select id="queryDiscountRuleByDiscNo" parameterType="java.lang.String" resultMap="BaseResultMap">
 		select 
 		<include refid="Base_Column_List"></include>
 		from t_activity_discount_rule
 		where data_state=1
 		and disc_rule_no =#{discRuleNo}
 		
 	</select>
 	<!-- 通过停车场编码,折扣类型,终端来源,车辆类型,出场时间查询停车场所有折扣规则 -->
 	<select id="queryDiscontRuleForList" parameterType="com.zteits.clouds.api.dto.bill.discount.param.QueryDiscountRuleRequest"
 	 resultType="com.zteits.bill.domain.DiscontRuleForParkDO">
 	       select  a.pl_no               as plNo,
			       a.disc_no             as discNo,
			       b.disc_rule_no        as discRuleNo,
			       b.disc_rule_name      as discRuleName,
			       a.disc_res            as discRes,
			       a.disc_type           as discType,
			       b.disc_terminal_res   as discTerminalRes,
			       b.disc_pay_type       as discPayType,
			       b.dis_car_type        as disCarType,
			       b.disc_value          as discValue,
			       b.is_t_limit          as isTLimit,
			       b.eff_date            as effDate,
			       b.exp_date            as expDate,
			       b.special_day_type    as specialDayType
			from t_activity_discount a ,t_activity_discount_rule b 
			where a.disc_no=b.disc_no
			and a.data_state=b.data_state
			and a.disc_state =1  /**折扣状态:1、上架;2、下架.*/
			<if test="plNo != null and plNo !=''">
			  and a.pl_no=#{plNo}
			</if>
			<if test="discType != null">
			  and a.disc_type=#{discType}   /**折扣类型:1.停车支付折扣 2:购买会员卡活动.*/
			</if>
			<if test="discTerminalRes != null">
			   and b.disc_terminal_res =#{discTerminalRes}    /**终端来源:1:PDA 2:APP 3:公众号.*/
			</if>
			<if test="disCarTpye != null">
			   and b.dis_car_type  =#{disCarTpye}      /**车辆类型:1-大型车;2-小型车 3:不限制.*/
			</if>
            <if test="payType != null and payType == 36">
                and (b.disc_pay_type = #{payType})    /**支付方式-- 1:支付宝 2:微信 3:银联 4:微信公众号 5 个人账户*/
            </if>
            <if test="payType != null and payType != 36">
            and (b.disc_pay_type = #{payType} or b.disc_pay_type = -1)    /**支付方式-- 1:支付宝 2:微信 3:银联 4:微信公众号 5 个人账户*/
            </if>
			<if test="parkOutTime != null">
			  <![CDATA[and a.begin_time <= #{parkOutTime}]]>
			  <![CDATA[and a.end_time >=#{parkOutTime}]]>
			</if>
 	</select>
 	 <!-- 根据折扣规则编码查询折扣价格 -->
 	<select id="queryDiscountRuleById" parameterType="java.lang.String" resultMap="BaseResultMap">
 		select 
 		<include refid="Base_Column_List"></include>
 		from t_activity_discount_rule
 		where data_state=1
 		and disc_no =#{discNo}
 	</select>

    <!-- 查询自助折扣 -->
    <select id="queryDiscountRuleInfo" resultType="com.zteits.bill.domain.TActivityDiscountRule">
        select
        a.disc_no as discNo,
        a.disc_rule_no as discRuleNo,
        a.disc_rule_name as discRuleNo,
        a.disc_value as discValue,
        a.disc_pay_type as discPayType
        from t_activity_discount_rule a
        where a.data_state=1
        and a.disc_no = #{discNo}
    </select>

    <!-- 查询普通折扣 -->
    <select id="queryDiscountRuleInfos" resultType="com.zteits.bill.domain.TActivityDiscountRule">
        select
        <include refid="Base_Column_List"></include>
        from t_activity_discount_rule
        where data_state=1
        and disc_rule_no = #{discRuleNo}
        and disc_pay_type != #{discPayType}
    </select>

    <!-- 查询自主折扣 -->
    <select id="queryDiscountRuleInfoSelf" resultType="com.zteits.bill.domain.TActivityDiscountRule">
        select
        <include refid="Base_Column_List"></include>
        from t_activity_discount_rule
        where data_state=1
        and disc_rule_no = #{discRuleNo}
        and disc_pay_type = #{discPayType}
    </select>

    <!-- 删除折扣规则-根据折扣编码 -->
 	<update id="updateDiscountRule" parameterType="com.zteits.bill.domain.TActivityDiscountRule">
    update t_activity_discount_rule
    <set>
      <if test="discRuleNo != null">
        disc_rule_no = #{discRuleNo,jdbcType=VARCHAR},
      </if>
      <if test="discRuleName != null">
        disc_rule_name = #{discRuleName,jdbcType=VARCHAR},
      </if>
      <if test="discTerminalRes != null">
        disc_terminal_res = #{discTerminalRes,jdbcType=INTEGER},
      </if>
      <if test="discPayType != null">
        disc_pay_type = #{discPayType,jdbcType=INTEGER},
      </if>
      <if test="disCarType != null">
        dis_car_type = #{disCarType,jdbcType=INTEGER},
      </if>
      <if test="discValue != null">
        disc_value = #{discValue,jdbcType=VARCHAR},
      </if>
      <if test="isTLimit != null">
        is_t_limit = #{isTLimit,jdbcType=INTEGER},
      </if>
      <if test="effDate != null">
        eff_date = #{effDate,jdbcType=TIME},
      </if>
      <if test="expDate != null">
        exp_date = #{expDate,jdbcType=TIME},
      </if>
      <if test="specialDayType != null">
        special_day_type = #{specialDayType,jdbcType=INTEGER},
      </if>
      <if test="remarks != null">
        remarks = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="dataState != null">
        data_state = #{dataState,jdbcType=INTEGER},
      </if>
      <if test="createEmpid != null">
        create_empid = #{createEmpid,jdbcType=VARCHAR},
      </if>
      <if test="createName != null">
        create_name = #{createName,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="modifyEmpid != null">
        modify_empid = #{modifyEmpid,jdbcType=VARCHAR},
      </if>
      <if test="modifyName != null">
        modify_name = #{modifyName,jdbcType=VARCHAR},
      </if>
      <if test="modifyDate != null">
        modify_date = #{modifyDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where disc_no = #{discNo,jdbcType=VARCHAR}
  </update>
 	 
  <!-- 添加规则详情 -->
  <insert id="addDiscountRule">
    insert into t_activity_discount_rule (disc_no, disc_rule_no, disc_rule_name, 
      disc_terminal_res, 
      disc_pay_type, dis_car_type, disc_value, 
      is_t_limit, eff_date, exp_date, 
      special_day_type, remarks, data_state, 
      create_empid, create_name, create_date, 
      modify_empid, modify_name, modify_date
      )
    values 
    <foreach collection="discountRuleList" index="index" item="discountRule" separator="," open="" close="">
    (#{discountRule.discNo,jdbcType=VARCHAR}, #{discountRule.discRuleNo,jdbcType=VARCHAR}, #{discountRule.discRuleName,jdbcType=VARCHAR}, 
      #{discountRule.discTerminalRes,jdbcType=INTEGER}, 
      #{discountRule.discPayType,jdbcType=INTEGER}, #{discountRule.disCarType,jdbcType=INTEGER}, #{discountRule.discValue,jdbcType=VARCHAR}, 
      #{discountRule.isTLimit,jdbcType=INTEGER}, #{discountRule.effDate,jdbcType=TIME}, #{discountRule.expDate,jdbcType=TIME}, 
      #{discountRule.specialDayType,jdbcType=INTEGER}, #{discountRule.remarks,jdbcType=VARCHAR}, #{discountRule.dataState,jdbcType=INTEGER}, 
      #{discountRule.createEmpid,jdbcType=VARCHAR}, #{discountRule.createName,jdbcType=VARCHAR}, #{discountRule.createDate,jdbcType=TIMESTAMP}, 
      #{discountRule.modifyEmpid,jdbcType=VARCHAR}, #{discountRule.modifyName,jdbcType=VARCHAR}, #{discountRule.modifyDate,jdbcType=TIMESTAMP}
      )
    </foreach>
  </insert>
  
  <!-- 删除折扣规则 -->
  <delete id="deleteDiscountRuleByDiscNo" parameterType="java.lang.String">
    delete from t_activity_discount_rule
    where disc_no =  #{discNo,jdbcType=VARCHAR}
  </delete>
 
</mapper>