2024-07-29 11:06:15 +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.ics.admin.mapper.IcsCustomerStaffMapper" >
<resultMap type= "com.ics.common.core.domain.IcsCustomerStaff" id= "IcsCustomerStaffResult" >
<result property= "id" column= "id" />
<result property= "username" column= "username" />
<result property= "name" column= "name" />
<result property= "photo" column= "photo" />
<result property= "address" column= "address" />
<result property= "email" column= "email" />
<result property= "degree" column= "degree" />
<result property= "urgent" column= "urgent" />
<result property= "mobile" column= "mobile" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "deleteFlag" column= "delete_flag" />
<result property= "icsCustomerId" column= "ics_customer_id" />
<result property= "openid" column= "openid" />
2024-09-08 01:43:38 +08:00
<result property= "gzhOpenid" column= "gzh_openid" />
2024-09-22 23:13:28 +08:00
<result property= "roomRole" column= "room_role" />
<result property= "roomRoleType" column= "room_role_type" />
2024-07-29 11:06:15 +08:00
<result property= "avatar" column= "avatar" />
<result property= "gender" column= "gender" />
<result property= "status" column= "status" />
<result property= "parkId" column= "park_id" />
<result property= "cardNo" column= "card_no" />
<result property= "visitTime" column= "visit_time" />
<result property= "leaveTime" column= "leave_time" />
<result property= "visitContent" column= "visit_content" />
<result property= "tenantId" column= "tenant_id" />
<result property= "toName" column= "to_name" />
<result property= "toPhone" column= "to_phone" />
<result property= "toCustomer" column= "to_customer" />
<result property= "toCustomerId" column= "to_customer_id" />
<result property= "dataType" column= "data_type" />
</resultMap>
<sql id= "selectIcsCustomerStaffVo" >
2024-09-22 23:13:28 +08:00
SELECT id, username, mobile, create_by, create_time, update_by,name,photo,address,email,degree,urgent, update_time, delete_flag, ics_customer_id, openid, gzh_openid, room_role, room_role_type, avatar, gender, status, park_id,card_no, visit_time,
2024-07-29 11:06:15 +08:00
leave_time,visit_content,to_name,to_phone,to_customer,to_customer_id,data_type,park_id,tenant_id
FROM ics_customer_staff
</sql>
<select id= "selectIcsCustomerStaffList" parameterType= "com.ics.common.core.domain.IcsCustomerStaff" resultMap= "IcsCustomerStaffResult" >
SELECT cs.id, cs.username, cs.mobile, cs.create_by, cs.create_time, cs.update_by,cs.name,cs.photo,cs.address,cs.email,cs.degree,cs.urgent,cs.update_time,
cs.delete_flag, cs.ics_customer_id, cs.openid, cs.avatar, cs.gender, cs.status, cs.park_id,cs.card_no,cs.data_type
FROM ics_customer_staff cs
left join tb_staff_customer tsc on cs.id = tsc.staff_id
left join ics_customer icc on tsc.ics_customer_id = icc.id
<where >
2024-08-07 16:32:49 +08:00
cs.data_type is not null
2024-07-29 11:06:15 +08:00
<if test= "username != null and username != ''" > AND cs.username LIKE CONCAT('%', #{username}, '%') </if>
<if test= "icsCustomerId != null and icsCustomerId != ''" > AND tsc.ics_customer_id = #{icsCustomerId} </if>
<if test= "mobile != null and mobile != ''" > AND cs.mobile LIKE CONCAT('%', #{mobile}, '%') </if>
<if test= "name != null and name != ''" > AND cs.name LIKE CONCAT('%', #{name}, '%') </if>
<if test= "parkId != null and parkId != ''" > AND icc.park_id = #{parkId} </if>
<if test= "tenantId != null and tenantId != ''" > AND cs.tenant_id = #{tenantId} </if>
<if test= "dataType != null and dataType != ''" > AND cs.data_type = #{dataType} </if>
2024-09-22 23:13:28 +08:00
<if test= "roomRole != null" > AND cs.room_role = #{roomRole} </if>
<if test= "roomRoleType != null" > AND cs.room_role_type = #{roomRoleType} </if>
2024-07-29 11:06:15 +08:00
</where>
</select>
<select id= "selectIcsCustomerStaffById" parameterType= "Long" resultMap= "IcsCustomerStaffResult" >
<include refid= "selectIcsCustomerStaffVo" />
WHERE id = #{id}
</select>
<insert id= "insertIcsCustomerStaff" parameterType= "com.ics.common.core.domain.IcsCustomerStaff" >
INSERT INTO ics_customer_staff
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "id != null " > id,</if>
<if test= "username != null and username != ''" > username,</if>
<if test= "name != null and name != ''" > `name`,</if>
<if test= "photo != null and photo != ''" > `photo`,</if>
<if test= "address != null and address != ''" > address,</if>
<if test= "email != null and email != ''" > email,</if>
<if test= "degree != null and degree != ''" > `degree`,</if>
<if test= "urgent != null and urgent != ''" > urgent,</if>
<if test= "mobile != null and mobile != ''" > mobile,</if>
<if test= "password != null and password != ''" > password,</if>
<if test= "createBy != null and createBy != ''" > create_by,</if>
<if test= "createTime != null " > create_time,</if>
<if test= "updateBy != null and updateBy != ''" > update_by,</if>
<if test= "updateTime != null " > update_time,</if>
<if test= "deleteFlag != null " > delete_flag,</if>
<if test= "icsCustomerId != null " > ics_customer_id,</if>
<if test= "openid != null and openid != ''" > openid,</if>
2024-09-08 01:43:38 +08:00
<if test= "gzhOpenid != null and gzhOpenid != ''" > gzh_openid,</if>
2024-09-22 23:13:28 +08:00
<if test= "roomRole != null" > room_role,</if>
<if test= "roomRoleType != null" > room_role_type,</if>
2024-07-29 11:06:15 +08:00
<if test= "avatar != null and avatar != ''" > avatar,</if>
<if test= "gender != null and gender != ''" > gender,</if>
<if test= "status != null and status != ''" > status,</if>
<if test= "parkId != null " > park_id,</if>
<if test= "cardNo != null and cardNo !=''" > ,</if>
<if test= "visitTime != null " > ,</if>
<if test= "leaveTime != null " > ,</if>
<if test= "visitContent != null and visitContent !=''" > ,</if>
<if test= "toName != null and toName!=''" > ,</if>
<if test= "toPhone != null and toPhone!=''" > ,</if>
<if test= "toCustomer != null and toCustomer!=''" > ,</if>
<if test= "toCustomerId != null and toCustomerId!=''" > ,</if>
<if test= "dataType != null dataType!=''" > ,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "id != null " > #{id},</if>
<if test= "username != null and username != ''" > #{username},</if>
<if test= "mobile != null and mobile != ''" > #{mobile},</if>
<if test= "name != null and name != ''" > #{name},</if>
<if test= "photo != null and photo != ''" > #{photo},</if>
<if test= "address != null and address != ''" > #{address},</if>
<if test= "email != null and email != ''" > #{email},</if>
<if test= "degree != null and degree != ''" > #{degree},</if>
<if test= "urgent != null and urgent != ''" > #{urgent},</if>
<if test= "password != null and password != ''" > #{password},</if>
<if test= "createBy != null and createBy != ''" > #{createBy},</if>
<if test= "createTime != null " > #{createTime},</if>
<if test= "updateBy != null and updateBy != ''" > #{updateBy},</if>
<if test= "updateTime != null " > #{updateTime},</if>
<if test= "deleteFlag != null " > #{deleteFlag},</if>
<if test= "icsCustomerId != null " > #{icsCustomerId},</if>
<if test= "openid != null and openid != ''" > #{openid},</if>
2024-09-08 01:43:38 +08:00
<if test= "gzhOpenid != null and gzhOpenid != ''" > #{gzhOpenid},</if>
2024-09-22 23:13:28 +08:00
<if test= "roomRole != null" > #{roomRole},</if>
<if test= "roomRoleType != null" > #{roomRoleType},</if>
2024-07-29 11:06:15 +08:00
<if test= "avatar != null and avatar != ''" > #{avatar},</if>
<if test= "gender != null and gender != ''" > #{gender},</if>
<if test= "status != null and status != ''" > #{status},</if>
<if test= "parkId != null " > #{parkId},</if>
<if test= "cardNo != null and cardNo !=''" > #{cardNo}</if>
<if test= "visitTime != null " > #{visitTime}</if>
<if test= "leaveTime != null " > #{leaveTime}</if>
<if test= "visitContent != null and visitContent !=''" > #{visitContent}</if>
<if test= "toName != null and toName!=''" > #{toName}</if>
<if test= "toPhone != null and toPhone!=''" > #{toPhone}</if>
<if test= "toCustomer != null and toCustomer!=''" > #{toCustomer}</if>
<if test= "toCustomerId != null and toCustomerId!=''" > #{toCustomerId}</if>
<if test= "dataType != null dataType!=''" > #{dataType}</if>
</trim>
</insert>
<update id= "updateIcsCustomerStaff" parameterType= "com.ics.common.core.domain.IcsCustomerStaff" >
UPDATE ics_customer_staff
<trim prefix= "SET" suffixOverrides= "," >
<if test= "username != null and username != ''" > username = #{username},</if>
<if test= "mobile != null and mobile != ''" > mobile = #{mobile},</if>
<if test= "password != null and password != ''" > password = #{password},</if>
<if test= "name != null and name != ''" > `name` = #{name},</if>
<if test= "photo != null and photo != ''" > `photo` = #{photo},</if>
<if test= "address != null and address != ''" > `address` = #{address},</if>
<if test= "email != null and email != ''" > `email` = #{email},</if>
<if test= "degree != null and degree != ''" > `degree` = #{degree},</if>
<if test= "urgent != null and urgent != ''" > `urgent` = #{urgent},</if>
<if test= "createBy != null and createBy != ''" > create_by = #{createBy},</if>
<if test= "createTime != null " > create_time = #{createTime},</if>
<if test= "updateBy != null and updateBy != ''" > update_by = #{updateBy},</if>
<if test= "updateTime != null " > update_time = #{updateTime},</if>
<if test= "deleteFlag != null " > delete_flag = #{deleteFlag},</if>
<if test= "icsCustomerId != null " > ics_customer_id = #{icsCustomerId},</if>
<if test= "openid != null and openid != ''" > openid = #{openid},</if>
2024-09-08 01:43:38 +08:00
<if test= "gzhOpenid != null and gzhOpenid != ''" > gzh_openid=#{gzhOpenid},</if>
2024-09-22 23:13:28 +08:00
<if test= "roomRole != null" > room_role = #{roomRole},</if>
<if test= "roomRoleType != null" > room_role_type = #{roomRoleType},</if>
2024-07-29 11:06:15 +08:00
<if test= "avatar != null and avatar != ''" > avatar = #{avatar},</if>
<if test= "gender != null and gender != ''" > gender = #{gender},</if>
<if test= "status != null and status != ''" > status = #{status},</if>
<if test= "parkId != null " > park_id = #{parkId},</if>
<if test= "cardNo != null and cardNo !=''" > card_no = #{cardNo}</if>
<if test= "visitTime != null " > visit_time = #{visitTime}</if>
<if test= "leaveTime != null " > leave_time = #{leaveTime}</if>
<if test= "visitContent != null and visitContent !=''" > visit_content = #{visitContent}</if>
<if test= "toName != null and toName!=''" > to_name = #{toName}</if>
<if test= "toPhone != null and toPhone!=''" > to_phone = #{toPhone}</if>
<if test= "toCustomer != null and toCustomer!=''" > to_customer = #{toCustomer}</if>
<if test= "toCustomerId != null and toCustomerId!=''" > to_customer_id = #{toCustomerId}</if>
</trim>
WHERE id = #{id}
</update>
<update id= "updateByCustomer" parameterType= "Long" >
UPDATE ics_customer_staff set ics_customer_id = null where id = #{id}
</update>
<delete id= "deleteIcsCustomerStaffById" parameterType= "Long" >
DELETE FROM ics_customer_staff WHERE id = #{id}
</delete>
<delete id= "deleteIcsCustomerStaffByIds" parameterType= "String" >
DELETE FROM ics_customer_staff where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
<select id= "checkPhoneUnique" parameterType= "String" resultType= "com.ics.common.core.domain.IcsCustomerStaff" >
<include refid= "selectIcsCustomerStaffVo" />
WHERE mobile=#{mobile}
</select>
<select id= "selectUserByOpenid" resultType= "com.ics.common.core.domain.IcsCustomerStaff" >
<include refid= "selectIcsCustomerStaffVo" />
WHERE openid=#{openId}
</select>
<select id= "checkMobileUnique" resultType= "java.lang.String" >
SELECT count(1) FROM ics_customer_staff WHERE mobile=#{mobile}
</select>
<select id= "selectUserByMobile" resultType= "com.ics.common.core.domain.IcsCustomerStaff" >
<include refid= "selectIcsCustomerStaffVo" />
WHERE mobile=#{mobile}
</select>
<select id= "getUserList" resultType= "com.ics.common.core.domain.IcsCustomerStaff" >
SELECT cs.id, cs.username, cs.mobile, cs.create_by, cs.create_time, cs.update_by,cs.name,cs.photo,cs.address,cs.email,cs.degree,cs.urgent,cs.update_time,
cs.delete_flag, cs.ics_customer_id, cs.openid, cs.avatar, cs.gender, cs.status, cs.park_id,cs.card_no,cs.data_type
FROM ics_customer_staff cs
left join tb_staff_customer tsc on cs.id = tsc.staff_id
<where >
<if test= "username != null and username != ''" > AND cs.username LIKE CONCAT('%', #{username}, '%') </if>
<if test= "icsCustomerId != null and icsCustomerId != ''" > AND tsc.ics_customer_id = #{icsCustomerId} </if>
<if test= "mobile != null and mobile != ''" > AND cs.mobile LIKE CONCAT('%', #{mobile}, '%') </if>
<if test= "name != null and name != ''" > AND cs.name LIKE CONCAT('%', #{name}, '%') </if>
<if test= "dataType != null and dataType != ''" > AND cs.data_type = #{dataType} </if>
<if test= "parkId != null and parkId != ''" > AND cs.park_id = #{parkId} </if>
<if test= "tenantId != null and tenantId != ''" > AND cs.tenant_id = #{tenantId} </if>
</where>
group by cs.id
</select>
<select id= "selectUserByMobileAndOpenId" resultType= "com.ics.common.core.domain.IcsCustomerStaff" >
<include refid= "selectIcsCustomerStaffVo" /> where mobile = #{mobile} and park_id = #{parkId}
</select>
2024-09-08 01:43:38 +08:00
<!-- 绑定用户的微信公众号openid -->
2024-09-10 19:56:15 +08:00
<update id= "clearGzhOpenid" >
< ![CDATA[
update ics_customer_staff set gzh_openid = null where gzh_openid = #{openid} and delete_flag=0 and data_type is not null and data_type< >'1'
]]>
</update>
2024-09-08 01:43:38 +08:00
<update id= "updateGzhOpenid" >
< ![CDATA[
2024-09-10 19:56:15 +08:00
update ics_customer_staff set gzh_openid = #{openid} where mobile = #{mobile} and delete_flag=0 and gzh_openid is null and data_type is not null and data_type< >'1'
2024-09-08 01:43:38 +08:00
]]>
</update>
2024-07-29 11:06:15 +08:00
2024-09-10 19:56:15 +08:00
<select id= "getUserByGzhOpenid" resultType= "com.ics.common.core.domain.IcsCustomerStaff" >
<include refid= "selectIcsCustomerStaffVo" />
WHERE gzh_openid=#{openId} and delete_flag=0
</select>
2024-07-29 11:06:15 +08:00
</mapper>