parent
1781257140
commit
f70ead46a9
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,15 @@
|
||||
app.alipay.host=https://mapi-hk.alipay.com/gateway.do
|
||||
|
||||
app.alipay.sftp-host=sftp.alipay.com
|
||||
|
||||
app.alipay.merchants.online.pid=2088821643021586
|
||||
app.alipay.merchants.online.key=hmwjrganlzb4aqgggdgdlod7l3lsjkn6
|
||||
app.alipay.merchants.online.sftp-username=openvisePTY
|
||||
app.alipay.merchants.online.sftp-password=XNBB3S
|
||||
app.alipay.merchants.online.private-key=classpath:data/crypt/alipay_private.pem
|
||||
app.alipay.merchants.online.public-key=classpath:data/crypt/alipay_public.pem
|
||||
|
||||
app.alipay.merchants.retail.pid=2088721525235246
|
||||
app.alipay.merchants.retail.key=jb5mt4vhtlzg1xlc0k967sib7v81sba6
|
||||
app.alipay.merchants.retail.sftp-username=openvisePTY
|
||||
app.alipay.merchants.retail.sftp-password=XNBB3S
|
@ -0,0 +1,9 @@
|
||||
app.bestpay.merchant-id=01010101010376850
|
||||
app.bestpay.production-key=924181926043
|
||||
app.bestpay.host=https://cbp.bestpay.com.cn/cashier
|
||||
app.bestpay.debug=false
|
||||
|
||||
app.bestpay.ftp.host=58.213.97.77
|
||||
app.bestpay.ftp.username=cbp
|
||||
app.bestpay.ftp.password=cbp@oig
|
||||
|
@ -0,0 +1,6 @@
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
spring.datasource.schema-name=royalpay_production
|
||||
spring.datasource.host=192.168.0.49:3306
|
||||
spring.datasource.url=jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=root
|
@ -0,0 +1,7 @@
|
||||
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
spring.datasource.schema-name=rppaymentdev
|
||||
spring.datasource.host=119.28.3.196:3310
|
||||
spring.datasource.url=jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
|
||||
spring.datasource.username=readonly
|
||||
spring.datasource.password=read0nly
|
@ -0,0 +1,6 @@
|
||||
app.jd.rsa-private-key-string=MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIYEz9fiv9jVJ5swEWQ6s+UB17CLo1D717U36f0JXzqFJoIOGENQ+MW9Wo/oEbyyXgDwPFfIEnwqJ8bPj+cavMQKaKZZ1yZGJE2uCNn/dZhpEQC9hvPRFexNMoVekBdmnPpXpOZiowI7mhsO0SC5lx8knuBGQVQmz+DwRwVLVfnPAgMBAAECgYB50IvezeLVQ0IBw9o7AUScpmUXuoTSymbR+CW98rPVLEvJMOiK32GP0sIrRaRBoNri/XnLzDZJF8QZ6HYDeQETzICBDI42QID1R925zHW7p6cf66EePNnH0B6lv57o6zYpTYglW9jeUreSTOUdWnnDbW4XMzDjUUFuXHujVj2vQQJBAPiTDNOmsQFNpZ23MRB2blk9DjAnQbt3ZrHn+ZJU/up9QCfc7Iz9qelLZLifnageS7vwqb8T4pMTrJC8MXKoR2ECQQCKBbVQ65HDRoODkf/w00BnL1YgkqkkM2CMo4/BMSLMZbTIGv3uHXXfh3/1PCFQXa2+lO6jO0D2dZOCFxdg4D8vAkEA6Sn2ZCn96r0M1s3ZhhmxFKACyQRp0hEEEWkJX0u++fGW1k2SzgW69Yy048FFP0d7vsTWVNewNknEGteMgoJ6wQJAJv6934Lux9EgTwfs28mTpJOHLeTBzOyHFrUPZHHRdxY1IWQe4iuIpgLOcCbw8pfFAtdpJM0U6Y0Gg/aqMECrGQJAIEYcVNMHKj96+wOYC2DZfKLn6FK/oMDCCzUchdOB/7Q9naaGPTJhc+Upi0UKK7214vCyiRLTFcgPP3esCVDqAw==
|
||||
app.jd.rsa-public-key-string=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCKE5N2xm3NIrXON8Zj19GNtLZ8xwEQ6uDIyrS3S03UhgBJMkGl4msfq4Xuxv6XUAN7oU1XhV3/xtabr9rXto4Ke3d6WwNbxwXnK5LSgsQc1BhT5NcXHXpGBdt7P8NMez5qGieOKqHGvT0qvjyYnYA29a8Z4wzNR7vAVHp36uD5RwIDAQAB
|
||||
app.jd.des-key-string=ti+JnsgV/XOKBwHZE2eUTJRMO/6DtqhY
|
||||
app.jd.md5-key=DI9JrGHK8W35Jeyt
|
||||
app.jd.merchant-id=110519142002
|
||||
app.jd.agent-id=110519142
|
@ -0,0 +1,6 @@
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
spring.datasource.schema-name=royalpay_production
|
||||
spring.datasource.host=192.168.0.49:3306
|
||||
spring.datasource.url=jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=root
|
@ -0,0 +1,7 @@
|
||||
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
spring.datasource.schema-name=royalpay_production
|
||||
spring.datasource.host=10.0.0.30:3306
|
||||
spring.datasource.url=jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
|
||||
spring.datasource.username=ap_prod_user
|
||||
spring.datasource.password=Pine@ppl321
|
@ -0,0 +1,7 @@
|
||||
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
spring.datasource.schema-name=royalpay_production
|
||||
spring.datasource.host=119.28.3.196:3310
|
||||
spring.datasource.url=jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
|
||||
spring.datasource.username=readonly
|
||||
spring.datasource.password=read0nly
|
@ -0,0 +1,20 @@
|
||||
|
||||
app.wechatpay.api-host=https://apihk.mch.weixin.qq.com
|
||||
app.wechatpay.merchants.1307485301.app-id=wx703febcbd34dae38
|
||||
app.wechatpay.merchants.1307485301.merchant-id=1307485301
|
||||
app.wechatpay.merchants.1307485301.mch-key=7e2d8c4aab15e4cabec1207ba79086b1
|
||||
app.wechatpay.merchants.1307485301.key-file=classpath:apiclient_cert.p12
|
||||
app.wechatpay.merchants.1307485301.example-sub-merchant-id=11755174
|
||||
|
||||
app.wechatpay.merchants.1431999902.app-id=wx703febcbd34dae38
|
||||
app.wechatpay.merchants.1431999902.merchant-id=1431999902
|
||||
app.wechatpay.merchants.1431999902.mch-key=p3tgzrAJbe6eQrunbv8jb8gz5yXxvJdE
|
||||
app.wechatpay.merchants.1431999902.key-file=classpath:apiclient_new_cert.p12
|
||||
app.wechatpay.merchants.1431999902.example-sub-merchant-id=42991963
|
||||
|
||||
app.wechatpay.merchants.1487387142.app-id=wx3e14d1144d898197
|
||||
app.wechatpay.merchants.1487387142.mp-id=globalpay
|
||||
app.wechatpay.merchants.1487387142.merchant-id=1487387142
|
||||
app.wechatpay.merchants.1487387142.mch-key=OuvLIL93STqFhTngNaBGT8751ZJn4FKL
|
||||
app.wechatpay.merchants.1487387142.key-file=classpath:napclient_cert.p12
|
||||
app.wechatpay.merchants.1487387142.example-sub-merchant-id=203312199
|
@ -0,0 +1,131 @@
|
||||
server.port=5000
|
||||
|
||||
spring.profiles.active=dev,alipay,bestpay,jd,wechat
|
||||
|
||||
env.company=RoyalPay
|
||||
|
||||
multipart.max-file-size=10Mb
|
||||
|
||||
spring.datasource.test-while-idle=true
|
||||
#连接池检测释放周期
|
||||
spring.datasource.time-between-eviction-runs-millis=500
|
||||
spring.datasource.validation-query=select 1
|
||||
#最大连接数
|
||||
spring.datasource.max-active=1000
|
||||
spring.datasource.max-pool-prepared-statement-per-connection-size=100
|
||||
spring.datasource.max-idle=150
|
||||
#建立连接最大等待时间
|
||||
spring.datasource.max-wait=3000
|
||||
spring.datasource.filters=stat,wall,log4j
|
||||
|
||||
spring.redis.host=127.0.0.1
|
||||
spring.redis.port=6379
|
||||
spring.redis.database=1
|
||||
|
||||
spring.data.mongodb.host=10.30.0.8
|
||||
spring.data.mongodb.port=27017
|
||||
spring.data.mongodb.database=admin
|
||||
spring.data.mongodb.username=mongouser
|
||||
spring.data.mongodb.password=Royalpay123
|
||||
|
||||
mybatis.autosql.default-dialect=mysql
|
||||
|
||||
app.redis.prefix=payment
|
||||
app.redis.settle.check-code.prefix=settlementCheckCode
|
||||
|
||||
logging.level.java.sql.Connection=debug
|
||||
logging.level.java.sql.Statement=debug
|
||||
logging.level.java.sql.PreparedStatement=debug
|
||||
logging.level.au.com.royalpay.payment=debug
|
||||
logging.pattern.console=[%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){blue}] %clr(%-5level) %logger: %msg%n
|
||||
|
||||
jetty.threadPool.maxThreads=1000
|
||||
|
||||
spring.mail.host=smtp.office365.com
|
||||
spring.mail.port=587
|
||||
|
||||
stockholder.mails=leo.huang@royalpay.com.au
|
||||
|
||||
|
||||
app.attachment.host=https://file.royalpay.com.au/
|
||||
app.attachment.source=03
|
||||
|
||||
##合同模板
|
||||
app.agreetemplate.classic.path=https://file.royalpay.com.au/open/2017/07/10/1499665073802_qV7fpEuS9rdbTnpa4po6rmbW9CSUfE.pdf
|
||||
##聚合支付合同模板
|
||||
#app.agreetemplate.aggregate.path=https://file.royalpay.com.au/open/2017/11/10/1510280089107_D7CMUz4S1iwBI9IPj5P6ItkiGClmPK.pdf
|
||||
app.agreetemplate.aggregate.path=https://file.royalpay.com.au/open/2017/11/17/1510890355946_hQt6yGc0NJ8TYeK7XCuuSAnTI31M7v.pdf
|
||||
|
||||
app.host.main=https://mpay.royalpay.com.au/
|
||||
app.host.regions.cn=https://mpay-cn.royalpay.com.au/
|
||||
app.host.regions.au=https://mpay-au.royalpay.com.au/
|
||||
app.debug=true
|
||||
|
||||
app.name=RoyalPay
|
||||
|
||||
app.cms.host=https://www.royalpay.com.au/
|
||||
|
||||
app.server.ip=127.0.0.1
|
||||
|
||||
app.redpack_auth.enable=false
|
||||
hf.rsa-file=/opt/2000604000101.pfx
|
||||
##积分商城
|
||||
app.customer.host=https://customer.royalpay.com.au/
|
||||
customer.app.appid=customer
|
||||
customer.app.auth-code=xxnpdBRwd4sIaCCI
|
||||
|
||||
app.settlement.email-to=astro.dai@royalpay.com.au
|
||||
app.settlement.email-cc=leo.huang@royalpay.com.au
|
||||
|
||||
app.mpsupport.appid=royalpay
|
||||
app.mpsupport.auth_code=W3xucYnbmbE6rZDmA2V9BsKmagTrVIny
|
||||
|
||||
app.run-tasks=false
|
||||
app.allow-clearing-generation=false
|
||||
|
||||
app.mail.appid=1
|
||||
app.mail.host=https://mailsupport.royalpay.com.au
|
||||
mail.send.credentialCode=Fd1aRfdjc9
|
||||
|
||||
apple.message.apns.password=F1b5*ChJPp73
|
||||
android.message.secret=2b96d9bc6169c9554218aab1
|
||||
android.message.appkey=3f33a10d0a7d4ac94d8f2431
|
||||
|
||||
spring.thymeleaf.mode=LEGACYHTML5
|
||||
|
||||
app.mpsupport.host=https://mp.royalpay.com.au
|
||||
app.foreign-currency=AUD
|
||||
|
||||
app.ofei.md5-key=Khjx6wejblaJzmG0JBWFlPFKAUxhFIXQ
|
||||
app.ofei.pwd=aomi@8888
|
||||
app.ofei.sp-code=A1407200
|
||||
|
||||
mail.mailgun.api_key=api:key-2e67b891a1a7974bf3a40ea440d5a77f
|
||||
mail.mailgun.public_key=api:pubkey-1aaaffc2662ba1b400c409d3e974ba7e
|
||||
mail.mailgun.domain=mail.royalpay.com.au
|
||||
mail.mailgun.default.merchantlist=merchants@mail.royalpay.com.au
|
||||
|
||||
|
||||
##############
|
||||
##短信key
|
||||
##############
|
||||
royalpay.sms.appid=1400094878
|
||||
royalpay.sms.appkey=43390d81e20c5191c278fbf4cd275be2
|
||||
|
||||
|
||||
#清算银行配置
|
||||
settle.abafile.default-bank=CBA
|
||||
settle.abafile.remains-to=ANZ
|
||||
|
||||
settle.abafile.bank.CBA.bank=CBA
|
||||
settle.abafile.bank.CBA.apca=301500
|
||||
settle.abafile.bank.CBA.bsb=063109
|
||||
settle.abafile.bank.CBA.account-no=11655861
|
||||
settle.abafile.bank.CBA.account-name=Tunnel Show Pty Ltd
|
||||
|
||||
settle.abafile.bank.ANZ.manual-sending=true
|
||||
settle.abafile.bank.ANZ.bank=ANZ
|
||||
settle.abafile.bank.ANZ.apca=514624
|
||||
settle.abafile.bank.ANZ.bsb=013006
|
||||
settle.abafile.bank.ANZ.account-no=837022519
|
||||
settle.abafile.bank.ANZ.account-name=Tunnel Show Pty Ltd
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,192 @@
|
||||
<?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="au.com.royalpay.payment.manage.analysis.mappers.BDAnalysisMapper">
|
||||
<select id="getBDSaleList" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
d.bd_name,d.bd_id,sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,-temp.clearing_amount*d.proportion))
|
||||
total,
|
||||
ifnull(sum(if(temp.refund_id is not null,if(temp.transaction_type='Debit',temp.clearing_amount,-temp.clearing_amount)*d.proportion,0)),0) refund_fee
|
||||
FROM
|
||||
(SELECT l.client_id,l.clearing_amount,l.refund_id,l.transaction_type,o.create_time FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o
|
||||
ON o.order_id = l.order_id
|
||||
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
||||
<if test="end!=null">and o.create_time < #{end}</if>
|
||||
<if test="begin_month">and DATE_FORMAT(o.create_time,'%Y-%m') >=#{begin_month}</if>
|
||||
<if test="end_month">and DATE_FORMAT(o.create_time,'%Y-%m') <= #{end_month}</if>
|
||||
where (l.transaction_type='Credit' or l.refund_id is not null)
|
||||
) temp
|
||||
INNER JOIN sys_client_bd d ON temp.client_id = d.client_id AND d.start_date <= temp.create_time and
|
||||
d.is_valid = '1'
|
||||
AND (d.end_date is null or d.end_date > temp.create_time)
|
||||
<if test="org_id!=null and org_ids==null">
|
||||
INNER JOIN sys_managers m on m.manager_id = d.bd_id and m.org_id = #{org_id}
|
||||
</if>
|
||||
<if test="org_ids!=null">
|
||||
INNER JOIN sys_managers m on m.manager_id = d.bd_id and m.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
<if test="bd_group!=null">and temp.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>
|
||||
GROUP BY d.bd_id
|
||||
ORDER BY total DESC
|
||||
</select>
|
||||
<select id="getBDSalePartnerList" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
c.client_id,c.client_moniker,c.short_name,c.approve_time,IFNULL(sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,-temp.clearing_amount*d.proportion)),0)
|
||||
total FROM (SELECT l.client_id,l.clearing_amount,l.transaction_type,l.refund_id,o.create_time FROM
|
||||
pmt_transactions l
|
||||
INNER JOIN pmt_orders o
|
||||
ON o.order_id = l.order_id
|
||||
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
||||
<if test="end!=null">and o.create_time < #{end}</if>
|
||||
WHERE l.transaction_type = 'Credit' or l.refund_id is not null) temp
|
||||
RIGHT JOIN sys_client_bd d ON temp.client_id = d.client_id AND d.start_date <= temp.create_time and
|
||||
d.is_valid = '1'
|
||||
AND (d.end_date is null or d.end_date > temp.create_time)
|
||||
INNER JOIN sys_clients c ON c.client_id = d.client_id
|
||||
<where>
|
||||
<if test="bd_id!=null">AND d.bd_id = #{bd_id}</if>
|
||||
</where>
|
||||
GROUP BY d.client_id
|
||||
ORDER BY total DESC;
|
||||
</select>
|
||||
|
||||
<select id="getMonthSalesList" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT DATE_FORMAT(c.datelist,'%Y-%m') y_m,IFNULL(temp.total,0) total FROM
|
||||
(SELECT c.short_name,c.approve_time,
|
||||
IFNULL(sum(if(t.transaction_type='Credit',t.clearing_amount*b.proportion,-t.clearing_amount*b.proportion)),0)
|
||||
total,DATE_FORMAT(t.transaction_time,'%Y-%m') transaction_month
|
||||
FROM pmt_transactions t
|
||||
LEFT JOIN sys_clients c ON t.client_id = c.client_id AND c.is_valid=1
|
||||
RIGHT JOIN sys_client_bd b ON b.client_id=c.client_id AND b.is_valid='1' AND b.start_date <=
|
||||
t.transaction_time AND (b.end_date is null or b.end_date >= t.transaction_time)
|
||||
<where>
|
||||
(t.transaction_type='Credit' or t.refund_id is not null)
|
||||
<if test="client_id">AND c.client_id=#{client_id}</if>
|
||||
AND b.bd_id= #{bd_id} and DATE_FORMAT(t.transaction_time,'%Y-%m') >=#{begin_month} AND
|
||||
DATE_FORMAT(t.transaction_time,'%Y-%m') <= #{end_month}
|
||||
</where>
|
||||
GROUP BY DATE_FORMAT(t.transaction_time,'%Y-%m')
|
||||
) temp
|
||||
RIGHT JOIN calendar c on DATE_FORMAT(c.datelist,'%Y-%m') = temp.transaction_month
|
||||
WHERE DATE_FORMAT(c.datelist,'%Y-%m') >= #{begin_month} AND DATE_FORMAT(c.datelist,'%Y-%m') <=
|
||||
#{end_month}
|
||||
GROUP BY DATE_FORMAT(c.datelist,'%Y-%m')
|
||||
</select>
|
||||
|
||||
<select id="getMonthClientsByBD" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
c.client_id,
|
||||
c.short_name,
|
||||
c.approve_time
|
||||
FROM sys_clients c
|
||||
RIGHT JOIN sys_client_bd b ON b.client_id = c.client_id
|
||||
WHERE b.bd_id = #{bd_id} AND b.is_valid = '1' AND
|
||||
b.start_date <= #{begin_month} AND (b.end_date IS NULL OR b.end_date >= #{end_month})
|
||||
AND c.is_valid = 1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getClientsMonthSale" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
c.client_id,
|
||||
c.client_moniker,
|
||||
c.short_name,
|
||||
DATE_FORMAT(c.approve_time, '%Y-%m-%d') approve_time,
|
||||
IFNULL(sum(if(temp.transaction_type = 'Credit', temp.clearing_amount * d.proportion,
|
||||
-temp.clearing_amount * d.proportion)), 0) total,
|
||||
ifnull(sum(if(DATE_FORMAT(temp.create_time, '%Y-%m') = #{month}, sum(
|
||||
if(temp.transaction_type = 'Credit', temp.clearing_amount * d.proportion,
|
||||
-temp.clearing_amount * d.proportion)), 0)),
|
||||
0) month_total
|
||||
FROM
|
||||
(SELECT
|
||||
l.client_id,
|
||||
l.clearing_amount,
|
||||
l.transaction_type,
|
||||
l.refund_id,
|
||||
o.create_time
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o
|
||||
ON o.order_id = l.order_id
|
||||
AND DATE_FORMAT(o.create_time, '%Y-%m') >= #{begin_month}
|
||||
AND DATE_FORMAT(o.create_time, '%Y-%m') <= #{end_month}
|
||||
WHERE l.transaction_type = 'Credit' OR l.refund_id is not null) temp
|
||||
RIGHT JOIN sys_client_bd d ON temp.client_id = d.client_id AND d.start_date <= temp.create_time
|
||||
AND (d.end_date IS NULL OR d.end_date > temp.create_time)
|
||||
LEFT JOIN sys_clients c ON c.client_id = d.client_id AND c.is_valid = 1
|
||||
WHERE d.bd_id = #{bd_id} AND d.is_valid = '1'
|
||||
GROUP BY d.client_id
|
||||
ORDER BY total DESC;
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getMonths" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT DATE_FORMAT(c.datelist, '%Y-%m') y_m
|
||||
FROM calendar c
|
||||
WHERE DATE_FORMAT(c.datelist, '%Y-%m') <= #{begin_month} AND
|
||||
DATE_FORMAT(c.datelist, '%Y-%m') >= #{end_month}
|
||||
GROUP BY y_m
|
||||
</select>
|
||||
<select id="countApproved" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
|
||||
select
|
||||
a.bd_id,
|
||||
a.bd_name,
|
||||
sum(a.proportion) num
|
||||
from sys_client_bd a inner join
|
||||
(select bd_id,
|
||||
max(create_time) create_time
|
||||
from sys_client_bd
|
||||
where client_id in(select client_id from sys_clients c where c.approve_time >= #{begin} AND c.approve_time < #{end} AND c.is_valid = 1 AND c.approve_result = 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>
|
||||
<if test="source==1">and c.source=1</if>
|
||||
<if test="source==2">and c.source!=1</if>
|
||||
|
||||
<![CDATA[
|
||||
)
|
||||
and start_date <=#{end}
|
||||
and is_valid=1
|
||||
AND (end_date > #{begin} OR end_date IS NULL)
|
||||
GROUP BY bd_id,client_id
|
||||
) b
|
||||
on a.bd_id = b.bd_id and a.create_time = b.create_time
|
||||
where a.is_valid = 1
|
||||
]]>
|
||||
group by bd_id
|
||||
order by num desc
|
||||
</select>
|
||||
<select id="getBDSalePartnerReport" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT c.industry,c.royalpayindustry,
|
||||
count(DISTINCT c.client_id) partner_counts,
|
||||
IFNULL(sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,-temp.clearing_amount*d.proportion)),0)
|
||||
total
|
||||
FROM (SELECT l.client_id,l.clearing_amount,l.transaction_type,l.refund_id,o.create_time FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o
|
||||
ON o.order_id = l.order_id
|
||||
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
||||
<if test="end!=null">and o.create_time < #{end}</if>
|
||||
WHERE l.transaction_type = 'Credit' or l.refund_id is not null) temp
|
||||
RIGHT JOIN sys_client_bd d ON temp.client_id = d.client_id AND d.start_date <= temp.create_time and
|
||||
d.is_valid = '1'
|
||||
AND (d.end_date is null or d.end_date > temp.create_time)
|
||||
INNER JOIN sys_clients c ON c.client_id = d.client_id
|
||||
<where>
|
||||
<if test="bd_id!=null">AND d.bd_id = #{bd_id}</if>
|
||||
</where>
|
||||
GROUP BY c.royalpayindustry
|
||||
ORDER BY partner_counts DESC;
|
||||
</select>
|
||||
|
||||
</mapper>
|
Binary file not shown.
@ -0,0 +1,151 @@
|
||||
<?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="au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper">
|
||||
<select id="countNewClients" resultType="java.lang.Integer">
|
||||
<![CDATA[
|
||||
SELECT count(client_id)
|
||||
FROM sys_clients
|
||||
WHERE
|
||||
create_time >= #{begin} AND create_time <= #{end} and is_valid=1 and (approve_result is null or approve_result !=0)
|
||||
]]>
|
||||
<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>
|
||||
</select>
|
||||
|
||||
<select id="countNewClientsHistory" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT DATE_FORMAT(a.datelist,'%Y-%m-%d') datelist,count(c.client_id) num
|
||||
FROM sys_clients c
|
||||
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}-->
|
||||
<!--</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>
|
||||
<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>
|
||||
GROUP BY a.datelist
|
||||
</select>
|
||||
<select id="countClients" resultType="java.lang.Integer">
|
||||
<![CDATA[
|
||||
SELECT count(client_id)
|
||||
FROM sys_clients
|
||||
WHERE
|
||||
create_time <= #{end} AND is_valid=1 and (approve_result is null or approve_result !=0)
|
||||
]]>
|
||||
<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>
|
||||
</select>
|
||||
<select id="countTradedPartners" resultType="java.lang.Integer">
|
||||
<![CDATA[
|
||||
SELECT count(DISTINCT p.client_id) c
|
||||
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 o.create_time >= #{begin} AND o.create_time <= #{end}
|
||||
]]>
|
||||
<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>
|
||||
</select>
|
||||
|
||||
<select id="countTradePartnersHistory" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT DATE_FORMAT(date(o.create_time),'%Y-%m-%d') datelist,count(DISTINCT p.client_id) num
|
||||
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 o.create_time >= #{begin} AND o.create_time <= #{end}
|
||||
]]>
|
||||
<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>
|
||||
<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>
|
||||
)
|
||||
</if>
|
||||
GROUP BY date(o.create_time)
|
||||
</select>
|
||||
|
||||
<select id="listPartnersTradeAmount" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT
|
||||
p.client_moniker,p.short_name,ifnull(sum(if(t.transaction_type='Credit',t.clearing_amount,0)),0)aud_fee,
|
||||
count(DISTINCT t.order_id) orders,max(t.clearing_amount)max_order,ifnull(sum(if(t.refund_id is not null,if(t.transaction_type='Debit',t.clearing_amount,-t.clearing_amount),0)),0)refund_amount,
|
||||
ifnull(sum(if(t.refund_id is not null and t.transaction_type='Debit',1,0)),0)refund_orders,max(if(t.refund_id is not null and t.transaction_type='Debit',t.clearing_amount,0))max_refund
|
||||
FROM sys_clients p
|
||||
INNER JOIN pmt_transactions t ON t.client_id = p.client_id and (t.transaction_type='Credit' or t.refund_id is not null)
|
||||
INNER JOIN pmt_orders o ON t.order_id = o.order_id
|
||||
WHERE o.create_time >= #{begin} AND o.create_time <= #{end}
|
||||
]]>
|
||||
<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>
|
||||
<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>
|
||||
)
|
||||
</if>
|
||||
GROUP BY p.client_id
|
||||
</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">
|
||||
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
|
||||
</if>
|
||||
<where>
|
||||
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>
|
||||
<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>
|
||||
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
|
||||
]]>
|
||||
GROUP by c.sub_merchant_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
Binary file not shown.
@ -0,0 +1,185 @@
|
||||
<?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="au.com.royalpay.payment.manage.analysis.mappers.ClientRatesAnalysisMapper">
|
||||
<resultMap id="bd_client_analysis" type="com.alibaba.fastjson.JSONObject">
|
||||
<id column="client_id" property="client_id"/>
|
||||
<result column="client_moniker" property="client_moniker"/>
|
||||
<result column="short_name" property="short_name"/>
|
||||
<result column="client_create_time" property="client_create_time"/>
|
||||
<result column="approve_time" property="approve_time"/>
|
||||
<collection property="trade_analysis" ofType="com.alibaba.fastjson.JSONObject" javaType="arraylist">
|
||||
<id column="days_before_today" property="days_before_today"/>
|
||||
<result column="create_date" property="create_date"/>
|
||||
<result column="total_amount" property="total_amount"/>
|
||||
<result column="total_count" property="total_count"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="analysisRatesForBDUsers" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT *,floor(trade_clients/total_clients*100) percentage
|
||||
FROM (
|
||||
SELECT
|
||||
count(c.client_id) total_clients,
|
||||
sum(if(c.orders > 0, 1, 0)) trade_clients,
|
||||
m.display_name,
|
||||
m.manager_id
|
||||
FROM sys_managers m
|
||||
INNER JOIN sys_client_bd r ON r.bd_id = m.manager_id AND r.start_date <= #{end} AND r.is_valid = 1
|
||||
AND (r.end_date IS NULL OR r.end_date >= #{end})
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
c.client_id,
|
||||
count(o.order_id) orders
|
||||
FROM sys_clients c
|
||||
LEFT JOIN pmt_orders o
|
||||
ON o.client_id = c.client_id AND o.status > 4
|
||||
AND date(o.create_time) <= date(#{end})
|
||||
AND date(o.create_time) >= date(#{begin})
|
||||
and o.total_amount>10
|
||||
WHERE c.approve_result=1 and c.is_valid=1
|
||||
GROUP BY c.client_id
|
||||
) c ON c.client_id = r.client_id
|
||||
]]>
|
||||
<where>
|
||||
<if test="org_id!=null and org_ids==null">m.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and m.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
<if test="bd_group!=null">and m.manager_id in (select manager_id from financial_bd_config where (bd_group=#{bd_group} or manager_id=#{bd_group}))</if>
|
||||
</where>
|
||||
GROUP BY m.manager_id
|
||||
)t
|
||||
order by percentage desc
|
||||
</select>
|
||||
<select id="analysisTotal" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT *,floor(trade_clients/total_clients*100) percentage
|
||||
FROM (
|
||||
SELECT
|
||||
count(c.client_id) total_clients,
|
||||
sum(if(c.orders > 0, 1, 0)) trade_clients
|
||||
FROM (
|
||||
SELECT
|
||||
c.client_id,
|
||||
c.org_id,
|
||||
count(o.order_id) orders
|
||||
FROM sys_clients c
|
||||
LEFT JOIN pmt_orders o
|
||||
ON o.client_id = c.client_id AND o.status > 4
|
||||
AND date(o.create_time) <= date(#{end})
|
||||
AND date(o.create_time) >= date(#{begin})
|
||||
and o.total_amount>10
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
and c.client_id in
|
||||
<foreach collection="client_ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
WHERE c.approve_result=1 and c.is_valid=1
|
||||
GROUP BY c.client_id
|
||||
) c
|
||||
<where>
|
||||
<if test="org_id!=null and org_ids==null">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>
|
||||
<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>
|
||||
)t
|
||||
order by percentage
|
||||
</select>
|
||||
<select id="analysisClientRates" resultMap="bd_client_analysis">
|
||||
<![CDATA[
|
||||
SELECT
|
||||
c.client_id,
|
||||
c.client_moniker,
|
||||
date_format(c.create_time, '%Y/%m/%d') client_create_time,
|
||||
date_format(c.approve_time, '%Y/%m/%d') approve_time,
|
||||
c.short_name,
|
||||
DATE_FORMAT(o.date, '%Y/%m/%d') create_date,
|
||||
datediff(#{end}, o.date) days_before_today,
|
||||
sum(o.orders) total_count,
|
||||
sum(o.total) total_amount
|
||||
FROM sys_clients c
|
||||
LEFT JOIN statistics_customer_order o ON o.client_id = c.client_id
|
||||
WHERE c.approve_result = 1 AND c.is_valid = 1
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
and c.client_id in
|
||||
<foreach collection="client_ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY c.client_id, create_date
|
||||
ORDER BY c.create_time
|
||||
</select>
|
||||
<select id="listClientsForBD" resultType="java.lang.String">
|
||||
<![CDATA[
|
||||
SELECT DISTINCT c.client_id FROM sys_clients c
|
||||
INNER JOIN sys_client_bd r ON r.client_id = c.client_id AND r.start_date <= curdate() AND r.is_valid = 1
|
||||
AND (r.end_date IS NULL OR r.end_date >= curdate()) AND r.bd_id = #{bd_id}
|
||||
]]>
|
||||
<where>
|
||||
<if test="noactive">
|
||||
<if test="notrade">
|
||||
<![CDATA[
|
||||
and (select ifnull(sum(o.total),0) from statistics_customer_order o where o.client_id=c.client_id and o.date>=#{begin})=0
|
||||
]]>
|
||||
</if>
|
||||
<if test="max_amount!=null">
|
||||
<![CDATA[
|
||||
and (select ifnull(sum(o.total),0) from statistics_customer_order o where o.client_id=c.client_id and o.date>=#{begin})<=#{max_amount}
|
||||
]]>
|
||||
</if>
|
||||
</if>
|
||||
<if test="transaction_rate">
|
||||
<![CDATA[
|
||||
and (select (ifnull(sum(if(o2.date>=#{last_begin} and o2.date<#{this_begin},o2.total,0)),0)-ifnull(sum(if(o2.date>=#{this_begin},o2.total,0)),0))/
|
||||
if(ifnull(sum(if(o2.date>=#{last_begin} and o2.date<#{this_begin},o2.total,0)),0)=0,1,sum(if(o2.date>=#{last_begin} and o2.date<#{this_begin},o2.total,0)))*100
|
||||
from statistics_customer_order o2 where o2.client_id=c.client_id and o2.date>=#{last_begin})>#{trade_degree}
|
||||
]]>
|
||||
</if>
|
||||
and c.approve_result=1 and c.is_valid=1
|
||||
</where>
|
||||
|
||||
|
||||
</select>
|
||||
<select id="listClientsForOrg" resultType="java.lang.String">
|
||||
<![CDATA[
|
||||
SELECT DISTINCT c.client_id FROM sys_clients c
|
||||
]]>
|
||||
<where>
|
||||
<if test="noactive">
|
||||
<if test="notrade">
|
||||
<![CDATA[
|
||||
and (select ifnull(sum(o.total),0) from statistics_customer_order o where o.client_id=c.client_id and o.date>=#{begin})=0
|
||||
]]>
|
||||
</if>
|
||||
<if test="max_amount!=null">
|
||||
<![CDATA[
|
||||
and (select ifnull(sum(o.total),0) from statistics_customer_order o where o.client_id=c.client_id and o.date>=#{begin})<=#{max_amount}
|
||||
]]>
|
||||
</if>
|
||||
</if>
|
||||
<if test="transaction_rate">
|
||||
<![CDATA[
|
||||
and (select (ifnull(sum(if(o2.date>=#{last_begin} and o2.date<#{this_begin},o2.total,0)),0)-ifnull(sum(if(o2.date>=#{this_begin},o2.total,0)),0))/
|
||||
if(ifnull(sum(if(o2.date>=#{last_begin} and o2.date<#{this_begin},o2.total,0)),0)=0,1,sum(if(o2.date>=#{last_begin} and o2.date<#{this_begin},o2.total,0)))*100
|
||||
from statistics_customer_order o2 where o2.client_id=c.client_id and o2.date>=#{last_begin})>#{trade_degree}
|
||||
]]>
|
||||
</if>
|
||||
and c.approve_result=1 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>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
Binary file not shown.
@ -0,0 +1,557 @@
|
||||
<?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="au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper">
|
||||
|
||||
<select id="getCustomerAndOrderStatistics" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT s.*,date_format(s.date,'%d/%m/%Y') trade_date,date_format(s.date,'%m-%d') app_trade_date FROM statistics_customer_order s
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
]]>
|
||||
<where>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="begin!=null">and s.date >= #{begin}</if>
|
||||
<if test="end!=null">and s.date <= #{end}</if>
|
||||
<if test="org_id!=null">and c.org_id = #{org_id}</if>
|
||||
</where>
|
||||
ORDER BY date DESC
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
DELETE FROM statistics_customer_order
|
||||
WHERE date >= #{begin}
|
||||
and date < #{end}
|
||||
<if test="client_id != null">
|
||||
and client_id = #{client_id}
|
||||
</if>
|
||||
<if test="channel != null">
|
||||
and channel = #{channel}
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<select id="getSumOrdersAndCustomersDaily" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT sum(s.customers) customers,sum(s.orders) orders,sum(s.new_customers) new_customers,
|
||||
sum(s.old_customers) old_customers,sum(s.total) total, sum(s.total)/sum(s.customers) single_amount,
|
||||
sum(s.refund_amount) refund_amount,sum(s.refund_orders) refund_orders,
|
||||
date_format(s.date,'%d/%m/%Y') trade_date
|
||||
FROM statistics_customer_order s
|
||||
<where>
|
||||
s.date = #{trade_date}
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="channel!=null">and s.channel = #{channel}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getSumCustomersAnalysisMonthly" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT sum(s.customers) customers,sum(s.orders) orders,sum(s.new_customers) new_customers,
|
||||
sum(s.old_customers) old_customers,sum(s.total) total, sum(s.total)/sum(s.customers) single_amount,
|
||||
date_format(s.date,'%m/%Y') trade_date
|
||||
FROM statistics_customer_order s
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
]]>
|
||||
<where>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="channel!=null">and s.channel = #{channel}</if>
|
||||
<if test="begin!=null">and s.date >= #{begin}</if>
|
||||
<if test="end!=null">and s.date < #{end}</if>
|
||||
<if test="org_id!=null">and c.org_id = #{org_id}</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>
|
||||
GROUP BY trade_date ORDER BY date DESC
|
||||
</select>
|
||||
|
||||
<select id="getSumCustomersAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT sum(s.customers) customers,sum(s.orders) orders,sum(s.new_customers) new_customers,
|
||||
sum(s.old_customers) old_customers,sum(s.total) total, sum(s.total)/sum(s.customers) single_amount,
|
||||
date_format(s.date,'%d/%m/%Y') trade_date
|
||||
FROM statistics_customer_order s
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
]]>
|
||||
<where>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="channel!=null">and s.channel = #{channel}</if>
|
||||
<if test="begin!=null">and s.date >= #{begin}</if>
|
||||
<if test="end!=null">and s.date < #{end}</if>
|
||||
<if test="org_id!=null">and c.org_id = #{org_id}</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>
|
||||
GROUP BY s.date ORDER BY date DESC
|
||||
</select>
|
||||
|
||||
<select id="getSumChannelAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT ifnull(sum(s.orders),0) orders,
|
||||
ifnull(sum(s.total),0) total,
|
||||
ifnull(sum(s.total)/sum(s.customers),0) single_amount,
|
||||
ifnull(date_format(s.date,'%d-%m-%Y'),0) trade_date
|
||||
FROM calendar cal
|
||||
LEFT JOIN statistics_customer_order s ON s.date=cal.datelist
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
]]>
|
||||
<where>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="channel!=null">and s.channel = #{channel}</if>
|
||||
<if test="begin!=null">and cal.datelist >= #{begin}</if>
|
||||
<if test="end!=null">and cal.datelist < #{end}</if>
|
||||
<if test="org_id!=null">and c.org_id = #{org_id}</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>
|
||||
GROUP BY s.date ORDER BY date DESC
|
||||
</select>
|
||||
|
||||
<!--<select id="getSumCustomersChannelAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT SUM(t.total) AS total_amount
|
||||
FROM statistics_customer_order t
|
||||
<where>
|
||||
t.date >= #{begin}
|
||||
AND #{end} > t.date
|
||||
<if test="channel!=null">
|
||||
AND t.channel = #{channel}
|
||||
</if>
|
||||
<if test="client_id !=null ">
|
||||
AND t.client_id = #{client_id}
|
||||
</if>
|
||||
</where>
|
||||
</select>-->
|
||||
|
||||
<select id="getSumCustomersChannelAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT SUM(IF(t.transaction_type = 'Credit', t.clearing_amount,0)) AS total_amount
|
||||
FROM pmt_transactions t
|
||||
<where>
|
||||
t.transaction_time >= #{begin}
|
||||
AND #{end} >= t.transaction_time
|
||||
<if test="channel!=null">
|
||||
AND t.channel = #{channel}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getAvgOrderAndCustomerStatistics" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
|
||||
SELECT AVG(total) total,avg(orders) orders,avg(single_amount)single_amount,avg(customers) customers,avg(new_customers) new_customers,avg(old_customers)old_customers
|
||||
FROM statistics_customer_order s
|
||||
]]>
|
||||
<where>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id!= null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="begin!=null">and s.date >= #{begin}</if>
|
||||
<if test="end!=null">and s.date < #{end}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getPartnerCustomerAndOrderStatistics" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT date_format(c.datelist,'%Y-%m-%d') datelist,date_format(c.datelist,'%Y-%m-%d') date,date_format(c.datelist,'%m-%d') app_trade_date,ifnull(sum(s.customers),0)customers,ifnull(sum(s.new_customers),0)new_customers,
|
||||
ifnull(sum(s.old_customers),0)old_customers,ifnull(sum(s.orders),0)orders,ifnull(sum(s.total),0)total,ifnull(sum(s.total)/sum(s.customers),0) single_amount FROM calendar c
|
||||
LEFT JOIN statistics_customer_order s on c.datelist= s.date ]]>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
|
||||
where c.datelist >= (SELECT date FROM statistics_customer_order
|
||||
<where>
|
||||
<if test="client_ids!=null">
|
||||
AND client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and client_id=#{client_id}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY date limit 1)
|
||||
<![CDATA[
|
||||
and c.datelist < date(now())
|
||||
]]>
|
||||
<if test="begin!=null">and c.datelist >= #{begin}</if>
|
||||
<if test="end!=null">and c.datelist < #{end}</if>
|
||||
GROUP BY s.date ORDER BY date
|
||||
</select>
|
||||
|
||||
<select id="getMaxAmount" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT sum(total) max_amount,date FROM statistics_customer_order where client_id=#{client_id} GROUP BY date order by max_amount desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getMaxOrders" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT sum(orders) max_orders,date FROM statistics_customer_order where client_id=#{client_id} GROUP BY date order by max_orders desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getMaxTransactionPartners" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT date,count(client_id) partners FROM statistics_customer_order where client_id>0 GROUP BY date order by partners desc LIMIT 1
|
||||
</select>
|
||||
<select id="getByConditions" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT t.*
|
||||
FROM statistics_customer_order t
|
||||
where
|
||||
t.date >= #{begin}
|
||||
AND #{end} > t.date
|
||||
<if test="channel!=null">
|
||||
AND t.channel = #{channel}
|
||||
</if>
|
||||
<if test="client_id !=null ">
|
||||
AND t.client_id = #{client_id}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="countChannel" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
ifnull(sum(s.orders),0) orders,
|
||||
ifnull(sum(s.total),0) total,
|
||||
ifnull(sum(s.single_amount),0) single_amount
|
||||
FROM statistics_customer_order s
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
<where>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="channel!=null">and s.channel = #{channel}</if>
|
||||
<if test="begin!=null">and s.date >= #{begin}</if>
|
||||
<if test="end!=null">and s.date < #{end}</if>
|
||||
<if test="org_id!=null">and c.org_id = #{org_id}</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>
|
||||
</select>
|
||||
|
||||
<select id="getChannelCommonCount" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
select ifnull(sum(CASE WHEN s.channel = 'Alipay' THEN s.total ELSE 0 END),0) alipayamount,
|
||||
ifnull(sum(CASE WHEN s.channel = 'Alipay' THEN s.orders ELSE 0 END),0) alipay_order_count,
|
||||
ifnull(sum(CASE WHEN s.channel = 'Bestpay' THEN s.total ELSE 0 END),0) bestpayamount,
|
||||
ifnull(sum(CASE WHEN s.channel = 'Bestpay' THEN s.orders ELSE 0 END),0) bestpay_order_count,
|
||||
ifnull(sum(CASE WHEN s.channel = 'Wechat' THEN s.total ELSE 0 END),0) wechatamount,
|
||||
ifnull(sum(CASE WHEN s.channel = 'Wechat' THEN s.orders ELSE 0 END),0) wechat_order_count,
|
||||
ifnull(sum(CASE WHEN s.channel = 'jd' THEN s.total ELSE 0 END),0) jdamount,
|
||||
ifnull(sum(CASE WHEN s.channel = 'jd' THEN s.orders ELSE 0 END),0) jd_order_count,
|
||||
ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.total ELSE 0 END),0) alipayonlineamount,
|
||||
ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.orders ELSE 0 END),0) alipayonline_order_count,
|
||||
ifnull(sum(CASE WHEN s.channel = 'hf' THEN s.total ELSE 0 END),0) hfamount,
|
||||
ifnull(sum(CASE WHEN s.channel = 'hf' THEN s.orders ELSE 0 END),0) hf_order_count,
|
||||
FROM statistics_customer_order s
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
]]>
|
||||
<where>
|
||||
s.client_id != 0
|
||||
<if test="begin!=null">and s.date >= #{begin}</if>
|
||||
<if test="end!=null">and s.date <= #{end}</if>
|
||||
<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>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getCommonCount" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
select
|
||||
ifnull(sum(s.orders),0) trade_count,
|
||||
ifnull(sum(s.total),0) trade_amount
|
||||
FROM statistics_customer_order s
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
]]>
|
||||
<where>
|
||||
s.client_id != 0
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="begin!=null">and s.date >= #{begin}</if>
|
||||
<if test="end!=null">and s.date < #{end}</if>
|
||||
<if test="channel!=null">and s.channel=#{channel}</if>
|
||||
<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>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getAreaMerchantTradeAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT ifnull(sum(s.total),0) total,ifnull(sum(s.orders),0) orders,c.client_moniker,c.short_name,c.bd_user_name,c.suburb,c.state,c.royalpayindustry,
|
||||
ifnull(sum(if(s.channel='Alipay'OR s.channel='AlipayOnline',s.total,0)),0) alipay_total,
|
||||
ifnull(sum(if(s.channel='Alipay'OR s.channel='AlipayOnline',s.orders,0)),0) alipay_order,
|
||||
ifnull(sum(if(s.channel='Wechat',s.total,0)),0) wechat_toatl,
|
||||
ifnull(sum(if(s.channel='Wechat',s.orders,0)),0) wechat_order
|
||||
FROM statistics_customer_order s
|
||||
RIGHT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
]]>
|
||||
<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)<= #{begin} and (d.end_date is null or date(d.end_date)>= #{end}) and
|
||||
d.is_valid=1
|
||||
</if>
|
||||
<where>
|
||||
<if test="begin!=null">and s.date >= #{begin}</if>
|
||||
<if test="end!=null">and s.date < #{end}</if>
|
||||
<if test="org_id!=null">and c.org_id = #{org_id}</if>
|
||||
<if test="state!=null">and c.state = #{state}</if>
|
||||
<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>
|
||||
<if test="client_monikers!=null">
|
||||
AND c.client_moniker IN
|
||||
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
|
||||
#{client_moniker}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY s.client_id ORDER BY total DESC
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getAreaMerchantTradeByLastCycle" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT c.client_moniker,
|
||||
ifnull(sum(s.total),0) old_total,
|
||||
ifnull(sum(if(s.channel='Alipay'OR s.channel='AlipayOnline',s.total,0)),0) old_alipay_total,
|
||||
ifnull(sum(if(s.channel='Wechat',s.total,0)),0) old_wechat_toatl
|
||||
FROM statistics_customer_order s
|
||||
RIGHT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
]]>
|
||||
<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)<= #{begin} and (d.end_date is null or date(d.end_date)>= #{end}) and
|
||||
d.is_valid=1
|
||||
</if>
|
||||
<where>
|
||||
<if test="begin!=null">and s.date >= DATE_ADD(#{begin},INTERVAL -datediff( #{end},#{begin}) DAY)</if>
|
||||
<if test="end!=null">and s.date < #{begin}</if>
|
||||
<if test="org_id!=null">and c.org_id = #{org_id}</if>
|
||||
<if test="state!=null">and c.state = #{state}</if>
|
||||
<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>
|
||||
<if test="client_monikers!=null">
|
||||
AND c.client_moniker IN
|
||||
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
|
||||
#{client_moniker}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY s.client_id ORDER BY old_total DESC
|
||||
</select>
|
||||
|
||||
|
||||
<select id="countTradedClientsByDate" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT date_format(s.date,'%d-%m-%Y') datelist,COUNT(DISTINCT s.client_id) num
|
||||
FROM statistics_customer_order s
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
<where>
|
||||
s.client_id != 0
|
||||
<if test="begin!=null">and s.date >= #{begin}</if>
|
||||
<if test="end!=null">and s.date < #{end}</if>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="channel!=null">and s.channel = #{channel}</if>
|
||||
<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>
|
||||
<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>
|
||||
GROUP BY datelist ORDER BY datelist
|
||||
</select>
|
||||
|
||||
<select id="countTradedClients" resultType="java.lang.Integer">
|
||||
SELECT ifnull(COUNT(DISTINCT s.client_id),0) traded_partners
|
||||
FROM statistics_customer_order s
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
<where>
|
||||
s.client_id != 0
|
||||
<if test="begin!=null">and s.date >= #{begin}</if>
|
||||
<if test="end!=null">and s.date < #{end}</if>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="channel!=null">and s.channel = #{channel}</if>
|
||||
<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>
|
||||
<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>
|
||||
</select>
|
||||
|
||||
<select id="countTotalCustomers" resultType="java.lang.Integer">
|
||||
SELECT ifnull(SUM(s.customers),0) total_customers
|
||||
FROM statistics_customer_order s
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
<where>
|
||||
s.client_id != 0
|
||||
<if test="begin!=null">and s.date >= DATE_FORMAT(DATE_ADD(#{end},INTERVAL -1 DAY),'%Y-%m-%d')</if>
|
||||
<if test="end!=null">and s.date < #{end}</if>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="channel!=null">and s.channel = #{channel}</if>
|
||||
<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>
|
||||
<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>
|
||||
</select>
|
||||
|
||||
<select id="countTotalOldCustomers" resultType="java.lang.Integer">
|
||||
SELECT ifnull(sum(s.old_customers),0) old_customers
|
||||
FROM statistics_customer_order s
|
||||
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
||||
<where>
|
||||
s.client_id != 0
|
||||
<if test="begin!=null">and s.date >= DATE_FORMAT(DATE_ADD(#{end},INTERVAL -1 DAY),'%Y-%m-%d')</if>
|
||||
<if test="end!=null">and s.date < #{end}</if>
|
||||
<if test="client_ids!=null">
|
||||
AND s.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and s.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="channel!=null">and s.channel = #{channel}</if>
|
||||
<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>
|
||||
<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>
|
||||
</select>
|
||||
</mapper>
|
Binary file not shown.
@ -0,0 +1,105 @@
|
||||
<?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="au.com.royalpay.payment.manage.analysis.mappers.EstimateAnalysisMapper">
|
||||
<select id="findLastCleanDays" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT MIN(calen.datelist) date_str
|
||||
FROM ( SELECT c.datelist
|
||||
FROM calendar c
|
||||
WHERE c.clearing_day = 1
|
||||
AND c.datelist< #{date}
|
||||
ORDER BY datelist DESC
|
||||
LIMIT #{num}
|
||||
) calen
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="findMaxCleanDays" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT c.datelist date_str
|
||||
FROM calendar c
|
||||
WHERE c.clearing_day = 1
|
||||
AND c.datelist<= #{date}
|
||||
ORDER BY datelist DESC
|
||||
LIMIT 1
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="checkDayIsCleanDay" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT *
|
||||
FROM calendar c
|
||||
WHERE c.clearing_day = 1
|
||||
AND c.datelist = #{date}
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="findAllTransactionByDate" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT SUM(IF(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) AS total_amount
|
||||
FROM pmt_transactions t
|
||||
<where>
|
||||
<if test="client_list!=null">
|
||||
t.client_id IN
|
||||
<foreach collection="client_list" item="client_id" open="(" close=")" separator=",">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
AND t.transaction_time >= #{start}
|
||||
AND #{end} >= t.transaction_time
|
||||
AND t.channel!='Settlement'
|
||||
</where>
|
||||
</select>
|
||||
<select id="findClearAmountByDate" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT sum(t.clearing_amount) AS total_amount
|
||||
FROM log_clearing_detail t
|
||||
<where>
|
||||
<if test="client_list!=null">
|
||||
t.client_id IN
|
||||
<foreach collection="client_list" item="client_id" open="(" close=")" separator=",">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
AND t.report_date = #{report_date}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="findByLogDate" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT * FROM log_clearing_estimate WHERE log_date = #{date} and log_type = #{log_type}
|
||||
</select>
|
||||
|
||||
<select id="getCleanAmount" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT sum(one_clean_amount) one_clean,
|
||||
sum(two_clean_amount) two_clean,
|
||||
sum(three_clean_amount) three_clean
|
||||
FROM log_clearing_estimate
|
||||
WHERE log_date >= #{start_date}
|
||||
<where>
|
||||
<if test="end_date!=null">
|
||||
#{end_date} >= log_date
|
||||
</if>
|
||||
AND log_type = 1
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="listEstimateLog" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT DATE_FORMAT(log_date, '%Y-%m-%d') log_date,one_clean_amount,two_clean_amount,three_clean_amount,
|
||||
( IFNULL(one_clean_amount,0) + IFNULL(two_clean_amount,0) +IFNULL(three_clean_amount,0)) total_amount
|
||||
FROM log_clearing_estimate
|
||||
WHERE log_type = #{log_type}
|
||||
ORDER BY log_date DESC
|
||||
</select>
|
||||
|
||||
<select id="findCleanLogsByDate" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT DATE_FORMAT(log_date, '%Y-%m-%d') log_date,one_clean_amount,two_clean_amount,three_clean_amount
|
||||
FROM log_clearing_estimate
|
||||
WHERE log_date >= #{start_date}
|
||||
and #{end_date} >= log_date
|
||||
and log_type = 1
|
||||
order by log_date desc
|
||||
</select>
|
||||
<select id="checkIsClearDay" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT 1 FROM calendar
|
||||
where datelist = #{datelist}
|
||||
AND clearing_day = 1
|
||||
</select>
|
||||
</mapper>
|
Binary file not shown.
@ -0,0 +1,256 @@
|
||||
<?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="au.com.royalpay.payment.manage.analysis.mappers.OrderAnalysisMapper">
|
||||
<resultMap id="successRateInTypes" type="com.alibaba.fastjson.JSONObject">
|
||||
<id column="gateway" property="gateway"/>
|
||||
<result column="label" property="label"/>
|
||||
<collection property="dates" ofType="com.alibaba.fastjson.JSONObject" javaType="arraylist">
|
||||
<id property="date" column="date"/>
|
||||
<result property="total" column="total"/>
|
||||
<result property="failed" column="failed"/>
|
||||
<result property="success" column="success"/>
|
||||
<result property="percentage" column="percentage"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
<select id="analysisOrderSuccessRateInTypes" resultMap="successRateInTypes">
|
||||
<![CDATA[
|
||||
|
||||
SELECT
|
||||
t.*,
|
||||
format(t.success / t.total * 100, 2) percentage
|
||||
FROM (
|
||||
SELECT
|
||||
gateway,
|
||||
(CASE gateway
|
||||
WHEN 0
|
||||
THEN 'Retail-In-Store(Scan)'
|
||||
WHEN 1
|
||||
THEN 'Retail-In-Store(QRCode)'
|
||||
WHEN 2
|
||||
THEN '商户二维码(JsApi)'
|
||||
WHEN 3
|
||||
THEN 'Gateway QR Code'
|
||||
WHEN 4
|
||||
THEN 'Gateway JsApi'
|
||||
WHEN 5
|
||||
THEN 'Gateway Retail Api(Scan)'
|
||||
WHEN 6
|
||||
THEN 'Gateway Retail Api(QRCode)'
|
||||
WHEN 7
|
||||
THEN '商户二维码(QRCode)'
|
||||
END) label,
|
||||
date_format(create_time, '%Y-%m-%d') date,
|
||||
count(order_id) total,
|
||||
sum(if(o.status < 5, 1, 0)) failed,
|
||||
sum(if(o.status > 4, 1, 0)) success
|
||||
FROM pmt_orders o
|
||||
WHERE date(o.create_time) >= date(#{begin}) AND date(o.create_time) <= date(#{end})
|
||||
AND o.status > 1
|
||||
GROUP BY date(o.create_time), o.gateway
|
||||
) t
|
||||
|
||||
]]>
|
||||
</select>
|
||||
<select id="analysisOrderSuccessRateOfAll" resultMap="successRateInTypes">
|
||||
<![CDATA[
|
||||
|
||||
SELECT
|
||||
t.*,
|
||||
format(t.success / t.total * 100, 2) percentage
|
||||
FROM (
|
||||
SELECT
|
||||
-1 gateway,
|
||||
'All' label,
|
||||
date_format(create_time, '%Y-%m-%d') date,
|
||||
count(order_id) total,
|
||||
sum(if(o.status < 5, 1, 0)) failed,
|
||||
sum(if(o.status > 4, 1, 0)) success
|
||||
FROM pmt_orders o
|
||||
WHERE date(o.create_time) >= date(#{begin}) AND date(o.create_time) <= date(#{end})
|
||||
AND o.status > 1
|
||||
GROUP BY date(o.create_time)
|
||||
) t
|
||||
|
||||
]]>
|
||||
</select>
|
||||
<select id="analysisOrderSuccessRateDetailOfClients" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
|
||||
SELECT
|
||||
t.*,
|
||||
format(t.success / t.total * 100, 2) percentage,
|
||||
if(t.retail_scan_total = 0, '-',
|
||||
format(t.retail_scan_success / t.retail_scan_total * 100, 2)) retail_scan_percentage,
|
||||
if(t.retail_qr_total = 0, '-', format(t.retail_qr_success / t.retail_qr_total * 100, 2))
|
||||
retail_qr_percentage,
|
||||
if(t.qrcode_jsapi_total = 0, '-', format(t.qrcode_jsapi_success / t.qrcode_jsapi_total * 100, 2))
|
||||
qrcode_jsapi_percentage,
|
||||
if(t.qrcode_code_total = 0, '-', format(t.qrcode_code_success / t.qrcode_code_total * 100, 2))
|
||||
qrcode_code_percentage,
|
||||
IF(t.gateway_code_total = 0, '-', FORMAT(t.gateway_code_success / t.gateway_code_total * 100, 2))
|
||||
gateway_code_percentage,
|
||||
if(t.gateway_jsapi_total = 0, '-', FORMAT(t.gateway_jsapi_success / t.gateway_jsapi_total * 100, 2))
|
||||
gateway_jsapi_percentage,
|
||||
if(t.retail_api_scan_total = 0, '-', FORMAT(t.retail_api_scan_success / t.retail_api_scan_total * 100, 2))
|
||||
retail_api_scan_percentage,
|
||||
if(t.retail_api_code_total = 0, '-', FORMAT(t.retail_api_code_success / t.retail_api_code_total * 100, 2))
|
||||
retail_api_code_percentage
|
||||
FROM (SELECT
|
||||
c.client_id,
|
||||
c.client_moniker,
|
||||
c.short_name,
|
||||
COUNT(order_id) total,
|
||||
sum(IF(o.status < 5, 1, 0)) failed,
|
||||
sum(IF(o.status > 4, 1, 0)) success,
|
||||
sum(IF(o.gateway = 0, 1, 0)) retail_scan_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 0, 1, 0)) retail_scan_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 0, 1, 0)) retail_scan_success,
|
||||
sum(IF(o.gateway = 1, 1, 0)) retail_qr_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 1, 1, 0)) retail_qr_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 1, 1, 0)) retail_qr_success,
|
||||
sum(IF(o.gateway = 2, 1, 0)) qrcode_jsapi_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 2, 1, 0)) qrcode_jsapi_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 2, 1, 0)) qrcode_jsapi_success,
|
||||
sum(IF(o.gateway = 3, 1, 0)) gateway_code_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 3, 1, 0)) gateway_code_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 3, 1, 0)) gateway_code_success,
|
||||
sum(IF(o.gateway = 4, 1, 0)) gateway_jsapi_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 4, 1, 0)) gateway_jsapi_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 4, 1, 0)) gateway_jsapi_success,
|
||||
sum(IF(o.gateway = 5, 1, 0)) retail_api_scan_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 5, 1, 0)) retail_api_scan_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 5, 1, 0)) retail_api_scan_success,
|
||||
sum(IF(o.gateway = 6, 1, 0)) retail_api_code_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 6, 1, 0)) retail_api_code_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 6, 1, 0)) retail_api_code_success,
|
||||
sum(IF(o.gateway = 7, 1, 0)) qrcode_code_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 7, 1, 0)) qrcode_code_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 7, 1, 0)) qrcode_code_success,
|
||||
sum(IF(o.gateway = 8, 1, 0)) gateway_h5_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 8, 1, 0)) gateway_h5_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 8, 1, 0)) gateway_h5_success
|
||||
FROM sys_clients c
|
||||
INNER JOIN pmt_orders o
|
||||
ON o.client_id = c.client_id AND o.status > 1 AND DATE(o.create_time) = DATE(#{date})
|
||||
WHERE c.is_valid = 1
|
||||
GROUP BY c.client_id
|
||||
) t
|
||||
ORDER BY t.failed DESC
|
||||
|
||||
]]>
|
||||
</select>
|
||||
<select id="analysisOrderSuccessRateDetailOfGlobal" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
|
||||
SELECT
|
||||
t.*,
|
||||
format(t.success / t.total * 100, 2) percentage,
|
||||
if(t.retail_scan_total = 0, '-', format(t.retail_scan_success / t.retail_scan_total * 100, 2))
|
||||
retail_scan_percentage,
|
||||
if(t.retail_qr_total = 0, '-', format(t.retail_qr_success / t.retail_qr_total * 100, 2))
|
||||
retail_qr_percentage,
|
||||
if(t.qrcode_jsapi_total = 0, '-', format(t.qrcode_jsapi_success / t.qrcode_jsapi_total * 100, 2))
|
||||
qrcode_jsapi_percentage,
|
||||
if(t.qrcode_code_total = 0, '-', format(t.qrcode_code_success / t.qrcode_code_total * 100, 2))
|
||||
qrcode_code_percentage,
|
||||
IF(t.gateway_code_total = 0, '-', FORMAT(t.gateway_code_success / t.gateway_code_total * 100, 2))
|
||||
gateway_code_percentage,
|
||||
if(t.gateway_jsapi_total = 0, '-', FORMAT(t.gateway_jsapi_success / t.gateway_jsapi_total * 100, 2))
|
||||
gateway_jsapi_percentage,
|
||||
if(t.retail_api_scan_total = 0, '-', FORMAT(t.retail_api_scan_success / t.retail_api_scan_total * 100, 2))
|
||||
retail_api_scan_percentage,
|
||||
if(t.retail_api_code_total = 0, '-', FORMAT(t.retail_api_code_success / t.retail_api_code_total * 100, 2))
|
||||
retail_api_code_percentage
|
||||
FROM (SELECT
|
||||
COUNT(order_id) total,
|
||||
sum(IF(o.status < 5, 1, 0)) failed,
|
||||
sum(IF(o.status > 4, 1, 0)) success,
|
||||
sum(IF(o.gateway = 0, 1, 0)) retail_scan_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 0, 1, 0)) retail_scan_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 0, 1, 0)) retail_scan_success,
|
||||
sum(IF(o.gateway = 1, 1, 0)) retail_qr_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 1, 1, 0)) retail_qr_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 1, 1, 0)) retail_qr_success,
|
||||
sum(IF(o.gateway = 2, 1, 0)) qrcode_jsapi_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 2, 1, 0)) qrcode_jsapi_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 2, 1, 0)) qrcode_jsapi_success,
|
||||
sum(IF(o.gateway = 3, 1, 0)) gateway_code_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 3, 1, 0)) gateway_code_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 3, 1, 0)) gateway_code_success,
|
||||
sum(IF(o.gateway = 4, 1, 0)) gateway_jsapi_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 4, 1, 0)) gateway_jsapi_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 4, 1, 0)) gateway_jsapi_success,
|
||||
sum(IF(o.gateway = 5, 1, 0)) retail_api_scan_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 5, 1, 0)) retail_api_scan_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 5, 1, 0)) retail_api_scan_success,
|
||||
sum(IF(o.gateway = 6, 1, 0)) retail_api_code_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 6, 1, 0)) retail_api_code_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 6, 1, 0)) retail_api_code_success,
|
||||
sum(IF(o.gateway = 7, 1, 0)) qrcode_code_total,
|
||||
sum(IF(o.status < 5 AND o.gateway = 7, 1, 0)) qrcode_code_failed,
|
||||
sum(IF(o.status > 4 AND o.gateway = 7, 1, 0)) qrcode_code_success
|
||||
FROM pmt_orders o
|
||||
WHERE o.status > 1 AND DATE(o.create_time) = DATE(#{date})
|
||||
) t
|
||||
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="listCustomersData" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT o.customer_id,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount,
|
||||
COUNT(DISTINCT o.order_id) orders,max(t.clearing_amount) max_order
|
||||
FROM pmt_orders o
|
||||
INNER JOIN pmt_transactions t on t.order_id=o.order_id and t.system_generate=0 and (t.transaction_type='Credit' or t.transaction_type>0)
|
||||
<where>
|
||||
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
||||
<if test="end!=null">and o.create_time < #{end}</if>
|
||||
<if test="openid_type==0">
|
||||
AND o.customer_id LIKE 'o32%' and o.channel='Wechat'
|
||||
</if>
|
||||
<if test="openid_type==1">
|
||||
AND o.customer_id LIKE 'obJ%' and o.channel='Wechat'
|
||||
</if>
|
||||
<if test="openid_type==2">
|
||||
and o.channel='Alipay'
|
||||
</if>
|
||||
<if test="openid_type==3">
|
||||
and o.channel='Bestpay'
|
||||
</if>
|
||||
<if test="customer_id!=null">
|
||||
and o.customer_id=#{customer_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and o.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
</where>
|
||||
GROUP BY o.customer_id
|
||||
</select>
|
||||
|
||||
<select id="listCustomersDataAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT sum(if(t.transaction_type='Credit',t.clearing_amount,0)) total_amount
|
||||
FROM pmt_orders o
|
||||
INNER JOIN pmt_transactions t on t.order_id=o.order_id and t.system_generate=0 and (t.transaction_type='Credit' or t.refund_id is not null)
|
||||
<where>
|
||||
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
||||
<if test="end!=null">and o.create_time < #{end}</if>
|
||||
<if test="openid_type==0">
|
||||
AND customer_id LIKE 'o32%'
|
||||
</if>
|
||||
<if test="openid_type==1">
|
||||
AND customer_id LIKE 'obJ%'
|
||||
</if>
|
||||
<if test="openid_type==2">
|
||||
and o.channel='Alipay'
|
||||
</if>
|
||||
<if test="openid_type==3">
|
||||
and o.channel='Bestpay'
|
||||
</if>
|
||||
<if test="customer_id!=null">
|
||||
and o.customer_id=#{customer_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and o.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
Binary file not shown.
@ -0,0 +1,866 @@
|
||||
<?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="au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper">
|
||||
|
||||
|
||||
<select id="getOneOrder" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT transaction_amount
|
||||
FROM pmt_transactions
|
||||
WHERE order_id = #{order_id}
|
||||
LIMIT 1;
|
||||
</select>
|
||||
|
||||
<select id="getEarliestOrder" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT *
|
||||
FROM pmt_transactions
|
||||
WHERE client_id = #{client_id} AND clearing_amount > 1
|
||||
ORDER BY transaction_time
|
||||
LIMIT 1;
|
||||
</select>
|
||||
|
||||
<select id="getTransactionCommonAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT ifnull(sum(if(t.transaction_type = 'Credit' ,t.clearing_amount,0)), 0) total_amount,
|
||||
ifnull(sum(if(t.transaction_type = 'Credit' and t.refund_id is null,1,0)), 0) total_count,
|
||||
ifnull(sum(if(t.refund_id is not null,if(t.transaction_type = 'Debit',t.clearing_amount,-t.clearing_amount),0)), 0) refund_amount,
|
||||
ifnull(sum(if(t.clearing_status != 1,if(t.transaction_type = 'Credit',t.clearing_amount,-t.clearing_amount),0)), 0) notsettle_amount,
|
||||
ifnull(max(if(t.transaction_type = 'Credit',t.clearing_amount,0)),0) max_order_amount
|
||||
FROM pmt_transactions t
|
||||
]]>
|
||||
<where>
|
||||
t.channel != 'Settlement'
|
||||
<if test="client_id != null">
|
||||
and t.client_id = #{client_id}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="analysisTotalAmount" resultType="java.math.BigDecimal">
|
||||
<![CDATA[
|
||||
SELECT ifnull(sum(if(l.transaction_type = 'Credit',l.clearing_amount,-l.clearing_amount)), 0)
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND
|
||||
o.create_time <= #{end}
|
||||
WHERE (l.transaction_type = 'Credit' or l.refund_id is not null)
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and l.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
</select>
|
||||
|
||||
<select id="analysisTotalCount" resultType="java.lang.Double">
|
||||
<![CDATA[
|
||||
SELECT ifnull(count(DISTINCT l.order_id), 0)
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND
|
||||
o.create_time <= #{end}
|
||||
WHERE l.transaction_type = 'Credit'
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and l.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="analysisRefundAmount" resultType="java.lang.Double">
|
||||
<![CDATA[
|
||||
SELECT ifnull(sum(if(l.transaction_type='Debit',l.clearing_amount,-l.clearing_amount)), 0)
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND
|
||||
o.create_time <= #{end}
|
||||
WHERE l.refund_id is not null
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="analysisNotSettled" resultType="java.lang.Double">
|
||||
<![CDATA[
|
||||
SELECT ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0)
|
||||
FROM pmt_transactions
|
||||
WHERE clearing_status = 0
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and client_id=#{client_id}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="analysisPreAmount" resultType="java.lang.Double">
|
||||
<![CDATA[
|
||||
SELECT ifnull(sum(l.clearing_amount), 0)
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND
|
||||
o.create_time <= #{end}
|
||||
WHERE clearing_status=2
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT
|
||||
o.order_description,
|
||||
o.order_detail,
|
||||
ifnull(sum(ol.clearing_amount), 0) aud_fee,
|
||||
ol.transaction_time pay_time,
|
||||
o.create_time,
|
||||
p.client_moniker,
|
||||
p.short_name
|
||||
FROM pmt_orders o
|
||||
INNER JOIN pmt_transactions ol ON o.order_id = ol.order_id
|
||||
INNER JOIN sys_clients p ON p.client_id = o.client_id and p.is_valid=1
|
||||
WHERE ol.transaction_type = 'Credit' AND o.create_time >= #{begin} AND o.create_time <= #{end}
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and o.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
<![CDATA[
|
||||
GROUP BY o.order_id
|
||||
]]>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getTradeAmountInTypes" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT
|
||||
CASE o.gateway
|
||||
WHEN 0
|
||||
THEN 'Retail In-Store'
|
||||
WHEN 1
|
||||
THEN 'Retail In-Store'
|
||||
WHEN 2
|
||||
THEN 'QR Code'
|
||||
WHEN 3
|
||||
THEN 'Online API'
|
||||
WHEN 4
|
||||
THEN 'WeChat HTML5'
|
||||
WHEN 5
|
||||
THEN 'Retail API'
|
||||
WHEN 6
|
||||
THEN 'Retail API'
|
||||
WHEN 7
|
||||
THEN 'QR Code'
|
||||
WHEN 8
|
||||
THEN 'Mobile H5'
|
||||
WHEN 9
|
||||
THEN 'Third Party Gateway'
|
||||
WHEN 10
|
||||
THEN 'APP'
|
||||
WHEN 11
|
||||
THEN 'Share Code'
|
||||
WHEN 12
|
||||
THEN 'MICROAPP'
|
||||
WHEN 13
|
||||
THEN 'Native QR Code'
|
||||
WHEN 14
|
||||
THEN 'Share Link'
|
||||
END AS gateway_label,
|
||||
ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,0)), 0) aud_fee
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o ON o.order_id = l.order_id
|
||||
WHERE (l.transaction_type = 'Credit' or l.refund_id is not null)
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND l.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and l.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
||||
<if test="end!=null">and o.create_time <= #{end}</if>
|
||||
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and l.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
GROUP BY gateway_label
|
||||
</select>
|
||||
|
||||
<select id="tradeAnalysisInHours" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT h, round(sum(count)/datediff(#{end},#{begin}),1) count, round(sum(aud_fee)/datediff(#{end},#{begin}),2) aud_fee
|
||||
FROM(
|
||||
SELECT HOUR(o.create_time) h, DATE(o.create_time) dt, sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)) count, ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,0)), 0) aud_fee
|
||||
FROM pmt_transactions l
|
||||
inner join pmt_orders o on o.order_id = l.order_id
|
||||
WHERE (l.transaction_type='Credit' or l.refund_id is not null)
|
||||
]]>
|
||||
<if test="begin">and o.create_time >= #{begin}</if>
|
||||
<if test="end">and o.create_time <= #{end}</if>
|
||||
<if test="gateway!=null">
|
||||
and o.gateway in
|
||||
<foreach collection="gateway" separator="," open="(" close=")" item="gate">#{gate}</foreach>
|
||||
</if>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and l.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
<if test="bd_group!=null">and l.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>
|
||||
<![CDATA[
|
||||
GROUP BY HOUR(o.create_time), DATE(o.create_time))t
|
||||
GROUP BY h
|
||||
order by h
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="tradeAnalysisInDays" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT
|
||||
date_format(o.create_time, '%Y-%m-%d') date_str,
|
||||
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount, 0)), 0) aud_fee,
|
||||
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)),0) order_count
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND o.create_time <= #{end}
|
||||
]]>
|
||||
WHERE (l.transaction_type = 'Credit' or l.refund_id is not null)
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and l.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
<![CDATA[
|
||||
GROUP BY date(o.create_time)
|
||||
ORDER BY date(o.create_time)
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="tradeAnalysisInDay" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT
|
||||
date_format(#{begin}, '%Y-%m-%d') date_str,
|
||||
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount,0)), 0) aud_fee,
|
||||
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)),0) order_count
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND o.create_time <= #{end}
|
||||
]]>
|
||||
WHERE (l.transaction_type = 'Credit' or l.refund_id is not null)
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and l.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
</select>
|
||||
<select id="countCustomers" resultType="java.lang.Integer">
|
||||
<![CDATA[
|
||||
SELECT COUNT(*) FROM (SELECT o.customer_id FROM pmt_transactions t
|
||||
INNER JOIN pmt_orders o ON o.order_id = t.order_id
|
||||
]]>
|
||||
<![CDATA[
|
||||
WHERE o.create_time >= #{begin} AND o.create_time < #{end}
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and o.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
<![CDATA[
|
||||
GROUP BY o.customer_id) p
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="countNewCustomers" resultType="java.lang.Integer">
|
||||
<![CDATA[
|
||||
SELECT COUNT(DISTINCT customer_id) FROM (SELECT o.customer_id FROM pmt_transactions t
|
||||
INNER JOIN pmt_orders o ON o.order_id = t.order_id
|
||||
]]>
|
||||
<![CDATA[
|
||||
WHERE o.create_time >= #{begin} AND o.create_time < #{end}
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and t.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and t.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
<if test="channel !=null"> and o.channel = #{channel}</if>
|
||||
<![CDATA[
|
||||
GROUP BY o.customer_id) p
|
||||
where p.customer_id NOT IN (SELECT o.customer_id FROM pmt_transactions t INNER JOIN pmt_orders o ON o.order_id = t.order_id
|
||||
]]>
|
||||
<![CDATA[
|
||||
WHERE o.create_time < #{begin}
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<![CDATA[
|
||||
)
|
||||
]]>
|
||||
</select>
|
||||
<select id="countOldCustomers" resultType="java.lang.Integer">
|
||||
<![CDATA[
|
||||
SELECT COUNT(DISTINCT customer_id) FROM (SELECT o.customer_id FROM pmt_transactions t
|
||||
INNER JOIN pmt_orders o ON o.order_id = t.order_id
|
||||
]]>
|
||||
<![CDATA[
|
||||
WHERE o.create_time >= #{begin} AND o.create_time < #{end}
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and t.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and t.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
<if test="channel !=null"> and o.channel = #{channel}</if>
|
||||
<![CDATA[
|
||||
GROUP BY o.customer_id) p
|
||||
where p.customer_id IN (SELECT o.customer_id FROM pmt_transactions t INNER JOIN pmt_orders o ON o.order_id = t.order_id
|
||||
]]>
|
||||
<![CDATA[
|
||||
WHERE o.create_time < #{begin}
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<![CDATA[
|
||||
)
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="getCountCustomers" resultType="java.lang.Integer">
|
||||
<![CDATA[
|
||||
SELECT count(DISTINCT o.customer_id) FROM pmt_orders o where
|
||||
o.create_time < #{date} and o.status>=5
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="getTradePartnersInTypes" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT
|
||||
CASE o.gateway
|
||||
WHEN 0
|
||||
THEN 'Retail In-Store'
|
||||
WHEN 1
|
||||
THEN 'Retail In-Store'
|
||||
WHEN 2
|
||||
THEN 'QR Code'
|
||||
WHEN 3
|
||||
THEN 'Online API'
|
||||
WHEN 4
|
||||
THEN 'WeChat HTML5'
|
||||
WHEN 5
|
||||
THEN 'Retail API'
|
||||
WHEN 6
|
||||
THEN 'Retail API'
|
||||
WHEN 7
|
||||
THEN 'QR Code'
|
||||
WHEN 8
|
||||
THEN 'Mobile H5'
|
||||
WHEN 9
|
||||
THEN 'Third Party Gateway'
|
||||
WHEN 10
|
||||
THEN 'APP'
|
||||
WHEN 11
|
||||
THEN 'Share Code'
|
||||
WHEN 12
|
||||
THEN 'MICROAPP'
|
||||
WHEN 13
|
||||
THEN 'Native QR Code'
|
||||
WHEN 14
|
||||
THEN 'Share Link'
|
||||
END AS gateway_label,
|
||||
ifnull(COUNT(DISTINCT l.client_id), 0) partner_count
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o ON o.order_id = l.order_id
|
||||
WHERE l.transaction_type = 'Credit'
|
||||
AND o.create_time >= #{begin} AND o.create_time <= #{end}
|
||||
]]>
|
||||
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and l.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
<if test="bd_group!=null">and l.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>
|
||||
GROUP BY gateway_label
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getPartnersByTradeType" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT c.short_name ,ifnull(SUM(if(l.transaction_type = 'Credit',l.clearing_amount,0)), 0) total
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o ON o.order_id = l.order_id
|
||||
left JOIN sys_clients c on c.client_id=o.client_id AND c.is_valid=1
|
||||
WHERE (l.transaction_type = 'Credit' or l.refund_id is not null) AND o.create_time >= #{begin} AND o.create_time <= #{end}
|
||||
]]>
|
||||
<if test="trade_type=='Retail In-Store'">
|
||||
and (o.gateway=0 or o.gateway=1)
|
||||
</if>
|
||||
<if test="trade_type=='QR Code'">
|
||||
and (o.gateway=2 or o.gateway=7)
|
||||
</if>
|
||||
<if test="trade_type=='Online API'">
|
||||
and o.gateway=3
|
||||
</if>
|
||||
<if test="trade_type=='WeChat HTML5'">
|
||||
and o.gateway=4
|
||||
</if>
|
||||
<if test="trade_type=='Retail API'">
|
||||
and (o.gateway=5 or o.gateway=6)
|
||||
</if>
|
||||
<if test="trade_type=='Mobile H5'">
|
||||
and o.gateway=8
|
||||
</if>
|
||||
<if test="trade_type=='Third Party Gateway'">
|
||||
and o.gateway=9
|
||||
</if>
|
||||
<if test="trade_type=='APP'">
|
||||
and o.gateway=10
|
||||
</if>
|
||||
<if test="trade_type=='Share Code'">
|
||||
and o.gateway=11
|
||||
</if>
|
||||
<if test="trade_type=='MICROAPP'">
|
||||
and o.gateway=12
|
||||
</if>
|
||||
<if test="trade_type=='Native QR Code'">
|
||||
and o.gateway=13
|
||||
</if>
|
||||
<if test="trade_type=='Share Link'">
|
||||
and o.gateway=14
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and l.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
<if test="bd_group!=null">and l.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>
|
||||
GROUP BY l.client_id
|
||||
ORDER BY total desc
|
||||
|
||||
</select>
|
||||
|
||||
<!--<select id="getOrdersByGateway" resultType="com.alibaba.fastjson.JSONObject">-->
|
||||
<!--<![CDATA[-->
|
||||
<!--SELECT o.create_time,l.clearing_amount order_total,c.short_name-->
|
||||
<!--FROM pmt_transactions l-->
|
||||
<!--INNER JOIN pmt_orders o ON o.order_id = l.order_id-->
|
||||
<!--LEFT JOIN sys_clients c ON c.client_id = o.client_id AND c.is_valid=1-->
|
||||
<!--WHERE l.transaction_type = 'Credit' AND o.create_time >= #{begin} AND o.create_time <= #{end}-->
|
||||
<!--]]>-->
|
||||
<!--<if test="trade_type=='Retail In-Store'">-->
|
||||
<!--and (o.gateway=0 or o.gateway=1)-->
|
||||
<!--</if>-->
|
||||
<!--<if test="trade_type=='QR Code'">-->
|
||||
<!--and (o.gateway=2 or o.gateway=7)-->
|
||||
<!--</if>-->
|
||||
<!--<if test="trade_type=='Online API'">-->
|
||||
<!--and o.gateway=3-->
|
||||
<!--</if>-->
|
||||
<!--<if test="trade_type=='WeChat HTML5'">-->
|
||||
<!--and o.gateway=4-->
|
||||
<!--</if>-->
|
||||
<!--<if test="trade_type=='Retail API'">-->
|
||||
<!--and (o.gateway=5 or o.gateway=6)-->
|
||||
<!--</if>-->
|
||||
<!--<if test="org_id!=null">and l.org_id=#{org_id}</if>-->
|
||||
<!--</select>-->
|
||||
|
||||
<select id="getOrdersByGateway" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT po.create_time,
|
||||
ptran.clearing_amount order_total,
|
||||
sysc.short_name
|
||||
FROM pmt_transactions ptran,
|
||||
pmt_orders po,
|
||||
sys_clients sysc
|
||||
WHERE ptran.transaction_type = 'Credit'
|
||||
AND ptran.order_id = po.order_id
|
||||
AND po.client_id = sysc.client_id
|
||||
AND po.create_time >= #{begin}
|
||||
AND po.create_time <= #{end}
|
||||
]]>
|
||||
<if test="trade_type=='Retail In-Store'">
|
||||
and (po.gateway=0 or po.gateway=1)
|
||||
</if>
|
||||
<if test="trade_type=='QR Code'">
|
||||
and (po.gateway=2 or po.gateway=7)
|
||||
</if>
|
||||
<if test="trade_type=='Online API'">
|
||||
and po.gateway=3
|
||||
</if>
|
||||
<if test="trade_type=='WeChat HTML5'">
|
||||
and po.gateway=4
|
||||
</if>
|
||||
<if test="trade_type=='Mobile H5'">
|
||||
and po.gateway=8
|
||||
</if>
|
||||
<if test="trade_type=='Retail API'">
|
||||
and (po.gateway=5 or po.gateway=6)
|
||||
</if>
|
||||
<if test="trade_type=='Third Party Gateway'">
|
||||
and o.gateway=9
|
||||
</if>
|
||||
<if test="trade_type=='APP'">
|
||||
and o.gateway=10
|
||||
</if>
|
||||
<if test="trade_type=='Share Code'">
|
||||
and o.gateway=11
|
||||
</if>
|
||||
<if test="trade_type=='MICROAPP'">
|
||||
and o.gateway=12
|
||||
</if>
|
||||
<if test="trade_type=='Native QR Code'">
|
||||
and o.gateway=13
|
||||
</if>
|
||||
<if test="trade_type=='Share Link'">
|
||||
and o.gateway=14
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and ptran.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and ptran.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
</select>
|
||||
<select id="listExchangeRates" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT max(t.transaction_time) mx,t.exchange_rate,date(t.transaction_time) `date`
|
||||
FROM
|
||||
pmt_transactions t
|
||||
WHERE date(t.transaction_time) >= #{begin} And date(t.transaction_time) <= #{end} AND
|
||||
t.transaction_type ='Credit' AND t.channel =#{channel}
|
||||
GROUP BY
|
||||
date(t.transaction_time)
|
||||
order by `date` asc
|
||||
]]>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getCustomersAndOrdersInDaysUseInScheduled" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT DATE(o.create_time) AS date,
|
||||
COUNT(DISTINCT o.order_id) AS orders,
|
||||
COUNT(DISTINCT o.customer_id) AS customers,
|
||||
o.channel AS channel,
|
||||
ifnull(SUM(if(t.transaction_type = 'Credit', t.clearing_amount, 0)), 0) AS total,
|
||||
ifnull(SUM(if(t.refund_id>0, t.clearing_amount, 0)), 0) AS refund_amount,
|
||||
SUM(if(t.refund_id>0, 1, 0)) AS refund_orders,
|
||||
round(SUM(if(t.transaction_type='Credit',t.clearing_amount,0))/COUNT(DISTINCT o.customer_id),2) single_amount
|
||||
FROM pmt_transactions t
|
||||
INNER JOIN pmt_orders o ON o.order_id = t.order_id
|
||||
]]>
|
||||
WHERE (t.transaction_type = 'Credit' or t.refund_id is not null)
|
||||
<if test="begin!=null">and o.create_time >= #{begin}</if>
|
||||
<if test="end!=null">and o.create_time < #{end}</if>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and o.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
GROUP BY date , channel ORDER BY date DESC
|
||||
</select>
|
||||
|
||||
<select id="getOrgTransactionAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT o.org_id, o.name org_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount
|
||||
FROM pmt_transactions t
|
||||
INNER JOIN pmt_orders ord on ord.order_id = t.order_id
|
||||
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1
|
||||
RIGHT JOIN sys_org o on o.org_id = c.org_id and o.org_id != 1 and o.type=0
|
||||
where (t.transaction_type = 'Credit' or t.refund_id is not null)
|
||||
]]>
|
||||
<if test="begin!=null">and t.transaction_time >= #{begin}</if>
|
||||
<if test="end!=null">and t.transaction_time <= #{end}</if>
|
||||
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and o.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
GROUP BY o.org_id order by amount desc
|
||||
</select>
|
||||
|
||||
<select id="getPartnersAmountByOrg" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT c.client_moniker,c.short_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount
|
||||
FROM pmt_transactions t
|
||||
INNER JOIN pmt_orders ord on ord.order_id = t.order_id
|
||||
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1 AND c.org_id = #{org_id}
|
||||
where (t.transaction_type = 'Credit' or t.refund_id is not null)
|
||||
]]>
|
||||
<if test="begin!=null">and t.transaction_time >= #{begin}</if>
|
||||
<if test="end!=null">and t.transaction_time <= #{end}</if>
|
||||
GROUP BY c.client_id order by amount desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getPlatformAmount" resultType="com.alibaba.fastjson.JSONObject">
|
||||
<![CDATA[
|
||||
SELECT ifnull(sum(if(l.transaction_type = 'Credit',l.clearing_amount,0)), 0) amount,
|
||||
ifnull(count(DISTINCT l.order_id), 0) order_count
|
||||
FROM pmt_transactions l
|
||||
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND
|
||||
o.create_time <= #{end}
|
||||
WHERE (l.transaction_type = 'Credit' or l.refund_id is not null)
|
||||
]]>
|
||||
<if test="client_ids!=null">
|
||||
AND o.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and o.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="channel!=null">and o.channel=#{channel}</if>
|
||||
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and l.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
</select>
|
||||
|
||||
<select id="countAmountRangeAnalysis" resultType="java.lang.Integer">
|
||||
select count(DISTINCT t.order_id) FROM pmt_transactions t
|
||||
INNER JOIN sys_clients c on c.client_id = t.client_id
|
||||
where t.transaction_type = 'Credit' and t.refund_id is null and t.channel != 'Settlement'
|
||||
<if test="begin!=null">and t.transaction_time >= #{begin}</if>
|
||||
<if test="end!=null">and t.transaction_time <= #{end}</if>
|
||||
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
|
||||
<if test="channel!=null">and t.channel=#{channel}</if>
|
||||
<if test="amount_from!=null">and t.clearing_amount >= #{amount_from}</if>
|
||||
<if test="amount_to!=null">and t.clearing_amount < #{amount_to}</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="listAmountRangeOrders" resultType="com.alibaba.fastjson.JSONObject">
|
||||
select c.client_moniker,c.short_name,t.order_id,t.clearing_amount,t.transaction_time,t.channel,o.customer_id,o.customer_ip,o.gateway
|
||||
FROM pmt_transactions t
|
||||
LEFT JOIN pmt_orders o on o.order_id=t.order_id
|
||||
INNER JOIN sys_clients c on c.client_id = t.client_id
|
||||
where t.transaction_type = 'Credit' and t.refund_id is null and t.channel != 'Settlement'
|
||||
<if test="begin!=null">and t.transaction_time >= #{begin}</if>
|
||||
<if test="end!=null">and t.transaction_time <= #{end}</if>
|
||||
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
|
||||
<if test="channel!=null">and t.channel=#{channel}</if>
|
||||
<if test="amount_from!=null">and t.clearing_amount >= #{amount_from}</if>
|
||||
<if test="amount_to!=null">and t.clearing_amount < #{amount_to}</if>
|
||||
</select>
|
||||
|
||||
<!--交易金额分析 饼图 -->
|
||||
<!--不更改-->
|
||||
<select id="getAmountRangeAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
select
|
||||
sum(if(t.clearing_amount >= 0 and t.clearing_amount < 20,1,0)) amount0_20,
|
||||
sum(if(t.clearing_amount >= 20 and t.clearing_amount < 50,1,0)) amount20_50,
|
||||
sum(if(t.clearing_amount >= 50 and t.clearing_amount < 100,1,0)) amount50_100,
|
||||
sum(if(t.clearing_amount >= 100 and t.clearing_amount < 200,1,0)) amount100_200,
|
||||
sum(if(t.clearing_amount >= 200 and t.clearing_amount < 500,1,0)) amount200_500,
|
||||
sum(if(t.clearing_amount >= 500 and t.clearing_amount < 1000,1,0)) amount500_1000,
|
||||
sum(if(t.clearing_amount >= 1000 and t.clearing_amount < 2000,1,0)) amount1000_2000,
|
||||
sum(if(t.clearing_amount >= 2000 and t.clearing_amount < 3000,1,0)) amount2000_3000,
|
||||
sum(if(t.clearing_amount >= 3000 and t.clearing_amount < 5000,1,0)) amount3000_5000,
|
||||
sum(if(t.clearing_amount >= 5000,1,0)) amount5000
|
||||
FROM pmt_transactions t
|
||||
INNER JOIN sys_clients c on c.client_id = t.client_id
|
||||
where t.transaction_type = 'Credit' and t.refund_id is null and t.channel != 'Settlement'
|
||||
<if test="begin!=null">and t.transaction_time >= #{begin}</if>
|
||||
<if test="end!=null">and t.transaction_time <= #{end}</if>
|
||||
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
|
||||
<if test="channel!=null">and t.channel=#{channel}</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getClientTransaction" resultType="com.alibaba.fastjson.JSONObject">
|
||||
select
|
||||
IFNULL(sum(if(l.transaction_type='credit',l.clearing_amount,0)),0) trade_amount,
|
||||
ifnull(sum(if(l.refund_id>0,l.clearing_amount,0)),0) refund_amount,
|
||||
ifnull(sum(if(l.transaction_type='Credit',1,0)),0) trade_count,
|
||||
ifnull(sum(if(l.refund_id>0,1,0)),0) refund_orders
|
||||
FROM pmt_transactions l
|
||||
where l.channel!='Settlement' and l.system_generate=0
|
||||
<if test="client_ids!=null">
|
||||
AND l.client_id IN
|
||||
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
||||
#{client_id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="client_ids==null and client_id != null">
|
||||
and l.client_id=#{client_id}
|
||||
</if>
|
||||
<if test="begin!=null">and l.transaction_time >= #{begin}</if>
|
||||
<if test="end!=null">and l.transaction_time < #{end}</if>
|
||||
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
||||
<if test="org_ids!=null">and l.org_id in
|
||||
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getAreaMerchantAmountAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT c.client_moniker,c.short_name,c.bd_user_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) total,
|
||||
COUNT(DISTINCT t.order_id) orders,
|
||||
c.suburb,c.state,c.royalpayindustry,sum(if(t.channel='Alipay' OR t.channel='AlipayOnline',t.clearing_amount,0)) alipay_total,
|
||||
sum(if(t.channel='Alipay'OR t.channel='AlipayOnline',1,0)) alipay_order,sum(if(t.channel='Wechat',t.clearing_amount,0)) wechat_toatl,
|
||||
sum(if(t.channel='Wechat',1,0)) wechat_order
|
||||
FROM pmt_transactions t
|
||||
INNER JOIN pmt_orders ord on ord.order_id = t.order_id
|
||||
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1
|
||||
<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)<= #{begin} and (d.end_date is null or date(d.end_date)>= #{end}) and
|
||||
d.is_valid=1
|
||||
</if>
|
||||
where (t.transaction_type = 'Credit')
|
||||
<if test="begin!=null">and t.transaction_time >= #{begin}</if>
|
||||
<if test="end!=null">and t.transaction_time <= #{end}</if>
|
||||
<if test="state!=null">and c.state <= #{state}</if>
|
||||
<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>
|
||||
<if test="client_monikers!=null">
|
||||
AND c.client_moniker IN
|
||||
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
|
||||
#{client_moniker}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY c.client_id order by total desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getAreaMerchantAmountByCycle" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT c.client_moniker,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) old_total,
|
||||
sum(if(t.channel='Alipay'OR t.channel='AlipayOnline',t.clearing_amount,0)) old_alipay_total,
|
||||
sum(if(t.channel='Wechat',t.clearing_amount,0)) old_wechat_toatl
|
||||
FROM pmt_transactions t
|
||||
INNER JOIN pmt_orders ord on ord.order_id = t.order_id
|
||||
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1
|
||||
<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_ADD(#{begin},INTERVAL -datediff( #{end},#{begin}) DAY) and (d.end_date is null or date(d.end_date)>= #{begin}) and
|
||||
d.is_valid=1
|
||||
</if>
|
||||
where (t.transaction_type = 'Credit')
|
||||
<if test="begin!=null">and t.transaction_time >= DATE_ADD(#{begin},INTERVAL -datediff( #{end},#{begin}) DAY)</if>
|
||||
<if test="end!=null">and t.transaction_time <= #{begin}</if>
|
||||
<if test="state!=null">and c.state <= #{state}</if>
|
||||
<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>
|
||||
<if test="client_monikers!=null">
|
||||
AND c.client_moniker IN
|
||||
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
|
||||
#{client_moniker}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY c.client_id order by old_total desc
|
||||
</select>
|
||||
</mapper>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue