diff --git a/pom.xml b/pom.xml
index 52dd127ca..43203c321 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
4.0.0manage
- 1.1.15
+ 1.1.30UTF-8
diff --git a/src/db/modify.sql b/src/db/modify.sql
index 929d90dc1..982d51c8e 100644
--- a/src/db/modify.sql
+++ b/src/db/modify.sql
@@ -721,4 +721,6 @@ ADD INDEX `report_id` (`report_id`) USING HASH ;
update pmt_custom_reports set report_serial=uuid();
alter pmt_custom_reports add PRIMARY key (report_serial);
-alter table sys_org add COLUMN `state` varchar(20) DEFAULT NULL COMMENT '州 (使用标准码 NSW,QLD,WA,VIC,ACT,NT,TAS,SA)';
\ No newline at end of file
+alter table sys_org add COLUMN `state` varchar(20) DEFAULT NULL COMMENT '州 (使用标准码 NSW,QLD,WA,VIC,ACT,NT,TAS,SA)';
+
+INSERT INTO `royalpay`.`sys_configs`(`config_key`, `config_value`, `config_desc`) VALUES ('rick_interior_send_email', 'dll19920503@qq.com', '内部调用测试发送邮箱');
\ No newline at end of file
diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/BDAnalysisService.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/BDAnalysisService.java
index ae814453e..7f9360453 100644
--- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/BDAnalysisService.java
+++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/BDAnalysisService.java
@@ -30,4 +30,10 @@ public interface BDAnalysisService {
* @return bd_id, bd_name, num
*/
List approvedAnalysis(JSONObject params);
+
+ /**
+ * BD销售每日数据统计
+ * @param format
+ */
+ void generateReport(String format);
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/BDAnalysisServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/BDAnalysisServiceImpl.java
index 579561871..9fadea1d5 100644
--- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/BDAnalysisServiceImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/BDAnalysisServiceImpl.java
@@ -3,14 +3,19 @@ package au.com.royalpay.payment.manage.analysis.core.impls;
import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean;
import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService;
import au.com.royalpay.payment.manage.analysis.mappers.BDAnalysisMapper;
+import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
+import au.com.royalpay.payment.manage.mappers.log.StatisticsBDSalesReportMapper;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.IOUtils;
+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.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -18,8 +23,12 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
+import java.util.UUID;
/**
* Created by yishuqian on 30/09/2016.
@@ -30,24 +39,52 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
@Resource
private BDAnalysisMapper bdAnalysisMapper;
+ @Resource
+ private StatisticsBDSalesReportMapper bdSalesReportMapper;
+
+ @Resource
+ private TransactionAnalysisMapper transactionAnalysisMapper;
+
@Override
public List getSalesAnalysis(JSONObject jsonObject) {
return listSalesAnalysis(jsonObject);
}
- private List listSalesAnalysis(JSONObject jsonObject){
+ private List listSalesAnalysis(JSONObject jsonObject) {
List listCountApproved = bdAnalysisMapper.countApproved(jsonObject);
- List bdSaleList = bdAnalysisMapper.getBDSaleList(jsonObject);
- for(JSONObject countApproved : listCountApproved){
- for(JSONObject saleList : bdSaleList){
- if(countApproved.getString("bd_id").equals(saleList.getString("bd_id"))){
- saleList.put("num",countApproved.getString("num"));
+ List bdSaleList = bdSalesReportMapper.getBDSaleList(jsonObject);
+ for (JSONObject countApproved : listCountApproved) {
+ for (JSONObject saleList : bdSaleList) {
+ if (countApproved.getString("bd_id").equals(saleList.getString("bd_id"))) {
+ saleList.put("num", countApproved.getString("num"));
+ }
+ }
+ }
+ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
+ if (sd.format(jsonObject.getDate("end")).equals(sd.format(DateUtils.addDays(new Date(), 1)))) {
+ jsonObject.put("begin", DateUtils.addDays(jsonObject.getDate("end"), -1));
+ jsonObject.put("end",jsonObject.getDate("end"));
+ List todaySaleList = bdAnalysisMapper.getBDSaleList(jsonObject);
+ for (JSONObject todayBDSaleItem : todaySaleList) {
+ boolean flag = false;
+ for(JSONObject baSaleItem: bdSaleList){
+ if (baSaleItem.getString("bd_id").equals(todayBDSaleItem.getString("bd_id"))) {
+ BigDecimal newAmount = baSaleItem.getBigDecimal("total").add(todayBDSaleItem.getBigDecimal("total"));
+ baSaleItem.put("total",newAmount);
+ flag = true;
+ }
+ }
+ if (!flag) {
+ bdSaleList.add(todayBDSaleItem);
}
}
}
+
return bdSaleList;
}
+ //单独计算当日数据
+
@Override
public List getSalesPartnersByBD(JSONObject jsonObject) {
@@ -58,32 +95,32 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
public List getSalesPartnersReportByBD(JSONObject jsonObject) {
List bdAnalysis = bdAnalysisMapper.getBDSalePartnerReport(jsonObject);
List result = new ArrayList<>();
- String keys_1[] = {"1","2","3","4","5","6","7","8","9"};
- String key_2[] = {"10","11","12"};
- result = getPartnerTypes(keys_1,result,1,5,bdAnalysis);
- return getPartnerTypes(key_2,result,2,6,bdAnalysis);
+ String keys_1[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9"};
+ String key_2[] = {"10", "11", "12"};
+ result = getPartnerTypes(keys_1, result, 1, 5, bdAnalysis);
+ return getPartnerTypes(key_2, result, 2, 6, bdAnalysis);
}
- private List getPartnerTypes(String keys[],List result,int short_length,int long_length,List bdAnalysis){
- for(String key : keys){
+ private List getPartnerTypes(String keys[], List result, int short_length, int long_length, List bdAnalysis) {
+ for (String key : keys) {
int countValue = 0;
int countTotal = 0;
JSONObject object = new JSONObject();
JSONArray list = new JSONArray();
- for(JSONObject type : bdAnalysis){
- if(type.getString("royalpayindustry") != null && type.getString("royalpayindustry").startsWith(key) && (type.getString("royalpayindustry").length()==short_length || type.getString("royalpayindustry").length()==long_length)){
+ for (JSONObject type : bdAnalysis) {
+ if (type.getString("royalpayindustry") != null && type.getString("royalpayindustry").startsWith(key) && (type.getString("royalpayindustry").length() == short_length || type.getString("royalpayindustry").length() == long_length)) {
countValue += type.getIntValue("partner_counts");
countTotal += type.getIntValue("total");
list.add(type);
}
}
- if(countValue == 0){
+ if (countValue == 0) {
continue;
}
- object.put("count_value",countValue);
- object.put("count_total",countTotal);
- object.put("mccCode",key);
- object.put("children",list);
+ object.put("count_value", countValue);
+ object.put("count_total", countTotal);
+ object.put("mccCode", key);
+ object.put("children", list);
result.add(object);
}
return result;
@@ -92,7 +129,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
@Override
public void exportSalesExcel(AnalysisBean analysisBean, HttpServletResponse httpResponse, JSONObject manager) throws IOException {
httpResponse.setContentType("application/vnd.ms-excel");
- String fileName = analysisBean.getBegin_month()+"~"+analysisBean.getEnd_month();
+ String fileName = analysisBean.getBegin_month() + "~" + analysisBean.getEnd_month();
// String fileName = new String(URLEncoder.encode(defaultname,"utf8"));
httpResponse.setHeader("Content-Disposition", "attachment;filename="
+ fileName + ".xls");
@@ -113,20 +150,20 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
List bds = bdAnalysisMapper.getBDSaleList(params);
HSSFWorkbook workbook = new HSSFWorkbook();
- for (JSONObject bd:bds){
+ for (JSONObject bd : bds) {
String bd_id = bd.getString("bd_id");
String bd_name = bd.getString("bd_name");
JSONObject monthParams = new JSONObject();
- monthParams.put("bd_id",bd_id);
- monthParams.put("begin_month",analysisBean.getBegin_month());
- monthParams.put("end_month",analysisBean.getEnd_month());
+ monthParams.put("bd_id", bd_id);
+ monthParams.put("begin_month", analysisBean.getBegin_month());
+ monthParams.put("end_month", analysisBean.getEnd_month());
List monthTotalSale = bdAnalysisMapper.getMonthSalesList(monthParams);
- for (JSONObject month:monthTotalSale){
- monthParams.put("month",month.getString("y_m"));
- List clientsMonthSale = bdAnalysisMapper.getClientsMonthSale(bd_id,analysisBean.getBegin_month(),analysisBean.getEnd_month(),month.getString("y_m"));
- month.put("clients",clientsMonthSale);
+ for (JSONObject month : monthTotalSale) {
+ monthParams.put("month", month.getString("y_m"));
+ List clientsMonthSale = bdAnalysisMapper.getClientsMonthSale(bd_id, analysisBean.getBegin_month(), analysisBean.getEnd_month(), month.getString("y_m"));
+ month.put("clients", clientsMonthSale);
}
- exportExcel(workbook,bd_name,monthTotalSale);
+ exportExcel(workbook, bd_name, monthTotalSale);
}
OutputStream outputStream = httpResponse.getOutputStream();
try {
@@ -144,14 +181,70 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
return bdAnalysisMapper.countApproved(params);
}
+ /**
+ * BD销售每日数据统计
+ * @param date
+ */
+ @Override
+ public void generateReport(String date) {
+ try {
+ Date beginTime = DateUtils.parseDate(date, new String[]{"yyyy-MM-dd"});
+ Date yesterdayEndTime = DateUtils.addDays(beginTime, 1);
+ String endDate = DateFormatUtils.format(yesterdayEndTime, "yyyy-MM-dd");
+ Date endTime = DateUtils.parseDate(endDate, new String[]{"yyyy-MM-dd"});
+ JSONObject params = new JSONObject();
+ params.put("begin", beginTime);
+ params.put("end", endTime);
+ List bdSaleList = bdAnalysisMapper.getOneDayBDSaleList(params);
+ if (bdSaleList.size() != 0) {
+ for (JSONObject item : bdSaleList) {
+ JSONObject existBDSalesReport = bdSalesReportMapper.findByBDIdAndLogDate(item.getString("bd_id"),beginTime,0);
+ if(existBDSalesReport==null){
+ JSONObject object = new JSONObject(item);
+ object.put("log_id", UUID.randomUUID().toString());
+ object.put("log_date", beginTime);
+ object.put("create_time", new Date());
+ bdSalesReportMapper.save(object);
+ }else{
+ existBDSalesReport.put("pay_amount",item.getString("pay_amount"));
+ existBDSalesReport.put("refund_amount",item.getString("refund_amount"));
+ existBDSalesReport.put("net_amount",item.getString("net_amount"));
+ bdSalesReportMapper.update(existBDSalesReport);
+ }
+ }
+ }
+ List orgSaleList= transactionAnalysisMapper.getOneDayOrgMerchantSaleList(params);
+ if (orgSaleList.size() != 0) {
+ for (JSONObject item : orgSaleList) {
+ JSONObject existOrgSalesReport = bdSalesReportMapper.findByBDIdAndLogDate(item.getString("bd_id"),beginTime,1);
+ if(existOrgSalesReport==null){
+ JSONObject object = new JSONObject(item);
+ object.put("log_id", UUID.randomUUID().toString());
+ object.put("log_date", beginTime);
+ object.put("create_time", new Date());
+ bdSalesReportMapper.save(object);
+ }else{
+ existOrgSalesReport.put("pay_amount",item.getString("pay_amount"));
+ existOrgSalesReport.put("refund_amount",item.getString("refund_amount"));
+ existOrgSalesReport.put("net_amount",item.getString("net_amount"));
+ bdSalesReportMapper.update(existOrgSalesReport);
+ }
+
+ }
+ }
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
@Override
public void exportPartnerExcelByBd(AnalysisBean analysisBean, HttpServletResponse httpResponse, JSONObject manager) throws IOException {
OutputStream ous = null;
- try{
+ try {
JSONObject parmerters = analysisBean.toParams(null);
List listPartnerByBd = bdAnalysisMapper.getBDSalePartnerList(parmerters);
httpResponse.setContentType("application/octet-stream;");
- httpResponse.addHeader("Content-Disposition", "attachment; filename=" + "Merchant_list--" +parmerters.getString("bd_name") + analysisBean.getBegin() + "~" + analysisBean.getEnd() + ".xls");
+ httpResponse.addHeader("Content-Disposition", "attachment; filename=" + "Merchant_list--" + parmerters.getString("bd_name") + analysisBean.getBegin() + "~" + analysisBean.getEnd() + ".xls");
ous = httpResponse.getOutputStream();
HSSFWorkbook wb = new HSSFWorkbook();
HSSFFont font = wb.createFont();
@@ -159,7 +252,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
font.setFontHeightInPoints((short) 15);
CellStyle analysisStyle = wb.createCellStyle();
analysisStyle.setFont(font);
- Sheet sheet = wb.createSheet("Merchant list" );
+ Sheet sheet = wb.createSheet("Merchant list");
sheet.createFreezePane(1, 2);
sheet.setDefaultColumnWidth((short) 25);
int rowNum = 0;
@@ -168,7 +261,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
for (int i = 0; i < title.length; i++) {
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
}
- for(JSONObject partner : listPartnerByBd){
+ for (JSONObject partner : listPartnerByBd) {
row = sheet.createRow(++rowNum);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("short_name"));
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("client_moniker"));
@@ -176,7 +269,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
}
wb.write(ous);
ous.flush();
- }catch (IOException e){
+ } catch (IOException e) {
} finally {
IOUtils.closeQuietly(ous);
}
@@ -186,7 +279,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
@Override
public void exportPartnerExcelByData(AnalysisBean analysisBean, HttpServletResponse httpResponse, JSONObject manager) throws IOException {
OutputStream ous = null;
- try{
+ try {
JSONObject parmerters = analysisBean.toParams(null);
List listPartnerByData = listSalesAnalysis(parmerters);
httpResponse.setContentType("application/octet-stream;");
@@ -198,31 +291,31 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
font.setFontHeightInPoints((short) 15);
CellStyle analysisStyle = wb.createCellStyle();
analysisStyle.setFont(font);
- Sheet sheet = wb.createSheet("Merchant Sale List" );
+ Sheet sheet = wb.createSheet("Merchant Sale List");
sheet.createFreezePane(1, 2);
sheet.setDefaultColumnWidth((short) 25);
int rowNum = 0;
Row row = sheet.createRow(rowNum);
- String[] title = {"BD Name", "AUD Amount", "Refund Fee","New Merchants"};
+ String[] title = {"BD Name", "AUD Amount", "Refund Fee", "New Merchants"};
for (int i = 0; i < title.length; i++) {
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
}
- for(JSONObject dataSale : listPartnerByData){
+ for (JSONObject dataSale : listPartnerByData) {
row = sheet.createRow(++rowNum);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("bd_name"));
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("total"));
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("refund_fee"));
- row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("num") == null? "0" : dataSale.getString("num"));
+ row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("num") == null ? "0" : dataSale.getString("num"));
}
wb.write(ous);
ous.flush();
- }catch (IOException e){
+ } catch (IOException e) {
} finally {
IOUtils.closeQuietly(ous);
}
}
- private void exportExcel(HSSFWorkbook workbook,String title,List monthTotalSale) {
+ private void exportExcel(HSSFWorkbook workbook, String title, List monthTotalSale) {
// 声明一个工作薄
// 生成一个表格
HSSFSheet sheet = workbook.createSheet(title);
@@ -271,9 +364,9 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
// comment.setAuthor("leno");
//产生表格标题行
- HSSFRow row0= sheet.createRow(0);
- HSSFRow row1= sheet.createRow(1);
- HSSFRow row2= sheet.createRow(2);
+ HSSFRow row0 = sheet.createRow(0);
+ HSSFRow row1 = sheet.createRow(1);
+ HSSFRow row2 = sheet.createRow(2);
HSSFCell cell00 = row0.createCell(0);
HSSFCell cell01 = row0.createCell(1);
HSSFCell cell20 = row2.createCell(0);
@@ -294,15 +387,13 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
cell20.setCellValue(text20);
-
-
for (int i = 0; i < monthTotalSale.size(); i++) {
- sheet.addMergedRegion(new CellRangeAddress(0,0,2*i+2,2*i+3));
- HSSFCell cell02 = row0.createCell(i*2+2);
- HSSFCell cell12 = row1.createCell(i*2+2);
- HSSFCell cell13 = row1.createCell(i*2+3);
- HSSFCell cell22 = row2.createCell(i*2+2);
- HSSFCell cell23 = row2.createCell(i*2+3);
+ sheet.addMergedRegion(new CellRangeAddress(0, 0, 2 * i + 2, 2 * i + 3));
+ HSSFCell cell02 = row0.createCell(i * 2 + 2);
+ HSSFCell cell12 = row1.createCell(i * 2 + 2);
+ HSSFCell cell13 = row1.createCell(i * 2 + 3);
+ HSSFCell cell22 = row2.createCell(i * 2 + 2);
+ HSSFCell cell23 = row2.createCell(i * 2 + 3);
cell02.setCellStyle(style);
cell12.setCellStyle(style);
@@ -314,19 +405,18 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
HSSFRichTextString text13 = new HSSFRichTextString("增长百分比");
HSSFRichTextString text22 = new HSSFRichTextString(monthTotalSale.get(i).getString("total"));
double rate = 0;
- if (i>0){
- BigDecimal lastTotal = monthTotalSale.get(i-1).getBigDecimal("total");
- BigDecimal total = monthTotalSale.get(i).getBigDecimal("total");
- if (lastTotal.compareTo(new BigDecimal(0))==0 && total.compareTo(new BigDecimal(0)) !=0){
- rate=100;
- }
- else if (lastTotal.compareTo(new BigDecimal(0))==0 && total.compareTo(new BigDecimal(0)) ==0){
- rate=0;
- }else {
- rate = total.subtract(lastTotal).multiply(new BigDecimal(100)).divide(lastTotal,2,BigDecimal.ROUND_DOWN).doubleValue();
- }
+ if (i > 0) {
+ BigDecimal lastTotal = monthTotalSale.get(i - 1).getBigDecimal("total");
+ BigDecimal total = monthTotalSale.get(i).getBigDecimal("total");
+ if (lastTotal.compareTo(new BigDecimal(0)) == 0 && total.compareTo(new BigDecimal(0)) != 0) {
+ rate = 100;
+ } else if (lastTotal.compareTo(new BigDecimal(0)) == 0 && total.compareTo(new BigDecimal(0)) == 0) {
+ rate = 0;
+ } else {
+ rate = total.subtract(lastTotal).multiply(new BigDecimal(100)).divide(lastTotal, 2, BigDecimal.ROUND_DOWN).doubleValue();
+ }
}
- HSSFRichTextString text23 = i==0?new HSSFRichTextString("-"):new HSSFRichTextString(String.valueOf(rate));
+ HSSFRichTextString text23 = i == 0 ? new HSSFRichTextString("-") : new HSSFRichTextString(String.valueOf(rate));
cell02.setCellValue(text0);
cell12.setCellValue(text12);
cell13.setCellValue(text13);
@@ -335,35 +425,34 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
}
List partnersSale = (List) monthTotalSale.get(0).get("clients");
- for (int m=0;m clients = (List) monthTotalSale.get(n).get("clients");
- HSSFCell celli2 = row.createCell(n*2+2);
- HSSFCell celli3 = row.createCell(n*2+3);
+ HSSFCell celli2 = row.createCell(n * 2 + 2);
+ HSSFCell celli3 = row.createCell(n * 2 + 3);
celli2.setCellStyle(style2);
celli3.setCellStyle(style2);
HSSFRichTextString texti2 = new HSSFRichTextString(clients.get(m).getString("month_total"));
double rate = 0;
- if (n>0){
- List lastClients = (List) monthTotalSale.get(n-1).get("clients");
+ if (n > 0) {
+ List lastClients = (List) monthTotalSale.get(n - 1).get("clients");
BigDecimal lastTotal = lastClients.get(m).getBigDecimal("month_total");
BigDecimal total = clients.get(m).getBigDecimal("month_total");
- if (lastTotal.compareTo(new BigDecimal(0))==0 && total.compareTo(new BigDecimal(0)) !=0){
- rate=100;
- }
- else if (lastTotal.compareTo(new BigDecimal(0))==0 && total.compareTo(new BigDecimal(0)) ==0){
- rate=0;
- }else {
- rate = total.subtract(lastTotal).multiply(new BigDecimal(100)).divide(lastTotal,2,BigDecimal.ROUND_DOWN).doubleValue();
+ if (lastTotal.compareTo(new BigDecimal(0)) == 0 && total.compareTo(new BigDecimal(0)) != 0) {
+ rate = 100;
+ } else if (lastTotal.compareTo(new BigDecimal(0)) == 0 && total.compareTo(new BigDecimal(0)) == 0) {
+ rate = 0;
+ } else {
+ rate = total.subtract(lastTotal).multiply(new BigDecimal(100)).divide(lastTotal, 2, BigDecimal.ROUND_DOWN).doubleValue();
}
}
HSSFRichTextString texti3 = new HSSFRichTextString(String.valueOf(rate));
diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/OrgAnalysisServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/OrgAnalysisServiceImp.java
index 66510785d..39c91dcae 100644
--- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/OrgAnalysisServiceImp.java
+++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/OrgAnalysisServiceImp.java
@@ -1,12 +1,19 @@
package au.com.royalpay.payment.manage.analysis.core.impls;
import au.com.royalpay.payment.manage.analysis.core.OrgAnalysisService;
+import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
+import au.com.royalpay.payment.manage.mappers.log.StatisticsBDSalesReportMapper;
import au.com.royalpay.payment.manage.organizations.core.OrgManager;
import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
/**
@@ -17,14 +24,53 @@ public class OrgAnalysisServiceImp implements OrgAnalysisService {
@Resource
private TransactionAnalysisMapper transactionAnalysisMapper;
+ @Resource
+ private StatisticsBDSalesReportMapper statisticsBDSalesReportMapper;
+
@Resource
private OrgManager orgManager;
+ @Resource
+ private CustomerAndOrdersStatisticsMapper customerAndOrdersStatisticsMapper;
+
@Override
public List getSalesAnalysis(JSONObject params,JSONObject manager) {
orgManager.checkOrgIds(manager,params);
- List OrgTransaction = transactionAnalysisMapper.getOrgTransactionAnalysis(params);
- return OrgTransaction;
+ params.put("org_type",0);
+ List OrgTransaction = statisticsBDSalesReportMapper.getPartnerAmountList(params);
+ List newOrgTransaction = new ArrayList<>();
+ OrgTransaction.forEach(item->{
+ newOrgTransaction.add(new JSONObject(){{
+ put("org_id",item.getString("org_id"));
+ put("org_name",item.getString("org_name"));
+ put("amount",item.getString("clearing_amount"));
+ }}
+ );
+ });
+ //判断查询的最后一天是否是当日,若是当日,将当日数据添加至结果集内
+ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
+ if (sd.format(params.getDate("end")).equals(sd.format(DateUtils.addDays(new Date(), 1)))) {
+ params.put("begin", DateUtils.addDays(params.getDate("end"), -1));
+ params.put("end",params.getDate("end"));
+ List todayOrgTransaction = transactionAnalysisMapper.getOneDayOrgMerchantSaleList(params);
+ if(todayOrgTransaction.size()!=0){
+ for (JSONObject todayOrgTransactionItem : todayOrgTransaction) {
+ boolean flag = false;
+ for (JSONObject orgTransaction : newOrgTransaction) {
+ if (orgTransaction.getString("org_id").equals(todayOrgTransactionItem.getString("org_id"))) {
+ BigDecimal newAmount = orgTransaction.getBigDecimal("amount").add(todayOrgTransactionItem.getBigDecimal("clearing_amount"));
+ orgTransaction.put("amount", newAmount);
+ flag = true;
+ }
+ }
+ if (!flag) {
+ todayOrgTransactionItem.put("amount",todayOrgTransactionItem.getString("clearing_amount"));
+ newOrgTransaction.add(todayOrgTransactionItem);
+ }
+ }
+ }
+ }
+ return newOrgTransaction;
}
@Override
diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.java b/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.java
index 9d51ce7ba..c3cc1400c 100644
--- a/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.java
+++ b/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.java
@@ -26,4 +26,7 @@ public interface BDAnalysisMapper {
List countApproved(JSONObject params);
List getBDSalePartnerReport(JSONObject jsonObject);
+
+ //获取指定一天销售数据
+ List getOneDayBDSaleList(JSONObject params);
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java b/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java
index bd09a889d..6e9a570e9 100644
--- a/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java
+++ b/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java
@@ -77,6 +77,9 @@ public interface TransactionAnalysisMapper {
JSONObject getClientTransaction(JSONObject params);
+ List getWeekClientTransaction(JSONObject params);
+
+
@CountRef(".countAreaMerchantAmountAnalysis")
PageList getAreaMerchantAmountAnalysis(JSONObject params, PageBounds pagination);
@@ -93,4 +96,6 @@ public interface TransactionAnalysisMapper {
* @return
*/
BigDecimal getCnyAmount(JSONObject params);
+
+ List getOneDayOrgMerchantSaleList(JSONObject params);
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java
index 5dd8f117f..310c063d1 100644
--- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java
+++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java
@@ -26,6 +26,8 @@ import javax.servlet.http.HttpServletResponse;
public interface RetailAppService {
JSONObject getTransactionCommonData(JSONObject device, AppQueryBean appQueryBean);
+ List getTransactionCommonWeekData(JSONObject device, AppQueryBean appQueryBean);
+
JSONObject getClientSettlementLog(JSONObject device, AppQueryBean appQueryBean);
JSONObject getTransactionLogsByClearingDetailId(JSONObject device, int clearing_detail_id, String timezone);
diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java
index a10060690..ba640eac3 100644
--- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java
+++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java
@@ -109,7 +109,6 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
-import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@@ -219,7 +218,7 @@ public class RetailAppServiceImp implements RetailAppService {
private final int BIND_PHONE_TEMPLID = 126978;
private Map senderMap = new HashMap<>();
- private final String fileName[] = { "client_bank_file", "client_id_file", "client_company_file" };
+ private final String fileName[] = {"client_bank_file", "client_id_file", "client_company_file"};
@Resource
public void setAppMsgSenders(AppMsgSender[] senders) {
@@ -270,6 +269,27 @@ public class RetailAppServiceImp implements RetailAppService {
return res;
}
+ @Override
+ public List getTransactionCommonWeekData(JSONObject device, AppQueryBean appQueryBean) {
+ String clientType = device.getString("client_type");
+ deviceSupport.findRegister(clientType);
+ int client_id = device.getIntValue("client_id");
+ JSONObject client = clientManager.getClientInfo(client_id);
+ String timezone = client.getString("timezone");
+ if (timezone != null && !timezone.isEmpty()) {
+ appQueryBean.setTimezone(timezone);
+ }
+ JSONObject params = appQueryBean.toParams();
+ setAllClientIds(params, client_id);
+ params.put("client_id", client_id);
+ List res = transactionAnalysisMapper.getWeekClientTransaction(params);
+ res.forEach(r -> {
+ r.put("date",r.getDate("date").toString());
+ });
+ res.remove(res.size() - 1);
+ return res;
+ }
+
@Override
public JSONObject getTradeCommonDate(JSONObject device, AppQueryBean appQueryBean) {
String clientType = device.getString("client_type");
@@ -310,7 +330,7 @@ public class RetailAppServiceImp implements RetailAppService {
@Override
public JSONObject getQrcode(JSONObject device, QRCodeConfig config, int client_id) {
JSONObject client = merchantInfoProvider.getClientInfo(client_id);
- String url = PlatformEnvironment.getEnv().concatUrl("/api/payment/v1.0/partners/" + client.getString("client_moniker"));
+ String url = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/payment/partners/" + client.getString("client_moniker"));
if (config.isCNY()) {
url += "_CNY";
}
@@ -492,7 +512,7 @@ public class RetailAppServiceImp implements RetailAppService {
@Override
public JSONObject ctripCouponInfo(JSONObject device, String coupon_id) {
- return couponVerificationService.ctripCouponInfo(coupon_id,device.getIntValue("client_id"), true);
+ return couponVerificationService.ctripCouponInfo(coupon_id, device.getIntValue("client_id"), true);
}
@@ -506,7 +526,7 @@ public class RetailAppServiceImp implements RetailAppService {
PageList cusCouponLogs = couponAccuessLogMapper.getCouponAccuessLog(
client.getIntValue("client_id"), keyword, new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit(), Order.formString("creation_date.desc")));
HashMap couponMap = new HashMap<>();
- for(JSONObject cusCouponLog : cusCouponLogs) {
+ for (JSONObject cusCouponLog : cusCouponLogs) {
cusCouponLog.put("client_moniker", client_moniker);
if (couponMap.containsKey(cusCouponLog.getString("coupon_id"))) {
cusCouponLog.put("coupon", couponMap.get(cusCouponLog.getString("coupon_id")));
@@ -529,7 +549,7 @@ public class RetailAppServiceImp implements RetailAppService {
Date date = new Date();
couponAccuessLog.put("client_id", client_id);
couponAccuessLog.put("order_id", "NON_PLATFORM_ORDER");
- couponAccuessLog.put("coupon_id", "CTRIP_"+coupon_id);
+ couponAccuessLog.put("coupon_id", "CTRIP_" + coupon_id);
couponAccuessLog.put("customer_openid", "NON_PLATFORM_ORDER");
couponAccuessLog.put("coupon_deal_amount", 0);
couponAccuessLog.put("currency", "AUD");
@@ -589,7 +609,7 @@ public class RetailAppServiceImp implements RetailAppService {
|| ("Company".equals(clientWithConfig.getString("business_structure")) && StringUtils.isEmpty(clientWithConfig.getString("acn")))
|| (!"Company".equals(clientWithConfig.getString("business_structure")) && StringUtils.isEmpty(clientWithConfig.getString("abn")))
|| (StringUtils.isEmpty(clientWithConfig.getString("company_website")) && StringUtils.isEmpty(clientWithConfig.getString("company_photo"))
- && StringUtils.isEmpty(clientWithConfig.getString("store_photo")))) {
+ && StringUtils.isEmpty(clientWithConfig.getString("store_photo")))) {
res.put("base_info_lack", true);
}
@@ -621,7 +641,7 @@ public class RetailAppServiceImp implements RetailAppService {
|| ("Company".equals(client.getString("business_structure")) && StringUtils.isEmpty(client.getString("acn")))
|| (!"Company".equals(client.getString("business_structure")) && StringUtils.isEmpty(client.getString("abn")))
|| (StringUtils.isEmpty(client.getString("company_website")) && StringUtils.isEmpty(client.getString("company_photo"))
- && StringUtils.isEmpty(client.getString("store_photo")))) {
+ && StringUtils.isEmpty(client.getString("store_photo")))) {
result.put("base_info_lack", true);
}
@@ -1296,10 +1316,10 @@ public class RetailAppServiceImp implements RetailAppService {
String father = "";
String html = doc.body().children().wrap(father).html();
// logger.debug("wrapped html---->"+html);
- if (res.getIntValue("type")==2) {
- List buttons = JSONObject.parseArray(res.getString("buttons"),JSONObject.class);
+ if (res.getIntValue("type") == 2) {
+ List buttons = JSONObject.parseArray(res.getString("buttons"), JSONObject.class);
res.put("buttons", buttons);
- }else {
+ } else {
res.put("content", doc.html());
}
return res;
@@ -1331,14 +1351,14 @@ public class RetailAppServiceImp implements RetailAppService {
if (latestConfirmNotice != null) {
latestConfirmNotice.put("id", latestConfirmNotice.getString("notice_id"));
latestConfirmNotice.remove("notice_id");
- List buttons = JSONObject.parseArray(latestConfirmNotice.getString("buttons"),JSONObject.class);
+ List buttons = JSONObject.parseArray(latestConfirmNotice.getString("buttons"), JSONObject.class);
latestConfirmNotice.put("buttons", buttons);
String content = latestConfirmNotice.getString("content");
- if (content.indexOf("%excharge_rate%")>0) {
+ if (content.indexOf("%excharge_rate%") > 0) {
JSONObject rate = merchantInfoProvider.clientCurrentRate(client_id, new Date(), "CB_BankPay");
if (rate != null) {
content = content.replace("%excharge_rate%", (rate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() + "%"));
- }else {
+ } else {
content = content.replace("%excharge_rate%", "(暂未配置)");
}
}
@@ -1351,10 +1371,10 @@ public class RetailAppServiceImp implements RetailAppService {
String EndDate = DateFormatUtils.format(rate.getDate("expiry_date"), "yyyy-MM-dd");
String[] rateName = {"清算时间", "签约费率", "结束时间"};
String[] rateKey = {cleanDays, rateValue, EndDate};
- for(int i =0;i {
try {
@@ -2016,23 +2036,23 @@ public class RetailAppServiceImp implements RetailAppService {
throw new EmailException("Email Sending Failed", e);
}
});
- stringRedisTemplate.boundValueOps(getUpdateAccountEmailKey(codeKey)).set(codeKeyValue+"&"+email.getString("contact_email"), 5, TimeUnit.MINUTES);
+ stringRedisTemplate.boundValueOps(getUpdateAccountEmailKey(codeKey)).set(codeKeyValue + "&" + email.getString("contact_email"), 5, TimeUnit.MINUTES);
}
@Override
public void updateAccountEmail(JSONObject device, JSONObject params) {
String key = stringRedisTemplate.boundValueOps(getUpdateAccountEmailKey(device.getString("account_id"))).get();
- if(key == null){
+ if (key == null) {
throw new BadRequestException("Captcha has expired");
}
String captcha = key.split("&")[0];
String email = key.split("&")[1];
- if(!StringUtils.equals(captcha,params.getString("captcha"))){
+ if (!StringUtils.equals(captcha, params.getString("captcha"))) {
throw new BadRequestException("Verification code is wrong");
}
- JSONObject account = new JSONObject();
- account.put("account_id",device.getString("account_id"));
- account.put("contact_email",email);
+ JSONObject account = new JSONObject();
+ account.put("account_id", device.getString("account_id"));
+ account.put("contact_email", email);
clientAccountMapper.update(account);
deleteAccountEmailKey(device.getString("account_id"));
}
@@ -2041,7 +2061,7 @@ public class RetailAppServiceImp implements RetailAppService {
public void bindAccountPhone(JSONObject device, JSONObject phone) {
String codeKey = device.getString("account_id");
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).get();
- if(StringUtils.isNotEmpty(codeKeyValueRedis)){
+ if (StringUtils.isNotEmpty(codeKeyValueRedis)) {
throw new BadRequestException("Captcha has been sent.Please check your phone or try again in 5 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
@@ -2058,25 +2078,25 @@ public class RetailAppServiceImp implements RetailAppService {
e.printStackTrace();
throw new ServerErrorException("Phone number is wrong.Please try again.");
}
- stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue+"&"+nationCode+"&"+phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES);
+ stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES);
}
@Override
public void updateAccountPhone(JSONObject device, JSONObject params) {
String key = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(device.getString("account_id"))).get();
- if(key == null){
+ if (key == null) {
throw new BadRequestException("Captcha has expired");
}
String captcha = key.split("&")[0];
String nation_code = key.split("&")[1];
String contact_phone = key.split("&")[2];
- if(!StringUtils.equals(captcha,params.getString("captcha"))){
+ if (!StringUtils.equals(captcha, params.getString("captcha"))) {
throw new BadRequestException("Verification code is wrong");
}
- JSONObject account = new JSONObject();
- account.put("account_id",device.getString("account_id"));
- account.put("contact_phone",contact_phone);
- account.put("nation_code","+" + nation_code);
+ JSONObject account = new JSONObject();
+ account.put("account_id", device.getString("account_id"));
+ account.put("contact_phone", contact_phone);
+ account.put("nation_code", "+" + nation_code);
clientAccountMapper.update(account);
deleteAccountPhoneKey(device.getString("account_id"));
}
@@ -2120,7 +2140,7 @@ public class RetailAppServiceImp implements RetailAppService {
}
@Override
- public JSONObject toggleCBBankChannel(JSONObject device,String noticeId) {
+ public JSONObject toggleCBBankChannel(JSONObject device, String noticeId) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
@@ -2143,7 +2163,7 @@ public class RetailAppServiceImp implements RetailAppService {
}
@Override
- public JSONObject toggleCBBankCustomerSurcharge(JSONObject device,boolean customerSurcharge) {
+ public JSONObject toggleCBBankCustomerSurcharge(JSONObject device, boolean customerSurcharge) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
@@ -2158,7 +2178,7 @@ public class RetailAppServiceImp implements RetailAppService {
result.put("status", "Fail");
if (customerSurcharge) {
result.put("message", "开启客户支付手续费失败,失败原因:" + e.getMessage());
- }else {
+ } else {
result.put("message", "关闭客户支付手续费失败,失败原因:" + e.getMessage());
}
@@ -2168,7 +2188,7 @@ public class RetailAppServiceImp implements RetailAppService {
result.put("status", "Success");
if (customerSurcharge) {
result.put("message", "开启客户支付手续费成功!");
- }else {
+ } else {
result.put("message", "关闭客户支付手续费成功!");
}
result.put("customerSurcharge", String.valueOf(customerSurcharge));
@@ -2371,20 +2391,20 @@ public class RetailAppServiceImp implements RetailAppService {
return result;
}
- private void deleteAccountEmailKey(String codeKey){
+ private void deleteAccountEmailKey(String codeKey) {
stringRedisTemplate.delete(getUpdateAccountEmailKey(codeKey));
}
- private void deleteAccountPhoneKey(String codeKey){
+ private void deleteAccountPhoneKey(String codeKey) {
stringRedisTemplate.delete(getUpdateAccountPhoneKey(codeKey));
}
- private String getUpdateAccountEmailKey(String codeKey){
- return BIND_ACCOUNT_EMAIL_PREFIX+codeKey;
+ private String getUpdateAccountEmailKey(String codeKey) {
+ return BIND_ACCOUNT_EMAIL_PREFIX + codeKey;
}
- private String getUpdateAccountPhoneKey(String codeKey){
- return BIND_ACCOUNT_PHONE_PREFIX+codeKey;
+ private String getUpdateAccountPhoneKey(String codeKey) {
+ return BIND_ACCOUNT_PHONE_PREFIX + codeKey;
}
private JSONObject getBankAccountByClientId(int client_id) {
diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java
index 0a30d20b6..ca677b3b1 100644
--- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java
+++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java
@@ -104,6 +104,12 @@ public class RetailAppController {
return retailAppService.getTransactionCommonData(device, appQueryBean);
}
+ // 查询7天的交易金额
+ @RequestMapping(value = "/common/week", method = RequestMethod.GET)
+ public List getTransactionCommonWeekData(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean appQueryBean) {
+ return retailAppService.getTransactionCommonWeekData(device, appQueryBean);
+ }
+
/**
* 流水页今日数据
*
diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppPermissionSupportImpl.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppPermissionSupportImpl.java
index 3fceada66..d1523e2f3 100644
--- a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppPermissionSupportImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppPermissionSupportImpl.java
@@ -19,9 +19,7 @@ import javax.annotation.Resource;
public class AppPermissionSupportImpl implements AppPermissionSupport {
@Resource
private SysAppsMapper sysAppsMapper;
- private final String signTemplate = "%s&%s&%s&%s&%s";
private Logger logger = LoggerFactory.getLogger(getClass());
- public static final String[] NODES_IP_ADDRESSS = new String[]{"119.28.3.196","150.109.64.108", "119.28.178.24", "119.28.24.146", "119.28.77.25"};
@Override
public JSONObject validateSign(String appid, long timestamp, String ip, String requestUri, String sign) {
@@ -41,19 +39,10 @@ public class AppPermissionSupportImpl implements AppPermissionSupport {
throw new ForbiddenException("Timeout");
}
String auth = app.getString("auth_code");
- String str = String.format(signTemplate, appid, auth, timestamp, requestUri, ip);
- logger.debug("sso-str before hash:" + str);
+ String str = String.join("&", appid, auth, timestamp + "", requestUri);
+ logger.debug("sso-str before hash:{}", str);
String hash = DigestUtils.sha256Hex(str).toLowerCase();
if (!StringUtils.equals(hash, sign)) {
- for (String nodeIp : NODES_IP_ADDRESSS) {
- logger.error("[{}]请求的签名有误,使用节点 [{}] 签名", appid, nodeIp);
- str = String.format(signTemplate, appid, auth, timestamp, requestUri, nodeIp);
- logger.debug("NodeIp check sso-str before hash:" + str);
- hash = DigestUtils.sha256Hex(str).toLowerCase();
- if (StringUtils.equals(hash, sign)) {
- return app;
- }
- }
throw new ForbiddenException("InvalidSign");
}
return app;
diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/SSOSupportImpl.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/SSOSupportImpl.java
index d713a2140..fc82e9d99 100644
--- a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/SSOSupportImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/SSOSupportImpl.java
@@ -58,7 +58,7 @@ public class SSOSupportImpl implements SSOSupport {
public String cacheClient(String appid, JSONObject clientUser) {
String code = Long.toString(System.currentTimeMillis(), 36) + RandomStringUtils.random(10, true, true);
String cacheKey = accountCacheKey("client", appid, code);
- logger.debug("========cacheClient,key:"+cacheKey+"========");
+ logger.debug("========cacheClient,key:{}========", cacheKey);
stringRedisTemplate.boundValueOps(cacheKey).set(clientUser.toJSONString(), 30, TimeUnit.SECONDS);
return code;
}
@@ -70,7 +70,7 @@ public class SSOSupportImpl implements SSOSupport {
private JSONObject getCachedAccount(String appid, String code, String type) {
String cacheKey = accountCacheKey(type, appid, code);
- logger.debug("========getCachedAccount,key:"+cacheKey+"========");
+ logger.debug("========getCachedAccount,key:{}========", cacheKey);
String jsonstr = stringRedisTemplate.boundValueOps(cacheKey).get();
stringRedisTemplate.delete(cacheKey);
if (jsonstr != null) {
@@ -81,7 +81,7 @@ public class SSOSupportImpl implements SSOSupport {
@Override
public JSONObject getCachedClientAccount(String appid, String code) {
- logger.debug("========getCachedClientAccount,appid:"+appid+",code:"+code+"========");
+ logger.debug("========getCachedClientAccount,appid:{},code:{}========", appid, code);
return getCachedAccount(appid, code, "client");
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/ManualServiceimpl.java b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/ManualServiceimpl.java
index c5f08f985..485c09450 100644
--- a/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/ManualServiceimpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/ManualServiceimpl.java
@@ -108,6 +108,5 @@ public class ManualServiceimpl implements ManualService {
}
});
- clientModifySupport.processClientConfigModify(new SwitchPermissionModify(null, client_moniker, "tax_in_surcharge", false));
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/AnalysisController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/AnalysisController.java
new file mode 100644
index 000000000..46216c5b4
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/AnalysisController.java
@@ -0,0 +1,28 @@
+package au.com.royalpay.payment.manage.dev.web;
+
+import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+@RestController
+@RequestMapping("/analysis")
+public class AnalysisController {
+
+ @Resource
+ private BDAnalysisService bdAnalysisService;
+
+
+ @GetMapping("/report/bd/sales")
+ public void reportDBSalesList(@RequestParam("date") String date) throws ParseException {
+ Date newDate = new SimpleDateFormat("yyyy-MM-dd").parse(date);
+ bdAnalysisService.generateReport(DateFormatUtils.format(newDate, "yyyy-MM-dd"));
+ }
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/StatisticsBDSalesReportMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/StatisticsBDSalesReportMapper.java
new file mode 100644
index 000000000..35b7c4693
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/StatisticsBDSalesReportMapper.java
@@ -0,0 +1,29 @@
+package au.com.royalpay.payment.manage.mappers.log;
+
+import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
+import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
+import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by dulingling on 2019-08-14
+ */
+@AutoMapper(tablename = "statistics_bd_sales", pkName = "log_id")
+public interface StatisticsBDSalesReportMapper {
+
+ @AutoSql(type = SqlType.INSERT)
+ void save(JSONObject report);
+
+ List getBDSaleList(JSONObject params);
+
+ List getPartnerAmountList(JSONObject params);
+
+ JSONObject findByBDIdAndLogDate(@Param("bd_id") String bd_id, @Param("log_date")Date beginTime,@Param("isOrg") int isOrg);
+
+ @AutoSql(type = SqlType.UPDATE)
+ void update(JSONObject existBDSalesReport);
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java
index eb3072085..4ff99a7c9 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java
@@ -5376,7 +5376,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
rpayApi.modifySurchargeConfig(clientMapper.findClient(client_id));
}
}
- clientModifySupport.processClientConfigModify(new SwitchPermissionModify(null, client.getString("client_moniker"), "tax_in_surcharge", false));
adminAccounts.forEach(o -> {
sendClientPostponeNotify(o, expireDate);
});
@@ -5396,7 +5395,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
public boolean postponeClientRate(int clientId, String clientMoniker, String nextYearExipryDate) {
try {
clientRateMapper.postponeMerchantRateByClientId(clientId);
- clientModifySupport.processClientConfigModify(new SwitchPermissionModify(null, clientMoniker, "tax_in_surcharge", false));
List adminAccounts = clientAccountMapper.listAdminAccounts(clientId);
adminAccounts.forEach(o -> {
sendClientPostponeNotify(o, nextYearExipryDate);
diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java
index 1697bf419..2eddba926 100644
--- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java
@@ -32,6 +32,7 @@ import au.com.royalpay.payment.tools.connections.mpsupport.exceptions.WechatExce
import au.com.royalpay.payment.tools.device.message.AppMessage;
import au.com.royalpay.payment.tools.device.message.AppMsgSender;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
+import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.event.WechatExceptionEvent;
import au.com.royalpay.payment.tools.locale.LocaleSupport;
@@ -134,6 +135,9 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
private MpWechatApiProvider mpWechatApiProvider;
private ApplicationEventPublisher publisher;
+ @Resource
+ private SysConfigManager sysConfigManager;
+
@Resource
public void setAppMsgSenders(AppMsgSender[] senders) {
@@ -818,9 +822,9 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
* 如果是内部调单,密送bd与上面定义的‘emailsBccs’
* 如果没有勾选发送商户
* 如果不是内部调单,直接发送商户;
- * 如果是内部调单,则自定义“"18852852189@163.com"为收件人,密送同上
+ * 如果是内部调单,则自定义sys_configs配置中KEY为"rick_interior_send_email"为收件人,密送同上
*
- * Arrays.asList("18852852189@139.com", "1370256381@qq.com")为本地debug模式的测试邮箱
+ * Arrays.asList(自定义sys_configs配置中KEY为"rick_interior_send_email")为本地debug模式的测试邮箱
*/
if (isSendClient == 1) {
ctx.setVariable("emailsTos", clientEmails);
@@ -829,7 +833,8 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
ctx.setVariable("emailsCcs", null);
if (PlatformEnvironment.getEnv().isDebug()) {
emailsBccs = new ArrayList<>(Arrays.asList(
- "18852852189@139.com", "1370256381@qq.com"
+ sysConfigManager.getSysConfig().getString("rick_interior_send_email"),
+ sysConfigManager.getSysConfig().getString("rick_interior_send_email")
));
}
emailsBccs.addAll(bdEmails);
@@ -839,13 +844,14 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
if (orderType == RiskOrderTypeEnum.ROYALPAY_ORDER.getOrderType().intValue()) {
if (PlatformEnvironment.getEnv().isDebug()) {
emailsBccs = new ArrayList<>(Arrays.asList(
- "18852852189@139.com", "1370256381@qq.com"
+ sysConfigManager.getSysConfig().getString("rick_interior_send_email"),
+ sysConfigManager.getSysConfig().getString("rick_interior_send_email")
));
}
emailsBccs.addAll(bdEmails);
ctx.setVariable("emailsBccs", emailsBccs);
ctx.setVariable("emailsTos", Arrays.asList(
- "18852852189@163.com"
+ sysConfigManager.getSysConfig().getString("rick_interior_send_email")
));
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java
index fa09f6708..960feab9c 100644
--- a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java
@@ -125,7 +125,7 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService {
transaction.put("bill_id", detailId);
transaction.put("total_surcharge", BigDecimal.ZERO);
transaction.put("tax_amount", BigDecimal.ZERO);
- transaction.put("amount", detail.getBigDecimal("debit_amount").negate());
+ transaction.put("amount", detail.getBigDecimal("total_surcharge").negate());
transaction.put("post_balance", surchargeAccount.getBigDecimal("balance").add(transaction.getBigDecimal("amount")));
transaction.put("operation", manager.getString("manager_id"));
transaction.put("create_time", new Date());
diff --git a/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java
index b4082fb18..3b9102fbf 100644
--- a/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java
@@ -104,7 +104,6 @@ public class ClientContractServiceImpl implements ClientContractService {
contract.put("confirm_time", now);
contract.put("signatory", account.getString("display_name"));
clientsContractMapper.update(contract);
- clientManager.setClientTaxInSurcharge(clientAccountMapper.findById(account_id),client.getString("client_moniker"), false);
}
@Override
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/DBSaleAnalysisTask.java b/src/main/java/au/com/royalpay/payment/manage/task/DBSaleAnalysisTask.java
new file mode 100644
index 000000000..8ce4fd026
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/task/DBSaleAnalysisTask.java
@@ -0,0 +1,34 @@
+package au.com.royalpay.payment.manage.task;
+
+import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+/**
+ * Created by dulingling on 2019-08-14
+ */
+@Component
+@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")
+public class DBSaleAnalysisTask {
+
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
+
+ @Resource
+ private BDAnalysisService bdAnalysisService;
+
+ @Scheduled(cron = "0 0 1 * * ?")
+ public void dailyReportAutoGenerateReport() {
+ synchronizedScheduler.executeProcess("manage_task:dailyDBSaleReportAutoGenerateReport", 120_000, () -> {
+ Date yesterday = DateUtils.addDays(new Date(), -1);
+ bdAnalysisService.generateReport(DateFormatUtils.format(yesterday, "yyyy-MM-dd"));
+ });
+ }
+}
diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.xml
index 2f2de891e..24e059359 100644
--- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.xml
+++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.xml
@@ -3,67 +3,45 @@
@@ -179,11 +157,11 @@
where client_id in(select client_id from sys_clients c where c.approve_time >= #{begin} AND c.approve_time < #{end} AND c.is_valid = 1 AND c.approve_result = 1
]]>
- and c.org_id=#{org_id}
- and c.org_id in
- #{org_id}
- and c.source=1
- and c.source!=1
+ and c.org_id=#{org_id}
+ and c.org_id in
+ #{org_id}
+ and c.source=1
+ and c.source!=1
- group by bd_id
- order by num desc
+ group by bd_id
+ order by num desc
+
+
+
diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml
index 96ee0b611..5dd530b90 100644
--- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml
+++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml
@@ -716,25 +716,45 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/StatisticsBDSalesReportMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/StatisticsBDSalesReportMapper.xml
new file mode 100644
index 000000000..f92f48fae
--- /dev/null
+++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/StatisticsBDSalesReportMapper.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.xml
index 7576f7ee4..583edb902 100644
--- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.xml
+++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/FinancialSurchargeAccountDetailMapper.xml
@@ -17,6 +17,7 @@
fsad.total_surcharge,
fsad.credit_amount,
fsad.debit_amount,
+ fsad.checkout,
sc.client_moniker,
sc.short_name,
sc.company_name
diff --git a/src/main/resources/templates/mail/risk_upload_mail.html b/src/main/resources/templates/mail/risk_upload_mail.html
index 719540fd0..3cd7b9e38 100644
--- a/src/main/resources/templates/mail/risk_upload_mail.html
+++ b/src/main/resources/templates/mail/risk_upload_mail.html
@@ -100,7 +100,6 @@
Platform Transaction ID
Order Description
Customer ID
-
IP
Total Amount
Input Amount
Pay Amount
@@ -119,7 +118,6 @@
-
@@ -132,6 +130,7 @@
+
请查收关于被抽查的订单交易的相关信息,并在下午6:00 (悉尼时间)前将所需材料直接回复该邮件,未能按时提交完整证明材料,支付渠道将被关停,请您务必配合调查。感谢。
Please find sampled transactions in attachment, and reply required materials to this email before 6:00 pm (AEST). If you can not provide qualified materials on time, the payment channels would be suspended or restricted with amount limit. Please be sure to assist the investigation. Thanks.