diff --git a/src/db/modify.sql b/src/db/modify.sql index 16a0e84b5..61a23de4a 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -538,5 +538,9 @@ CREATE TABLE `sys_client_pre_apply` ( alter table sys_accounts add COLUMN nation_code VARCHAR(5) DEFAULT NULL ; -ALTER TABLE `sys_client_pre_apply` - MODIFY COLUMN `agree` tinyint(1) DEFAULT 0; \ No newline at end of file +alter table sys_client_pre_apply add COLUMN `client_moniker` varchar(20) DEFAULT NULL COMMENT '客户简写识别码'; + +alter table sys_client_pre_apply modify COLUMN `agree` tinyint(1) DEFAULT 0; + + +insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`) values ( 'royalpayindustry.json', '[{"children":[{"children":[],"label":"机票","mccCode":"10001"},{"children":[],"label":"旅游行业","mccCode":"10002"},{"children":[],"label":"私人定制旅游","mccCode":"10003"},{"children":[],"label":"租车","mccCode":"10004"},{"children":[],"label":"巴士","mccCode":"10005"}],"label":"旅游出行","mccCode":"1"},{"children":[{"children":[],"label":"饭店","mccCode":"20001"},{"children":[],"label":"奶茶店","mccCode":"20002"},{"children":[],"label":"烧烤","mccCode":"20003"},{"children":[],"label":"火锅","mccCode":"20004"},{"children":[],"label":"Coffee","mccCode":"20005"},{"children":[],"label":"酒吧","mccCode":"20006"}],"label":"餐饮","mccCode":"2"},{"children":[{"children":[],"label":"培训类","mccCode":"30001"},{"children":[],"label":"移民留学","mccCode":"30002"},{"children":[],"label":"私人幼儿园","mccCode":"30003"}],"label":"教育","mccCode":"3"},{"children":[{"children":[],"label":"换汇","mccCode":"40001"},{"children":[],"label":"房产","mccCode":"40002"}],"label":"商务咨询","mccCode":"4"},{"children":[{"children":[],"label":"公众号服务商","mccCode":"50001"},{"children":[],"label":"各种媒体类宣传","mccCode":"50002"}],"label":"传媒","mccCode":"5","value":"{\"category\":\"SERVICE\",\"code\":\"7542\",\"description\":\"Car Washes\",\"parentCode\":\"S10\"}"},{"children":[{"children":[],"label":"美容院","mccCode":"60001"},{"children":[],"label":"医疗美容","mccCode":"60002"}],"label":"医美","mccCode":"6"},{"children":[{"label":"超市","mccCode":"70001"},{"children":[],"label":"服装店","mccCode":"70002"},{"children":[],"label":"鞋店","mccCode":"70003"},{"children":[],"label":"珠宝店","mccCode":"70004"},{"children":[],"label":"箱包","mccCode":"70005"}],"label":"零售","mccCode":"7"},{"children":[{"children":[],"label":"桌游吧","mccCode":"80001"},{"children":[],"label":"演唱会","mccCode":"80002"},{"children":[],"label":"马术训练","mccCode":"80003"},{"children":[],"label":"瑜伽","mccCode":"80004"},{"children":[],"label":"健身","mccCode":"80005"},{"children":[],"label":"社团","mccCode":"80006"},{"children":[],"label":"网吧","mccCode":"80007"},{"children":[],"label":"KTV","mccCode":"80008"},{"children":[],"label":"电影","mccCode":"80009"}],"label":"休闲娱乐","mccCode":"8"},{"children":[{"children":[],"label":"摄影","mccCode":"90001"},{"children":[],"label":"massage","mccCode":"90002"},{"children":[],"label":"通讯运营商","mccCode":"90003"},{"children":[],"label":"车行","mccCode":"90004"},{"children:":[],"label":"软件服务","mccCode":"90005"}],"label":"其他服务类","mccCode":"9"},{"children":[{"children":[],"label":"Hotel","mccCode":"100001"},{"children":[],"label":"Motel","mccCode":"100002"}],"label":"酒店","mccCode":"10"},{"children":[{"children":[],"label":"代购","mccCode":"110001"},{"children":[],"label":"物流(大宗出口贸易)","mccCode":"110002"},{"children":[],"label":"红酒出口","mccCode":"110003"},{"children":[],"label":"综合电商","mccCode":"110004"}],"label":"出口贸易","mccCode":"11"},{"children":[{"children":[],"label":"建材","mccCode":"120001"},{"children":[],"label":"家居","mccCode":"120002"}],"label":"家居建材","mccCode":"12"}]'); \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/beans/AreaMerchantTradeQueryBean.java b/src/main/java/au/com/royalpay/payment/manage/analysis/beans/AreaMerchantTradeQueryBean.java new file mode 100644 index 000000000..d4ec6ec0c --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/beans/AreaMerchantTradeQueryBean.java @@ -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; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/AreaMerchantTradeAnalysis.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/AreaMerchantTradeAnalysis.java new file mode 100644 index 000000000..791f273fc --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/AreaMerchantTradeAnalysis.java @@ -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; + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/AreaMerchantTradeAnalysisImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/AreaMerchantTradeAnalysisImpl.java new file mode 100644 index 000000000..f68b05a02 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/AreaMerchantTradeAnalysisImpl.java @@ -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 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 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 getAreaMerchantTradeAnalysis(JSONObject params, PageBounds pageBounds); } 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 99b8af194..5d070545f 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 @@ -72,4 +72,6 @@ public interface TransactionAnalysisMapper { int getCountCustomers(@Param("date") Date date); JSONObject getClientTransaction(JSONObject params); + + PageList getAreaMerchantAmountAnalysis(JSONObject params,PageBounds pagination); } diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/web/AreaMerchantTradeController.java b/src/main/java/au/com/royalpay/payment/manage/analysis/web/AreaMerchantTradeController.java new file mode 100644 index 000000000..e6735aaac --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/web/AreaMerchantTradeController.java @@ -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); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java b/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java index d1f3778ca..0a4d56048 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java @@ -13,6 +13,8 @@ public interface OrgManager { List listOrgsWithChid(JSONObject manager,OrgInfo orgInfo); + List listOrgAndChild(JSONObject manager); + JSONObject listAllOrgs(OrgInfo orgInfo,JSONObject manager); JSONObject getOrgDetail(int orgId,JSONObject manager); diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java index 003ead382..91dffda39 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java @@ -63,7 +63,25 @@ public class OrgManagerImpl implements OrgManager { return orgs; } - + @Override + public List listOrgAndChild(JSONObject manager) { + JSONObject params = new JSONObject(); + params.put("type",0); + List listOrgsByChild = orgMapper.listOrgsWithChid(params); + List listOrgs = orgMapper.listOrgsWithParent(params); + for(JSONObject org: listOrgs){ + List children = new ArrayList<>(); + for(JSONObject child:listOrgsByChild){ + if(child.getIntValue("parent_org_id") == org.getIntValue("org_id")){ + children.add(child); + } + } + if(children.size()> 0){ + org.put("children",children); + } + } + return listOrgs; + } @Override public JSONObject listAllOrgs(OrgInfo orgInfo,JSONObject manager) { diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java b/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java index f86ff0da7..0e35e8948 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java @@ -37,6 +37,12 @@ public class OrgManageController { return orgManager.listOrgsWithChid(manager,orgInfo); } + @RequestMapping(value = "/child",method = RequestMethod.GET) + @RequireManager + public List listOrgAndChild(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,OrgInfo orgInfo) { + return orgManager.listOrgAndChild(manager); + } + @RequestMapping(value = "/listsOrg", method = RequestMethod.GET) @RequireManager public JSONObject listsOrg(OrgInfo orgInfo,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml index 8ae13e128..e930ab947 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml @@ -354,4 +354,33 @@ #{org_id} + + + \ No newline at end of file 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 faf20b1d1..f065eda02 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 @@ -793,4 +793,35 @@ and l.org_id in #{org_id} + + + \ No newline at end of file diff --git a/src/main/ui/static/analysis/merchant_amount_analysis.js b/src/main/ui/static/analysis/merchant_amount_analysis.js new file mode 100644 index 000000000..c9a7984a0 --- /dev/null +++ b/src/main/ui/static/analysis/merchant_amount_analysis.js @@ -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; +}); \ No newline at end of file diff --git a/src/main/ui/static/analysis/templates/merchant_amount_analysis.html b/src/main/ui/static/analysis/templates/merchant_amount_analysis.html new file mode 100644 index 000000000..d937f16b8 --- /dev/null +++ b/src/main/ui/static/analysis/templates/merchant_amount_analysis.html @@ -0,0 +1,201 @@ + +
+
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ ~ +
+ +
+ +
+ Today +
+
+ Yesterday +
+ + +
+ +
+
+
+
+
+
+
+
+
+
+
+

List of Client

+ Excel +
+
+ + + + + + + + + + + + + + + + + + + +
Partner CodeShort nameBd nameStateAmount
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/src/main/ui/static/analysis/transaction/templates/analysis_transaction.html b/src/main/ui/static/analysis/transaction/templates/analysis_transaction.html index 65c373c1e..aaf4db977 100644 --- a/src/main/ui/static/analysis/transaction/templates/analysis_transaction.html +++ b/src/main/ui/static/analysis/transaction/templates/analysis_transaction.html @@ -31,6 +31,10 @@
  • 交易金额分析|Transaction Amount Analysis
  • + +
  • + 商户交易额 +