fix 商户活跃度&&消费者排名sql优化

master
luoyang 6 years ago
parent 68a1942364
commit 05c5d7207a

@ -15,6 +15,8 @@ public interface CustomersAnalysisService {
JSONObject getCustomersRanking(JSONObject params, int page, int limit);
JSONObject getCustomersTotal(JSONObject params);
JSONObject getOrdersByOpenid(JSONObject params, int page, int limit);
void sendPartnerTransactionDaily(Date date);

@ -58,8 +58,8 @@ public class ClientRatesAnalysisServiceImpl implements ClientRatesAnalysisServic
if (ManagerRole.BD_LEADER.hasRole(manager.getIntValue("role"))) {
params.put("bd_group", manager.getString("manager_id"));
}
params.put("begin", beginDate);
params.put("end", endDate);
params.put("begin", DateFormatUtils.format(beginDate,"yyyy-MM-dd"));
params.put("end", DateFormatUtils.format(endDate,"yyyy-MM-dd"));
orgManager.checkOrgIds(manager,params);
JSONObject result = new JSONObject();
List<JSONObject> bdAnalysis = clientRatesAnalysisMapper.analysisRatesForBDUsers(params);

@ -82,6 +82,14 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
return result;
}
@Override
public JSONObject getCustomersTotal(JSONObject params) {
JSONObject result = new JSONObject();
result.put("analysis", orderAnalysisMapper.listCustomersDataAnalysis(params));
result.put("openid_type", params.getIntValue("openid_type"));
return result;
}
@Override
public JSONObject getOrdersByOpenid(JSONObject params, int page, int limit) {
PageList<JSONObject> logs = orderMapper.listOrderByCustomer(params, new PageBounds(page, limit, Order.formString("create_time.desc")));

@ -85,6 +85,17 @@ public class CustomersAnalysisController {
return customersAnalysisService.getCustomersRanking(params,analysis.getPage(),analysis.getLimit());
}
@ManagerMapping(value = "/ranking/{openid_type}/total",role = ManagerRole.RISK_MANAGER)
public JSONObject getCustomersTotal(@PathVariable int openid_type, AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
JSONObject params = analysis.toParams(null);
params.put("openid_type",openid_type);
if (manager.getInteger("org_id") != null) {
params.put("org_id", manager.getIntValue("org_id"));
}
return customersAnalysisService.getCustomersTotal(params);
}
@ManagerMapping(value = "/{customer_id}/orders",role = ManagerRole.DEVELOPER)
public JSONObject getCustomerOrders(@PathVariable String customer_id, TradeLogQuery tradeLogQuery, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
JSONObject params = tradeLogQuery.toParams(null);

@ -30,7 +30,7 @@
INNER JOIN (
SELECT
c.client_id,
SUM(o.orders) orders
NULLIF (SUM(o.orders),0) orders
FROM sys_clients c
LEFT JOIN statistics_customer_order o
ON o.client_id = c.client_id AND o.total > 10
@ -61,13 +61,13 @@
SELECT
c.client_id,
c.org_id,
count(o.order_id) orders
NULLIF (SUM(o.orders),0) 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
LEFT JOIN statistics_customer_order o
ON o.client_id = c.client_id
AND date(o.date) <= date(#{end})
AND date(o.date) >= date(#{begin})
and o.total>10
]]>
<if test="client_ids!=null">
and c.client_id in

@ -78,7 +78,6 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', '
$scope.customer_loading = false;
$scope.customers = resp.data.data;
$scope.customers_type = resp.data.openid_type;
$scope.customers_analysis = resp.data.analysis;
$scope.pagination = resp.data.pagination;
if($scope.customers.length>0){
$scope.order_params.customer_id = $scope.customers[0].customer_id;
@ -89,6 +88,9 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', '
}
});
$http.get('/analysis/customers/ranking/'+$scope.params.openid_type+'/total', {params: params}).then(function (resp) {
$scope.customers_analysis = resp.data.analysis;
});
};
//$scope.listCustomers(1);

Loading…
Cancel
Save