移风店镇项目初始化
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.
 
 
 
 
 

125 lines
3.9 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="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>
</mapper>