358 lines
14 KiB
XML
Raw Normal View History

<?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"/>
<result column="is_refund_application" property="isRefundApplication"/>
<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"/>
</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>
2022-01-04 10:19:03 +08:00
<if test="null != tenantId and tenantId !=''">
tenant_id,
</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>
<if test="null != isRefundApplication and '' != isRefundApplication">
is_refund_application,
</if>
<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
</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 != tenantId and '' != tenantId">
#{tenantId},
</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>
<if test="null != isRefundApplication and '' != isRefundApplication">
#{isRefundApplication},
</if>
<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}
</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>
<if test="null != avatar and '' != avatar">avatar = #{avatar},</if>
2021-07-30 17:23:38 +08:00
<if test="null != balance ">balance = #{balance},</if>
<if test="null != password and '' != password">password = #{password},</if>
<if test="null != status">status = #{status},</if>
<if test="null != isRefundApplication">is_refund_application = #{isRefundApplication},</if>
<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>
2022-01-13 11:54:53 +08:00
<if test="null != soc">soc = #{soc},</if>
<if test="null != isRefund">is_refund = #{isRefund},</if>
<if test="null != socProtect">soc_protect = #{socProtect},</if>
</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,
weixin_login weixinlogin,alipay_login alipayLogin,is_refund_application isRefundApplication,
alipay_open_id alipayOpenId, avatar, balance, password,
`status`,create_by createBy ,create_time createTime,
2022-01-04 10:19:03 +08:00
update_time updateTime, update_by updateBy,tenant_id tenantId,
2021-08-27 15:46:45 +08:00
del_flag delflag, remark,soc,
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,
xau.`status`,xau.create_time createTime,xau.is_refund_application isRefundApplication,
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
<if test="phone != null and phone != ''">
2021-12-27 15:45:06 +08:00
and xau.phone like concat('%', #{phone}, '%')
</if>
2022-01-04 10:19:03 +08:00
<if test="tenantId !=null and tenantId !=''">
and xau.tenant_id=#{tenantId}
</if>
ORDER BY xau.create_time DESC
</select>
2021-11-16 14:42:33 +08:00
<select id="userSum" resultType="map">
select
count(xau.app_user_id) userSum,
2022-03-02 13:55:12 +08:00
(select count(DISTINCT user_id) from xhpc_charge_order where create_time &gt;= #{time} and tenant_id =#{tenantId}) userVitality
2022-03-02 13:32:17 +08:00
from xhpc_app_user xau where 1=1
2021-11-16 14:42:33 +08:00
<if test="phone != null and phone != ''">
2021-12-27 15:45:06 +08:00
and xau.phone like concat('%', #{phone}, '%')
2021-11-16 14:42:33 +08:00
</if>
2022-03-01 16:42:08 +08:00
<if test="tenantId !=null and tenantId !=''">
and xau.tenant_id =#{tenantId}
</if>
2021-11-16 14:42:33 +08:00
ORDER BY xau.create_time DESC
</select>
<select id="getAppUserByPhone" parameterType="java.lang.String" resultMap="XhpcAppUserResult">
select *
from xhpc_app_user
2022-02-16 14:21:06 +08:00
WHERE del_flag = 0 and phone = #{phone} and tenant_id=#{tenantId} 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>
<update id="updateUserIsRefund">
update xhpc_app_user set is_refund=#{isRefund} where app_user_id=#{userId}
</update>
<update id="updateCommunityIsRefund">
UPDATE xhpc_community_personnel
<set>
<if test="null != isRefund">is_refund = #{isRefund},</if>
<if test="null != socProtect">soc_protect = #{socProtect},</if>
<if test="null != soc ">soc = #{soc},</if>
</set>
WHERE community_personnel_id = #{userId}
</update>
<update id="updateCustomersSocProtect">
UPDATE xhpc_customers_personnel
<set>
<if test="null != socProtect">soc_protect = #{socProtect},</if>
<if test="null != soc ">soc = #{soc},</if>
</set>
WHERE customers_personnel_id = #{userId}
</update>
<insert id="addUserLoginTime">
INSERT INTO xhpc_user_login
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != appUserId">
app_user_id,
</if>
<if test="null != account and '' != account">
account,
</if>
<if test="null != userType ">
user_type,
</if>
<if test="null != openId and '' != openId">
open_id,
</if>
<if test="null != type">
type,
</if>
<if test="null != status">
status,
</if>
2022-01-04 10:19:03 +08:00
<if test="tenantId !=null and tenantId !=''">
tenant_id,
</if>
<if test="createTime !=null">
create_time,
2022-01-04 10:19:03 +08:00
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != appUserId">
#{appUserId},
</if>
<if test="null != account and '' != account">
#{account},
</if>
<if test="null != userType">
#{userType},
</if>
<if test="null != openId">
#{openId},
</if>
<if test="null != type">
#{type},
</if>
<if test="null != status">
#{status},
</if>
2022-01-04 10:19:03 +08:00
<if test="tenantId !=null and tenantId !=''">
#{tenantId},
</if>
<if test="createTime !=null">
#{createTime},
</if>
</trim>
</insert>
<update id="updateCommunityPersonnel">
UPDATE xhpc_community_personnel
<set>
<if test="null != weixinOpenId and '' != weixinOpenId">weixin_open_id = #{weixinOpenId},</if>
<if test="null != alipayOpenId and '' != alipayOpenId">alipay_open_id = #{alipayOpenId},</if>
<if test="null != weixinLogin ">weixin_login = #{weixinLogin},</if>
<if test="null != alipayLogin ">alipay_login = #{alipayLogin},</if>
</set>
WHERE community_personnel_id = #{appUserId}
</update>
<update id="updateCustomersPersonnel">
UPDATE xhpc_customers_personnel
<set>
<if test="null != weixinOpenId and '' != weixinOpenId">weixin_open_id = #{weixinOpenId},</if>
<if test="null != alipayOpenId and '' != alipayOpenId">alipay_open_id = #{alipayOpenId},</if>
<if test="null != weixinLogin ">weixin_login = #{weixinLogin},</if>
<if test="null != alipayLogin ">alipay_login = #{alipayLogin},</if>
</set>
WHERE customers_personnel_id = #{appUserId}
</update>
<select id="getUserLoginTime" resultType="map">
select app_user_id as appUserId,
account as account,
user_type as userType,
open_id as openId,
status as status
2022-01-05 14:12:06 +08:00
from xhpc_user_login
where type = #{type}
and open_id = #{openid}
2022-01-05 14:52:00 +08:00
<if test="tenantId !=null and tenantId !=''">
and tenant_id=#{tenantId}
</if>
order by create_time desc
2022-01-05 14:52:00 +08:00
limit 1
</select>
<update id="updateUserLoginTime">
update xhpc_user_login set status =0 where account=#{account} and status=1
</update>
</mapper>