TdCCustPersonSMapper.xml 18.3 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
<?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.TdCCustPersonSMapper">
    <resultMap id="BaseSResultMap" type="com.zteits.pay.domain.TdCCustPerson">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="cust_id" jdbcType="VARCHAR" property="custId"/>
        <result column="cust_name" jdbcType="VARCHAR" property="custName"/>
        <result column="cust_nickname" jdbcType="VARCHAR" property="custNickname"/>
        <result column="user_name" jdbcType="VARCHAR" property="userName"/>
        <result column="user_password" jdbcType="VARCHAR" property="userPassword"/>
        <result column="user_phone" jdbcType="VARCHAR" property="userPhone"/>
        <result column="sex" jdbcType="INTEGER" property="sex"/>
        <result column="email" jdbcType="VARCHAR" property="email"/>
        <result column="cust_type" jdbcType="INTEGER" property="custType"/>
        <result column="parent_id" jdbcType="BIGINT" property="parentId"/>
        <result column="cer_type" jdbcType="INTEGER" property="cerType"/>
        <result column="cer_number" jdbcType="VARCHAR" property="cerNumber"/>
        <result column="deivce_type" jdbcType="INTEGER" property="deivceType"/>
        <result column="device_no" jdbcType="VARCHAR" property="deviceNo"/>
        <result column="token_id" jdbcType="VARCHAR" property="tokenId"/>
        <result column="prov_id" jdbcType="VARCHAR" property="provId"/>
        <result column="city_id" jdbcType="VARCHAR" property="cityId"/>
        <result column="area_id" jdbcType="VARCHAR" property="areaId"/>
        <result column="alias" jdbcType="VARCHAR" property="alias"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="petty_pay_state" jdbcType="INTEGER" property="pettyPayState"/>
        <result column="petty_pay_pass" jdbcType="VARCHAR" property="pettyPayPass"/>
        <result column="petty_pay_amount" jdbcType="INTEGER" property="pettyPayAmount"/>
        <result column="msg_push_state" jdbcType="INTEGER" property="msgPushState"/>
        <result column="direct_debit_state" jdbcType="INTEGER" property="directDebitState"/>
        <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="address" jdbcType="VARCHAR" property="address"/>
        <result column="head_pic_url" jdbcType="VARCHAR" property="headPicUrl"/>
        <result column="birth_date" jdbcType="TIMESTAMP" property="birthDate"/>
        <result column="org_id" jdbcType="BIGINT" property="orgId"/>
        <result column="org_name" jdbcType="VARCHAR" property="orgName"/>
        <result column="freeze_state" jdbcType="INTEGER" property="freezeState" />
        <result column="freeze_date" jdbcType="TIMESTAMP" property="freezeDate" />
        <result column="etc_open_state" jdbcType="INTEGER" property="etcOpenState" />
    </resultMap>
    <sql id="Base_Column_List">
    id, cust_id, cust_name, cust_nickname, user_name, user_password, user_phone, sex, 
    email, cust_type, parent_id, cer_type, cer_number, deivce_type, device_no, token_id, 
    prov_id, city_id, area_id, alias, remark, petty_pay_state, petty_pay_pass, petty_pay_amount, 
    msg_push_state, direct_debit_state, data_state, create_empid, create_date, modfiy_empid, 
    modfiy_date, address, head_pic_url, birth_date, org_id, org_name, freeze_state, freeze_date, etc_open_state
  </sql>


    <!-- 分页查询APP账户 -->
    <select id="queryPersonForPage" resultType="com.zteits.clouds.api.dto.pay.TdCCustPersonDTO"
            parameterType="com.zteits.clouds.api.dto.pay.param.TdCCustPersonRequest">
        select
        tp.cust_id custId,
        tp.cust_name custName,
        tp.user_phone userPhone,
        tp.deivce_type deivceType,
        tp.device_no deviceNo,
        tp.petty_pay_state pettyPayState,
        tp.msg_push_state msgPushState,
        tp.direct_debit_state directDebitState,
        tp.create_date createDate,
        tp.freeze_state freezeState,
        ifnull(A.type1,0) typeOne,
        ifnull(A.type7,0) typeSeven,
        ifnull(A.typeSum,0) acctBalance
        from td_c_cust_person tp
        left join
        (select ap.cust_id,
        sum(case when ap.acct_type=1 then acct_balance ELSE NULL
        END) type1,
        sum(case when ap.acct_type=7 then acct_balance ELSE NULL
        END) type7,
        sum(case when ap.acct_type in(1,7) then acct_balance ELSE NULL
        END) typeSum
        from td_c_acct_person ap
        where ap.acct_type in (1,7) and ap.data_state = 1 group by ap.cust_id)A on tp.cust_id = A.cust_id
        <if test="(carNumber != null and carNumber != '') or (userPhoneOrCarNumber != null and userPhoneOrCarNumber != '')">
            left JOIN td_c_car tc on tp.cust_id = tc.cust_id and tc.data_state = 1
        </if>
        where tp.data_state = 1
        <if test="carNumber != null and carNumber != ''">
            and tc.car_number like concat('%',#{carNumber,jdbcType=VARCHAR},'%')
        </if>
        <if test="userPhone != null and userPhone != ''">
            and tp.user_phone like concat('%',#{userPhone,jdbcType=VARCHAR},'%')
        </if>
        <if test="userPhoneOrCarNumber != null and userPhoneOrCarNumber != ''">
            and (
            tp.user_phone like concat('%',#{userPhoneOrCarNumber,jdbcType=VARCHAR},'%')
            or tc.car_number like concat('%',#{userPhoneOrCarNumber,jdbcType=VARCHAR},'%')
            )
        </if>
        <if test="deivceType != null">
            and tp.deivce_type = = #{deivceType,jdbcType=INTEGER}
        </if>
        <if test="deivceTypeList != null and deivceTypeList.size > 0">
            and tp.deivce_type in
            <foreach collection="deivceTypeList" open="(" close=")" item="deivceType" separator=",">
                #{deivceType}
            </foreach>
        </if>
        <if test="freezeStateList != null and freezeStateList.size > 0">
            and tp.freeze_state in
            <foreach collection="freezeStateList" open="(" close=")" item="freezeState" separator=",">
                #{freezeState}
            </foreach>
        </if>
        order by tp.create_date desc
    </select>

    <select id="selectByUserPhone" resultMap="BaseSResultMap" parameterType="java.lang.String">
        select
        <include refid="Base_Column_List"/>
        from td_c_cust_person
        where user_phone = #{userPhone,jdbcType=VARCHAR}
        and data_state = 1
        LIMIT 0,1

    </select>

    <update id="updateByUserPhone" parameterType="com.zteits.pay.domain.TdCCustPerson">
        update td_c_cust_person
        <set>
            <if test="custName != null">
                cust_name = #{custName,jdbcType=VARCHAR},
            </if>
            <if test="userName != null">
                user_name = #{userName,jdbcType=VARCHAR},
            </if>
            <if test="userPassword != null">
                user_password = #{userPassword,jdbcType=VARCHAR},
            </if>
            <if test="sex != null">
                sex = #{sex,jdbcType=INTEGER},
            </if>
            <if test="email != null">
                email = #{email,jdbcType=VARCHAR},
            </if>
            <if test="custType != null">
                cust_type = #{custType,jdbcType=INTEGER},
            </if>
            <if test="parentId != null">
                parent_id = #{parentId,jdbcType=BIGINT},
            </if>
            <if test="cerType != null">
                cer_type = #{cerType,jdbcType=INTEGER},
            </if>
            <if test="cerNumber != null">
                cer_number = #{cerNumber,jdbcType=VARCHAR},
            </if>
            <if test="deivceType != null">
                deivce_type = #{deivceType,jdbcType=INTEGER},
            </if>
            <if test="deviceNo != null">
                device_no = #{deviceNo,jdbcType=VARCHAR},
            </if>
            <if test="tokenId != null">
                token_id = #{tokenId,jdbcType=VARCHAR},
            </if>
            <if test="provId != null">
                prov_id = #{provId,jdbcType=VARCHAR},
            </if>
            <if test="cityId != null">
                city_id = #{cityId,jdbcType=VARCHAR},
            </if>
            <if test="areaId != null">
                area_id = #{areaId,jdbcType=VARCHAR},
            </if>
            <if test="alias != null">
                alias = #{alias,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
            <if test="dataState != null">
                data_state = #{dataState,jdbcType=INTEGER},
            </if>
            <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>
            <if test="pettyPayState != null">
                petty_pay_state = #{pettyPayState,jdbcType=INTEGER},
            </if>
            <if test="pettyPayPass != null">
                petty_pay_pass = #{pettyPayPass,jdbcType=VARCHAR},
            </if>
            <if test="pettyPayAmount != null">
                petty_pay_amount = #{pettyPayAmount,jdbcType=INTEGER},
            </if>
            <if test="msgPushState != null">
                msg_push_state = #{msgPushState,jdbcType=INTEGER},
            </if>
            <if test="address != null">
                address = #{address,jdbcType=VARCHAR},
            </if>
            <if test="orgId != null">
                org_id = #{orgId,jdbcType=BIGINT},
            </if>
        </set>
        where user_phone = #{userPhone,jdbcType=VARCHAR}
        and data_state = 1
    </update>


    <update id="updateByCustId" parameterType="com.zteits.pay.domain.TdCCustPerson">
        update td_c_cust_person
        <set>
            <if test="custName != null">
                cust_name = #{custName,jdbcType=VARCHAR},
            </if>
            <if test="custNickname != null">
                cust_nickname = #{custNickname,jdbcType=VARCHAR},
            </if>
            <if test="userName != null">
                user_name = #{userName,jdbcType=VARCHAR},
            </if>
            <if test="userPassword != null">
                user_password = #{userPassword,jdbcType=VARCHAR},
            </if>
            <if test="userPhone != null">
                user_phone = #{userPhone,jdbcType=VARCHAR},
            </if>
            <if test="sex != null">
                sex = #{sex,jdbcType=INTEGER},
            </if>
            <if test="email != null">
                email = #{email,jdbcType=VARCHAR},
            </if>
            <if test="custType != null">
                cust_type = #{custType,jdbcType=INTEGER},
            </if>
            <if test="parentId != null">
                parent_id = #{parentId,jdbcType=BIGINT},
            </if>
            <if test="cerType != null">
                cer_type = #{cerType,jdbcType=INTEGER},
            </if>
            <if test="cerNumber != null">
                cer_number = #{cerNumber,jdbcType=VARCHAR},
            </if>
            <if test="deivceType != null">
                deivce_type = #{deivceType,jdbcType=INTEGER},
            </if>
            <if test="deviceNo != null">
                device_no = #{deviceNo,jdbcType=VARCHAR},
            </if>
            <if test="tokenId != null">
                token_id = #{tokenId,jdbcType=VARCHAR},
            </if>
            <if test="provId != null">
                prov_id = #{provId,jdbcType=VARCHAR},
            </if>
            <if test="cityId != null">
                city_id = #{cityId,jdbcType=VARCHAR},
            </if>
            <if test="areaId != null">
                area_id = #{areaId,jdbcType=VARCHAR},
            </if>
            <if test="alias != null">
                alias = #{alias,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
            <if test="pettyPayState != null">
                petty_pay_state = #{pettyPayState,jdbcType=INTEGER},
            </if>
            <if test="pettyPayPass != null">
                petty_pay_pass = #{pettyPayPass,jdbcType=VARCHAR},
            </if>
            <if test="pettyPayAmount != null">
                petty_pay_amount = #{pettyPayAmount,jdbcType=INTEGER},
            </if>
            <if test="msgPushState != null">
                msg_push_state = #{msgPushState,jdbcType=INTEGER},
            </if>
            <if test="directDebitState != null">
                direct_debit_state = #{directDebitState,jdbcType=INTEGER},
            </if>
            <if test="dataState != null">
                data_state = #{dataState,jdbcType=INTEGER},
            </if>
            <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>
            <if test="address != null">
                address = #{address,jdbcType=VARCHAR},
            </if>
            <if test="headPicUrl != null">
                head_pic_url = #{headPicUrl,jdbcType=VARCHAR},
            </if>
            <if test="birthDate != null">
                birth_date = #{birthDate,jdbcType=TIMESTAMP},
            </if>
            <if test="orgId != null">
                org_id = #{orgId,jdbcType=BIGINT},
            </if>
            <if test="orgName != null">
                org_name = #{orgName,jdbcType=VARCHAR},
            </if>
            <if test="freezeState != null">
                freeze_state = #{freezeState,jdbcType=INTEGER},
            </if>
            <if test="freezeDate != null">
                freeze_date = #{freezeDate,jdbcType=TIMESTAMP},
            </if>
        </set>
        where cust_id = #{custId,jdbcType=VARCHAR}
    </update>

    <!-- 根据客户id查询客户信息 langlw 2017-11-2 -->
    <select id="queryPersonByCustId" resultMap="BaseSResultMap" parameterType="java.lang.String">
        select
        <include refid="Base_Column_List"/>
        from td_c_cust_person
        where cust_id = #{custId,jdbcType=VARCHAR}
        and data_state = 1
    </select>

    <!-- 修改客户基本信息 -->
    <update id="updateCustPersonBaseInfoByCustId" parameterType="com.zteits.pay.domain.TdCCustPerson">
     update td_c_cust_person
    set
      cust_nickname = #{custNickname,jdbcType=VARCHAR},
      sex = #{sex,jdbcType=INTEGER},
      prov_id = #{provId,jdbcType=VARCHAR},
      city_id = #{cityId,jdbcType=VARCHAR},
      area_id = #{areaId,jdbcType=VARCHAR},
      modfiy_empid = #{modfiyEmpid,jdbcType=VARCHAR},
      modfiy_date = #{modfiyDate,jdbcType=TIMESTAMP},
      birth_date = #{birthDate,jdbcType=TIMESTAMP},
      head_pic_url = #{headPicUrl,jdbcType=VARCHAR}
    where   cust_id = #{custId,jdbcType=VARCHAR}
  </update>

    <!-- 用户分析 -->
    <select id="queryUserPersonStatistic"
            parameterType="com.zteits.clouds.api.dto.pay.param.TdCCustPersonQueryStatisticRequest"
            resultType="com.zteits.clouds.api.dto.pay.custperson.CustPersonStatisticDTO">
    select
    ifnull(sum(case when deivce_type = 1 or deivce_type = 2 then 1 else 0 end),0) as registerNum,
    ifnull(sum(case when deivce_type = 1 then 1 else 0 end),0)  as  androidRegisterNum,
    ifnull(sum(case when deivce_type = 2 then 1 else 0 end),0)  as iosRegisterNum,
    ifnull(sum(case when create_date >= #{startTime} and #{endTime}  >= create_date and (deivce_type = 1 or deivce_type = 2) then 1 else 0 end),0)  as todayRegisterNum,
    ifnull(sum(case when create_date >= #{startTime} and #{endTime}  >= create_date and deivce_type = 1 then 1 else 0 end),0)  as todayAndroidRegisterNum,
    ifnull(sum(case when create_date >= #{startTime} and #{endTime}  >= create_date and deivce_type = 2 then 1 else 0 end),0)  as todayIosRegisterNum,
    ifnull(sum(case when modfiy_date >= #{startTime} and #{endTime}  >= modfiy_date and (deivce_type = 1 or deivce_type = 2) then 1 else 0 end),0)  as todayActiveNum,
    ifnull(sum(case when modfiy_date >= #{startTime} and #{endTime}  >= modfiy_date and deivce_type = 1 then 1 else 0 end),0)  as todayAndroidActiveNum,
    ifnull(sum(case when modfiy_date >= #{startTime} and #{endTime}  >= modfiy_date and deivce_type = 2 then 1 else 0 end),0)  as todayIosActiveNum
    from td_c_cust_person
    where data_state = 1
  </select>

    <!-- 用户分析 -->
    <select id="queryUserPersonStatisticForHour"
            parameterType="com.zteits.clouds.api.dto.pay.param.TdCCustPersonQueryStatisticRequest"
            resultType="com.zteits.clouds.api.dto.pay.custperson.CustPersonStatisticForHourDTO">
    SELECT
    FLOOR(HOUR (create_date)) AS hour,
    ifnull(count(create_date),0) as num
    FROM  td_c_cust_person
    where data_state = 1 and deivce_type in (1,2)
    and create_date >= #{startTime} and #{endTime}  >= create_date
    GROUP BY FLOOR(HOUR (create_date))
  </select>

    <!-- 用户分析-注册量-周折线图 -->
    <select id="queryUserPersonStatisticForWeek"
            parameterType="com.zteits.clouds.api.dto.pay.param.TdCCustPersonQueryStatisticRequest"
            resultType="com.zteits.clouds.api.dto.pay.custperson.CustPersonStatisticForWeekDTO">
    SELECT
    DATE_FORMAT(create_date,'%Y-%m-%d') AS createDate,
    ifnull(count(create_date),0) as num
    FROM  td_c_cust_person
    where data_state = 1 and deivce_type in (1,2)
    and create_date >= #{startTime} and #{endTime}  >= create_date
    GROUP BY  DATE_FORMAT(create_date,'%Y-%m-%d') desc
  </select>

</mapper>