From 80ead71db4df7b32ac1ad1c1471465f7a27de1a8 Mon Sep 17 00:00:00 2001 From: Todking Date: Tue, 11 Jan 2022 14:26:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?add=20a+kyc=E9=80=9A=E7=9F=A5=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=A1=A8=E6=A0=BC=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ApsNoticeClientRepository.java | 3 + .../service/ApsNoticeClientsService.java | 5 + .../Impl/ApsNoticeClientsServiceImpl.java | 174 ++++++++++++++++++ .../ApsNoticeClientRepositoryImpl.java | 6 + .../apsKYC/web/RestApsKYCController.java | 13 ++ .../mappers/apskyc/ApsNoticeClientMapper.java | 3 + .../mappers/apskyc/ApsNoticeClientMapper.xml | 9 + src/main/ui/static/apsKYC/aps_kyc.js | 7 + .../ui/static/apsKYC/templates/aps_kyc.html | 22 +-- 9 files changed, 231 insertions(+), 11 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/repository/ApsNoticeClientRepository.java b/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/repository/ApsNoticeClientRepository.java index b15062316..6e10f4f1e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/repository/ApsNoticeClientRepository.java +++ b/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/repository/ApsNoticeClientRepository.java @@ -6,6 +6,7 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; import java.util.Date; +import java.util.List; public interface ApsNoticeClientRepository { void saveApsNoticeClient(ApsNoticeClient apsNoticeClient); @@ -17,4 +18,6 @@ public interface ApsNoticeClientRepository { void updateApsNoticeClientByPartnerCode(Date modifyTime, String modifier, String partnerCode); ApsNoticeClient getApsNoticeClientById(String id); + + List apsNoticeClients(String id, String clientStatus); } diff --git a/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/service/ApsNoticeClientsService.java b/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/service/ApsNoticeClientsService.java index 9722b87d9..09ac8ef61 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/service/ApsNoticeClientsService.java +++ b/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/service/ApsNoticeClientsService.java @@ -4,6 +4,11 @@ import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + public interface ApsNoticeClientsService { PageList getApsNoticeClients(String id, String clientStatus, PageBounds pageBounds); + + void exportApsNoticeClients(String id, String clientStatus, HttpServletRequest request, HttpServletResponse response); } diff --git a/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/service/Impl/ApsNoticeClientsServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/service/Impl/ApsNoticeClientsServiceImpl.java index df18b6421..e3c9d6e97 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/service/Impl/ApsNoticeClientsServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/apsKYC/domain/service/Impl/ApsNoticeClientsServiceImpl.java @@ -1,18 +1,34 @@ package au.com.royalpay.payment.manage.apsKYC.domain.service.Impl; +import au.com.royalpay.payment.manage.apsKYC.domain.entity.ApsNotice; +import au.com.royalpay.payment.manage.apsKYC.domain.entity.ApsNoticeClient; import au.com.royalpay.payment.manage.apsKYC.domain.repository.ApsNoticeClientRepository; import au.com.royalpay.payment.manage.apsKYC.domain.service.ApsNoticeClientsService; +import au.com.royalpay.payment.manage.mappers.apskyc.ApsNoticeMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; +import com.alibaba.fastjson.JSON; 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.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.xssf.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.OutputStream; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; @Service @@ -30,6 +46,9 @@ public class ApsNoticeClientsServiceImpl implements ApsNoticeClientsService { @Autowired private ClientAccountMapper clientAccountMapper; + @Autowired + private ApsNoticeMapper apsNoticeMapper; + @Override public PageList getApsNoticeClients(String id, String clientStatus, PageBounds pageBounds) { PageList apsNoticeClients = apsNoticeClientRepository.getApsNoticeClients(id, clientStatus, pageBounds); @@ -57,4 +76,159 @@ public class ApsNoticeClientsServiceImpl implements ApsNoticeClientsService { } return apsNoticeClients; } + + @Override + public void exportApsNoticeClients(String id, String clientStatus, HttpServletRequest request, HttpServletResponse response) { + List apsNoticeClients = apsNoticeClientRepository.apsNoticeClients(id, clientStatus); + + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + OutputStream os = null; + XSSFWorkbook xWorkbook = null; + + try { + ApsNotice apsNotice = apsNoticeMapper.getApsNoticesById(id); + String fileName = apsNotice.getTitle() + "(" + df.format(new Date()) + ").xlsx"; + os = response.getOutputStream(); + response.reset(); + response.setHeader("Content-disposition", "attachment; filename = " + URLEncoder.encode(fileName, "UTF-8")); + response.setContentType("application/octet-streem"); + + //创建表格工作空间 + xWorkbook = new XSSFWorkbook(); + //创建一个新表格 + XSSFSheet xSheet = xWorkbook.createSheet("商户列表"); + //set Sheet页头部 + setSheetHeader(xWorkbook, xSheet); + //set Sheet页内容 + setSheetContent(xWorkbook, xSheet, apsNoticeClients); + xWorkbook.write(os); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (null != os) { + try { + os.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (null != xWorkbook) { + try { + xWorkbook.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + private void setSheetContent(XSSFWorkbook xWorkbook, XSSFSheet xSheet, List apsNoticeClients) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + //创建内容样式(头部以下的样式) + CellStyle cs = xWorkbook.createCellStyle(); + cs.setWrapText(true); + + //设置水平垂直居中 + cs.setAlignment(CellStyle.ALIGN_CENTER); + cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + + if (null != apsNoticeClients && apsNoticeClients.size() > 0) { + for (int i = 0; i < apsNoticeClients.size(); i++) { + XSSFRow xRow = xSheet.createRow(i + 1); + //设置第一列 + XSSFCell xCell0 = xRow.createCell(0); + xCell0.setCellStyle(cs); + xCell0.setCellValue(apsNoticeClients.get(i).getPartnerCode()); + //设置第二列 + XSSFCell xCell1 = xRow.createCell(1); + xCell1.setCellStyle(cs); + JSONObject clinet = clientMapper.findClientByMoniker(apsNoticeClients.get(i).getPartnerCode()); + if (clinet != null && clinet.containsKey("bd_user_name") && StringUtils.isNotBlank(clinet.getString("bd_user_name"))) { + xCell1.setCellValue(clinet.getString("bd_user_name")); + } else { + xCell1.setCellValue("未配置BD"); + } + //设置第三列 + XSSFCell xCell2 = xRow.createCell(2); + xCell2.setCellStyle(cs); + xCell2.setCellValue(apsNoticeClients.get(i).getStatus()); + String userName = "未知"; + if (StringUtils.isNotBlank(apsNoticeClients.get(i).getUserId())) { + if (!apsNoticeClients.get(i).getUserId().equals("0")) { + JSONObject user = clientAccountMapper.findDetail(apsNoticeClients.get(i).getUserId()); + if (user != null) { + userName = user.getString("username"); + } + } + switch (apsNoticeClients.get(i).getStatus()) { + case 0: + xCell2.setCellValue("未读"); + case 1: + xCell2.setCellValue("已读(" + userName + ":" + df.format(apsNoticeClients.get(i).getReadTime()) + ")"); + case 2: + xCell2.setCellValue("同意(" + userName + ":" + df.format(apsNoticeClients.get(i).getStatusTime()) + ")"); + case 3: + xCell2.setCellValue("拒绝(" + userName + ":" + df.format(apsNoticeClients.get(i).getStatusTime()) + ")"); + } + //设置第四列 + XSSFCell xCell3 = xRow.createCell(3); + xCell3.setCellStyle(cs); + switch (apsNoticeClients.get(i).getHandle()) { + case 0: + xCell3.setCellValue("未处理"); + case 1: + if (StringUtils.isNotBlank(apsNoticeClients.get(i).getModifier())) { + JSONObject modifier = managerMapper.findDetail(apsNoticeClients.get(i).getModifier()); + if (modifier != null) { + xCell3.setCellValue("已处理(" + modifier.getString("username") + ":" + df.format(apsNoticeClients.get(i).getModifyTime()) + ")"); + } else { + xCell3.setCellValue("已处理(未知用户:" + df.format(apsNoticeClients.get(i).getModifyTime()) + ")"); + } + } + } + } + } + } + } + + private void setSheetHeader(XSSFWorkbook xWorkbook, XSSFSheet xSheet) { + //设置表格的宽度 xSheet.setColumnWidth(0, 20 * 256); 中的数字 20 自行设置为自己适用的 + xSheet.setColumnWidth(0, 10 * 256); + xSheet.setColumnWidth(1, 30 * 256); + xSheet.setColumnWidth(2, 40 * 256); + xSheet.setColumnWidth(3, 40 * 256); + //创建表格的样式 + CellStyle cs = xWorkbook.createCellStyle(); + //设置水平、垂直居中 + cs.setAlignment(CellStyle.ALIGN_CENTER); + cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + //设置字体 + Font headerFont = xWorkbook.createFont(); + headerFont.setFontHeightInPoints((short) 12); + /*headerFont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);*/ + headerFont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); + headerFont.setFontName("宋体"); + cs.setFont(headerFont); + cs.setWrapText(true);//是否自动换行 + + //创建一行 + XSSFRow xRow0 = xSheet.createRow(0); + //设置每一列 + XSSFCell xCell0 = xRow0.createCell(0); + xCell0.setCellStyle(cs); + xCell0.setCellValue("商户名称"); + + XSSFCell xCell1 = xRow0.createCell(1); + xCell1.setCellStyle(cs); + xCell1.setCellValue("所属BD"); + + XSSFCell xCell2 = xRow0.createCell(2); + xCell2.setCellStyle(cs); + xCell2.setCellValue("商户操作状态"); + + XSSFCell xCell3 = xRow0.createCell(3); + xCell3.setCellStyle(cs); + xCell3.setCellValue("运营操作状态"); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/apsKYC/infrastructure/repository/ApsNoticeClientRepositoryImpl.java b/src/main/java/au/com/royalpay/payment/manage/apsKYC/infrastructure/repository/ApsNoticeClientRepositoryImpl.java index 7ec2184a6..6205defaf 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apsKYC/infrastructure/repository/ApsNoticeClientRepositoryImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/apsKYC/infrastructure/repository/ApsNoticeClientRepositoryImpl.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import java.util.Date; +import java.util.List; @Repository public class ApsNoticeClientRepositoryImpl implements ApsNoticeClientRepository { @@ -41,4 +42,9 @@ public class ApsNoticeClientRepositoryImpl implements ApsNoticeClientRepository public ApsNoticeClient getApsNoticeClientById(String id) { return mapper.getApsNoticeClientById(id); } + + @Override + public List apsNoticeClients(String id, String clientStatus) { + return mapper.apsNoticeClients(id, clientStatus); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/apsKYC/web/RestApsKYCController.java b/src/main/java/au/com/royalpay/payment/manage/apsKYC/web/RestApsKYCController.java index af25f4059..e471002e4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apsKYC/web/RestApsKYCController.java +++ b/src/main/java/au/com/royalpay/payment/manage/apsKYC/web/RestApsKYCController.java @@ -15,6 +15,8 @@ import com.github.miemiedev.mybatis.paginator.domain.PageList; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; @RestController @RequestMapping(value = "/aps/kyc") @@ -101,4 +103,15 @@ public class RestApsKYCController { public void updateApsNoticeClient(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody ApsNoticeClient apsNoticeClient) { apsNoticeService.updateApsNoticeClient(manager, apsNoticeClient); } + + /** + * 导出商户名单 + * + * @param id + * @param clientStatus + */ + @ManagerMapping(value = "/notice/clients/excel", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.SALES_MANAGER}) + public void exportApsNoticeClients(@RequestParam String id, @RequestParam(required = false) String clientStatus, HttpServletRequest request, HttpServletResponse response) throws Exception { + apsNoticeClientsService.exportApsNoticeClients(id, clientStatus, request, response); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/apskyc/ApsNoticeClientMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/apskyc/ApsNoticeClientMapper.java index d761dc23b..026ac85b6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/apskyc/ApsNoticeClientMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/apskyc/ApsNoticeClientMapper.java @@ -10,6 +10,7 @@ import com.yixsoft.support.mybatis.autosql.annotations.SqlType; import org.apache.ibatis.annotations.Param; import java.util.Date; +import java.util.List; @AutoMapper(tablename = "sys_aps_notice_clients", pkName = "id") public interface ApsNoticeClientMapper { @@ -31,4 +32,6 @@ public interface ApsNoticeClientMapper { @AutoSql(SqlType.UPDATE) void toUpdateApsKycClient(JSONObject updateReadTime); + + List apsNoticeClients(String id, String clientStatus); } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/apskyc/ApsNoticeClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/apskyc/ApsNoticeClientMapper.xml index 5f387d033..2bbbbd0f5 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/apskyc/ApsNoticeClientMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/apskyc/ApsNoticeClientMapper.xml @@ -31,5 +31,14 @@ AND c.is_valid = 0 AND c.handle = 0 + diff --git a/src/main/ui/static/apsKYC/aps_kyc.js b/src/main/ui/static/apsKYC/aps_kyc.js index efbca9970..103897614 100644 --- a/src/main/ui/static/apsKYC/aps_kyc.js +++ b/src/main/ui/static/apsKYC/aps_kyc.js @@ -54,6 +54,13 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) { that.loadApsNoticeClients(page); } }; + that.download = function () { + var url = "/aps/kyc/notice/clients/excel?id=" + that.clientId + if (that.clientStatus != -1) { + url = url + "&clientStatus=" + that.clientStatus + } + return url; + } that.getNoticeClients = function (title, id, page, index) { that.selectIndex = index that.showClients = true diff --git a/src/main/ui/static/apsKYC/templates/aps_kyc.html b/src/main/ui/static/apsKYC/templates/aps_kyc.html index 374ee55a6..1f139cfdf 100644 --- a/src/main/ui/static/apsKYC/templates/aps_kyc.html +++ b/src/main/ui/static/apsKYC/templates/aps_kyc.html @@ -90,17 +90,17 @@