李旭东
2023-12-08 7efc6ed86025b610cab109a2e9f83362740d8ed4
hd/pipe/secure/src/main/resources/mapping/IntegralDetailMapper.xml
对比新文件
@@ -0,0 +1,325 @@
<?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.thhy.secure.modules.biz.integralAccount.mapper.IntegralDetailMapper">
  <insert id="insertDetailAndUpdate">
    insert into t_integral_detail
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="type != null">
        type,
      </if>
      <if test="integralSource != null">
        integralSource,
      </if>
      <if test="integralWater != null">
        integralWater,
      </if>
      <if test="balanc != null">
        balanc,
      </if>
      <if test="createTime != null">
        createTime,
      </if>
      <if test="createUser != null">
        createUser,
      </if>
      <if test="companyId != null">
        companyId,
      </if>
      <if test="userId != null">
        userId,
      </if>
      <if test="userType != null">
        userType,
      </if>
      <if test="remark != null">
        remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=INTEGER},
      </if>
      <if test="integralSource != null">
        #{integralSource,jdbcType=VARCHAR},
      </if>
      <if test="integralWater != null">
        #{integralWater,jdbcType=DOUBLE},
      </if>
      <if test="balanc != null">
        #{balanc,jdbcType=DOUBLE},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=VARCHAR},
      </if>
      <if test="userType != null">
        #{userType,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
    on duplicate key update
    <trim suffixOverrides=",">
      <if test="type != null">
        type = #{type,jdbcType=INTEGER},
      </if>
      <if test="integralSource != null">
        integralSource = #{integralSource,jdbcType=VARCHAR},
      </if>
      <if test="integralWater != null">
        integralWater = #{integralWater,jdbcType=DOUBLE},
      </if>
      <if test="balanc != null">
        balanc = #{balanc,jdbcType=DOUBLE},
      </if>
      <if test="createTime != null">
        createTime = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        createUser = #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="companyId != null">
        companyId = #{companyId,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        userId = #{userId,jdbcType=VARCHAR},
      </if>
      <if test="userType != null">
        userType = #{userType,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <insert id="insertAndUpdateAccount">
    insert into t_integral_account
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="userId != null">
        userId,
      </if>
      <if test="totalIntegral != null">
        totalIntegral,
      </if>
      <if test="accumulateIntegral != null">
        accumulateIntegral,
      </if>
      <if test="totalConsumption != null">
        totalConsumption,
      </if>
      <if test="createTime != null">
        createTime,
      </if>
      <if test="createUser != null">
        createUser,
      </if>
      <if test="updateTime != null">
        updateTime,
      </if>
      <if test="updateUser != null">
        updateUser,
      </if>
      <if test="userType != null">
        userType,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=VARCHAR},
      </if>
      <if test="totalIntegral != null">
        #{totalIntegral,jdbcType=DOUBLE},
      </if>
      <if test="accumulateIntegral != null">
        #{accumulateIntegral,jdbcType=DOUBLE},
      </if>
      <if test="totalConsumption != null">
        #{totalConsumption,jdbcType=DOUBLE},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null">
        #{updateUser,jdbcType=VARCHAR},
      </if>
      <if test="userType != null">
        #{userType,jdbcType=INTEGER},
      </if>
    </trim>
    on duplicate key update
    <trim suffixOverrides=",">
      <if test="totalIntegral != null">
        totalIntegral = #{totalIntegral,jdbcType=DOUBLE},
      </if>
      <if test="accumulateIntegral != null">
        accumulateIntegral = #{accumulateIntegral,jdbcType=DOUBLE},
      </if>
      <if test="totalConsumption != null">
        totalConsumption = #{totalConsumption,jdbcType=DOUBLE},
      </if>
      <if test="createTime != null">
        createTime=#{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        createUser = #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        updateTime = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null">
        updateUser = #{updateUser,jdbcType=VARCHAR},
      </if>
      <if test="userType != null">
        userType = #{userType,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <delete id="delete">
    update t_integral_detail set isUse = 0 where id = #{id,jdbcType=VARCHAR}
  </delete>
  <!-- 积分超市 -->
  <select id="selectPageInfoList" resultType="com.thhy.secure.modules.biz.integralAccount.entity.IntegralDetailDto">
    SELECT
    t.*,
    spu.real_name realName,
    spu.user_type userTypeName
    FROM t_integral_detail t
    LEFT JOIN sys_plat_user spu on spu.user_id = t.userId
    WHERE t.isUse = 1 and t.type = 2  and t.companyId = #{companyId}
    <if test="userId != null and userId !=''">
      AND spu.user_id =#{userId}
    </if>
    <if test="startTime != null and startTime != '' and endTime !=null and endTime !=''">
      AND t.createTime BETWEEN #{startTime} and #{endTime}
    </if>
    <if test="userType != null and userType != ''">
      AND t.userType = #{userType}
    </if>
    order by  t.createTime desc
  </select>
  <!-- 积分超市 -->
  <select id="selectPageList" resultType="com.thhy.secure.modules.biz.integralAccount.entity.IntegralDetailEntity">
      SELECT
        t.*,
        spu.real_name realName,
        spu.user_type userTypeName,
        DATE_FORMAT(t.createTime, '%Y-%m-%d %H:%m:%s') createDate
    FROM t_integral_detail t
      LEFT JOIN sys_plat_user spu on spu.user_id = t.userId
      WHERE t.isUse = 1 and t.type = 2  and t.companyId = #{companyId}
      <if test="userId != null and userId !=''">
        AND spu.user_id =#{userId}
      </if>
      <if test="startTime != null and startTime != '' and endTime !=null and endTime !=''">
        AND t.createTime BETWEEN #{startTime} and #{endTime}
      </if>
      <if test="userType != null and userType != ''">
        AND t.userType = #{userType}
      </if>
    order by  t.createTime desc
  </select>
  <select id="selectSafeIntegralPageList" resultType="com.thhy.secure.modules.biz.integralAccount.entity.IntegralAccountEntity">
    SELECT
      t.id,
      spu.real_name realName,
      t.accumulateIntegral,
      t.totalIntegral,
      t.totalConsumption,
      t.userType,
      t.createTime,
      t.userId
    FROM t_integral_account t
    LEFT JOIN sys_plat_user spu on spu.user_id = t.userId
    WHERE 1=1
    <if test="userType != null and userType !=''">
      and t.userType = #{userType}
    </if>
    <if test="userId != null and userId !=''">
      AND spu.user_id  =#{userId}
    </if>
    <if test="startIntegral != null and startIntegral != '' and endIntegra !=null and endIntegra !=''">
      AND t.accumulateIntegral BETWEEN #{startIntegral} and #{endIntegra}
    </if>
    order by  t.accumulateIntegral desc
  </select>
  <select id="selectSafeIntegralInfo" resultType="com.thhy.secure.modules.biz.integralAccount.entity.IntegralDetailDto">
    SELECT
            t.*,
            DATE_FORMAT(t.createTime, '%Y-%m-%d %H:%m:%s') createDate
    FROM t_integral_detail t
    WHERE t.isUse = 1
    <if test="companyId != null and companyId !=''">
      and t.companyId = #{companyId}
    </if>
    <if test="userId != null and userId !=''">
      and t.userId = #{userId}
    </if>
    <if test="id != null and id !=''">
      and t.id = #{id}
    </if>
    <if test="type != null and type !=''">
      AND t.type = #{type}
    </if>
    <if test="startTime != null and startTime != '' and endTime !=null and endTime !=''">
      AND t.createTime BETWEEN #{startTime} and #{endTime}
    </if>
    order by t.createTime desc
  </select>
  <select id="selectByOne" resultType="com.thhy.secure.modules.biz.integralAccount.entity.IntegralAccountEntity">
    SELECT
            t.id,
            t.userId,
            spu.real_name realName,
            t.accumulateIntegral,
            t.totalIntegral,
            t.totalConsumption,
            t.userType
    FROM t_integral_account t
                 LEFT JOIN sys_plat_user spu on spu.user_id = t.userId
    WHERE 1=1
    <if test="id != null and id != ''">
      AND t.id = #{id,jdbcType=VARCHAR}
    </if>
    <if test="userId != null and userId != ''">
      AND t.userId = #{userId}
    </if>
  </select>
</mapper>