Merge branch 'master' of https://git.royalpay.com.au/git/royalv2.manage
commit
068904c74b
@ -0,0 +1,120 @@
|
||||
package au.com.royalpay.payment.manage.analysis.beans;
|
||||
|
||||
import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
* Created by yuan on 2018/6/5.
|
||||
*/
|
||||
public class AreaMerchantTradeQueryBean {
|
||||
private final DateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
int page = 1;
|
||||
int limit = 10;
|
||||
private String state;
|
||||
private String org_id;
|
||||
private String bd;
|
||||
private String begin;
|
||||
private String end;
|
||||
private String client_moniker;
|
||||
|
||||
public JSONObject toParams(){
|
||||
JSONObject params = new JSONObject();
|
||||
if (StringUtils.isNotEmpty(state)) {
|
||||
params.put("state",state);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(org_id)) {
|
||||
params.put("org_id",org_id);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(bd)) {
|
||||
params.put("bd_user",bd);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(client_moniker)) {
|
||||
params.put("client_monikers",client_moniker.split(","));
|
||||
}
|
||||
if (begin != null) {
|
||||
try {
|
||||
params.put("begin", format.parse(begin));
|
||||
} catch (ParseException e) {
|
||||
throw new ParamInvalidException("begin", "error.payment.valid.invalid_date_format");
|
||||
}
|
||||
}
|
||||
if (end != null) {
|
||||
try {
|
||||
params.put("end", DateUtils.addDays(format.parse(end), 1));
|
||||
} catch (ParseException e) {
|
||||
throw new ParamInvalidException("end", "error.payment.valid.invalid_date_format");
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getOrg_id() {
|
||||
return org_id;
|
||||
}
|
||||
|
||||
public void setOrg_id(String org_id) {
|
||||
this.org_id = org_id;
|
||||
}
|
||||
|
||||
public String getBd() {
|
||||
return bd;
|
||||
}
|
||||
|
||||
public void setBd(String bd) {
|
||||
this.bd = bd;
|
||||
}
|
||||
|
||||
public String getBegin() {
|
||||
return begin;
|
||||
}
|
||||
|
||||
public void setBegin(String begin) {
|
||||
this.begin = begin;
|
||||
}
|
||||
|
||||
public String getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public void setEnd(String end) {
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public String getClient_moniker() {
|
||||
return client_moniker;
|
||||
}
|
||||
|
||||
public void setClient_moniker(String client_moniker) {
|
||||
this.client_moniker = client_moniker;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package au.com.royalpay.payment.manage.analysis.core;
|
||||
|
||||
import au.com.royalpay.payment.manage.analysis.beans.AreaMerchantTradeQueryBean;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Created by yuan on 2018/6/5.
|
||||
*/
|
||||
public interface AreaMerchantTradeAnalysis {
|
||||
JSONObject listAreaMerchantTrade(JSONObject manager,AreaMerchantTradeQueryBean queryBean);
|
||||
|
||||
void importTradeExcel(JSONObject manager,AreaMerchantTradeQueryBean queryBean,HttpServletResponse response) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,254 @@
|
||||
package au.com.royalpay.payment.manage.analysis.core.impls;
|
||||
|
||||
import au.com.royalpay.payment.manage.analysis.beans.AreaMerchantTradeQueryBean;
|
||||
import au.com.royalpay.payment.manage.analysis.core.AreaMerchantTradeAnalysis;
|
||||
import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper;
|
||||
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
|
||||
import au.com.royalpay.payment.manage.organizations.core.OrgManager;
|
||||
import au.com.royalpay.payment.tools.env.SysConfigManager;
|
||||
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
||||
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.PageBounds;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.hssf.util.HSSFColor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by yuan on 2018/6/5.
|
||||
*/
|
||||
@Service
|
||||
public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
||||
|
||||
@Autowired
|
||||
private TransactionAnalysisMapper transactionAnalysisMapper;
|
||||
|
||||
@Autowired
|
||||
private CustomerAndOrdersStatisticsMapper customerAndOrdersStatisticsMapper;
|
||||
|
||||
@Autowired
|
||||
private OrgManager orgManager;
|
||||
|
||||
@Autowired
|
||||
private SysConfigManager sysConfigManager;
|
||||
@Override
|
||||
public JSONObject listAreaMerchantTrade(JSONObject manager, AreaMerchantTradeQueryBean queryBean) {
|
||||
if (manager == null || !manager.getBooleanValue("is_valid")) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
JSONObject params = queryBean.toParams();
|
||||
PageList<JSONObject> clientAmount = null;
|
||||
orgManager.checkOrgIds(manager,params);
|
||||
if(params.containsKey("begin") && params.containsKey("end")){
|
||||
if (params.getDate("end").after(new Date()) && params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){
|
||||
clientAmount = transactionAnalysisMapper.getAreaMerchantAmountAnalysis(params,new PageBounds(queryBean.getPage(),queryBean.getLimit()));
|
||||
}else {
|
||||
clientAmount = customerAndOrdersStatisticsMapper.getAreaMerchantTradeAnalysis(params,new PageBounds(queryBean.getPage(),queryBean.getLimit()));
|
||||
}
|
||||
}
|
||||
return PageListUtils.buildPageListResult(clientAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importTradeExcel(JSONObject manager, AreaMerchantTradeQueryBean queryBean,HttpServletResponse response) throws Exception {
|
||||
if (manager == null || !manager.getBooleanValue("is_valid")) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
JSONObject params = queryBean.toParams();
|
||||
orgManager.checkOrgIds(manager,params);
|
||||
PageList<JSONObject> clientAmount = null;
|
||||
if(params.containsKey("begin") && params.containsKey("end")){
|
||||
if (params.getDate("end").after(new Date()) && params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){
|
||||
clientAmount = transactionAnalysisMapper.getAreaMerchantAmountAnalysis(params,new PageBounds());
|
||||
}else {
|
||||
clientAmount = customerAndOrdersStatisticsMapper.getAreaMerchantTradeAnalysis(params,new PageBounds());
|
||||
}
|
||||
}
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
// 声明一个工作薄
|
||||
// 生成一个表格
|
||||
HSSFSheet sheet = workbook.createSheet("clientAmount_excel");
|
||||
// 设置表格默认列宽度为15个字节
|
||||
sheet.setDefaultColumnWidth((short) 40);
|
||||
// 生成一个样式
|
||||
HSSFCellStyle style = workbook.createCellStyle();
|
||||
// 设置这些样式
|
||||
style.setFillForegroundColor(HSSFColor.LIGHT_ORANGE.index);
|
||||
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
||||
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
||||
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
||||
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
||||
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
||||
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
||||
HSSFFont font = workbook.createFont();
|
||||
font.setFontHeightInPoints((short) 16);
|
||||
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
||||
// 把字体应用到当前的样式
|
||||
style.setFont(font);
|
||||
|
||||
HSSFCellStyle style2 = workbook.createCellStyle();
|
||||
// 设置这些样式
|
||||
style2.setFillForegroundColor(HSSFColor.WHITE.index);
|
||||
style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
||||
style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
||||
style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
||||
style2.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
||||
style2.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
||||
style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
||||
HSSFFont font2 = workbook.createFont();
|
||||
font2.setFontHeightInPoints((short) 12);
|
||||
font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
|
||||
// 把字体应用到当前的样式
|
||||
style2.setFont(font2);
|
||||
HSSFRow row0 = sheet.createRow(0);
|
||||
HSSFCell cell00 = row0.createCell(0);
|
||||
HSSFCell cell01 = row0.createCell(1);
|
||||
HSSFCell cell02 = row0.createCell(2);
|
||||
HSSFCell cell03 = row0.createCell(3);
|
||||
HSSFCell cell04 = row0.createCell(4);
|
||||
HSSFCell cell05 = row0.createCell(5);
|
||||
HSSFCell cell06 = row0.createCell(6);
|
||||
HSSFCell cell07 = row0.createCell(7);
|
||||
HSSFCell cell08 = row0.createCell(8);
|
||||
HSSFCell cell09 = row0.createCell(9);
|
||||
HSSFCell cell10 = row0.createCell(10);
|
||||
HSSFCell cell11 = row0.createCell(11);
|
||||
cell00.setCellStyle(style);
|
||||
cell01.setCellStyle(style);
|
||||
cell02.setCellStyle(style);
|
||||
cell03.setCellStyle(style);
|
||||
cell04.setCellStyle(style);
|
||||
cell05.setCellStyle(style);
|
||||
cell06.setCellStyle(style);
|
||||
cell07.setCellStyle(style);
|
||||
cell08.setCellStyle(style);
|
||||
cell09.setCellStyle(style);
|
||||
cell10.setCellStyle(style);
|
||||
cell11.setCellStyle(style);
|
||||
|
||||
HSSFRichTextString text00 = new HSSFRichTextString("Partner Code");
|
||||
HSSFRichTextString text01 = new HSSFRichTextString("Short name");
|
||||
HSSFRichTextString text02 = new HSSFRichTextString("Bd name");
|
||||
HSSFRichTextString text03 = new HSSFRichTextString("State");
|
||||
HSSFRichTextString text04 = new HSSFRichTextString("Suburb");
|
||||
HSSFRichTextString text05 = new HSSFRichTextString("Industry");
|
||||
HSSFRichTextString text06 = new HSSFRichTextString("Amount");
|
||||
HSSFRichTextString text07 = new HSSFRichTextString("Orders");
|
||||
HSSFRichTextString text08 = new HSSFRichTextString("Alipay Amount");
|
||||
HSSFRichTextString text09 = new HSSFRichTextString("Alipay Orders");
|
||||
HSSFRichTextString text10 = new HSSFRichTextString("Wechat Amount");
|
||||
HSSFRichTextString text11 = new HSSFRichTextString("Wechat Orders");
|
||||
cell00.setCellValue(text00);
|
||||
cell01.setCellValue(text01);
|
||||
cell02.setCellValue(text02);
|
||||
cell03.setCellValue(text03);
|
||||
cell04.setCellValue(text04);
|
||||
cell05.setCellValue(text05);
|
||||
cell06.setCellValue(text06);
|
||||
cell07.setCellValue(text07);
|
||||
cell08.setCellValue(text08);
|
||||
cell09.setCellValue(text09);
|
||||
cell10.setCellValue(text10);
|
||||
cell11.setCellValue(text11);
|
||||
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
||||
String json = sysConfig.getString("royalpayindustry.json");
|
||||
JSONArray jsonArray = JSONObject.parseArray(json);
|
||||
for (int i = 0; i < clientAmount.size(); i++) {
|
||||
HSSFRow row = sheet.createRow(i + 1);
|
||||
HSSFCell cell0 = row.createCell(0);
|
||||
HSSFCell cell1 = row.createCell(1);
|
||||
HSSFCell cell2 = row.createCell(2);
|
||||
HSSFCell cell3 = row.createCell(3);
|
||||
HSSFCell cell4 = row.createCell(4);
|
||||
HSSFCell cell5 = row.createCell(5);
|
||||
HSSFCell cell6 = row.createCell(6);
|
||||
HSSFCell cell7 = row.createCell(7);
|
||||
HSSFCell cell8 = row.createCell(8);
|
||||
HSSFCell cell9 = row.createCell(9);
|
||||
HSSFCell cel10 = row.createCell(10);
|
||||
HSSFCell cel11 = row.createCell(11);
|
||||
cell0.setCellStyle(style2);
|
||||
cell1.setCellStyle(style2);
|
||||
cell2.setCellStyle(style2);
|
||||
cell3.setCellStyle(style2);
|
||||
cell4.setCellStyle(style2);
|
||||
cell5.setCellStyle(style2);
|
||||
cell6.setCellStyle(style2);
|
||||
cell7.setCellStyle(style2);
|
||||
cell8.setCellStyle(style2);
|
||||
cell9.setCellStyle(style2);
|
||||
cel10.setCellStyle(style2);
|
||||
cel11.setCellStyle(style2);
|
||||
String industry = getRoyalpayIindustry(clientAmount.get(i).getString("royalpayindustry"),jsonArray);
|
||||
HSSFRichTextString text0 = new HSSFRichTextString(clientAmount.get(i).getString("client_moniker"));
|
||||
HSSFRichTextString text1 = new HSSFRichTextString(clientAmount.get(i).getString("short_name"));
|
||||
HSSFRichTextString text2 = new HSSFRichTextString(clientAmount.get(i).getString("bd_user_name"));
|
||||
HSSFRichTextString text3 = new HSSFRichTextString(clientAmount.get(i).getString("state"));
|
||||
HSSFRichTextString text4 = new HSSFRichTextString(clientAmount.get(i).getString("suburb"));
|
||||
HSSFRichTextString text5 = new HSSFRichTextString(industry == null?"":industry);
|
||||
HSSFRichTextString text6 = new HSSFRichTextString(clientAmount.get(i).getString("total"));
|
||||
HSSFRichTextString text7 = new HSSFRichTextString(clientAmount.get(i).getString("orders"));
|
||||
HSSFRichTextString text8 = new HSSFRichTextString(clientAmount.get(i).getString("alipay_total"));
|
||||
HSSFRichTextString text9 = new HSSFRichTextString(clientAmount.get(i).getString("alipay_order"));
|
||||
HSSFRichTextString text_10 = new HSSFRichTextString(clientAmount.get(i).getString("wechat_toatl"));
|
||||
HSSFRichTextString text_11 = new HSSFRichTextString(clientAmount.get(i).getString("wechat_order"));
|
||||
cell0.setCellValue(text0);
|
||||
cell1.setCellValue(text1);
|
||||
cell2.setCellValue(text2);
|
||||
cell3.setCellValue(text3);
|
||||
cell4.setCellValue(text4);
|
||||
cell5.setCellValue(text5);
|
||||
cell6.setCellValue(text6);
|
||||
cell7.setCellValue(text7);
|
||||
cell8.setCellValue(text8);
|
||||
cell9.setCellValue(text9);
|
||||
cel10.setCellValue(text_10);
|
||||
cel11.setCellValue(text_11);
|
||||
}
|
||||
JSONObject parmerters = new JSONObject();
|
||||
parmerters.put("dateFrom", StringUtils.isNotBlank(queryBean.getBegin()) ? queryBean.getBegin() : "");
|
||||
parmerters.put("dateTo", StringUtils.isNotBlank(queryBean.getEnd()) ? queryBean.getEnd() : DateFormatUtils.format(new Date(), "yyyyMMdd"));
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
String fileName = StringUtils.isEmpty(parmerters.getString("dateFrom")) ? parmerters.getString("dateTo")
|
||||
: (parmerters.getString("dateFrom") + "~" + parmerters.getString("dateTo"));
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
|
||||
try {
|
||||
workbook.write(outputStream);
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String getRoyalpayIindustry(String industryMccCode,JSONArray jsonArray) {
|
||||
String industry = null;
|
||||
for(int i = 0;i<jsonArray.size();i++){
|
||||
JSONObject myjObject = jsonArray.getJSONObject(i);
|
||||
if(myjObject.getString("mccCode").equals(industryMccCode)){
|
||||
industry = myjObject.getString("label");
|
||||
}else {
|
||||
JSONArray children = myjObject.getJSONArray("children");
|
||||
for(int j = 0;j<children.size();j++){
|
||||
JSONObject child = children.getJSONObject(j);
|
||||
if(child.getString("mccCode").equals(industryMccCode)) {
|
||||
industry = child.getString("label");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return industry;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package au.com.royalpay.payment.manage.analysis.web;
|
||||
|
||||
import au.com.royalpay.payment.manage.analysis.beans.AreaMerchantTradeQueryBean;
|
||||
import au.com.royalpay.payment.manage.analysis.core.AreaMerchantTradeAnalysis;
|
||||
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
|
||||
import au.com.royalpay.payment.tools.CommonConsts;
|
||||
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Created by yuan on 2018/6/5.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/area/merchant")
|
||||
public class AreaMerchantTradeController {
|
||||
|
||||
@Resource
|
||||
private AreaMerchantTradeAnalysis areaMerchantTradeAnalysis;
|
||||
|
||||
@ManagerMapping(value = "",method = RequestMethod.GET,role = ManagerRole.ADMIN)
|
||||
public JSONObject listClientAmount(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,AreaMerchantTradeQueryBean queryBean){
|
||||
return areaMerchantTradeAnalysis.listAreaMerchantTrade(manager,queryBean);
|
||||
}
|
||||
|
||||
@ManagerMapping(value = "/excel",method = RequestMethod.GET,role = ManagerRole.ADMIN)
|
||||
public void exportExcel(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,AreaMerchantTradeQueryBean queryBean,HttpServletResponse httpResponse)throws Exception{
|
||||
areaMerchantTradeAnalysis.importTradeExcel(manager,queryBean,httpResponse);
|
||||
}
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
|
||||
define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', 'uiBootstrap', 'uiRouter', 'ngBootSwitch', 'ngFileUpload','./transaction/analysis-transaction'], function (angular) {
|
||||
'use strict';
|
||||
var app = angular.module('merchantAmount', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch']);
|
||||
app.config(['$stateProvider', function ($stateProvider) {
|
||||
$stateProvider.state('analysis_transaction.merchantAmountAnalysis', {
|
||||
url: '/amount',
|
||||
templateUrl: '/static/analysis/templates/merchant_amount_analysis.html',
|
||||
controller: 'clientAmountListCtrl'
|
||||
})
|
||||
}]);
|
||||
app.controller('clientAmountListCtrl', ['$scope', '$http','$filter', '$uibModal', 'commonDialog','stateMap' , function ($scope, $http,$filter, $uibModal, commonDialog,stateMap) {
|
||||
$scope.params = {yesterday:new Date(new Date().setDate(new Date().getDate()-1))};
|
||||
$scope.pagination = {};
|
||||
$scope.states = stateMap.configs();
|
||||
|
||||
$scope.chooseToday = function () {
|
||||
$scope.params.begin = $scope.params.end = new Date();
|
||||
$scope.loadClientsAmount(1);
|
||||
};
|
||||
$scope.chooseYesterday = function () {
|
||||
var yesterday = new Date();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
$scope.params.begin = $scope.params.end = yesterday;
|
||||
$scope.loadClientsAmount(1);
|
||||
};
|
||||
$scope.thisMonth = function () {
|
||||
$scope.params.end = new Date();
|
||||
var monthBegin = new Date();
|
||||
monthBegin.setDate(1);
|
||||
$scope.params.begin = monthBegin;
|
||||
$scope.loadClientsAmount(1);
|
||||
};
|
||||
$scope.lastMonth = function () {
|
||||
var monthFinish = new Date();
|
||||
monthFinish.setDate(0);
|
||||
$scope.params.end = monthFinish;
|
||||
var monthBegin = new Date();
|
||||
monthBegin.setDate(0);
|
||||
monthBegin.setDate(1);
|
||||
$scope.params.begin = monthBegin;
|
||||
$scope.loadClientsAmount(1);
|
||||
};
|
||||
|
||||
$scope.loadBdsOrOrgs = function () {
|
||||
$http.get('/sys/manager_accounts/roles/bd_user').then(function (resp) {
|
||||
$scope.bds = resp.data;
|
||||
});
|
||||
$http.get('/sys/orgs/child', {params: {}}).then(function (resp) {
|
||||
$scope.orgs = resp.data;
|
||||
});
|
||||
};
|
||||
$scope.chooseOrg = function (org) {
|
||||
if(org != null){
|
||||
$scope.params.org_id = org.org_id;
|
||||
$scope.org_name = org.name;
|
||||
}else {
|
||||
$scope.params.org_id = '';
|
||||
$scope.org_name = 'All';
|
||||
}
|
||||
};
|
||||
$scope.loadBdsOrOrgs();
|
||||
$scope.export = function () {
|
||||
$scope.exportUrl='/area/merchant/excel';
|
||||
var connectSymbol = '?';
|
||||
var params = angular.copy($scope.params);
|
||||
if(!params.begin || !params.end){
|
||||
commonDialog.alert({title: 'Error', content: '开始时间和截止时间不能为空', type: 'error'});
|
||||
return;
|
||||
}
|
||||
if (checkDate(params.end,params.begin)>31){
|
||||
commonDialog.alert({title: 'Error', content: '日期区间不能超过31天', type: 'error'});
|
||||
return;
|
||||
}
|
||||
if (params.begin) {
|
||||
params.begin = $filter('date')(params.begin, 'yyyyMMdd');
|
||||
$scope.exportUrl += connectSymbol + 'begin=' + params.begin;
|
||||
connectSymbol = '&';
|
||||
}
|
||||
if (params.end) {
|
||||
params.end = $filter('date')(params.end, 'yyyyMMdd');
|
||||
$scope.exportUrl += connectSymbol + 'end=' + params.end;
|
||||
connectSymbol = '&';
|
||||
}
|
||||
if (params.bd) {
|
||||
$scope.exportUrl += connectSymbol + 'bd=' + params.bd;
|
||||
}
|
||||
if (params.state) {
|
||||
$scope.exportUrl += connectSymbol + 'state=' + params.state;
|
||||
}
|
||||
if (params.org_id) {
|
||||
$scope.exportUrl += connectSymbol + 'org_id=' + params.org_id;
|
||||
}
|
||||
if (params.client_moniker) {
|
||||
$scope.exportUrl += connectSymbol + 'client_moniker=' + params.client_moniker;
|
||||
}
|
||||
};
|
||||
$scope.loadClientsAmount = function (page) {
|
||||
var params = angular.copy($scope.params);
|
||||
if(!params.begin || !params.end){
|
||||
commonDialog.alert({title: 'Error', content: '开始时间和截止时间不能为空', type: 'error'});
|
||||
return;
|
||||
}
|
||||
if (checkDate(params.end,params.begin)>31){
|
||||
commonDialog.alert({title: 'Error', content: '日期区间不能超过31天', type: 'error'});
|
||||
return;
|
||||
}
|
||||
if (params.begin) {
|
||||
params.begin = $filter('date')(params.begin, 'yyyyMMdd');
|
||||
}
|
||||
if (params.end) {
|
||||
params.end = $filter('date')(params.end, 'yyyyMMdd');
|
||||
}
|
||||
params.page = page || $scope.pagination.page || 1;
|
||||
$http.get('/area/merchant', {params: params}).then(function (resp) {
|
||||
$scope.clientAmount = resp.data.data;
|
||||
$scope.pagination = resp.data.pagination;
|
||||
})
|
||||
};
|
||||
$scope.lastMonth();
|
||||
|
||||
function checkDate(d1,d2){
|
||||
d1 = $filter('date')(d1, 'yyyy-MM-dd');
|
||||
d2 = $filter('date')(d2, 'yyyy-MM-dd');
|
||||
var day = 24 * 60 * 60 *1000;
|
||||
try{
|
||||
var dateArr = d1.split("-");
|
||||
var checkDate = new Date();
|
||||
checkDate.setFullYear(dateArr[0], dateArr[1]-1, dateArr[2]);
|
||||
var checkTime = checkDate.getTime();
|
||||
|
||||
var dateArr2 = d2.split("-");
|
||||
var checkDate2 = new Date();
|
||||
checkDate2.setFullYear(dateArr2[0], dateArr2[1]-1, dateArr2[2]);
|
||||
var checkTime2 = checkDate2.getTime();
|
||||
|
||||
var cha = (checkTime - checkTime2)/day;
|
||||
return cha;
|
||||
}catch(e){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
return app;
|
||||
});
|
@ -0,0 +1,201 @@
|
||||
<style>
|
||||
.dropdown-submenu {
|
||||
position: relative;
|
||||
}
|
||||
.dropdown-submenu > .dropdown-menu {
|
||||
top: 0;
|
||||
left: 100%;
|
||||
margin-top: -6px;
|
||||
margin-left: -1px;
|
||||
-webkit-border-radius: 0 6px 6px 6px;
|
||||
-moz-border-radius: 0 6px 6px;
|
||||
border-radius: 0 6px 6px 6px;
|
||||
}
|
||||
.dropdown-submenu:hover > .dropdown-menu {
|
||||
display: block;
|
||||
}
|
||||
.triangle > a:after {
|
||||
display: block;
|
||||
content: " ";
|
||||
float: right;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-color: transparent;
|
||||
border-style: solid;
|
||||
border-width: 5px 0 5px 5px;
|
||||
border-left-color: #ccc;
|
||||
margin-top: 5px;
|
||||
margin-right: -10px;
|
||||
}
|
||||
.dropdown-submenu:hover > a:after {
|
||||
border-left-color: #fff;
|
||||
}
|
||||
.dropdown-submenu.pull-left {
|
||||
float: none;
|
||||
}
|
||||
.dropdown-submenu.pull-left > .dropdown-menu {
|
||||
left: -100%;
|
||||
margin-left: 10px;
|
||||
-webkit-border-radius: 6px 0 6px 6px;
|
||||
-moz-border-radius: 6px 0 6px 6px;
|
||||
border-radius: 6px 0 6px 6px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="box-solid">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-horizontal">
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="control-label col-xs-4 col-sm-4">Organization</label>
|
||||
<div class="col-xs-6">
|
||||
<div class="dropdown">
|
||||
<input id="dLabel" data-toggle="dropdown" data-target="#" class="form-control"
|
||||
ng-model="org_name" placeholder="All"
|
||||
maxlength="50" readonly="readonly">
|
||||
<ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
|
||||
<li class="dropdown-submenu">
|
||||
<a tabindex="-1" href="" ng-click="chooseOrg(org)">All</a>
|
||||
</li>
|
||||
<li class="dropdown-submenu" ng-repeat="org in orgs" ng-class="{'triangle':org.children}">
|
||||
<a tabindex="-1" href="" ng-model="org.org_id" ng-click="chooseOrg(org)">{{org.name}}</a>
|
||||
<ul class="dropdown-menu" ng-if="org.children">
|
||||
<li><a tabindex="-1" href="javascript:;" ng-repeat="child in org.children" ng-click="chooseOrg(child)">{{child.name}}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="control-label col-xs-4 col-sm-4"
|
||||
>BD User</label>
|
||||
<div class="col-xs-6">
|
||||
<select id="bd-select" class="form-control" ng-model="params.bd"
|
||||
ng-options="bd.manager_id as bd.display_name group by bd.org_name for bd in bds|bdOrg:params.org_id">
|
||||
<option value="">All</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="control-label col-xs-4 col-sm-4">State</label>
|
||||
<div class="col-xs-6">
|
||||
<select class="form-control" name="state"
|
||||
ng-model="params.state" maxlength="20"
|
||||
ng-options="state.value as state.label for state in states">
|
||||
<option value="">All</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="control-label col-xs-4 col-sm-4">
|
||||
Partner Code</label>
|
||||
<div class="col-xs-6">
|
||||
<textarea type="text" class="form-control" id="suburb-search"
|
||||
ng-model="params.client_moniker" placeholder="code1,code2,code3,……"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-xs-12 col-sm-12">
|
||||
<label class="control-label col-xs-4 col-sm-2">Date Range</label>
|
||||
<div class="col-sm-9 col-xs-8">
|
||||
<div class="form-control-static form-inline">
|
||||
<div style="display: inline-block">
|
||||
<input class="form-control" id="date-from-input"
|
||||
ng-model="params.begin"
|
||||
uib-datepicker-popup size="10" placeholder="From"
|
||||
is-open="dateBegin.open" ng-click="dateBegin.open=true"
|
||||
datepicker-options="{maxDate:params.yesterday}">
|
||||
</div>
|
||||
~
|
||||
<div style="display: inline-block">
|
||||
<input class="form-control" id="date-to-input"
|
||||
ng-model="params.end"
|
||||
uib-datepicker-popup size="10" placeholder="To"
|
||||
is-open="dateTo.open" ng-click="dateTo.open=true"
|
||||
datepicker-options="{minDate:params.begin,maxDate:params.yesterday}">
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<a role="button" class="btn btn-default btn-sm"
|
||||
ng-click="chooseToday()">Today</a>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a role="button" class="btn btn-default btn-sm"
|
||||
ng-click="chooseYesterday()">Yesterday</a>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a role="button" class="btn btn-default btn-sm"
|
||||
ng-click="thisMonth()">This Month</a>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a role="button" class="btn btn-default btn-sm"
|
||||
ng-click="lastMonth()">Last Month</a>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-primary" type="button" ng-click="loadClientsAmount(1)"><i
|
||||
class="fa fa-search"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">List of Client</h3>
|
||||
<a ng-if="clientAmount.length" class="btn btn-primary pull-right" role="button" ng-click="export()" ng-href="{{exportUrl}}"><i class="glyphicon glyphicon-save"></i> Excel</a>
|
||||
</div>
|
||||
<div class="box-body no-padding table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Partner Code</th>
|
||||
<th>Short name</th>
|
||||
<th>Bd name</th>
|
||||
<th>State</th>
|
||||
<th>Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="client in clientAmount">
|
||||
<td ng-bind="client.client_moniker"></td>
|
||||
<td ng-bind="client.short_name"></td>
|
||||
<td ng-bind="client.bd_user_name"></td>
|
||||
<td ng-bind="client.state"></td>
|
||||
<td ng-bind="client.total"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="box-footer" ng-if="clientAmount.length">
|
||||
<uib-pagination class="pagination"
|
||||
total-items="pagination.totalCount"
|
||||
boundary-links="true"
|
||||
ng-model="pagination.page"
|
||||
items-per-page="pagination.limit"
|
||||
max-size="10"
|
||||
ng-change="loadClientsAmount()"
|
||||
previous-text="‹"
|
||||
next-text="›"
|
||||
first-text="«"
|
||||
last-text="»"></uib-pagination>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total
|
||||
Pages:{{pagination.totalPages}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in new issue