2021-07-27 18:38:32 +08:00
|
|
|
<?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.xhpc.user.mapper.XhpcAppUserMapper">
|
|
|
|
|
|
|
|
|
|
<resultMap type="com.xhpc.user.domain.XhpcAppUser" id="XhpcAppUserResult">
|
|
|
|
|
<result column="app_user_id" property="appUserId"/>
|
|
|
|
|
<result column="phone" property="phone"/>
|
|
|
|
|
<result column="weixin_open_id" property="weixinOpenId"/>
|
|
|
|
|
<result column="alipay_open_id" property="alipayOpenId"/>
|
|
|
|
|
<result column="weixin_login" property="weixinLogin"/>
|
|
|
|
|
<result column="alipay_login" property="alipayLogin"/>
|
|
|
|
|
<result column="avatar" property="avatar"/>
|
|
|
|
|
<result column="balance" property="balance"/>
|
|
|
|
|
<result column="password" property="password"/>
|
|
|
|
|
<result column="status" property="status"/>
|
2021-08-02 18:36:17 +08:00
|
|
|
<result column="is_refund_application" property="isRefundApplication"/>
|
2021-07-27 18:38:32 +08:00
|
|
|
<result column="del_flag" property="delFlag"/>
|
|
|
|
|
<result column="create_by" property="createBy"/>
|
|
|
|
|
<result column="create_time" property="createTime"/>
|
|
|
|
|
<result column="update_by" property="updateBy"/>
|
|
|
|
|
<result column="update_time" property="updateTime"/>
|
|
|
|
|
<result column="remark" property="remark"/>
|
2021-08-26 19:35:19 +08:00
|
|
|
<result column="soc" property="soc"/>
|
2021-07-27 18:38:32 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<insert id="insert" parameterType="com.xhpc.user.domain.XhpcAppUser" useGeneratedKeys="true"
|
|
|
|
|
keyProperty="appUserId">
|
|
|
|
|
INSERT INTO xhpc_app_user
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="null != appUserId and '' != appUserId">
|
|
|
|
|
app_user_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != phone and '' != phone">
|
|
|
|
|
phone,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != weixinOpenId and '' != weixinOpenId">
|
|
|
|
|
weixin_open_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != alipayOpenId and '' != alipayOpenId">
|
|
|
|
|
alipay_open_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != weixinLogin and '' != weixinLogin">
|
|
|
|
|
weixin_login,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != alipayLogin and '' != alipayLogin">
|
|
|
|
|
alipay_login,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != avatar and '' != avatar">
|
|
|
|
|
avatar,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != balance and '' != balance">
|
|
|
|
|
balance,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != password and '' != password">
|
|
|
|
|
password,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != status and '' != status">
|
|
|
|
|
status,
|
|
|
|
|
</if>
|
2021-08-02 18:36:17 +08:00
|
|
|
<if test="null != isRefundApplication and '' != isRefundApplication">
|
|
|
|
|
is_refund_application,
|
|
|
|
|
</if>
|
2021-07-27 18:38:32 +08:00
|
|
|
<if test="null != delFlag and '' != delFlag">
|
|
|
|
|
del_flag,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != createBy and '' != createBy">
|
|
|
|
|
create_by,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != createTime ">
|
|
|
|
|
create_time,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != updateBy and '' != updateBy">
|
|
|
|
|
update_by,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != updateTime ">
|
|
|
|
|
update_time,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != remark and '' != remark">
|
2021-08-26 19:35:19 +08:00
|
|
|
remark,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != soc and '' != soc">
|
|
|
|
|
soc
|
2021-07-27 18:38:32 +08:00
|
|
|
</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="null != appUserId and '' != appUserId">
|
|
|
|
|
#{appUserId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != phone and '' != phone">
|
|
|
|
|
#{phone},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != weixinOpenId and '' != weixinOpenId">
|
|
|
|
|
#{weixinOpenId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != alipayOpenId and '' != alipayOpenId">
|
|
|
|
|
#{alipayOpenId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != weixinLogin and '' != weixinLogin">
|
|
|
|
|
#{weixinLogin},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != alipayLogin and '' != alipayLogin">
|
|
|
|
|
#{alipayLogin},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != avatar and '' != avatar">
|
|
|
|
|
#{avatar},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != balance and '' != balance">
|
|
|
|
|
#{balance},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != password and '' != password">
|
|
|
|
|
#{password},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != status and '' != status">
|
|
|
|
|
#{status},
|
|
|
|
|
</if>
|
2021-08-02 18:36:17 +08:00
|
|
|
<if test="null != isRefundApplication and '' != isRefundApplication">
|
|
|
|
|
#{isRefundApplication},
|
|
|
|
|
</if>
|
2021-07-27 18:38:32 +08:00
|
|
|
<if test="null != delFlag and '' != delFlag">
|
|
|
|
|
#{delFlag},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != createBy and '' != createBy">
|
|
|
|
|
#{createBy},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != createTime ">
|
|
|
|
|
#{createTime},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != updateBy and '' != updateBy">
|
|
|
|
|
#{updateBy},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != updateTime ">
|
|
|
|
|
#{updateTime},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != remark and '' != remark">
|
2021-08-26 19:35:19 +08:00
|
|
|
#{remark},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="null != soc and '' != soc">
|
|
|
|
|
#{soc}
|
2021-07-27 18:38:32 +08:00
|
|
|
</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="update" parameterType="com.xhpc.user.domain.XhpcInternetUser">
|
|
|
|
|
UPDATE xhpc_app_user
|
|
|
|
|
<set>
|
|
|
|
|
<if test="null != phone and '' != phone">phone = #{phone},</if>
|
|
|
|
|
<if test="null != weixinOpenId and '' != weixinOpenId">weixin_open_id = #{weixinOpenId},</if>
|
|
|
|
|
<if test="null != alipayOpenId and '' != alipayOpenId">alipay_open_id = #{alipayOpenId},</if>
|
2021-07-30 17:23:38 +08:00
|
|
|
<if test="null != weixinLogin ">weixin_login = #{weixinLogin},</if>
|
|
|
|
|
<if test="null != alipayLogin ">alipay_login = #{alipayLogin},</if>
|
2021-07-27 18:38:32 +08:00
|
|
|
<if test="null != avatar and '' != avatar">avatar = #{avatar},</if>
|
2021-07-30 17:23:38 +08:00
|
|
|
<if test="null != balance ">balance = #{balance},</if>
|
2021-07-27 18:38:32 +08:00
|
|
|
<if test="null != password and '' != password">password = #{password},</if>
|
|
|
|
|
<if test="null != status">status = #{status},</if>
|
2021-08-02 18:36:17 +08:00
|
|
|
<if test="null != isRefundApplication">is_refund_application = #{isRefundApplication},</if>
|
2021-07-27 18:38:32 +08:00
|
|
|
<if test="null != delFlag and '' != delFlag">del_flag = #{delFlag},</if>
|
|
|
|
|
<if test="null != createBy and '' != createBy">create_by = #{createBy},</if>
|
|
|
|
|
<if test="null != createTime ">create_time = #{createTime},</if>
|
|
|
|
|
<if test="null != updateBy and '' != updateBy">update_by = #{updateBy},</if>
|
|
|
|
|
<if test="null != updateTime ">update_time = #{updateTime},</if>
|
2021-08-27 15:46:45 +08:00
|
|
|
<if test="null != remark and '' != remark">remark = #{remark},</if>
|
|
|
|
|
<if test="null != soc and '' != soc">soc = #{soc}</if>
|
2021-07-27 18:38:32 +08:00
|
|
|
</set>
|
|
|
|
|
WHERE app_user_id = #{appUserId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteById" parameterType="java.lang.Long">
|
|
|
|
|
update xhpc_app_user set del_flag = 2 where app_user_id = #{appUserId}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<select id="info" parameterType="java.lang.Long" resultType="java.util.Map">
|
|
|
|
|
select app_user_id appUserId, phone, weixin_open_id weixinOpenId,
|
2021-08-02 18:36:17 +08:00
|
|
|
weixin_login weixinlogin,alipay_login alipayLogin,is_refund_application isRefundApplication,
|
2021-07-27 18:38:32 +08:00
|
|
|
alipay_open_id alipayOpenId, avatar, balance, password,
|
|
|
|
|
`status`,create_by createBy ,create_time createTime,
|
|
|
|
|
update_time updateTime, update_by updateBy,
|
2021-08-27 15:46:45 +08:00
|
|
|
del_flag delflag, remark,soc,
|
2021-07-27 18:38:32 +08:00
|
|
|
CASE WHEN `status` = 0 THEN '正常' else '禁用' end statusName
|
|
|
|
|
from xhpc_app_user
|
|
|
|
|
WHERE del_flag = 0 and app_user_id = #{appUserId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectAppUserList" parameterType="java.lang.Long" resultType="java.util.Map">
|
2021-08-27 15:46:45 +08:00
|
|
|
select xau.app_user_id appUserId, xau.phone, xau.balance,soc,
|
2021-08-02 18:36:17 +08:00
|
|
|
xau.`status`,xau.create_time createTime,xau.is_refund_application isRefundApplication,
|
2021-08-02 11:42:20 +08:00
|
|
|
CASE WHEN xau.`status` = 0 THEN '正常' else '禁用' end statusName,
|
|
|
|
|
CASE WHEN a.count > 0 THEN '老用户' else '新用户' end newUser
|
|
|
|
|
from xhpc_app_user xau
|
|
|
|
|
LEFT JOIN (select count(1) count ,user_id from xhpc_charge_order where del_flag = 0 ) a on a.user_id =
|
|
|
|
|
xau.app_user_id
|
|
|
|
|
WHERE xau.del_flag = 0
|
2021-07-27 18:38:32 +08:00
|
|
|
<if test="phone != null and phone != ''">
|
2021-08-02 11:42:20 +08:00
|
|
|
and xau.phone like concat(concat('%', #{phone}), '%')
|
2021-07-27 18:38:32 +08:00
|
|
|
</if>
|
2021-08-02 11:42:20 +08:00
|
|
|
ORDER BY xau.create_time DESC
|
2021-07-27 18:38:32 +08:00
|
|
|
</select>
|
|
|
|
|
|
2021-11-16 14:42:33 +08:00
|
|
|
<select id="userSum" resultType="map">
|
|
|
|
|
select
|
|
|
|
|
count(xau.app_user_id) userSum,
|
2021-11-23 16:34:52 +08:00
|
|
|
(select count(DISTINCT user_id) from xhpc_charge_order where create_time >= #{time}) userVitality
|
2021-11-16 14:42:33 +08:00
|
|
|
from xhpc_app_user xau
|
|
|
|
|
<if test="phone != null and phone != ''">
|
|
|
|
|
and xau.phone like concat(concat('%', #{phone}), '%')
|
|
|
|
|
</if>
|
|
|
|
|
ORDER BY xau.create_time DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-27 18:38:32 +08:00
|
|
|
<select id="getAppUserByPhone" parameterType="java.lang.String" resultMap="XhpcAppUserResult">
|
|
|
|
|
select *
|
|
|
|
|
from xhpc_app_user
|
|
|
|
|
WHERE del_flag = 0 and phone = #{phone} LIMIT 1
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getAppUserByOpenid" parameterType="java.lang.String" resultMap="XhpcAppUserResult">
|
|
|
|
|
select *
|
|
|
|
|
from xhpc_app_user
|
|
|
|
|
WHERE del_flag = 0 and (weixin_open_id = #{openid}or alipay_open_id = #{openid}) LIMIT 1
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|