parent
5fd561a578
commit
333e496549
@ -0,0 +1,35 @@
|
||||
package au.com.royalpay.payment.manage.dataAnalysis.core;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* @Author lvjian
|
||||
* @Date 2018/6/28 18:40
|
||||
*/
|
||||
public interface DataAnalysisService {
|
||||
|
||||
/**
|
||||
* 获取数据分析1
|
||||
* @param params
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
JSONObject getDataAnalysis1(JSONObject params, JSONObject response);
|
||||
|
||||
/**
|
||||
* 获取数据分析2
|
||||
* @param params
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
JSONObject getDataAnalysis2(JSONObject params, JSONObject response);
|
||||
|
||||
/**
|
||||
* 新需求
|
||||
* 获取cny_amount统计值
|
||||
* @param params
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
JSONObject getCnyAmount(JSONObject params, JSONObject response);
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package au.com.royalpay.payment.manage.dataAnalysis.core;
|
||||
|
||||
import au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper;
|
||||
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.Order;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author lvjian
|
||||
* @Date 2018/6/28 18:42
|
||||
*/
|
||||
@Service
|
||||
public class DataAnalysisServiceImpl implements DataAnalysisService {
|
||||
|
||||
@Resource
|
||||
private ClientAnalysisMapper clientAnalysisMapper;
|
||||
|
||||
@Resource
|
||||
private TransactionAnalysisMapper transactionAnalysisMapper;
|
||||
|
||||
@Override
|
||||
public JSONObject getDataAnalysis1(JSONObject params, JSONObject response) {
|
||||
|
||||
//新加的商户数
|
||||
response.put("new_partners", clientAnalysisMapper.countNewClients(params));
|
||||
//总商户数
|
||||
response.put("total_partners", clientAnalysisMapper.countClients(params));
|
||||
//产生交易的商户数
|
||||
response.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
|
||||
//交易总额
|
||||
response.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDataAnalysis2(JSONObject params, JSONObject response) {
|
||||
|
||||
//交易笔数
|
||||
response.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
|
||||
List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params);
|
||||
//最大交易额
|
||||
if (!topOrders.isEmpty()) {
|
||||
response.put("max_order", topOrders.get(0).get("aud_fee"));
|
||||
} else {
|
||||
response.put("max_order", 0);
|
||||
}
|
||||
//总消费人数
|
||||
response.put("total_customers", transactionAnalysisMapper.countCustomers(params));
|
||||
//老客户人数
|
||||
response.put("old_customers", transactionAnalysisMapper.countOldCustomers(params));
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getCnyAmount(JSONObject params, JSONObject response) {
|
||||
response.put("cny_amount", transactionAnalysisMapper.getCnyAmount(params));
|
||||
return response;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package au.com.royalpay.payment.manage.dataAnalysis.web;
|
||||
|
||||
import au.com.royalpay.payment.manage.dataAnalysis.core.DataAnalysisService;
|
||||
import au.com.royalpay.payment.manage.dataAnalysis.util.MyUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author lvjian
|
||||
* @Date 2018/6/28 18:32
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/out")
|
||||
public class DataAnalysisController {
|
||||
|
||||
@Autowired
|
||||
private DataAnalysisService dataAnalysisService;
|
||||
|
||||
@RequestMapping(value = "/data_analysis")
|
||||
public JSONObject dataAnalysis(@RequestParam(value = "begin", required = false) String begin,
|
||||
@RequestParam(value = "offset", defaultValue = "1") Integer offset) throws ParseException {
|
||||
|
||||
JSONObject params = new JSONObject();
|
||||
if (begin == null) {
|
||||
Date beginInit = MyUtil.getYMD(new Date());
|
||||
Date endInit = DateUtils.addDays(beginInit,offset);
|
||||
params.put("begin",beginInit);
|
||||
params.put("end",endInit);
|
||||
} else {
|
||||
DateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
if (offset < 0) {
|
||||
params.put("end", format.parse(begin));
|
||||
params.put("begin", DateUtils.addDays(format.parse(begin),offset));
|
||||
} else {
|
||||
params.put("begin", format.parse(begin));
|
||||
params.put("end", DateUtils.addDays(format.parse(begin),offset));
|
||||
}
|
||||
}
|
||||
JSONObject response = new JSONObject();
|
||||
response = dataAnalysisService.getDataAnalysis1(params,response);
|
||||
response = dataAnalysisService.getDataAnalysis2(params,response);
|
||||
response = dataAnalysisService.getCnyAmount(params, response);
|
||||
return response;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue