@ -10,7 +10,8 @@
]]>
<if test= "org_id!=null and org_ids==null" > and org_id=#{org_id}</if>
<if test= "org_ids!=null" > and org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach>
</if>
</select>
<select id= "countNewClientsHistory" resultType= "com.alibaba.fastjson.JSONObject" >
@ -20,16 +21,17 @@
right join calendar a on a.datelist = date(c.create_time)
]]>
<!-- <if test="city!=null"> -->
<!-- INNER JOIN sys_client_bd b on b.client_id=c.client_id and b.start_date<=curdate() -->
<!-- AND (b.end_date is null or b.end_date>=curdate()) -->
<!-- inner join financial_bd_config bc on bc.manager_id=b.bd_id and bc.city=#{city} -->
<!-- INNER JOIN sys_client_bd b on b.client_id=c.client_id and b.start_date<=curdate() -->
<!-- AND (b.end_date is null or b.end_date>=curdate()) -->
<!-- inner join financial_bd_config bc on bc.manager_id=b.bd_id and bc.city=#{city} -->
<!-- </if> -->
< ![CDATA[
where a.datelist>= #{begin} AND a.datelist< #{end} AND c.is_valid=1
]]>
<if test= "org_id!=null and org_ids==null" > and c.org_id=#{org_id}</if>
<if test= "org_ids!=null" > and c.org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach>
</if>
<if test= "bd_group!=null" > and c.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
@ -50,7 +52,8 @@
]]>
<if test= "org_id!=null and org_ids==null" > and org_id=#{org_id}</if>
<if test= "org_ids!=null" > and org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach>
</if>
</select>
<!-- 显示所有的商户,包括禁用的 -->
@ -77,7 +80,8 @@
]]>
<if test= "org_id!=null and org_ids==null" > and org_id=#{org_id}</if>
<if test= "org_ids!=null" > and org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach>
</if>
GROUP BY YEAR(create_time),MONTH(create_time),DAY(create_time) ORDER BY create_time desc
</select>
@ -90,7 +94,8 @@
]]>
<if test= "org_id!=null and org_ids==null" > and org_id=#{org_id}</if>
<if test= "org_ids!=null" > and org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach>
</if>
</select>
<select id= "countTradedPartners" resultType= "java.lang.Integer" >
< ![CDATA[
@ -101,7 +106,8 @@
]]>
<if test= "org_id!=null and org_ids==null" > and p.org_id=#{org_id}</if>
<if test= "org_ids!=null" > and p.org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach>
</if>
</select>
<select id= "countTradePartnersHistory" resultType= "com.alibaba.fastjson.JSONObject" >
@ -113,7 +119,8 @@
]]>
<if test= "org_id!=null and org_ids==null" > and p.org_id=#{org_id}</if>
<if test= "org_ids!=null" > and p.org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach>
</if>
<if test= "bd_group!=null" > and p.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
@ -206,17 +213,17 @@
</if>
<if test= "bd_group != null" >
AND p.client_id IN (
SELECT b.client_id
FROM sys_client_bd b
INNER JOIN financial_bd_config c
ON c.manager_id = b.bd_id
WHERE b.is_valid = 1
AND b.start_date < = now()
AND (b.end_date IS NULL OR b.end_date > = now())
AND (c.bd_group = #{bd_group} OR c.manager_id = #{bd_group})
<if test= "bd_group_bd" >
AND c.manager_id = #{bd_group_bd}
</if>
SELECT b.client_id
FROM sys_client_bd b
INNER JOIN financial_bd_config c
ON c.manager_id = b.bd_id
WHERE b.is_valid = 1
AND b.start_date < = now()
AND (b.end_date IS NULL OR b.end_date > = now())
AND (c.bd_group = #{bd_group} OR c.manager_id = #{bd_group})
<if test= "bd_group_bd" >
AND c.manager_id = #{bd_group_bd}
</if>
)
</if>
GROUP BY p.client_id
@ -229,8 +236,8 @@
</select>
<select id= "countClientsTypes" resultType= "com.alibaba.fastjson.JSONObject" >
SELECT c.industry,c.royalpayindustry,count(1) partner_counts FROM sys_clients c
<if test= "bd_user!=null" >
SELECT c.industry,c.royalpayindustry,count(1) partner_counts FROM sys_clients c
<if test= "bd_user!=null" >
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
date(d.start_date)< = date(now()) and (d.end_date is null or date(d.end_date)> = date(now())) and
d.is_valid=1
@ -239,7 +246,8 @@
is_valid = 1 and industry < '400' AND approve_result=1
<if test= "org_id!=null and org_ids==null" > and org_id=#{org_id}</if>
<if test= "org_ids!=null" > and org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach>
</if>
<if test= "bd_group!=null" > and c.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
@ -249,79 +257,86 @@
)
</if>
</where>
GROUP BY c.royalpayindustry order by partner_counts desc
GROUP BY c.royalpayindustry order by partner_counts desc
</select>
<select id= "notTradeSubMerchantId" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT COUNT(DISTINCT c.client_id) client_count,
c.sub_merchant_id,
c.merchant_id
FROM sys_clients c
WHERE c.sub_merchant_id not in
(SELECT p.sub_merchant_id FROM sys_clients p INNER JOIN pmt_orders o ON o.client_id = p.client_id AND o.status >4 AND o.confirm_time IS NOT NULL
WHERE datediff(now(), o.create_time) < = 25 AND p.sub_merchant_id is not null GROUP BY p.sub_merchant_id) AND c.sub_merchant_id IS not null AND c.merchant_id IS NOT NULL
AND (c.approve_result = 1 OR c.approve_result= 2) AND c.is_valid = 1
AND c.enable_wechat = 1
]]>
GROUP by c.sub_merchant_id
</select>
SELECT COUNT(DISTINCT c.client_id) client_count,
c.sub_merchant_id,
c.merchant_id
FROM sys_clients c
WHERE c.sub_merchant_id not in
(SELECT p.sub_merchant_id FROM sys_clients p INNER JOIN pmt_orders o ON o.client_id = p.client_id AND o.status >4 AND o.confirm_time IS NOT NULL
WHERE datediff(now(), o.create_time) < = 25 AND p.sub_merchant_id is not null GROUP BY p.sub_merchant_id) AND c.sub_merchant_id IS not null AND c.merchant_id IS NOT NULL
AND (c.approve_result = 1 OR c.approve_result= 2) AND c.is_valid = 1
AND c.enable_wechat = 1
]]>
GROUP by c.sub_merchant_id
</select>
<select id= "tradeSubMerchantIdBy60Days" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT COUNT(DISTINCT c.client_id) client_count,
c.sub_merchant_id,
c.merchant_id,
tmp.create_time last_trade_time,
datediff(now(), tmp.create_time) diff_days
FROM sys_clients c INNER JOIN (SELECT sub_merchant_id, max(create_time) create_time
FROM pmt_orders where status>=5 and create_time>=#{begin} and create_time< =now()
and channel='Wechat'
GROUP BY sub_merchant_id
) tmp on c.sub_merchant_id = tmp.sub_merchant_id
WHERE
c.sub_merchant_id IS not null AND c.merchant_id IS NOT NULL
AND (c.approve_result = 1 OR c.approve_result= 2) AND c.is_valid = 1
AND c.enable_wechat = 1
]]>
GROUP BY c.sub_merchant_id ORDER BY diff_days desc
</select>
SELECT COUNT(DISTINCT c.client_id) client_count,
c.sub_merchant_id,
c.merchant_id,
tmp.create_time last_trade_time,
datediff(now(), tmp.create_time) diff_days
FROM sys_clients c INNER JOIN (SELECT sub_merchant_id, max(create_time) create_time
FROM pmt_orders where status>=5 and create_time>=#{begin} and create_time< =now()
and channel='Wechat'
GROUP BY sub_merchant_id
) tmp on c.sub_merchant_id = tmp.sub_merchant_id
WHERE
c.sub_merchant_id IS not null AND c.merchant_id IS NOT NULL
AND (c.approve_result = 1 OR c.approve_result= 2) AND c.is_valid = 1
AND c.enable_wechat = 1
]]>
GROUP BY c.sub_merchant_id ORDER BY diff_days desc
</select>
<select id= "countClientsSettlementCycle" resultType= "com.alibaba.fastjson.JSONObject" >
SELECT COUNT(DISTINCT c.client_id) client_count,
CASE c.clean_days
WHEN 1
THEN 'T+1'
WHEN 2
THEN 'T+2'
WHEN 3
THEN 'T+3'
END AS clean_days
WHEN 1
THEN 'T+1'
WHEN 2
THEN 'T+2'
WHEN 3
THEN 'T+3'
END AS clean_days
FROM sys_clients c
<where >
(c.approve_result = 1 OR c.approve_result= 2) AND c.is_valid = 1
<if test= "org_id!=null and org_ids==null" > and org_id=#{org_id}</if>
<if test= "org_ids!=null" > and org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
<if test= "bd_group!=null" > and c.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
where b.is_valid=1 and b.start_date< =now() and (b.end_date is null or b.end_date > = now())
AND (c.bd_group=#{bd_group} or c.manager_id=#{bd_group})
<if test= "bd_group_bd" > and c.manager_id=#{bd_group_bd}</if> )
</if>
<where >
(c.approve_result = 1 OR c.approve_result= 2) AND c.is_valid = 1
<if test= "org_id!=null and org_ids==null" > and org_id=#{org_id}</if>
<if test= "org_ids!=null" > and org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach>
</if>
<if test= "bd_group!=null" > and c.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
where b.is_valid=1 and b.start_date< =now() and (b.end_date is null or b.end_date > = now())
AND (c.bd_group=#{bd_group} or c.manager_id=#{bd_group})
<if test= "bd_group_bd" > and c.manager_id=#{bd_group_bd}</if> )
</if>
<if test= "begin!=null" >
AND c.client_id in (SELECT o.client_id FROM statistics_customer_order o
<where >
<if test= "begin!=null" >
o.date >=#{begin}
</if>
<if test= "eng!=null" >
AND c.client_id in (SELECT o.client_id FROM statistics_customer_order o
<where >
<if test= "begin!=null" >
o.date >=#{begin}
</if>
<if test= "eng!=null" >
o.date > #{end}
</if>
</where> )
</if>
</where>
)
</if>
</where>
GROUP by c.clean_days
</select>
<select id= "listSecurePayMchs" resultType= "com.alibaba.fastjson.JSONObject" >
SELECT * FROM sys_clients sc where sc.org_id in (112,113) and is_valid=1
</select>
</mapper>