日照智慧社区接口服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

212 lines
7.0 KiB

<?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.epmet.dao.PaCustomerDao">
<select id="selectCustomerByUserId" resultType="com.epmet.dto.PaCustomerDTO">
SELECT
pc.id,
pc.customer_name,
pc.is_initialize
FROM
pa_customer pc
INNER JOIN pa_customer_user_agency pcua ON pc.id = pcua.customer_id
WHERE
pc.del_flag = '0'
AND pcua.del_flag = '0'
AND pcua.user_id = #{userId}
</select>
<select id="registerInfo" resultType="com.epmet.dto.result.CustomerAgencyResultDTO">
SELECT
pc.id AS "customerId",
pca.id AS "agencyId",
pca.agency_name AS "agencyName",
(
CASE
WHEN pca.`level` = 'province' THEN
'省级'
WHEN pca.`level` = 'city' THEN
'市级'
WHEN pca.`level` = 'district' THEN
'区县级'
WHEN pca.`level` = 'street' THEN
'乡(镇、街道)级'
WHEN pca.`level` = 'community' THEN
'社区级'
ELSE
'无'
END
) AS "level",
pca.province AS "province",
pca.city AS "city",
pca.district AS "district",
pca.partybranchnum AS "partybranchnum",
pc.is_initialize AS "initState",
pa.phone AS "phone"
FROM
pa_customer_agency pca
INNER JOIN pa_customer pc ON pca.customer_id = pc.id
LEFT JOIN pa_customer_user_agency pcua ON pcua.agency_id = pca.id AND pcua.del_flag = '0'
LEFT JOIN pa_user pa ON pcua.user_id = pa.id AND pa.del_flag = '0'
WHERE
pca.del_flag = '0'
AND pc.del_flag = '0'
AND pc.source = #{source}
ORDER BY
pca.CREATED_TIME DESC
</select>
<select id="selectCustomerList" resultType="com.epmet.dto.result.RegisterByAuthResultDTO">
SELECT
id AS "customerId",
customer_name AS "customerName"
FROM
pa_customer
WHERE
del_flag = '0'
AND source = #{source}
<if test='null != initState and "" != initState'>
AND is_initialize = #{initState}
</if>
</select>
<!-- 查询客户名称 -->
<select id="selectCustomerName" resultType="java.lang.String">
SELECT
customer_name AS customerName
FROM
pa_customer
WHERE
del_flag = 0
AND id = #{customerId}
</select>
<select id="selectInitCustomerList" resultType="com.epmet.dto.result.UploadListResultDTO" parameterType="com.epmet.dto.form.UploadListFormDTO">
SELECT pc.ID AS "customerId",
mi.NICK_NAME AS "miniName",
pc.CUSTOMER_NAME,
ai.CLIENT_TYPE,
ai.AUTHORIZER_APPID AS "appId"
FROM pa_customer pc
INNER JOIN authorization_info ai ON pc.ID = ai.CUSTOMER_ID AND ai.DEL_FLAG = 0
INNER JOIN mini_info mi ON ai.CUSTOMER_ID = mi.CUSTOMER_ID
AND ai.CLIENT_TYPE = mi.CLIENT_TYPE
AND mi.DEL_FLAG = 0
WHERE pc.DEL_FLAG = 0
AND pc.SOURCE = #{source}
AND pc.IS_INITIALIZE = 1
<if test="customerId != null and customerId.trim() != ''">
AND pc.ID = #{customerId}
</if>
<if test="clientType != null and clientType.trim() != ''">
AND ai.CLIENT_TYPE = #{clientType}
</if>
ORDER BY
pc.created_time DESC,
<!-- pc.CUSTOMER_NAME, -->
ai.CLIENT_TYPE
</select>
<select id="selectCustomerAndUser" resultType="com.epmet.dto.result.CustomerAndUserResultDTO">
SELECT
pc.id AS "customerId",
pc.customer_name AS "customerName",
CONCAT(
pu.real_name,
IF (
pu.gender = 1,
'先生',
IF (pu.gender = 2, '女士', '')
)
) AS "appellation",
pu.phone AS "phone"
FROM
pa_customer pc
INNER JOIN pa_customer_user_agency pcua ON pc.id = pcua.customer_id
INNER JOIN pa_user pu ON pcua.user_id = pu.id
WHERE
pc.del_flag = '0'
AND pcua.del_flag = '0'
AND pu.del_flag = '0'
AND pc.id = #{customerId}
</select>
<update id="updateCustomerById">
UPDATE pa_customer
SET is_initialize = #{isInitialize}
WHERE
del_flag = '0'
AND id = #{id}
</update>
<update id="updateIdById">
UPDATE pa_customer
SET id = #{newCustomerId}
WHERE
del_flag = '0'
AND id = #{oldCustomerId}
</update>
<!-- 清除用户信息 -->
<delete id="clearCustomerInfo">
DELETE FROM auth_code WHERE CUSTOMER_ID = #{customerId};
DELETE FROM auth_result_record WHERE CUSTOMER_ID = #{customerId};
DELETE FROM authorization_info WHERE CUSTOMER_ID = #{customerId};
DELETE FROM binding_account WHERE CUSTOMER_ID = #{customerId};
DELETE FROM business_info WHERE CUSTOMER_ID = #{customerId};
DELETE FROM code_audit_record WHERE CUSTOMER_ID = #{customerId};
DELETE FROM code_audit_result WHERE CUSTOMER_ID = #{customerId};
DELETE FROM code_customer WHERE CUSTOMER_ID = #{customerId};
DELETE FROM code_operation_history WHERE CUSTOMER_ID = #{customerId};
DELETE FROM customer_mp WHERE CUSTOMER_ID = #{customerId};
DELETE FROM func_info WHERE CUSTOMER_ID = #{customerId};
DELETE FROM mini_category_info WHERE CUSTOMER_ID = #{customerId};
DELETE FROM mini_info WHERE CUSTOMER_ID = #{customerId};
DELETE FROM mini_network_info WHERE CUSTOMER_ID = #{customerId};
DELETE FROM open_platform_account WHERE CUSTOMER_ID = #{customerId};
DELETE FROM pa_customer_agency WHERE CUSTOMER_ID = #{customerId};
DELETE FROM pa_customer_user_agency WHERE CUSTOMER_ID = #{customerId};
DELETE FROM pa_customer WHERE ID = #{customerId};
</delete>
<!-- 根据客户Id查询当前客户的来源 -->
<select id="selectSourceById" resultType="java.lang.String">
SELECT
ID
FROM
PA_CUSTOMER
WHERE
ID = #{customerId}
AND
SOURCE = #{source}
</select>
<select id="selectCustomerListByTestId" resultType="com.epmet.dto.PaCustomerDTO">
SELECT
pc.ID,
pc.CUSTOMER_NAME
FROM
pa_customer pc
INNER JOIN ( SELECT SOURCE FROM pa_customer WHERE ID = #{customerId} ) t ON pc.SOURCE = t.SOURCE
WHERE
pc.DEL_FLAG = 0
AND IS_INITIALIZE = 1
AND pc.ID != #{customerId}
</select>
</mapper>