TdCCarSMapper.xml 8.74 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.TdCCarSMapper" >
  <resultMap id="BaseResultMap" type="com.zteits.pay.domain.TdCCar">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="cust_id" jdbcType="VARCHAR" property="custId" />
    <result column="car_number" jdbcType="VARCHAR" property="carNumber" />
    <result column="car_model_id" jdbcType="INTEGER" property="carModelId" />
    <result column="car_number_color" jdbcType="INTEGER" property="carNumberColor" />
    <result column="plate_type_id" jdbcType="INTEGER" property="plateTypeId" />
    <result column="car_brand_id" jdbcType="INTEGER" property="carBrandId" />
    <result column="car_shelf_num" jdbcType="VARCHAR" property="carShelfNum" />
    <result column="car_engine_num" jdbcType="VARCHAR" property="carEngineNum" />
    <result column="phone_number" jdbcType="VARCHAR" property="phoneNumber" />
    <result column="car_binding_status" jdbcType="INTEGER" property="carBindingStatus" />
    <result column="data_state" jdbcType="INTEGER" property="dataState" />
    <result column="create_empid" jdbcType="VARCHAR" property="createEmpid" />
    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
    <result column="modfiy_empid" jdbcType="VARCHAR" property="modfiyEmpid" />
    <result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
    <result column="examine_state" jdbcType="INTEGER" property="examineState" />
    <result column="cer_picture_path" jdbcType="VARCHAR" property="cerPicturePath" />
  </resultMap>
  <sql id="Base_Column_List">
    id, cust_id, car_number,car_number_color, car_model_id, plate_type_id, car_brand_id, car_shelf_num,
    car_engine_num, phone_number, car_binding_status, data_state, create_empid, create_date,
    modfiy_empid, modfiy_date, examine_state, cer_picture_path
  </sql>
  <select id="selectCustInfoBycustId" resultMap="BaseResultMap" parameterType="com.zteits.clouds.api.dto.pay.param.TdCCarRequest" >
    select
    <include refid="Base_Column_List" />
    from td_c_car
    where cust_id = #{custId,jdbcType=VARCHAR}
    <if test="examineState != null">
     and  examine_state = #{examineState,jdbcType=INTEGER}
    </if>
    <if test="carNumberColor != null">
      and  car_number_color = #{carNumberColor,jdbcType=INTEGER}
    </if>
    and data_state  = 1
  </select>

  <select id="selectCustInfoBycustIds" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from td_c_car
    where data_state  = 1
    <if test="custIds != null and custIds.size > 0">
      and cust_id in
      <foreach collection="custIds" open="(" close=")" item="custId" separator=",">
        #{custId}
      </foreach>
    </if>
  </select>

  <select id="selectCustInfo" resultMap="BaseResultMap" parameterType="com.zteits.pay.domain.TdCCar" >
    select
    <include refid="Base_Column_List" />
    from td_c_car
    where data_state  = 1
     <if test="custId != null" >
        and cust_id = #{custId,jdbcType=VARCHAR}
     </if>
    <if test="carNumber != null" >
         and car_number = #{carNumber,jdbcType=VARCHAR}
     </if>
    <if test="carNumberColor != null">
        and  car_number_color = #{carNumberColor,jdbcType=INTEGER}
    </if>
  </select>


   <update id="updateCars" parameterType="com.zteits.pay.domain.TdCCar" >
    update td_c_car
    <set >
      <if test="record.custId != null">
        cust_id = #{record.custId,jdbcType=VARCHAR},
      </if>
      <if test="record.carNumber != null">
        car_number = #{record.carNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.carModelId != null">
        car_model_id = #{record.carModelId,jdbcType=INTEGER},
      </if>
      <if test="record.plateTypeId != null">
        plate_type_id = #{record.plateTypeId,jdbcType=INTEGER},
      </if>
      <if test="record.carBrandId != null">
        car_brand_id = #{record.carBrandId,jdbcType=INTEGER},
      </if>
      <if test="record.carShelfNum != null">
        car_shelf_num = #{record.carShelfNum,jdbcType=VARCHAR},
      </if>
      <if test="record.carEngineNum != null">
        car_engine_num = #{record.carEngineNum,jdbcType=VARCHAR},
      </if>
      <if test="record.phoneNumber != null">
        phone_number = #{record.phoneNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.carBindingStatus != null">
        car_binding_status = #{record.carBindingStatus,jdbcType=INTEGER},
      </if>
      <if test="record.dataState != null">
        data_state = #{record.dataState,jdbcType=INTEGER},
      </if>
      <if test="record.createEmpid != null">
        create_empid = #{record.createEmpid,jdbcType=VARCHAR},
      </if>
      <if test="record.createDate != null">
        create_date = #{record.createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.modfiyEmpid != null">
        modfiy_empid = #{record.modfiyEmpid,jdbcType=VARCHAR},
      </if>
      <if test="record.modfiyDate != null">
        modfiy_date = #{record.modfiyDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.examineState != null">
        examine_state = #{record.examineState,jdbcType=INTEGER},
      </if>
      <if test="record.cerPicturePath != null">
        cer_picture_path = #{record.cerPicturePath,jdbcType=VARCHAR},
      </if>
    </set>

     where id = #{id,jdbcType=BIGINT}
  </update>

  <delete id="deleteCars" parameterType="java.lang.Long" >
    update td_c_car
    <set>
        data_state = 0,
      <if test="createEmpid != null" >
        create_empid = #{createEmpid,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="modfiyEmpid != null" >
        modfiy_empid = #{modfiyEmpid,jdbcType=VARCHAR},
      </if>
      <if test="modfiyDate != null" >
        modfiy_date = #{modfiyDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </delete>

  <insert id="insertCars" parameterType="com.zteits.pay.domain.TdCCar" >
    <selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER" >
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into td_c_car (cust_id, car_number, car_model_id,
    plate_type_id, car_brand_id, car_shelf_num,
    car_engine_num, phone_number, car_binding_status,
    data_state, create_empid, create_date,
    modfiy_empid, modfiy_date, examine_state,
    cer_picture_path)
    values (#{custId,jdbcType=VARCHAR}, #{carNumber,jdbcType=VARCHAR}, #{carModelId,jdbcType=INTEGER},
    #{plateTypeId,jdbcType=INTEGER}, #{carBrandId,jdbcType=INTEGER}, #{carShelfNum,jdbcType=VARCHAR},
    #{carEngineNum,jdbcType=VARCHAR}, #{phoneNumber,jdbcType=VARCHAR}, #{carBindingStatus,jdbcType=INTEGER},
    #{dataState,jdbcType=INTEGER}, #{createEmpid,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP},
    #{modfiyEmpid,jdbcType=VARCHAR}, #{modfiyDate,jdbcType=TIMESTAMP}, #{examineState,jdbcType=INTEGER},
    #{cerPicturePath,jdbcType=VARCHAR})
  </insert>

  <!-- 分页查询车辆审核信息(添加用户电话) -->
  <select id="queryUserCarInfoForPageAndPN" parameterType="com.zteits.clouds.api.dto.pay.car.param.UserCarInfoQueryForPageReq"
          resultType="com.zteits.clouds.api.dto.pay.TdCCarDTO">
    select
    a.id id,
    a.cust_id custId,
    a.car_number carNumber,
    a.car_model_id carModelId,
    a.plate_type_id plateTypeId,
    a.car_brand_id carBrandId,
    a.car_shelf_num carShelfNum,
    a.car_engine_num carEngineNum,
    a.phone_number phoneNumber,
    a.car_binding_status carBindingStatus,
    a.data_state dataState,
    a.create_empid createEmpid,
    a.create_date createDate,
    a.modfiy_empid modfiyEmpid,
    a.modfiy_date modfiyDate,
    a.examine_state examineState,
    a.cer_picture_path cerPicturePath,
    b.user_phone userPhone
    from td_c_car a
    left join td_c_cust_person b on a.cust_id=b.cust_id
    where a.data_state = 1
    <if test="phoneNum != null and phoneNum != ''">
      and b.user_phone = #{phoneNum,jdbcType=VARCHAR}
    </if>
    <if test="carNumber != null and carNumber != ''">
      and a.car_number = #{carNumber,jdbcType=VARCHAR}
    </if>

    <if test="carNumbers != null and carNumbers.size > 0 ">
      and a.car_number in
      <foreach collection="carNumbers" open="(" close=")" item="carNumber" separator=",">
        #{carNumber}
      </foreach>
    </if>
    <if test="carBindingStatus != null ">
      and a.car_binding_status = #{carBindingStatus}
    </if>
    <if test="examineStates != null and examineStates.size > 0">
      and a.examine_state in
      <foreach collection="examineStates" open="(" close=")" item="examineState" separator=",">
        #{examineState}
      </foreach>
    </if>
    order by a.modfiy_date desc,a.create_date desc
  </select>

</mapper>