Merge remote-tracking branch 'origin/transaction-up'

master
eason.qian 7 years ago
commit 16282c0cab

@ -231,3 +231,7 @@ CREATE TABLE `sys_wx_merchant_apply` (
`operator` varchar(50) DEFAULT NULL, `operator` varchar(50) DEFAULT NULL,
PRIMARY KEY (`merchant_app_id`) PRIMARY KEY (`merchant_app_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
alter table statistics_customer_order add column refund_orders int(10) DEFAULT NULL COMMENT '' AFTER `orders`;
alter table statistics_customer_order add column refund_amount DECIMAL(20,2) DEFAULT NULL COMMENT '' AFTER `total`;

@ -53,12 +53,10 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
@Override @Override
public JSONObject getCommonAnalysis1(JSONObject params) { public JSONObject getCommonAnalysis1(JSONObject params) {
JSONObject res = new JSONObject(); JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
res.put("new_partners", clientAnalysisMapper.countNewClients(params)); res.put("new_partners", clientAnalysisMapper.countNewClients(params));
res.put("total_partners", clientAnalysisMapper.countClients(params)); res.put("total_partners", clientAnalysisMapper.countClients(params));
res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params)); res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
// List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc"))); // List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc")));
// if (!topOrders.isEmpty()) { // if (!topOrders.isEmpty()) {
// res.put("top_amount_order", topOrders.get(0)); // res.put("top_amount_order", topOrders.get(0));
@ -75,7 +73,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
// res.put("total_partners", clientAnalysisMapper.countClients(params)); // res.put("total_partners", clientAnalysisMapper.countClients(params));
// res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params)); // res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); // res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); // res.put("trade_count", transactionAnalysisMapper.getClientTransaction(params).getIntValue("trade_count"));
List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc"))); List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc")));
if (!topOrders.isEmpty()) { if (!topOrders.isEmpty()) {
res.put("top_amount_order", topOrders.get(0)); res.put("top_amount_order", topOrders.get(0));
@ -212,7 +210,10 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
@Override @Override
public List<JSONObject> getTradeAnalysisInDays(JSONObject params) { public List<JSONObject> getTradeAnalysisInDays(JSONObject params) {
return transactionAnalysisMapper.tradeAnalysisInDays(params); if (!params.containsKey("client_ids") && !params.containsKey("org_id")) {
params.put("client_id", 0);
}
return customerAndOrdersStatisticsMapper.getSumCustomersAnalysis(params);
} }
@Override @Override
@ -227,9 +228,10 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
} }
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
params.put("client_id", partner.getIntValue("client_id")); params.put("client_id", partner.getIntValue("client_id"));
res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); JSONObject object = transactionAnalysisMapper.getClientTransaction(params);
res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); res.put("trade_amount", object.getBigDecimal("trade_amount"));
res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params)); res.put("trade_count", object.getIntValue("trade_count"));
res.put("refund_amount", object.getBigDecimal("refund_amount"));
res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params)); res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params));
res.put("pre_amount", transactionAnalysisMapper.analysisPreAmount(params)); res.put("pre_amount", transactionAnalysisMapper.analysisPreAmount(params));
List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc"))); List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc")));

@ -71,4 +71,5 @@ public interface TransactionAnalysisMapper {
int getCountCustomers(@Param("date") Date date); int getCountCustomers(@Param("date") Date date);
JSONObject getClientTransaction(JSONObject params);
} }

@ -24,6 +24,8 @@ public interface RetailAppService {
JSONObject listOrders(JSONObject device, AppQueryBean query); JSONObject listOrders(JSONObject device, AppQueryBean query);
JSONObject listOrdersNew(JSONObject device, AppQueryBean query);
JSONObject listOrdersShareCode(JSONObject device, AppQueryBean query); JSONObject listOrdersShareCode(JSONObject device, AppQueryBean query);
void updateDevToken(JSONObject device, String devToken); void updateDevToken(JSONObject device, String devToken);

@ -173,10 +173,10 @@ public class RetailAppServiceImp implements RetailAppService {
} }
JSONObject params = appQueryBean.toParams(); JSONObject params = appQueryBean.toParams();
setAllClientIds(params, client_id); setAllClientIds(params, client_id);
JSONObject res = new JSONObject();
params.put("client_id", client_id); params.put("client_id", client_id);
res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); // res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
// res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params)); // res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params));
res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params)); res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params));
res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params)); res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params));
@ -199,10 +199,11 @@ public class RetailAppServiceImp implements RetailAppService {
} }
JSONObject params = appQueryBean.toParams(); JSONObject params = appQueryBean.toParams();
setAllClientIds(params, client_id); setAllClientIds(params, client_id);
JSONObject res = new JSONObject();
params.put("client_id", client_id); params.put("client_id", client_id);
res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params)); res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params));
return res; return res;
} }
@ -356,6 +357,7 @@ public class RetailAppServiceImp implements RetailAppService {
params.put("dev_id", device.getString("dev_id")); params.put("dev_id", device.getString("dev_id"));
} }
params.put("client_id", client_id); params.put("client_id", client_id);
PageList<JSONObject> orders = orderMapper.listOrdersByClients(params, PageList<JSONObject> orders = orderMapper.listOrdersByClients(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc"))); new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc")));
TimeZoneUtils.switchTimeZone(orders, query.getTimezone(), "create_time", "transaction_time", "confirm_time"); TimeZoneUtils.switchTimeZone(orders, query.getTimezone(), "create_time", "transaction_time", "confirm_time");
@ -387,6 +389,70 @@ public class RetailAppServiceImp implements RetailAppService {
return PageListUtils.buildPageListResult(orders); return PageListUtils.buildPageListResult(orders);
} }
@Override
public JSONObject listOrdersNew(JSONObject device, AppQueryBean query) {
String clientType = device.getString("client_type");
DeviceRegister register = deviceSupport.findRegister(clientType);
int client_id = device.getIntValue("client_id");
JSONObject client = clientManager.getClientInfo(client_id);
String timezone = client.getString("timezone");
if (timezone != null && !timezone.isEmpty()) {
query.setTimezone(timezone);
}
JSONObject params = query.toParams();
setAllClientIds(params, client_id);
if (register.includeDevId()) {
params.put("dev_id", device.getString("dev_id"));
}
params.put("client_id", client_id);
PageList<JSONObject> orders = orderMapper.listTransactionsForApp(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc")));
TimeZoneUtils.switchTimeZone(orders, query.getTimezone(), "create_time", "transaction_time", "confirm_time");
ArrayList<String> date_contains = new ArrayList<>();
for (JSONObject order : orders) {
String customer_id = order.getString("customer_id");
if (StringUtils.isEmpty(customer_id)) {
continue;
}
switch (order.getString("channel")) {
case "Alipay":
JSONObject alipayUser = customerRelationAlipayMapper.findCustomerByUserId(customer_id);
order.put("nickname", alipayUser.getString("nickname"));
order.put("headimg", alipayUser.getString("headimg"));
break;
case "Wechat":
JSONObject weUser = customerMapper.findCustomerByOpenId(customer_id);
order.put("nickname", weUser.getString("nickname"));
order.put("headimg", weUser.getString("headimg"));
break;
default:
break;
}
Calendar calendar = (Calendar) order.get("create_time");
String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd");
String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss");
order.put("trade_date", trade_date);
order.put("trade_time", trade_time);
if (!date_contains.contains(trade_date)) {
String re_date = trade_date.replaceAll("-", "");
TradeLogQuery date_query = new TradeLogQuery();
date_query.setDatefrom(re_date);
date_query.setDateto(re_date);
// date_query.setStatus(OrderStatus.ALL);
if (params.containsKey("client_ids")) {
date_query.setClient_ids((String[]) params.get("client_ids"));
}
JSONObject date_params = date_query.toParams(query.getTimezone());
date_params.put("client_id", device.getIntValue("client_id"));
JSONObject analysis = orderMapper.analysisOrders(date_params);
order.put("date_total", analysis);
date_contains.add(trade_date);
}
}
return PageListUtils.buildPageListResult(orders);
}
@Override @Override
public JSONObject listOrdersShareCode(JSONObject device, AppQueryBean query) { public JSONObject listOrdersShareCode(JSONObject device, AppQueryBean query) {
query.setGateway_app("11"); query.setGateway_app("11");

@ -87,6 +87,11 @@ public class RetailAppController {
return retailAppService.listOrders(device, query); return retailAppService.listOrders(device, query);
} }
@RequestMapping(value = "/orders_new", method = RequestMethod.GET)
public JSONObject listOrdersNew(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean query) {
return retailAppService.listOrdersNew(device, query);
}
@RequestMapping(value = "/orders/share_code", method = RequestMethod.GET) @RequestMapping(value = "/orders/share_code", method = RequestMethod.GET)
public JSONObject listOrdersShareCode(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean query) { public JSONObject listOrdersShareCode(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean query) {
return retailAppService.listOrdersShareCode(device, query); return retailAppService.listOrdersShareCode(device, query);

@ -77,4 +77,6 @@ public interface OrderMapper {
List<JSONObject> listOrdersByClientsNoPages(JSONObject params); List<JSONObject> listOrdersByClientsNoPages(JSONObject params);
List<JSONObject> listAnalysisClientCustomer(JSONObject params); List<JSONObject> listAnalysisClientCustomer(JSONObject params);
PageList<JSONObject> listTransactionsForApp(JSONObject params, PageBounds pageBounds);
} }

@ -87,7 +87,7 @@
<select id="listPartnersTradeAmount" resultType="com.alibaba.fastjson.JSONObject"> <select id="listPartnersTradeAmount" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT SELECT
p.client_moniker,p.short_name,ifnull(sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)),0)aud_fee, 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, 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 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 FROM sys_clients p

@ -39,6 +39,7 @@
<select id="getSumOrdersAndCustomersDaily" resultType="com.alibaba.fastjson.JSONObject"> <select id="getSumOrdersAndCustomersDaily" resultType="com.alibaba.fastjson.JSONObject">
SELECT sum(s.customers) customers,sum(s.orders) orders,sum(s.new_customers) new_customers, 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.old_customers) old_customers,sum(s.total) total, sum(s.total)/sum(s.customers) single_amount,
ifnull(sum(s.refund_amount),0) refund_amount,ifnull(sum(s.refund_orders),0) refund_orders,
date_format(s.date,'%d/%m/%Y') trade_date date_format(s.date,'%d/%m/%Y') trade_date
FROM statistics_customer_order s FROM statistics_customer_order s
<where> <where>
@ -175,9 +176,8 @@
</where> </where>
</select>--> </select>-->
<select id="getSumCustomersChannelAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="getSumCustomersChannelAnalysis" resultType="com.alibaba.fastjson.JSONObject">
SELECT SUM(IF(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) AS total_amount SELECT SUM(IF(t.transaction_type = 'Credit', t.clearing_amount,0)) AS total_amount
FROM pmt_transactions t FROM pmt_transactions t
<where> <where>
t.transaction_time >= #{begin} t.transaction_time >= #{begin}

@ -197,8 +197,8 @@
</select> </select>
<select id="listCustomersData" resultType="com.alibaba.fastjson.JSONObject"> <select id="listCustomersData" resultType="com.alibaba.fastjson.JSONObject">
SELECT o.customer_id,sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)) amount, SELECT o.customer_id,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount,
sum(if(t.transaction_type='Credit',t.clearing_amount div 10,-(t.clearing_amount div 10))) points, sum(if(t.transaction_type='Credit',t.clearing_amount div 10,0)) points,
COUNT(DISTINCT o.order_id) orders,max(t.clearing_amount) max_order COUNT(DISTINCT o.order_id) orders,max(t.clearing_amount) max_order
FROM pmt_orders o 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) 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)
@ -228,8 +228,8 @@
</select> </select>
<select id="listCustomersDataAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="listCustomersDataAnalysis" resultType="com.alibaba.fastjson.JSONObject">
SELECT sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)) total_amount, SELECT sum(if(t.transaction_type='Credit',t.clearing_amount,0)) total_amount,
sum(if(t.transaction_type='Credit',t.clearing_amount div 10,-(t.clearing_amount div 10))) total_points sum(if(t.transaction_type='Credit',t.clearing_amount div 10,0)) total_points
FROM pmt_orders o 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) 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> <where>

@ -20,7 +20,7 @@
<select id="getTransactionCommonAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="getTransactionCommonAnalysis" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT ifnull(sum(if(t.transaction_type = 'Credit',t.clearing_amount,-t.clearing_amount)), 0) total_amount, 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.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.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(sum(if(t.clearing_status != 1,if(t.transaction_type = 'Credit',t.clearing_amount,-t.clearing_amount),0)), 0) notsettle_amount,
@ -99,7 +99,6 @@
</if> </if>
</select> </select>
<select id="analysisNotSettled" resultType="java.lang.Double"> <select id="analysisNotSettled" resultType="java.lang.Double">
<![CDATA[ <![CDATA[
SELECT ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0) SELECT ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0)
@ -136,7 +135,6 @@
</if> </if>
</select> </select>
<select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject"> <select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT SELECT
@ -169,6 +167,7 @@
]]> ]]>
</select> </select>
<select id="getTradeAmountInTypes" resultType="com.alibaba.fastjson.JSONObject"> <select id="getTradeAmountInTypes" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT SELECT
@ -198,7 +197,7 @@
WHEN 11 WHEN 11
THEN 'Share Code' THEN 'Share Code'
END AS gateway_label, END AS gateway_label,
ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,-l.clearing_amount)), 0) aud_fee ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,0)), 0) aud_fee
FROM pmt_transactions l FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id INNER JOIN pmt_orders o ON o.order_id = l.order_id
WHERE (l.transaction_type = 'Credit' or l.refund_id is not null) WHERE (l.transaction_type = 'Credit' or l.refund_id is not null)
@ -211,11 +210,12 @@
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
GROUP BY gateway_label GROUP BY gateway_label
</select> </select>
<select id="tradeAnalysisInHours" resultType="com.alibaba.fastjson.JSONObject"> <select id="tradeAnalysisInHours" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT h, round(sum(count)/datediff(#{end},#{begin}),1) count, round(sum(aud_fee)/datediff(#{end},#{begin}),2) aud_fee SELECT h, round(sum(count)/datediff(#{end},#{begin}),1) count, round(sum(aud_fee)/datediff(#{end},#{begin}),2) aud_fee
FROM( 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,-l.clearing_amount)), 0) aud_fee 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 FROM pmt_transactions l
inner join pmt_orders o on o.order_id = l.order_id inner join pmt_orders o on o.order_id = l.order_id
WHERE (l.transaction_type='Credit' or l.refund_id is not null) WHERE (l.transaction_type='Credit' or l.refund_id is not null)
@ -252,11 +252,12 @@
order by h order by h
]]> ]]>
</select> </select>
<select id="tradeAnalysisInDays" resultType="com.alibaba.fastjson.JSONObject"> <select id="tradeAnalysisInDays" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT SELECT
date_format(o.create_time, '%Y-%m-%d') date_str, date_format(o.create_time, '%Y-%m-%d') date_str,
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount, -l.clearing_amount)), 0) aud_fee, 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 ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)),0) order_count
FROM pmt_transactions l 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} INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND o.create_time <= #{end}
@ -279,11 +280,12 @@
ORDER BY date(o.create_time) ORDER BY date(o.create_time)
]]> ]]>
</select> </select>
<select id="tradeAnalysisInDay" resultType="com.alibaba.fastjson.JSONObject"> <select id="tradeAnalysisInDay" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT SELECT
date_format(#{end}, '%Y-%m-%d') date_str, date_format(#{end}, '%Y-%m-%d') date_str,
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount, -l.clearing_amount)), 0) aud_fee, 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 ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)),0) order_count
FROM pmt_transactions l 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} INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND o.create_time <= #{end}
@ -466,9 +468,10 @@
GROUP BY gateway_label GROUP BY gateway_label
</select> </select>
<select id="getPartnersByTradeType" resultType="com.alibaba.fastjson.JSONObject"> <select id="getPartnersByTradeType" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT c.short_name ,ifnull(SUM(if(l.transaction_type = 'Credit',l.clearing_amount,-l.clearing_amount)), 0) total SELECT c.short_name ,ifnull(SUM(if(l.transaction_type = 'Credit',l.clearing_amount,0)), 0) total
FROM pmt_transactions l FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id 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 left JOIN sys_clients c on c.client_id=o.client_id AND c.is_valid=1
@ -542,6 +545,7 @@
<!--</if>--> <!--</if>-->
<!--<if test="org_id!=null">and l.org_id=#{org_id}</if>--> <!--<if test="org_id!=null">and l.org_id=#{org_id}</if>-->
<!--</select>--> <!--</select>-->
<select id="getOrdersByGateway" resultType="com.alibaba.fastjson.JSONObject"> <select id="getOrdersByGateway" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT po.create_time, SELECT po.create_time,
@ -607,7 +611,9 @@
COUNT(DISTINCT o.order_id) AS orders, COUNT(DISTINCT o.order_id) AS orders,
COUNT(DISTINCT o.customer_id) AS customers, COUNT(DISTINCT o.customer_id) AS customers,
o.channel AS channel, o.channel AS channel,
ifnull(SUM(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)), 0) AS total, 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 round(SUM(if(t.transaction_type='Credit',t.clearing_amount,0))/COUNT(DISTINCT o.customer_id),2) single_amount
FROM pmt_transactions t FROM pmt_transactions t
INNER JOIN pmt_orders o ON o.order_id = t.order_id INNER JOIN pmt_orders o ON o.order_id = t.order_id
@ -629,9 +635,10 @@
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
GROUP BY date , channel ORDER BY date DESC GROUP BY date , channel ORDER BY date DESC
</select> </select>
<select id="getOrgTransactionAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="getOrgTransactionAnalysis" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT o.org_id, o.name org_name,sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)) amount SELECT o.org_id, o.name org_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount
FROM pmt_transactions t FROM pmt_transactions t
INNER JOIN pmt_orders ord on ord.order_id = t.order_id 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_clients c on t.client_id = c.client_id and c.is_valid = 1
@ -645,9 +652,10 @@
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
GROUP BY o.org_id order by amount desc GROUP BY o.org_id order by amount desc
</select> </select>
<select id="getPartnersAmountByOrg" resultType="com.alibaba.fastjson.JSONObject"> <select id="getPartnersAmountByOrg" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT c.client_moniker,c.short_name,sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)) amount SELECT c.client_moniker,c.short_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount
FROM pmt_transactions t FROM pmt_transactions t
INNER JOIN pmt_orders ord on ord.order_id = t.order_id 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} RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1 AND c.org_id = #{org_id}
@ -658,9 +666,10 @@
GROUP BY c.client_id order by amount desc GROUP BY c.client_id order by amount desc
</select> </select>
<select id="getPlatformAmount" resultType="com.alibaba.fastjson.JSONObject"> <select id="getPlatformAmount" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT ifnull(sum(if(l.transaction_type = 'Credit',l.clearing_amount,-l.clearing_amount)), 0) amount, SELECT ifnull(sum(if(l.transaction_type = 'Credit',l.clearing_amount,0)), 0) amount,
ifnull(count(DISTINCT l.order_id), 0) order_count ifnull(count(DISTINCT l.order_id), 0) order_count
FROM pmt_transactions l FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND
@ -709,6 +718,8 @@
<if test="amount_to!=null">and t.clearing_amount &lt; #{amount_to}</if> <if test="amount_to!=null">and t.clearing_amount &lt; #{amount_to}</if>
</select> </select>
<!--交易金额分析 饼图 -->
<!--不更改-->
<select id="getAmountRangeAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="getAmountRangeAnalysis" resultType="com.alibaba.fastjson.JSONObject">
select select
sum(if(t.clearing_amount &gt;= 0 and t.clearing_amount &lt; 20,1,0)) amount0_20, sum(if(t.clearing_amount &gt;= 0 and t.clearing_amount &lt; 20,1,0)) amount0_20,
@ -729,4 +740,29 @@
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if> <if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
<if test="channel!=null">and t.channel=#{channel}</if> <if test="channel!=null">and t.channel=#{channel}</if>
</select> </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,
sum(if(l.transaction_type='Credit',1,0)) trade_count,
sum(if(l.refund_id>0,1,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 &gt;= #{begin}</if>
<if test="end!=null">and l.transaction_time &lt; #{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>
</mapper> </mapper>

@ -95,6 +95,8 @@
<update id="updateRefundAmount"> <update id="updateRefundAmount">
<![CDATA[ <![CDATA[
UPDATE pmt_orders o UPDATE pmt_orders o
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
@ -113,16 +115,23 @@
THEN 7 THEN 7
END END
WHERE o.order_id = #{order_id} WHERE o.order_id = #{order_id}
]]> ]]>
</update> </update>
<update id="updateOrderCreationError"> <update id="updateOrderCreationError">
<![CDATA[ <![CDATA[
UPDATE pmt_orders UPDATE pmt_orders
SET status = #{status}, error_code = #{error_code}, error_message = #{error_message} SET status = #{status}, error_code = #{error_code}, error_message = #{error_message}
WHERE order_id = #{order_id} AND status <= #{status} WHERE order_id = #{order_id} AND status <= #{status}
]]> ]]>
</update> </update>
<select id="listOrders" resultType="com.alibaba.fastjson.JSONObject"> <select id="listOrders" resultType="com.alibaba.fastjson.JSONObject">
<if test="bd_user!=null"> <if test="bd_user!=null">
SELECT temp.* FROM ( SELECT temp.* FROM (
@ -150,7 +159,8 @@
<bind name="name_pattern" value="'%'+search_text+'%'"/> <bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'"> <if test="text_type=='all'">
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id =#{search_text} or o.channel = #{search_text} or t.order_id =#{search_text}) #{name_pattern} or t.system_transaction_id =#{search_text} or o.channel = #{search_text} or
t.order_id =#{search_text})
</if> </if>
<if test="text_type=='client_moniker'"> <if test="text_type=='client_moniker'">
and p.client_moniker=#{search_text} and p.client_moniker=#{search_text}
@ -177,16 +187,20 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and p.org_id=#{org_id}</if> <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 <if test="org_ids!=null">and p.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
<if test="from!=null">and o.create_time &gt;= #{from}</if> <if test="from!=null">and o.create_time &gt;= #{from}</if>
<if test="to!=null">and o.create_time &lt; #{to}</if> <if test="to!=null">and o.create_time &lt; #{to}</if>
<if test="date!=null">and date(o.create_time)=date(#{date})</if> <if test="date!=null">and date(o.create_time)=date(#{date})</if>
<if test="dev_id!=null">and o.dev_id=#{dev_id}</if> <if test="dev_id!=null">and o.dev_id=#{dev_id}</if>
<if test="status!=null"> <if test="status!=null">
and <foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach> and
<foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
</if> </if>
<if test="channel!=null"> <if test="channel!=null">
and <foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}</foreach> and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}
</foreach>
</if> </if>
<if test="bd_group!=null">and p.client_id in <if test="bd_group!=null">and p.client_id in
(SELECT b.client_id FROM sys_client_bd b (SELECT b.client_id FROM sys_client_bd b
@ -263,7 +277,8 @@
<bind name="name_pattern" value="'%'+search_text+'%'"/> <bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'"> <if test="text_type=='all'">
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text} #{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or
t.order_id = #{search_text}
or o.client_order_id = #{search_text}) or o.client_order_id = #{search_text})
</if> </if>
<if test="text_type=='client_moniker'"> <if test="text_type=='client_moniker'">
@ -294,33 +309,42 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and p.org_id=#{org_id}</if> <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 <if test="org_ids!=null">and p.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
<if test="from!=null">and o.create_time &gt;= #{from}</if> <if test="from!=null">and o.create_time &gt;= #{from}</if>
<if test="to!=null">and o.create_time &lt; #{to}</if> <if test="to!=null">and o.create_time &lt; #{to}</if>
<if test="date!=null">and date(o.create_time)=date(#{date})</if> <if test="date!=null">and date(o.create_time)=date(#{date})</if>
<if test="status!=null"> <if test="status!=null">
and <foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach> and
<foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
</if> </if>
<if test="channel!=null"> <if test="channel!=null">
and <foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}</foreach> and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}
</foreach>
</if> </if>
</where> </where>
GROUP BY o.order_id,t.refund_id GROUP BY o.order_id,t.refund_id
</select> </select>
<select id="analysisOrders" resultType="com.alibaba.fastjson.JSONObject"> <select id="analysisOrders" resultType="com.alibaba.fastjson.JSONObject">
select select
count(DISTINCT l.order_id) order_count, count(DISTINCT l.order_id) order_count,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null,l.clearing_amount,0)),0) paid_fee, ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,0)),0) paid_fee,
ifnull(sum(if(l.refund_id is not null,if(l.transaction_type='Debit',-l.clearing_amount,l.clearing_amount),0)),0) ifnull(sum(if(l.refund_id is not null,if(l.transaction_type='Debit',-l.clearing_amount,l.clearing_amount),0)),0)
refund_fee, refund_fee,
ifnull(sum(if(l.refund_id is not null AND l.pre_authorization=1,l.clearing_amount,0)),0) ifnull(sum(if(l.refund_id is not null AND l.pre_authorization=1,l.clearing_amount,0)),0)
pre_refund_fee, pre_refund_fee,
count(DISTINCT l.customer_id) customers, count(DISTINCT l.customer_id) customers,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY',l.display_amount,0)),0) display_amount, ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY',l.display_amount,0)),0)
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY' and l.pre_authorization=1,l.display_amount,0)),0) pre_display_amount, display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY',l.display_amount,0)),0) cny_display_amount, ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY' and
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY' and l.pre_authorization=1,l.display_amount,0)),0) pre_cny_display_amount l.pre_authorization=1,l.display_amount,0)),0) pre_display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY',l.display_amount,0)),0)
cny_display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY' and
l.pre_authorization=1,l.display_amount,0)),0) pre_cny_display_amount
from ( from (
<if test="bd_user!=null"> <if test="bd_user!=null">
SELECT temp.* FROM ( SELECT temp.* FROM (
@ -344,7 +368,8 @@
<bind name="name_pattern" value="'%'+search_text+'%'"/> <bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'"> <if test="text_type=='all'">
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text} #{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or
t.order_id = #{search_text}
or o.client_order_id = #{search_text}) or o.client_order_id = #{search_text})
</if> </if>
<if test="text_type=='client_moniker'"> <if test="text_type=='client_moniker'">
@ -373,7 +398,8 @@
</if> </if>
</if> </if>
<if test="org_ids!=null">and p.org_id in <if test="org_ids!=null">and p.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
<if test="order_id!=null">and o.order_id=#{order_id}</if> <if test="order_id!=null">and o.order_id=#{order_id}</if>
<if test="trade_type!=null">and o.gateway in <if test="trade_type!=null">and o.gateway in
<foreach collection="trade_type" item="gateway" open="(" close=")" separator=",">#{gateway}</foreach> <foreach collection="trade_type" item="gateway" open="(" close=")" separator=",">#{gateway}</foreach>
@ -384,10 +410,13 @@
<if test="date!=null">and date(o.create_time)=date(#{date})</if> <if test="date!=null">and date(o.create_time)=date(#{date})</if>
<if test="dev_id!=null">and o.dev_id=#{dev_id}</if> <if test="dev_id!=null">and o.dev_id=#{dev_id}</if>
<if test="status!=null"> <if test="status!=null">
and <foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach> and
<foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
</if> </if>
<if test="channel!=null"> <if test="channel!=null">
and <foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}</foreach> and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}
</foreach>
</if> </if>
<if test="bd_group!=null">and p.client_id in <if test="bd_group!=null">and p.client_id in
(SELECT b.client_id FROM sys_client_bd b (SELECT b.client_id FROM sys_client_bd b
@ -449,6 +478,8 @@
</select> </select>
<select id="listOrdersWithNoTransactions" resultType="com.alibaba.fastjson.JSONObject"> <select id="listOrdersWithNoTransactions" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT SELECT
o.order_id, o.order_id,
o.channel o.channel
@ -457,6 +488,8 @@
SELECT DISTINCT order_id SELECT DISTINCT order_id
FROM pmt_transactions FROM pmt_transactions
WHERE transaction_type = 'Credit') AND o.status >= 5 AND o.customer_payment_amount > 0 WHERE transaction_type = 'Credit') AND o.status >= 5 AND o.customer_payment_amount > 0
]]> ]]>
</select> </select>
@ -468,6 +501,7 @@
WHERE o.customer_id = #{customer_id} and t.transaction_time &gt;= '2017-11-07' WHERE o.customer_id = #{customer_id} and t.transaction_time &gt;= '2017-11-07'
</select> </select>
<select id="listOrderByCustomer" resultType="com.alibaba.fastjson.JSONObject"> <select id="listOrderByCustomer" resultType="com.alibaba.fastjson.JSONObject">
SELECT o.*,c.short_name,c.client_moniker FROM pmt_orders o SELECT o.*,c.short_name,c.client_moniker FROM pmt_orders o
LEFT JOIN sys_clients c on c.client_id = o.client_id LEFT JOIN sys_clients c on c.client_id = o.client_id
@ -483,7 +517,8 @@
<if test="to!=null">and o.create_time &lt; #{to}</if> <if test="to!=null">and o.create_time &lt; #{to}</if>
<if test="org_id!=null and org_ids==null">and c.org_id=#{org_id}</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 <if test="org_ids!=null">and c.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
</where> </where>
</select> </select>
@ -514,7 +549,8 @@
<bind name="name_pattern" value="'%'+search_text+'%'"/> <bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'"> <if test="text_type=='all'">
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text}) #{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or
t.order_id = #{search_text})
</if> </if>
<if test="text_type=='client_moniker'"> <if test="text_type=='client_moniker'">
and p.client_moniker=#{search_text} and p.client_moniker=#{search_text}
@ -541,15 +577,19 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and p.org_id=#{org_id}</if> <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 <if test="org_ids!=null">and p.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
<if test="from!=null">and o.create_time &gt;= #{from}</if> <if test="from!=null">and o.create_time &gt;= #{from}</if>
<if test="to!=null">and o.create_time &lt; #{to}</if> <if test="to!=null">and o.create_time &lt; #{to}</if>
<if test="date!=null">and date(o.create_time)=date(#{date})</if> <if test="date!=null">and date(o.create_time)=date(#{date})</if>
<if test="status!=null"> <if test="status!=null">
and <foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach> and
<foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
</if> </if>
<if test="channel!=null"> <if test="channel!=null">
and <foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}</foreach> and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}
</foreach>
</if> </if>
</where> </where>
GROUP BY o.order_id,t.refund_id GROUP BY o.order_id,t.refund_id
@ -558,24 +598,24 @@
<select id="listAnalysisClientCustomer" resultType="com.alibaba.fastjson.JSONObject"> <select id="listAnalysisClientCustomer" resultType="com.alibaba.fastjson.JSONObject">
SELECT SELECT
count(*) payment_times , count(*) payment_times ,
sum(customer_payment_amount) total_amount, sum(customer_payment_amount) total_amount,
o.client_id client_id, o.client_id client_id,
o.customer_id customer_id, o.customer_id customer_id,
o.channel channel, o.channel channel,
max( o.confirm_time) confirm_time max( o.confirm_time) confirm_time
from pmt_orders o from pmt_orders o
where o.customer_id is not null and o.channel is not null where o.customer_id is not null and o.channel is not null
and client_id = #{client_id} and client_id = #{client_id}
<if test="confirm_time"> <if test="confirm_time">
and o.confirm_time > #{confirm_time} and o.confirm_time > #{confirm_time}
</if> </if>
<if test="include_success_status!=null"> <if test="include_success_status!=null">
and o.status >#{include_success_status} and o.status >#{include_success_status}
</if> </if>
group by o.customer_id group by o.customer_id
</select> </select>
<select id="listPaid" resultType="com.alibaba.fastjson.JSONObject"> <select id="listPaid" resultType="com.alibaba.fastjson.JSONObject">
SELECT * FROM pmt_orders SELECT * FROM pmt_orders
@ -585,7 +625,63 @@
and client_id = #{client_id} and client_id = #{client_id}
</if> </if>
<if test="channels != null"> <if test="channels != null">
and channel IN <foreach collection="channels" item="channel" open="(" close=")" separator=",">#{channel}</foreach> and channel IN
<foreach collection="channels" item="channel" open="(" close=")" separator=",">#{channel}</foreach>
</if>
</where>
</select>
<select id="listTransactionsForApp" resultType="com.alibaba.fastjson.JSONObject">
select
o.order_id,
o.client_id,
o.display_amount,
o.customer_payment_amount,
o.coupon_payment_amount,
o.currency,
o.create_time,
o.confirm_time,
o.status,
o.gateway,
o.channel,
o.pre_authorization,
o.refund_amount refund_fee,
o.customer_id,
t.clearing_amount,
t.refund_id,
t.transaction_time,
t.transaction_type,
t.transaction_id,
t.exchange_rate,
t.clearing_status,
t.settle_amount
from pmt_orders o
left join pmt_transactions t on t.order_id=o.order_id and t.channel!='Settlement' and t.system_generate=0
<where>
<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="from!=null">and o.create_time &gt;= #{from}</if>
<if test="to!=null">and o.create_time &lt; #{to}</if>
<if test="date!=null">and date(o.create_time)=date(#{date})
</if>
<if test="trade_type!=null">and o.gateway in
<foreach collection="trade_type" item="gateway" open="(" close=")" separator=",">#{gateway}</foreach>
</if>
<if test="status!=null">
and
<foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
</if>
<if test="channel!=null">
and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}
</foreach>
</if> </if>
</where> </where>
</select> </select>

@ -158,6 +158,7 @@
FROM pmt_transactions FROM pmt_transactions
WHERE clearing_status = 0 AND client_id = #{client_id} WHERE clearing_status = 0 AND client_id = #{client_id}
</select> </select>
<select id="getClientAmountAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="getClientAmountAnalysis" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT SELECT
@ -228,6 +229,7 @@
ORDER BY t.transaction_type, t.transaction_time ORDER BY t.transaction_type, t.transaction_time
]]> ]]>
</select> </select>
<select id="listSettlementLog" resultType="com.alibaba.fastjson.JSONObject"> <select id="listSettlementLog" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT t.client_id,DATE(t.transaction_time) clearing_time,SUM(t.clearing_amount) total, SELECT t.client_id,DATE(t.transaction_time) clearing_time,SUM(t.clearing_amount) total,
@ -423,6 +425,7 @@
WHERE t.transaction_type = 'Credit' OR t.refund_id IS NOT NULL WHERE t.transaction_type = 'Credit' OR t.refund_id IS NOT NULL
ORDER BY t.order_id ASC ORDER BY t.order_id ASC
</select> </select>
<select id="listTransactionsForBDPrize" resultType="com.alibaba.fastjson.JSONObject"> <select id="listTransactionsForBDPrize" resultType="com.alibaba.fastjson.JSONObject">
SELECT SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))

@ -128,6 +128,8 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul
$scope.analysis.total_partners = resp.data.total_partners; $scope.analysis.total_partners = resp.data.total_partners;
$scope.analysis.traded_partners = resp.data.traded_partners; $scope.analysis.traded_partners = resp.data.traded_partners;
$scope.analysis.trade_amount = resp.data.trade_amount; $scope.analysis.trade_amount = resp.data.trade_amount;
$scope.analysis.trade_count = resp.data.trade_count;
// $scope.analysis.top_amount_order = resp.data.top_amount_order; // $scope.analysis.top_amount_order = resp.data.top_amount_order;
// $scope.analysis.trade_count = resp.data.trade_count; // $scope.analysis.trade_count = resp.data.trade_count;
// $scope.analysis.total_customers = resp.data.total_customers; // $scope.analysis.total_customers = resp.data.total_customers;
@ -140,7 +142,7 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul
// $scope.analysis.traded_partners = resp.data.traded_partners; // $scope.analysis.traded_partners = resp.data.traded_partners;
// $scope.analysis.trade_amount = resp.data.trade_amount; // $scope.analysis.trade_amount = resp.data.trade_amount;
$scope.analysis.top_amount_order = resp.data.top_amount_order; $scope.analysis.top_amount_order = resp.data.top_amount_order;
$scope.analysis.trade_count = resp.data.trade_count; // $scope.analysis.trade_count = resp.data.trade_count;
$scope.analysis.total_customers = resp.data.total_customers; $scope.analysis.total_customers = resp.data.total_customers;
$scope.analysis.new_customers = resp.data.total_customers - resp.data.old_customers; $scope.analysis.new_customers = resp.data.total_customers - resp.data.old_customers;
$scope.analysis.old_customers = resp.data.old_customers; $scope.analysis.old_customers = resp.data.old_customers;
@ -444,15 +446,21 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul
type: 'category', type: 'category',
boundaryGap: false boundaryGap: false
}, },
key: 'date_str' key: 'trade_date'
}, },
series: [ series: [
{ {
basic: {type: 'line', label: {normal: {show: true}}, showAllSymbols: true}, basic: {type: 'line', label: {normal: {show: true}}, showAllSymbols: true},
column: {key: 'aud_fee'} column: {key: 'total'}
} }
] ]
}; };
params.end = new Date();
var day = new Date();
day.setDate(day.getDate() - 7);
params.begin = day;
params.begin = $filter('date')(params.begin, 'yyyyMMdd');
params.end = $filter('date')(params.end, 'yyyyMMdd');
$http.get('/dashboard/system/fee_analysis', {params: params}).then(function (resp) { $http.get('/dashboard/system/fee_analysis', {params: params}).then(function (resp) {
$scope.analysis.trade_line = chartParser.parse(analysisConfig, resp.data); $scope.analysis.trade_line = chartParser.parse(analysisConfig, resp.data);
}) })

Loading…
Cancel
Save