|
- <?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.iformall.mapper.WxCUserCarMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserCar">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
-
- <result column="phone" jdbcType="VARCHAR" property="userPhone" />
-
- <result column="car_number" jdbcType="VARCHAR" property="carNumber" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="vendor_type" jdbcType="INTEGER" property="vendorType" />
- <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams" />
- <result column="vendor_person_id" jdbcType="VARCHAR" property="vendorPersonId" />
- </resultMap>
-
- <sql id="allColumns">
- wcuc.`id`,wcuc.`tenant_id`,wcuc.`parent_tenant_id`,wcuc.`c_user_id`,wcuc.`car_number`,wcuc.`create_date`,wcuc.`update_date`,wcuc.`vendor_type`,wcuc.`vendor_params`,wcuc.`vendor_person_id`
- </sql>
-
- <sql id="dynamicWhereConditions">
-
- where 1=1
- <if test=" null != id ">
- and wcuc.`id` = #{id}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and wcuc.`tenant_id` = #{tenantId}
- </if>
-
- <if test=" null != parentTenantId and '' != parentTenantId">
- and wcuc.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != cUserId ">
- and wcuc.`c_user_id` = #{cUserId}
- </if>
-
- <if test=" null != carNumber ">
- and wcuc.`car_number` like concat('%', #{carNumber},'%')
- </if>
- <!-- <if test=" null != carNumber ">
- and `car_number` like concat('%', #{carNumber},'%')
- </if> -->
-
- <if test=" null != createDate ">
- and wcuc.`create_date` = #{createDate}
- </if>
-
- <if test=" null != vendorType ">
- and wcuc.`vendor_type` = #{vendorType}
- </if>
-
- <!--<if test=" null != vendorParams ">
- and `vendor_params` like concat('%', #{vendorParams},'%')
- </if>-->
-
- <if test=" null != vendorPersonId ">
- and wcuc.`vendor_person_id` = #{vendorPersonId}
- </if>
-
- <if test=" null != ids ">
- and wcuc.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != userIds ">
- and wcuc.c_user_id in
- <foreach collection="userIds" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <!-- <if test=" null != sortColumns"> order by ${sortColumns} </if>-->
- order by wcuc.create_date
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCUserCar" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_c_user_car wcuc
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="countList" parameterType="com.iformall.domain.po.WxCUserCar" resultType="java.lang.Integer">
- select count(1) from wx_c_user_car wcuc
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="countUser" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Integer">
- select count(DISTINCT ubi.id)
- from wx_c_user_car uc
- left join wx_c_user_basic_info ubi on uc.c_user_id = ubi.id
- where uc.tenant_id = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and uc.parent_tenant_id = #{parentTenantId}
- </if>
- <if test=" null != startTime ">
- and ubi.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and ubi.create_date < #{endTime}
- </if>
-
- </select>
-
- <select id="queryCarCount" parameterType="hashmap" resultType="long">
- select count(id) from wx_c_user_car
- where `tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and create_date between #{startdate} and #{enddate}
- </select>
-
- <select id="queryCarCountHistory" resultType="hashmap" parameterType="hashmap">
- SELECT count(DISTINCT c.id) count, c.create_time FROM
- (SELECT ubi.id as id, DATE_FORMAT(uc.create_date, '%m/%d') create_time
- FROM wx_c_user_car uc, wx_c_user_basic_info ubi
- WHERE uc.c_user_id = ubi.id
- <if test=" null != tenantId and '' != tenantId">
- and uc.tenant_id = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and uc.parent_tenant_id = #{parentTenantId}
- </if>
- AND ubi.create_date BETWEEN #{startdate} AND #{enddate}) c
- GROUP BY c.create_time ORDER BY c.create_time
- </select>
-
- </mapper>
|