AppBindingMapper.xml 5.28 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="cn.com.glsx.dj.reports.mapper.AppBindingMapper">
  <resultMap id="BaseResultMap" type="cn.com.glsx.dj.reports.model.AppBinding">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="phone_num" jdbcType="VARCHAR" property="phoneNum" />
    <result column="sn" jdbcType="VARCHAR" property="sn" />
    <result column="bind_status" jdbcType="INTEGER" property="bindStatus" />
    <result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
    <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
    <result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
    <result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" />
    <result column="deleted_flag" jdbcType="CHAR" property="deletedFlag" />
  </resultMap>
  <resultMap id="BaseResultDTOMap" type="cn.com.glsx.dj.reports.dto.AppBindingDTO" extends="BaseResultMap">
    
  </resultMap>
  
  <resultMap id="BaseResultInsMap" type="cn.com.glsx.dj.reports.vo.InsVO">
    <result column="id" jdbcType="INTEGER" property="insId" />
    <result column="company_code" jdbcType="VARCHAR" property="companyCode" />
    <result column="success_date" jdbcType="VARCHAR" property="successDate" />
    <result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
    <result column="phone" jdbcType="INTEGER" property="phone" />
    <result column="stand_no" jdbcType="VARCHAR" property="standNo" />
    <result column="sub_device_sn" jdbcType="VARCHAR" property="subDeviceSn" />
    <result column="vehicle_id" jdbcType="INTEGER" property="vehicleId" />
    <result column="sum_amount" jdbcType="DOUBLE" property="sumAmount" />
    <result column="channel_code" jdbcType="VARCHAR" property="channelCode" />
  </resultMap>



	<sql id="Base_Column_List">
    id, phone_num, sn, bind_status, merchant_id, created_by, created_date, updated_by, 
    updated_date, deleted_flag
  </sql>
  <sql id="baseWhereClause" >
    <where>
		<if test="record.id != null">
			and id = #{record.id,jdbcType=INTEGER}
		</if>
		<if test="record.phoneNum != null and record.phoneNum !=''">
			and phone_num LIKE CONCAT('%',#{record.phoneNum,jdbcType=VARCHAR},'%')
		</if>
		<if test="record.sn != null and record.sn !=''">
			and sn = #{record.sn,jdbcType=VARCHAR}
		</if>
		<if test="record.bindStatus != null and record.bindStatus !=''">
			and bind_status = #{record.bindStatus,jdbcType=INTEGER}
		</if>
		<if test="record.createdDate != null and record.createdDate !=''">
			and created_date = #{record.createdDate,jdbcType=TIMESTAMP}
		</if>
		<if test="record.updatedDate != null and record.updatedDate !=''">
			and updated_date = #{record.updatedDate,jdbcType=TIMESTAMP}
		</if>
		<if test="record.merchantId != null">
			and merchant_id = #{record.merchantId}
		</if>
		<if test="record.merchantIds != null and record.merchantIds.size > 0 ">
            and merchant_id in
            <foreach item="merchantId" index="index" collection="record.merchantIds" open="(" separator="," close=")">
	            #{merchantId}
	        </foreach>
		</if>
		and deleted_flag = 'N'
    </where>
  </sql>
  
  <select id="findAppBindingForBind" parameterType="cn.com.glsx.dj.reports.dto.AppBindingDTO" resultMap="BaseResultDTOMap">
  	select <include refid="Base_Column_List"></include> 
  	from dj_app_binding 
  	WHERE (phone_num = #{record.phoneNum,jdbcType=VARCHAR} OR sn = #{record.sn,jdbcType=VARCHAR}) 
  </select>
  
  <select id="listBasic" parameterType="cn.com.glsx.dj.reports.dto.AppBindingDTO" resultMap="BaseResultDTOMap">
  	select <include refid="Base_Column_List"></include> 
  	from dj_app_binding 
  	<include refid="baseWhereClause"/>
  </select>

  <select id="listInsures" resultMap="BaseResultInsMap">
  	SELECT 
	o.company_code,
	date_format(o.success_date,'%Y-%m-%d %H:%i:%s') as success_date,
	o.id,
	o.merchant_id,
	o.phone,
	o.stand_no,
	o.sub_device_sn,
	o.vehicle_id,
	o.sum_amount
	FROM dj_insure_order o
	WHERE o.insurance_status=1
	AND o.merchant_id IS NOT NULL
	AND o.success_date IS NOT NULL
	AND o.deleted_flag='N'
	AND o.sum_amount IS NOT NULL 
	AND o.stand_no IS NOT null
  </select>
  
  <select id="getInsuresBySn" resultMap="BaseResultInsMap" parameterType="java.lang.String">
  	SELECT 
	o.company_code,
	date_format(o.success_date,'%Y-%m-%d %H:%i:%s') as success_date,
	o.id,
	o.merchant_id,
	o.phone,
	o.stand_no,
	o.sub_device_sn,
	o.vehicle_id,
	o.sum_amount
	FROM dj_insure_order o
	WHERE o.insurance_status IN(1,7,11)
	AND o.deleted_flag='N'
	AND o.sub_device_sn=#{sn,jdbcType=VARCHAR}
	limit 0,1
  </select>
  
  <select id="count" parameterType="cn.com.glsx.dj.reports.model.AppBinding" resultType="java.lang.Integer">
  		 select count(1) 
  		 FROM dj_app_binding 
	<where>
		deleted_flag = 'N'
		<if test="bindStatus != null">
			and bind_status = #{bindStatus} 
		</if>
		<if test="merchantId != null">
			and merchant_id = #{merchantId} 
		</if>
		<if test="createdDateStr != null and createdDateStr !=''">
			and DATE_FORMAT(created_date,'%Y-%m-%d') =
		#{createdDateStr,jdbcType=VARCHAR}
		</if>
		<if test="sn != null and sn != ''">
			and sn = #{sn}
		</if>
	</where>
  </select>
</mapper>