add 用户画像 关系图

master
luoyang 5 years ago
parent b7c3033f1f
commit 5b40aebdc7

@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.2.20</version>
<version>1.2.21</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.analysis.core;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;
@ -24,5 +25,7 @@ public interface CustomersAnalysisService {
void sendPartnerTransactionDaily(Date date);
List<JSONObject> getCustomersAnalysisMonthly(JSONObject params);
JSONObject getUserEcharts(JSONObject params, JSONObject manager);
}

@ -8,29 +8,38 @@ import au.com.royalpay.payment.manage.mappers.log.WechatTemplateMsgSendLogMapper
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerCustomerRelationAlipayMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.maxmind.geoip.LookupService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created by yishuqian on 10/11/2016.
@ -51,6 +60,10 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
private ClientMapper clientMapper;
@Resource
private ClientAccountMapper clientAccountMapper;
@Resource
private CustomerMapper customerMapper;
@Resource
private ManagerCustomerRelationAlipayMapper managerCustomerRelationAlipayMapper;
@Resource
private WechatTemplateMsgSendLogMapper wechatTemplateMsgSendLogMapper;
@ -60,6 +73,8 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
@Resource
private RetailAppService retailAppService;
@Resource
private LookupService lookupService;
@Override
public List<JSONObject> getCustomersAnalysis(JSONObject params) {
@ -95,6 +110,11 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
@Override
public JSONObject getCustomersRanking(JSONObject params, int page, int limit) {
PageList<JSONObject> logs = orderAnalysisMapper.listCustomersData(params, new PageBounds(page, limit, Order.formString("amount.desc")));
if (logs.size() > 0) {
for (JSONObject log : logs) {
generatorUserProfile(log, params);
}
}
JSONObject result = PageListUtils.buildPageListResult(logs);
result.put("analysis", orderAnalysisMapper.listCustomersDataAnalysis(params));
result.put("openid_type", params.getIntValue("openid_type"));
@ -180,7 +200,7 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
}
}
try {
retailAppService.sendTransactionDailyMessage(tradeInfo,client.getIntValue("client_id"));
retailAppService.sendTransactionDailyMessage(tradeInfo, client.getIntValue("client_id"));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
@ -224,6 +244,63 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
//
// }
@Override
public JSONObject getUserEcharts(JSONObject params, JSONObject manager) {
JSONObject graph = new JSONObject();
List<JSONObject> nodes = new ArrayList<>();
List<JSONObject> links = new ArrayList<>();
initUserInfo(nodes, params);
List<JSONObject> clients = orderAnalysisMapper.listClientsByCustomerId(params);
JSONObject total = orderAnalysisMapper.listClientsTotalByCustomerId(params);
int id = 1;
for (JSONObject client : clients) {
BigDecimal clientInTotal = client.getBigDecimal("orders").divide(total.getBigDecimal("orders"), 5, RoundingMode.HALF_UP).multiply(new BigDecimal(300));
BigDecimal orderInTotal = client.getBigDecimal("orders").divide(total.getBigDecimal("orders"), 5, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
BigDecimal amountInTotal = client.getBigDecimal("total_amount").divide(total.getBigDecimal("total_amount"), 5, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
JSONObject node = new JSONObject();
node.put("id", id);
node.put("category", id);
node.put("name", client.getString("client_moniker"));
node.put("label", client.getString("short_name"));
node.put("value", client.getString("short_name"));
node.put("symbolSize", clientInTotal.compareTo(new BigDecimal(10))<0?10:clientInTotal.toPlainString());
if (clientInTotal.compareTo(new BigDecimal(300)) == 0) {
node.put("symbolSize", 100);
}
node.put("ignore", true);
node.put("flag", true);
node.put("draggable", true);
nodes.add(node);
JSONObject totalAmountInfo = getClientAmountInfo(id,"x0", "交易金额", client);
totalAmountInfo.put("label", client.getString("total_amount"));
totalAmountInfo.put("value", client.getBigDecimal("total_amount").setScale(2,RoundingMode.HALF_UP));
totalAmountInfo.put("symbolSize",amountInTotal.compareTo(new BigDecimal(10))<0?10:amountInTotal.toPlainString());
nodes.add(totalAmountInfo);
JSONObject OrdersInfo = getClientAmountInfo(id,"x1", "订单数", client);
OrdersInfo.put("label", client.getString("orders"));
OrdersInfo.put("value", client.getString("orders"));
OrdersInfo.put("symbolSize", orderInTotal.compareTo(new BigDecimal(10))<0?10:orderInTotal.toPlainString());
nodes.add(OrdersInfo);
JSONObject priceInfo = getClientAmountInfo(id,"x2", "客单价", client);
BigDecimal price = client.getBigDecimal("total_amount").divide(client.getBigDecimal("orders"), 2, RoundingMode.HALF_UP);
priceInfo.put("label", price.toPlainString());
priceInfo.put("value", price.toPlainString());
priceInfo.put("symbolSize", price.divide(new BigDecimal(50), 0, RoundingMode.DOWN).compareTo(new BigDecimal(10))<0?5:price.divide(new BigDecimal(50), 0, RoundingMode.DOWN).toPlainString());
nodes.add(priceInfo);
id++;
}
for (JSONObject node : nodes) {
JSONObject link = new JSONObject();
String linkId = node.getString("id");
link.put("source", linkId);
link.put("target", linkId.indexOf("x")>0?linkId.substring(0,linkId.indexOf("x")):0);
links.add(link);
}
graph.put("nodes", nodes);
graph.put("links", links);
return graph;
}
private int setAllClientIds(JSONObject params, int clientId) {
JSONArray client_ids = clientManager.getAllClientIds(clientId);
if (client_ids.size() > 1) {
@ -268,6 +345,89 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
return msg;
}
private void initUserInfo(List<JSONObject> nodes, JSONObject params) {
JSONObject userInfo = new JSONObject();
if (params.getString("customer_id").startsWith("o")) {
userInfo = customerMapper.findCustomerByOpenId(params.getString("customer_id"));
} else {
userInfo = managerCustomerRelationAlipayMapper.findCustomerByUserId(params.getString("customer_id"));
}
JSONObject user = new JSONObject();
user.put("id", 0);
user.put("category", 0);
if (userInfo.size() > 0) {
user.put("name", userInfo.getString("nickname"));
} else {
user.put("name", params.getString("customer_id"));
}
user.put("symbolSize", 80);
user.put("ignore", true);
user.put("flag", true);
user.put("draggable", true);
String imgUrl = StringUtils.isNotBlank(userInfo.getString("headimg")) ? userInfo.getString("headimg") : PlatformEnvironment.getEnv().concatUrl("/static/images/r_logo.svg");
user.put("symbol", "image://" + imgUrl);
nodes.add(user);
}
private JSONObject getClientAmountInfo(int oldId, String newId, String name, JSONObject client) {
JSONObject amountInfo = new JSONObject();
amountInfo.put("ignore", true);
amountInfo.put("flag", true);
amountInfo.put("draggable", true);
amountInfo.put("id", String.valueOf(oldId) + newId);
amountInfo.put("name", name);
return amountInfo;
}
private void generatorUserProfile(JSONObject customer, JSONObject params) {
List<String> topAddress = new ArrayList<>();
String topAmountRange = "None";
String topTimeRange = "None";
params.put("customer_id", customer.getString("customer_id"));
List<JSONObject> mostUseClientsByCustomer = orderAnalysisMapper.mostUseClientsByCustomer(params);
List<JSONObject> mostUseIndustryByCustomer = orderAnalysisMapper.mostUseIndustryByCustomer(params);
List<JSONObject> mostUseAddressByCustomer = orderAnalysisMapper.mostUseAddressByCustomer(params);
for (JSONObject address : mostUseAddressByCustomer) {
String city = lookupService.getLocation(address.getString("customer_ip")).city;
if (topAddress.size() < 3 && !topAddress.contains(city)) {
topAddress.add(city);
}
}
JSONObject mostUseAmountByCustomer = orderAnalysisMapper.mostUseAmountByCustomer(params);
if (mostUseAmountByCustomer != null) {
int amount = mostUseAmountByCustomer.getIntValue("amount_int");
if (amount == 0) {
topAmountRange = "0~100";
}else {
topAmountRange = String.valueOf(amount * 100) + "~" + String.valueOf((amount + 1) * 100);
}
}
JSONObject mostUseTimesByCustomer = orderAnalysisMapper.mostUseTimesByCustomer(params);
if (mostUseTimesByCustomer != null) {
Date orderDate = mostUseTimesByCustomer.getDate("create_time");
Date nextHourDate = DateUtils.addHours(orderDate, 1);
orderDate = DateUtils.setMinutes(orderDate, 0);
nextHourDate = DateUtils.setMinutes(nextHourDate, 0);
topTimeRange = DateFormatUtils.format(orderDate, "HH:mm") + "-" + DateFormatUtils.format(nextHourDate, "HH:mm");
}
customer.put("top_clients", getTopInfo(mostUseClientsByCustomer, "client_moniker"));
customer.put("top_industry", getTopInfo(mostUseIndustryByCustomer, "royalpayindustry"));
customer.put("top_citys", String.join(",", topAddress));
customer.put("amount_range", topAmountRange);
customer.put("hour_range", topTimeRange);
customer.put("price", customer.getBigDecimal("amount").divide(customer.getBigDecimal("orders"), 2, RoundingMode.HALF_UP).toPlainString());
}
private String getTopInfo(List<JSONObject> list, String key) {
if (list != null && list.size() > 0) {
List<String> clients = list.stream().map(e -> e.getString(key)).collect(Collectors.toList());
return String.join(",", clients);
}
return "None";
}
// private TemplateMessage initWxMsg(JSONObject tradeInfo,String short_name,String clientCounts, String openId, String templateId,String path,String color) {
//

@ -22,10 +22,23 @@ public interface OrderAnalysisMapper {
JSONObject analysisOrderSuccessRateDetailOfGlobal(@Param("date") Date date);
@CountRef(".countCustomersData")
PageList<JSONObject> listCustomersData(JSONObject params, PageBounds pageBounds);
int countCustomersData(JSONObject params);
JSONObject listCustomersDataAnalysis(JSONObject params);
List<JSONObject> listClientsByCustomerId(JSONObject params);
JSONObject listClientsTotalByCustomerId(JSONObject params);
List<JSONObject> mostUseClientsByCustomer(JSONObject params);
List<JSONObject> mostUseIndustryByCustomer(JSONObject params);
List<JSONObject> mostUseAddressByCustomer(JSONObject params);
JSONObject mostUseAmountByCustomer(JSONObject params);
JSONObject mostUseTimesByCustomer(JSONObject params);
}

@ -123,5 +123,17 @@ public class CustomersAnalysisController {
return customersAnalysisService.getOrdersByOpenid(params, tradeLogQuery.getPage(), tradeLogQuery.getLimit());
}
@ManagerMapping(value = "/{customer_id}/user_echarts")
@ReadOnlyConnection
public JSONObject getUserEcharts(@PathVariable String customer_id, AnalysisBean analysisBean, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
JSONObject params = analysisBean.toParams(null);
params.put("customer_id", customer_id);
params.put("status", 5);
if (manager.getInteger("org_id") != null) {
params.put("org_id", manager.getIntValue("org_id"));
}
return customersAnalysisService.getUserEcharts(params, manager);
}
}

@ -15,198 +15,210 @@
<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
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
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
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
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 r.nickname,r.headimg,o.customer_id,sum(if(o.status='5',o.customer_payment_amount,0)) amount,
SELECT r.nickname,r.headimg,r.sex,o.customer_id,sum(o.customer_payment_amount) amount,
COUNT(DISTINCT o.order_id) orders,max(o.customer_payment_amount) max_order
FROM pmt_orders o
<if test="openid_type==4">
LEFT JOIN sys_customer_relation r on r.globalpay_openid = o.customer_id
</if>
<if test="openid_type!=4">
<if test="openid_type==2">
LEFT JOIN sys_customer_relation_alipay r on r.alipay_uid = o.customer_id
</if>
<if test="openid_type!=4 and openid_type!=2">
LEFT JOIN sys_customer_relation r on r.wechat_openid = o.customer_id
</if>
<where>
o.status>4
<if test="begin!=null">and o.create_time &gt;= #{begin}</if>
<if test="end!=null">and o.create_time &lt; #{end}</if>
<if test="openid_type==0">
@ -229,11 +241,99 @@
</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>
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
</where>
GROUP BY o.customer_id
</select>
<select id="mostUseClientsByCustomer" resultType="com.alibaba.fastjson.JSONObject">
select o.client_id,c.client_moniker,count(1) as orders from pmt_orders o INNER JOIN sys_clients c on
c.client_id=o.client_id
<where>
o.status>4
<if test="begin!=null">and o.create_time &gt;= #{begin}</if>
<if test="end!=null">and o.create_time &lt; #{end}</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 client_id order by orders desc limit 3;
</select>
<select id="mostUseIndustryByCustomer" resultType="com.alibaba.fastjson.JSONObject">
select o.client_id,c.royalpayindustry,count(1) as orders from pmt_orders o INNER JOIN sys_clients c on
c.client_id=o.client_id
<where>
o.status>4
<if test="begin!=null">and o.create_time &gt;= #{begin}</if>
<if test="end!=null">and o.create_time &lt; #{end}</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 c.royalpayindustry order by orders desc limit 3;
</select>
<select id="mostUseAddressByCustomer" resultType="com.alibaba.fastjson.JSONObject">
select o.customer_ip,count(1) as orders from pmt_orders o
<where>
o.status>4
<if test="begin!=null">and o.create_time &gt;= #{begin}</if>
<if test="end!=null">and o.create_time &lt; #{end}</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 substring_index(o.customer_ip,'.',2) order by orders desc limit 10;
</select>
<select id="mostUseAmountByCustomer" resultType="com.alibaba.fastjson.JSONObject">
SELECT count(1) as orders ,substring_index((o.customer_payment_amount/100),'.',1) as amount_int from pmt_orders o
<where>
o.status>4
<if test="begin!=null">and o.create_time &gt;= #{begin}</if>
<if test="end!=null">and o.create_time &lt; #{end}</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 substring_index((o.customer_payment_amount/100),'.',1) order by orders desc limit 1;
</select>
<select id="mostUseTimesByCustomer" resultType="com.alibaba.fastjson.JSONObject">
SELECT count(1) as orders ,hour(o.create_time),o.create_time from pmt_orders o
<where>
o.status>4
<if test="begin!=null">and o.create_time &gt;= #{begin}</if>
<if test="end!=null">and o.create_time &lt; #{end}</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 hour(o.create_time) order by orders desc limit 1
</select>
<select id="countCustomersData" resultType="int">
SELECT count(distinct o.customer_id)
FROM pmt_orders o
@ -260,7 +360,8 @@
</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>
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
</where>
</select>
@ -290,7 +391,50 @@
</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>
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
</where>
</select>
<select id="listClientsByCustomerId" resultType="com.alibaba.fastjson.JSONObject">
SELECT COUNT(1) as orders,SUM(IF(t.transaction_type='Credit',t.clearing_amount,0))
total_amount,c.client_moniker,c.short_name,o.customer_id,c.royalpayindustry,o.customer_ip
FROM pmt_orders o
INNER JOIN sys_clients c ON o.client_id=c.client_id
INNER JOIN pmt_transactions t ON t.order_id = o.order_id
<where>
o.status>4
<if test="begin!=null">and o.create_time &gt;= #{begin}</if>
<if test="end!=null">and o.create_time &lt; #{end}</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.client_id ORDER BY orders DESC
</select>
<select id="listClientsTotalByCustomerId" resultType="com.alibaba.fastjson.JSONObject">
SELECT COUNT(1) as orders,SUM(IF(t.transaction_type='Credit',t.clearing_amount,0))
total_amount
FROM pmt_orders o
INNER JOIN sys_clients c ON o.client_id=c.client_id
INNER JOIN pmt_transactions t ON t.order_id = o.order_id
<where>
o.status>4
<if test="begin!=null">and o.create_time &gt;= #{begin}</if>
<if test="end!=null">and o.create_time &lt; #{end}</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>

@ -571,7 +571,7 @@
<if test="include_success_status != null">
and o.status>#{include_success_status}
</if>
<if test="from!=null">and ocreate_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="org_id!=null and org_ids==null">and c.org_id=#{org_id}</if>
<if test="org_ids!=null">and c.org_id in

@ -13,6 +13,57 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', '
})
}]);
app.controller('customersListCtrl', ['$scope', '$http','$filter', '$uibModal', 'commonDialog', 'orderService', 'refunder', function ($scope, $http,$filter, $uibModal, commonDialog, orderService, refunder) {
$scope.one_customer = {};
var echartsConfig = function (graph) {
var categories = [];
var c = 0;
for (var i = 0; i < $scope.graph.nodes.length; i++) {
var id = ($scope.graph.nodes[i].id).toString();
if (id.indexOf("x") < 0) {
categories[c] = {
name: $scope.graph.nodes[i].name
};
c++;
}
}
$scope.graph.nodes.forEach(function (node) {
node.itemStyle = null;
// Use random x, y
node.x = node.y = null;
node.draggable = true;
});
return {
tooltip: {},
legend: [{
// selectedMode: 'single',
data: categories.map(function (a) {
return a.name;
})
}],
animation: false,
series : [
{
name: "用户关系图",
type: 'graph',
layout: 'force',
data: graph.nodes,
links: graph.links,
categories: categories,
roam: false,
label: {
show: true
},
focusNodeAdjacency: true,
draggable: false,
symbolRotate:undefined,
force: {
repulsion: 50,
edgeLength: [300, 200]
}
}
]
};
};
$scope.pagination = {};
$scope.params = {};
$scope.params.openid_type = '0';
@ -77,6 +128,8 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', '
$http.get('/analysis/customers/ranking/'+$scope.params.openid_type, {params: params}).then(function (resp) {
$scope.customer_loading = false;
$scope.customers = resp.data.data;
$scope.checkoutCustomer($scope.customers[0]);
$scope.generatorEcharts($scope.customers[0].customer_id);
$scope.customers_type = resp.data.openid_type;
$scope.pagination = resp.data.pagination;
if($scope.customers.length>0){
@ -88,6 +141,18 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', '
}
});
$scope.checkoutCustomer = function (data) {
$scope.one_customer = data;
$scope.one_customer.industry = data.top_industry.split(",");
$scope.one_customer.clients = data.top_clients.split(",");
};
$scope.generatorEcharts = function (customer_id) {
$http.get('/analysis/customers/'+ customer_id + '/user_echarts', {params: params}).then(function (resp) {
$scope.graph = resp.data;
$scope.testobj = echartsConfig($scope.graph);
});
};
$http.get('/analysis/customers/ranking/'+$scope.params.openid_type+'/total', {params: params}).then(function (resp) {
$scope.customers_analysis = resp.data.analysis;
});
@ -135,12 +200,12 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', '
// $scope.order_loading = true;
$scope.listCustomerOrders = function (page) {
$scope.order_loading = true;
var params = angular.copy($scope.order_params) || {};
if (params.datefrom) {
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
var params = angular.copy($scope.params) || {};
if (params.begin) {
params.datefrom = $filter('date')(params.begin, 'yyyyMMdd');
}
if (params.dateto) {
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
if (params.end) {
params.dateto = $filter('date')(params.end, 'yyyyMMdd');
}
params.gateway = [0, 1];
params.page = page || $scope.orderPagination.page || 1;

@ -1,3 +1,22 @@
<style>
.userfile {
width: 300px;
margin-left: 40px;
height: 600px;
display: inline-block;
vertical-align:top
}
.userechart {
width: 70%;
height: 600px;
display: inline-block;
margin-left: 20px;
}
.profile-user-img {
height: 100px;
}
</style>
<section class="content-header">
<h1>Customer Transaction Analysis</h1>
<ol class="breadcrumb">
@ -111,7 +130,7 @@
<tbody>
<tr ng-repeat="customer in customers"
ng-class="{'selectRow':order_params.customer_id==customer.customer_id}"
ng-click="order_params.customer_id=customer.customer_id;listCustomerOrders()">
ng-click="order_params.customer_id=customer.customer_id;listCustomerOrders();checkoutCustomer(customer);generatorEcharts(customer.customer_id)">
<td style="width: 60px" ng-if="customers_type ==0 || customers_type==1">
<span>
<img style="height: 30px;width: 30px" class="img-circle" ng-src="{{customer.headimg||'static/images/royalpay_sign_ln.png'}}" />
@ -162,7 +181,67 @@
</div>
</div>
</div>
<div class="box" ng-if="one_customer">
<div class="box-header">
<h3 class="box-title">用户画像</h3>
</div>
<div class="userfile">
<div class="box box-primary" style="box-shadow:0 1px 20px rgba(0,0,0,0.4)">
<div class="box-body box-profile">
<img ng-if="one_customer.headimg" class="profile-user-img img-responsive img-circle" ng-src="{{one_customer.headimg}}" >
<img ng-if="!one_customer.headimg" class="profile-user-img img-responsive img-circle" src="static/images/r_logo.svg" >
<h3 class="profile-username text-center">{{one_customer.nickname}}</h3>
<p class="text-muted text-center" ng-if="one_customer.sex=='f' || one_customer.sex=='1'">性别:女</p>
<p class="text-muted text-center" ng-if="one_customer.sex=='m' || one_customer.sex=='2'">性别:男</p>
<p class="text-muted text-center" ng-if="one_customer.sex!='m' && one_customer.sex!='f' && one_customer.sex=='0'">性别:未知</p>
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<b>常消费的店铺</b> <div class="pull-right">
<a ui-sref="partners.detail({clientMoniker:one_customer.clients[0]})">{{one_customer.clients[0]}} </a>
<span ng-if="one_customer.clients[1]">,</span>
<a ui-sref="partners.detail({clientMoniker:one_customer.clients[1]})">{{one_customer.clients[1]}}</a>
<span ng-if="one_customer.clients[2]">,</span>
<a ui-sref="partners.detail({clientMoniker:one_customer.clients[2]})">{{one_customer.clients[2]}}</a>
</div>
</li>
<li class="list-group-item">
<b>常消费的金额区间</b> <a class="pull-right">{{one_customer.amount_range}}</a>
</li>
<li class="list-group-item">
<b>常消费的时间段</b> <a class="pull-right">{{one_customer.hour_range}}</a>
</li>
<li class="list-group-item">
<b>常消费的城市</b> <a class="pull-right" style="width: 70%;text-align:right;white-space: nowrap;">{{one_customer.top_citys}}</a>
</li>
<li class="list-group-item">
<b>总金额数</b> <a class="pull-right">{{one_customer.amount}}</a>
</li>
<li class="list-group-item">
<b>总订单数</b> <a class="pull-right">{{one_customer.orders}}</a>
</li>
<li class="list-group-item">
<b>客单价</b> <a class="pull-right">{{one_customer.price}}</a>
</li>
<li class="list-group-item" style="height: 100px">
<b>常消费的行业</b> <a class="pull-right" style="width:50%;text-align:right;">
{{one_customer.industry[0]|partner_royalpay_industry}} <span ng-if="one_customer.industry[1]">,</span>
{{one_customer.industry[1]|partner_royalpay_industry}}
<span ng-if="one_customer.industry[2]">,</span>
{{one_customer.industry[2]|partner_royalpay_industry}}</a>
</li>
</ul>
</div>
<!-- /.box-body -->
</div>
</div>
<div class="box-body userechart">
<div class="chart" id="drageId" echarts="testobj" moved=true style="height: 600px"></div>
</div>
<loadingbar ng-if="customer_loading"></loadingbar>
</div>
</div>

@ -8,6 +8,7 @@ define(['angular', 'echarts'], function (angular, echarts) {
restrict: 'AEC',
scope: {
echarts: '=',
moved: '=',
chartSetter: '&'
},
link: function (scope, element, attr) {
@ -18,6 +19,15 @@ define(['angular', 'echarts'], function (angular, echarts) {
if (element.height() > 0 && element.width() > 0) {
scope.chartObj = echarts.init(element[0]);
initDefer.resolve();
if (scope.moved) {
scope.chartObj.on('mouseup', function (params) {
var option =scope.chartObj.getOption();
option.series[0].data[params.dataIndex].x = params.event.offsetX;
option.series[0].data[params.dataIndex].y = params.event.offsetY;
option.series[0].data[params.dataIndex].fixed = true;
scope.chartObj.setOption(option);
});
}
} else {
$timeout(initChart, 100)
}
@ -54,17 +64,17 @@ define(['angular', 'echarts'], function (angular, echarts) {
} catch (e) {
}
});
angular.element(window).bind('resize',function () {
angular.element(window).bind('resize', function () {
try {
setTimeout(function () {
if (scope.chartObj != null && !!scope.chartObj.getOption()) {
scope.chartObj.resize()
}
},1000)
}, 1000)
} catch (e) {
}
})
});
}
}
}]);

@ -29449,7 +29449,7 @@ define('zrender/mixin/Draggable', ['require'], function (require) {
if (draggingTarget) {
draggingTarget.dragging = false;
}
this.dispatchToElement(draggingTarget, 'dragend', e.event);
// this.dispatchToElement(draggingTarget, 'dragend', e.event);
if (this._dropTarget) {
this.dispatchToElement(this._dropTarget, 'drop', e.event);
}

Loading…
Cancel
Save