TVipCardSmapper.xml 21.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
<?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.TVipCardSmapper">
  <resultMap id="BaseResultMap" type="com.zteits.bill.domain.TVipCard">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="card_no" jdbcType="VARCHAR" property="cardNo" />
    <result column="card_name" jdbcType="VARCHAR" property="cardName" />
    <result column="car_type" jdbcType="INTEGER" property="carType" />
    <result column="card_type" jdbcType="INTEGER" property="cardType" />
    <result column="sale_channel" jdbcType="INTEGER" property="saleChannel" />
    <result column="use_type" jdbcType="INTEGER" property="useType" />
    <result column="valid_unit" jdbcType="INTEGER" property="validUnit" />
    <result column="valid_num" jdbcType="INTEGER" property="validNum" />
    <result column="special_day_type" jdbcType="INTEGER" property="specialDayType" />
    <result column="valid_start_time" jdbcType="TIME" property="validStartTime" />
    <result column="valid_end_time" jdbcType="TIME" property="validEndTime" />
    <result column="price" jdbcType="BIGINT" property="price" />
    <result column="is_support_renew" jdbcType="INTEGER" property="isSupportRenew" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="eff_date" jdbcType="TIMESTAMP" property="effDate" />
    <result column="exp_date" jdbcType="TIMESTAMP" property="expDate" />
    <result column="card_status" jdbcType="INTEGER" property="cardStatus" />
    <result column="auditor_status" jdbcType="INTEGER" property="auditorStatus" />
    <result column="data_state" jdbcType="INTEGER" property="dataState" />
    <result column="create_empid" jdbcType="BIGINT" property="createEmpid" />
    <result column="create_name" jdbcType="VARCHAR" property="createName" />
    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
    <result column="modify_empid" jdbcType="BIGINT" property="modifyEmpid" />
    <result column="modify_name" jdbcType="VARCHAR" property="modifyName" />
    <result column="modify_date" jdbcType="TIMESTAMP" property="modifyDate" />
    <result column="org_id" jdbcType="BIGINT" property="orgId" />
    <result column="org_name" jdbcType="VARCHAR" property="orgName" />
  </resultMap>
  <sql id="Base_Column_List">
    id, card_no, card_name, car_type, card_type, sale_channel, use_type, valid_unit,
    valid_num, special_day_type, valid_start_time, valid_end_time, price, is_support_renew,
    remark, eff_date, exp_date, card_status, auditor_status, data_state, create_empid,
    create_name, create_date, modify_empid, modify_name, modify_date, org_id, org_name
  </sql>
  <!--通过会员卡编码查询会员卡信息-->
  <select id="queryVipCardByCardNo" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardByCardNoRequest" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from t_vip_card
    where
	  <if test="isDataState == null">
		  data_state=1 and
	  </if>
	  card_no = #{cardNo,jdbcType=VARCHAR}
       <if test="beginTime != null and beginTime !=''">
          <![CDATA[ and #{beginTime} >= eff_date ]]>
           <![CDATA[ and #{beginTime} <= exp_date ]]>
       </if>
	   <choose>
	     <when test="cardStatus == 1">
	        and card_status=1  /**商品状态:1、上架;2、下架.*/
	     </when>
	     <when test="cardStatus == 2">
	        and card_status=2  /**商品状态:1、上架;2、下架.*/
	     </when>
	     <otherwise>
	        and card_status=1  /**商品状态:1、上架;2、下架.*/
	     </otherwise>
	   </choose>


  </select>

  <!-- 分页查询-会员卡规则 -->
  <select id="queryVIPCardRuleForPage" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVIPCardRuleRequest"
    resultMap="BaseResultMap">
     select a.id,
		       a.card_no,
		       a.card_name,
		       a.car_type,
		       a.card_type,
		       a.sale_channel,
		       a.use_type,
	           a.valid_num,
		       a.special_day_type,
		       a.valid_start_time,
		       a.valid_end_time,
		       a.price,
		       a.card_status,
		       a.eff_date,
		       a.exp_date,
		       a.card_status,
		       a.create_date,
		       a.create_empid,
		       a.create_name,
		       a.eff_date,
		       a.auditor_status,
		       a.exp_date
		from t_vip_card  a ,
            (select b.card_no
             from t_vip_card_park_sale_rel b
             where b.data_state=1
              <if test="plNos != null and plNos.size >0">
	            and b.pl_no in
	            <foreach collection="plNos" open="(" close=")" item="parkId" separator=",">
	                #{parkId}
	            </foreach>
	        </if>
              group by b.card_no
          )c
		where a.data_state =1
		      and a.card_no=c.card_no
		  <if test="cardType != null ">
		     and a.card_type = #{cardType}  /**卡类型 1-年卡;2-半年卡;3-季卡;4-月卡;5-日卡;*/
		  </if>
		 <if test="carType != null">
		    and a.car_type =#{carType}  /**1-大型车;2-小型车*/
		 </if>
		 <if test="cardStatus != null ">
		   and a.card_status=#{cardStatus} /**商品状态:1、上架;2、下架*/
		 </if>
		 <if test="cardNo != null and cardNo !=''">
		   and a.card_no=#{cardNo}
		 </if>
		 <if test="saleChannel != null and saleChannel !=''">
		   and a.sale_channel=#{saleChannel}
		 </if>
		  <if test="cardName != null and cardName !=''">
			  and a.card_name like '%${cardName}%'
		  </if>

		order by a.id desc

  </select>



   <!--通过会员卡对象查询会员卡信息 langlw 2017-10-30-->
  <select id="queryVipCardByVipCard" parameterType="com.zteits.bill.domain.TVipCard"
  	resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from t_vip_card
    where data_state = 1
    <if test="cardType != null">
		   and card_type =#{cardType}
	</if>
	<if test="cardNo != null">
		   and card_no =#{cardNo}
	</if>
  </select>


   <!--分页查询会员卡信息集合 langlw 2017-10-30 -->
  <select id="queryVipCardForPageByVipCard" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.VipCardForPageRequest"
  	resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from t_vip_card
    where data_state = 1
    <if test="cardStatus != null">
		   and card_status =#{cardStatus}
	</if>
	<if test="isEff != null and isEff==1 ">
		   <![CDATA[ and DATE_FORMAT(eff_date ,'%Y-%m-%d') <= DATE_FORMAT(now() ,'%Y-%m-%d') and  DATE_FORMAT(now() ,'%Y-%m-%d') <=  DATE_FORMAT(exp_date ,'%Y-%m-%d') ]]>
	</if>

  </select>
  <!-- 校验对应的时间段内停车场是否重复办理-->
  <select id="checkVipCardPark" resultType="com.zteits.bill.domain.CheckVipCardParkDO" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.CheckVipCardParkRequest">
      select a.card_no  as cardNo,
		       a.card_name as cardName,
		       a.eff_date as effDate,
		       a.exp_date as expDate,
		       b.pl_no as plNo
			from t_vip_card a ,
			t_vip_card_park_sale_rel b
			where a.data_state=b.data_state
			and a.data_state=1
			and a.card_status =1 /**商品状态:1、上架;2、下架.*/
			and a.auditor_status=2 /**审核状态:1:待审核 2:审核通过,3:审核驳回.*/
			<![CDATA[ and a.exp_date > #{effDate} ]]> /**前台开始时间小于结束时间 , 前台结束时间大于开始时间.*/
			<![CDATA[ and a.eff_date < #{expDate} ]]>/**前台开始时间小于结束时间 , 前台结束时间大于开始时间.*/
			and a.card_no=b.card_no
			and a.car_type =#{carType}   /**1-大型车;2-小型车 3:不限制*/
			and a.card_type=#{cardType}   /**卡类型 1-年卡;2-半年卡;3-季卡;4-月卡;5-日卡;*/
			and a.sale_channel=#{saleChannel} /**售卖渠道:1-APP、2-公众号、3-线下*/
			and a.use_type =#{useType}   /**使用类型:1-单体卡;2-共享卡*/
	        <if test="specialDayType != null ">
                and a.special_day_type=#{specialDayType}
            </if>

			and b.pl_no in
            <foreach collection="plNos" open="(" close=")" item="parkId" separator=",">
                #{parkId}
            </foreach>
  </select>

<select id="queryParkVipCardByPlNo" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVIPCardRuleRequest"
    resultMap="BaseResultMap">
     select a.id,
		       a.card_no,
		       a.card_name,
		       a.car_type,
		       a.card_type,
		       a.sale_channel,
		       a.use_type,
		       a.special_day_type,
		       a.valid_start_time,
		       a.valid_end_time,
		       a.price,
		       a.card_status,
		       a.eff_date,
		       a.exp_date,
		       a.card_status,
		       a.create_date,
		       a.create_empid,
		       a.create_name,
		       a.eff_date,
		       a.auditor_status,
		       a.exp_date
					FROM
				t_vip_card a,
				t_vip_card_park_sale_rel b
		   where a.data_state =1
		      and a.card_no=b.card_no
		  <if test="cardType != null ">
		     and a.card_type = #{cardType}  /**卡类型 1-年卡;2-半年卡;3-季卡;4-月卡;5-日卡;*/
		  </if>
		 <if test="cardStatus != null ">
		   and a.card_status=#{cardStatus} /**商品状态:1、上架;2、下架*/
		 </if>
		 <if test="cardNo != null and cardNo !=''">
		   and a.card_no=#{cardNo}
		 </if>
		 <if test="saleChannel != null and saleChannel !=''">
		   and a.sale_channel=#{saleChannel}
		 </if>
		GROUP BY a.card_type
  </select>


  <!--rnt 通过停车场编码查询会员卡  -->
  <select id="queryVipCardParkSaleRelForListByPlNo" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardByPlNoRequest"
  resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardAndCustInfoDTO" >
	   select
		a.id              as  id,
		a.card_no         as cardNo,
		a.card_name       as cardName,
		a.car_type        as carType,
		a.card_type       as cardType,
		a.use_type        as useType,
		c.pl_no           as plNo,
		a.price           as price,
		c.disc_value      as discValue,
		a.eff_date        as effDate,
		a.exp_date        as expDate,
	  	a.org_id          as orgId

		from  t_vip_card a,
		(select c.pl_no,c.card_no,c.disc_value
		from t_vip_card_park_sale_rel c
		where c.data_state=1
		<if test="plNos != null and plNos.size >0">
            and c.pl_no in
            <foreach collection="plNos" open="(" close=")" item="parkId" separator=",">
                #{parkId}
            </foreach>
        </if>
        <if test="plNo != null and plNo !='' ">
		   and c.pl_no =#{plNo}
		</if>
		group by c.pl_no,c.card_no,c.disc_value
		)c
		where a.card_no=c.card_no
		and a.data_state=1
	    and a.card_status=1
	  	<if test="orgId != null ">
		  	and a.org_id =#{orgId}
	  	</if>
	    <if test="saleChannel != null ">
		     and a.sale_channel =#{saleChannel}
	    </if>
		<![CDATA[ and DATE_FORMAT(a.eff_date ,'%Y-%m-%d') <= DATE_FORMAT(now() ,'%Y-%m-%d') and  DATE_FORMAT(now() ,'%Y-%m-%d') <=  DATE_FORMAT(a.exp_date ,'%Y-%m-%d') ]]>
		order by c.pl_no desc
  </select>

  <!-- 通过停车场编码查询会员卡编码  -->
  <select id="queryVipCardNosByPlNos" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardByPlNoRequest"
  resultType="java.lang.String">
	  select c.card_no
		from t_vip_card_park_sale_rel c
		where c.data_state=1
		<if test="plNos != null and plNos.size >0">
            and c.pl_no in
            <foreach collection="plNos" open="(" close=")" item="parkId" separator=",">
                #{parkId}
            </foreach>
        </if>
  </select>

   <!--rnt 通过custId查询个人拥有的会员卡-->
  <select id="queryVipCardByCustId" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardCustInfoByCustIdRequest"
  resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardAndCustInfoDTO" >
	   	select
		tv.id            as custCardRelId,
		a.id             as custCardId,
		a.cust_card_no   as custCardNo,
		a.cust_id        as peronCustId,
		a.car_number     as carNumber,
		b.car_type       as carType,
		b.card_type      as cardType,
		b.card_no        as cardNo,
		b.card_name      as cardName,
		a.num            as num,
		a.price          as price,
		a.discount_amount as discountAmount,
		a.total_amount   as totalAmount,
		a.eff_date       as effDate,
		a.exp_date       as expDate,
	    a.update_num     as updateNum,
		tv.pl_no         as plNo,
		b.use_type       as useType,
		b.card_status    as cardState,
		b.sale_channel   as saleChannel,
		b.org_id   as orgId
		from t_vip_card_park_cust_rel tv , t_vip_card_cust_info a,
		t_vip_card b
		where  tv.data_state = 1 and a.data_state=1 and b.data_state=1
		and  a.card_no = b.card_no and tv.cust_card_no = a.cust_card_no

	  <if test="custId != null and custId !='' ">
		  and tv.cust_id = #{custId}
	  </if>
	  <if test="carNumber != null and carNumber !='' ">
		  and tv.car_number = #{carNumber}
	  </if>
		<if test="custCardNo != null and custCardNo !='' ">
		   and tv.cust_card_no =#{custCardNo}
		</if>
	  <if test="cardNo != null and cardNo !='' ">
		  and a.card_no =#{cardNo}
	  </if>
	  <if test="cardNoList != null and cardNoList.size >0">
		  and a.card_no in
		  <foreach collection="cardNoList" open="(" close=")" item="cardNos" separator=",">
			  #{cardNos}
		  </foreach>
	  </if>

		<if test="saleChannelList != null and saleChannelList.size >0">
			and b.sale_channel in
			<foreach collection="saleChannelList" open="(" close=")" item="saleChannelLittle" separator=",">
			  #{saleChannelLittle}
			</foreach>
		</if>
		<if test="saleChannel != null ">
		   and b.sale_channel =#{saleChannel}
		</if>
		<if test="orgId != null ">
		  and b.org_id =#{orgId}
		</if>
		<![CDATA[ and  DATE_FORMAT(now() ,'%Y-%m-%d') <=  DATE_FORMAT(a.exp_date ,'%Y-%m-%d') ]]>
		ORDER BY tv.create_date desc
  </select>



	<!--rnt 通过custId查询个人拥有的会员卡-->
	<select id="queryVipCardAllByCustId" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardCustInfoByCustIdRequest"
			resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardAndCustInfoDTO" >
		select
		tv.id            as custCardRelId,
		a.id             as custCardId,
		a.cust_card_no   as custCardNo,
		a.cust_id        as peronCustId,
		a.car_number     as carNumber,
		b.car_type       as carType,
		b.card_type      as cardType,
		b.card_no        as cardNo,
		b.card_name      as cardName,
		a.num            as num,
		a.price          as price,
		a.discount_amount as discountAmount,
		a.total_amount   as totalAmount,
		a.eff_date       as effDate,
		a.exp_date       as expDate,
		tv.pl_no         as plNo,
		b.use_type       as useType,
		b.card_status    as cardState,
		b.sale_channel   as saleChannel,
		b.org_id   as orgId
		from t_vip_card_park_cust_rel tv , t_vip_card_cust_info a,
		t_vip_card b
		where  tv.data_state = 1 and a.data_state=1 and b.data_state=1
		and  a.card_no = b.card_no and tv.cust_card_no = a.cust_card_no

		<if test="custId != null and custId !='' ">
			and tv.cust_id = #{custId}
		</if>
		<if test="carNumber != null and carNumber !='' ">
			and tv.car_number = #{carNumber}
		</if>
		<if test="custCardNo != null and custCardNo !='' ">
			and tv.cust_card_no =#{custCardNo}
		</if>
		<if test="cardNo != null and cardNo !='' ">
			and a.card_no =#{cardNo}
		</if>
		<if test="cardNoList != null and cardNoList.size >0">
			and a.card_no in
			<foreach collection="cardNoList" open="(" close=")" item="cardNos" separator=",">
				#{cardNos}
			</foreach>
		</if>

		<if test="saleChannelList != null and saleChannelList.size >0">
			and b.sale_channel in
			<foreach collection="saleChannelList" open="(" close=")" item="saleChannelLittle" separator=",">
				#{saleChannelLittle}
			</foreach>
		</if>
		<if test="saleChannel != null ">
			and b.sale_channel =#{saleChannel}
		</if>
		<if test="orgId != null ">
			and b.org_id =#{orgId}
		</if>
		ORDER BY tv.create_date desc
		limit 1;
	</select>

     <!--rnt 通过CardNo查询会员卡详情-->
  <select id="queryVipCardMsgByCardNo" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardByCardNoRequest"
  resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardAndCustInfoDTO" >
	   select
		b.car_type       as carType,
		b.card_type      as cardType,
		b.card_no        as cardNo,
		b.card_name      as cardName,
		b.price          as price,
		b.eff_date       as effDate,
		b.exp_date       as expDate,
		b.is_support_renew  as isSupportRenew,
		b.use_type       as useType,
		b.sale_channel   as saleChannel,
		b.card_status    as cardState,
		tv.pl_no         as plNo,
		tv.disc_value    as discValue
		from  t_vip_card_park_sale_rel tv ,
		t_vip_card b
		where  tv.data_state = 1 and b.data_state=1
		and  tv.card_no = b.card_no
		and b.card_no = #{cardNo}
		ORDER BY tv.create_date desc
  </select>

  <!-- 通过卡规则查询卡费用 -->
  <select id="queryVipCardFeeByCardNo" parameterType="java.lang.String"
    resultType="java.lang.Long">
    select price from t_vip_card where card_no = #{cardNo}
  </select>
	<!--通过会员卡编码查询会员卡信息(不可修改)-->
	<select id="queryVipCardByOnlyCardNo" parameterType="java.lang.String"  resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List" />
		from t_vip_card
		where
		card_no = #{cardNo,jdbcType=VARCHAR}
	</select>

	<!-- 通过停车场编码List查询的的授权车的信息-->
	<select id="queryVipCardStatisticPlNos" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardByCarNumberAndPlNosRequest"
			resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardStatisticDTO" >
		select
		b.card_type      as cardType,
		ifnull(count(a.car_number),0)   as carNum,
		ifnull(sum(a.total_amount-a.discount_amount),0)   as totalAmount
		from t_vip_card_park_cust_rel tv , t_vip_card_cust_info a,
		t_vip_card b
		where  tv.data_state = 1 and a.data_state=1 and b.data_state=1
		and  a.card_no = b.card_no and tv.cust_card_no = a.cust_card_no
		and  b.use_type = 1
		<if test="plNos != null and plNos.size >0">
			and tv.pl_no in
			<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
				#{plNo}
			</foreach>
		</if>
		<if test="beginTime != null">
			AND a.create_date &gt;= #{beginTime}
		</if>
		<if test="endTime != null">
			AND a.create_date &lt;= #{endTime}
		</if>
		group by  b.card_type
	</select>


	<!-- 查询停车场会员卡购买数量是否超过最大限制数量-->
	<select id="queryVipCardMaxBuyNumIsLimit" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.VipCardBuyNumLimtReq"
	  resultType="com.zteits.bill.domain.sdomain.VipCardMaxBuyNumIsLimitDO">
		select c.buyTotal ,IFNULL(c.maxLimitNum,0) as maxLimitNum  from (
		SELECT
		count(b.id) as buyTotal,
		max(a.valid_num)  as maxLimitNum
		FROM
		t_vip_card a,
		t_vip_card_cust_info b,
		t_vip_card_park_cust_rel c
		where a.card_no=b.card_no
		and b.cust_card_no=c.cust_card_no
		and b.data_state=1
		and b.exp_date >= now()
		and a.exp_date >=now()
		and c.pl_no=#{plNo}
		and a.card_type=#{cardType}  /**卡类型 1-年卡 2-半年卡 3-季卡;4-月卡;5-日卡;*/
     <![CDATA[AND ((#{beginTime} >= b.eff_date AND #{beginTime} <= b.exp_date)
					OR (#{endTime} >= b.eff_date AND #{endTime} <= b.exp_date)
					OR (#{beginTime}  <=  b.eff_date AND #{endTime} >= b.exp_date )
					OR (#{beginTime} > b.eff_date AND #{endTime} < b.exp_date))
               ]]>
    )c
	</select>

	<!--查询会员卡停车场列表 niueb 2019/12/12-->
	<select id="queryParkListForVipCard" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardPlNoListRequest"
			resultType="java.lang.String">
		select distinct b.pl_no
		from t_vip_card a,
		t_vip_card_park_sale_rel b
		where a.data_state = 1
		and b.data_state = 1
		and a.card_no = b.card_no
		and a.org_id is not null
		<if test="orgId != null">
			and a.org_id = #{orgId,jdbcType=BIGINT}
		</if>
		and a.card_status = 1
		<if test="expDate != null">
			and a.exp_date > #{expDate,jdbcType=TIMESTAMP}
		</if>
		and a.sale_channel = 1
	</select>

	<!--查询会员卡热门停车场列表 niueb 2019/12/12-->
	<select id="queryHotParkListForVipCard" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardPlNoListRequest"
			resultType="java.lang.String">
		select c.pl_no
			from t_vip_card a,
		 	 	 t_vip_card_cust_info b,
     		 	 t_vip_card_park_cust_rel c
        where a.data_state = 1
        	and b.data_state = 1
        	and a.card_no = b.card_no
        	and a.org_id is not null
			<if test="orgId != null">
				and a.org_id = #{orgId,jdbcType=BIGINT}
			</if>
			and a.card_status = 1
			<if test="expDate != null">
				and a.exp_date > #{expDate,jdbcType=TIMESTAMP}
			</if>
			and a.sale_channel = 1
			and b.cust_card_no = c.cust_card_no
		group by c.pl_no
		order by count(1) desc
		limit 6
	</select>

	<!--根据车场编号查询会员卡信息 niueb 2019/12/12-->
	<select id="queryVipCardInfoByPlNo" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardByPlNoRequest"
			resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardDTO">
		select distinct
			a.card_no      as cardNo,
			a.card_name    as cardName,
			a.car_type     as carType,
			a.card_type    as cardType,
			a.sale_channel as saleChannel,
			a.use_type     as useType,
			a.valid_unit   as validUnit,
			a.valid_num    as validNum,
			a.special_day_type as specialDayType,
			a.valid_start_time as validStartTime,
			a.valid_end_time as validEndTime,
			a.price        as price,
			a.is_support_renew as isSupportRenew,
			a.remark       as remark,
			a.eff_date     as effDate,
			a.exp_date     as expDate,
			a.card_status  as cardStatus,
			a.auditor_status as auditorStatus,
			b.disc_value   as discValue
		from t_vip_card a,
		t_vip_card_park_sale_rel b
		where a.data_state = 1
		and b.data_state = 1
		and a.card_no = b.card_no
		and a.org_id is not null
		<if test="orgId != null">
			and a.org_id = #{orgId,jdbcType=BIGINT}
		</if>
		and a.card_status = 1
		and a.sale_channel = 1
        and a.exp_date > #{nowDate,jdbcType=TIMESTAMP}
		<if test="plNo != null and plNo != ''">
			and b.pl_no = #{plNo,jdbcType=VARCHAR}
		</if>
	</select>

</mapper>