|
|
|
@ -15,13 +15,14 @@ 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.geo.GeoIPSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.geo.entity.GeoLocation;
|
|
|
|
|
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;
|
|
|
|
@ -72,7 +73,7 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
|
|
|
|
|
@Resource
|
|
|
|
|
private RetailAppService retailAppService;
|
|
|
|
|
@Resource
|
|
|
|
|
private LookupService lookupService;
|
|
|
|
|
private GeoIPSupport geoIPSupport;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<JSONObject> getCustomersAnalysis(JSONObject params) {
|
|
|
|
@ -105,7 +106,7 @@ 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( params.getString("orderValue") )));
|
|
|
|
|
PageList<JSONObject> logs = orderAnalysisMapper.listCustomersData(params, new PageBounds(page, limit, Order.formString(params.getString("orderValue"))));
|
|
|
|
|
if (!logs.isEmpty()) {
|
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
|
generatorUserProfile(log, params);
|
|
|
|
@ -259,7 +260,7 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
|
|
|
|
|
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());
|
|
|
|
|
node.put("symbolSize", clientInTotal.compareTo(new BigDecimal(10)) < 0 ? 10 : clientInTotal.toPlainString());
|
|
|
|
|
if (clientInTotal.compareTo(new BigDecimal(300)) == 0) {
|
|
|
|
|
node.put("symbolSize", 100);
|
|
|
|
|
}
|
|
|
|
@ -267,21 +268,21 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
|
|
|
|
|
node.put("flag", true);
|
|
|
|
|
node.put("draggable", true);
|
|
|
|
|
nodes.add(node);
|
|
|
|
|
JSONObject totalAmountInfo = getClientAmountInfo(id,"x0", "交易金额", client);
|
|
|
|
|
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());
|
|
|
|
|
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);
|
|
|
|
|
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());
|
|
|
|
|
OrdersInfo.put("symbolSize", orderInTotal.compareTo(new BigDecimal(10)) < 0 ? 10 : orderInTotal.toPlainString());
|
|
|
|
|
nodes.add(OrdersInfo);
|
|
|
|
|
JSONObject priceInfo = getClientAmountInfo(id,"x2", "客单价", client);
|
|
|
|
|
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());
|
|
|
|
|
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++;
|
|
|
|
|
}
|
|
|
|
@ -289,7 +290,7 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
|
|
|
|
|
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);
|
|
|
|
|
link.put("target", linkId.indexOf("x") > 0 ? linkId.substring(0, linkId.indexOf("x")) : 0);
|
|
|
|
|
links.add(link);
|
|
|
|
|
}
|
|
|
|
|
graph.put("nodes", nodes);
|
|
|
|
@ -384,8 +385,8 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
|
|
|
|
|
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) && StringUtils.isNotBlank(city) && city != null) {
|
|
|
|
|
String city = geoIPSupport.getLocation(address.getString("customer_ip")).map(GeoLocation::getCity).orElse(null);
|
|
|
|
|
if (topAddress.size() < 3 && !topAddress.contains(city) && StringUtils.isNotBlank(city)) {
|
|
|
|
|
topAddress.add(city);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -394,7 +395,7 @@ public class CustomersAnalysisServiceImp implements CustomersAnalysisService {
|
|
|
|
|
int amount = mostUseAmountByCustomer.getIntValue("amount_int");
|
|
|
|
|
if (amount == 0) {
|
|
|
|
|
topAmountRange = "0~100";
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
topAmountRange = String.valueOf(amount * 100) + "~" + String.valueOf((amount + 1) * 100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|