From ebcac47ea02614adada50659a40546fe1e8de510 Mon Sep 17 00:00:00 2001 From: luoyang Date: Tue, 9 Jul 2019 11:08:58 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E8=87=AA=E5=8A=A9=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=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 --- pom.xml | 2 +- .../manage/merchants/core/ClientApply.java | 3 + .../merchants/core/impls/ClientApplyImpl.java | 182 ++++++++++++++---- .../merchants/web/PartnerApplyController.java | 14 +- .../templates/partner_application.html | 5 + 5 files changed, 163 insertions(+), 43 deletions(-) diff --git a/pom.xml b/pom.xml index 26c081eb6..c927011f5 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ UTF-8 1.1.2 - 1.1.11 + 1.1.12 diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientApply.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientApply.java index 68569df3b..76be422f8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientApply.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientApply.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.manage.merchants.beans.ClientApplyInfo; import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery; import com.alibaba.fastjson.JSONObject; +import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -40,4 +41,6 @@ public interface ClientApply { JSONObject findOrgByBDId(String bd_id); void notifyBD(String client_apply_id); + + void exportApplyPartnerList(JSONObject manager, HttpServletResponse response) throws Exception; } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientApplyImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientApplyImpl.java index 99b8288a4..2d9c07f5d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientApplyImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientApplyImpl.java @@ -27,6 +27,12 @@ import com.github.miemiedev.mybatis.paginator.domain.PageList; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.*; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; @@ -36,11 +42,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; +import java.io.OutputStream; +import java.math.BigDecimal; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; /** * Created by yishuqian on 18/10/2016. @@ -158,44 +167,44 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw JSONObject partner = info.insertObject(); - if (info.getClientMoniker()== null || info.getClientMoniker().isEmpty()){ + if (info.getClientMoniker() == null || info.getClientMoniker().isEmpty()) { throw new NotFoundException("clientMoniker can not be null"); } - if (info.getShortName() == null || info.getShortName().isEmpty()){ - partner.put("short_name","0"); + if (info.getShortName() == null || info.getShortName().isEmpty()) { + partner.put("short_name", "0"); } - if (!partner.containsKey("sector")){ - partner.put("sector","0"); + if (!partner.containsKey("sector")) { + partner.put("sector", "0"); } - if (!partner.containsKey("industry")){ - partner.put("industry","0"); + if (!partner.containsKey("industry")) { + partner.put("industry", "0"); } - if (info.getAddress() == null || info.getAddress().isEmpty()){ - partner.put("address","0"); + if (info.getAddress() == null || info.getAddress().isEmpty()) { + partner.put("address", "0"); } - if (info.getSuburb() == null || info.getSuburb().isEmpty()){ - partner.put("suburb","0"); + if (info.getSuburb() == null || info.getSuburb().isEmpty()) { + partner.put("suburb", "0"); } - if (info.getPostcode() == null || info.getPostcode().isEmpty()){ - partner.put("postcode","0"); + if (info.getPostcode() == null || info.getPostcode().isEmpty()) { + partner.put("postcode", "0"); } - if (info.getState() == null || info.getState().isEmpty()){ - partner.put("state","0"); + if (info.getState() == null || info.getState().isEmpty()) { + partner.put("state", "0"); } - if (info.getCountry() == null || info.getCountry().isEmpty()){ - partner.put("county","AUS"); + if (info.getCountry() == null || info.getCountry().isEmpty()) { + partner.put("county", "AUS"); } - if (info.getCompanyPhone()== null || info.getCompanyPhone().isEmpty()){ - partner.put("company_phone","0"); + if (info.getCompanyPhone() == null || info.getCompanyPhone().isEmpty()) { + partner.put("company_phone", "0"); } - if (info.getContactPerson() == null || info.getContactPerson().isEmpty()){ - partner.put("contact_person","0"); + if (info.getContactPerson() == null || info.getContactPerson().isEmpty()) { + partner.put("contact_person", "0"); } - if (info.getContactEmail() == null || info.getContactEmail().isEmpty()){ - partner.put("contact_email","0"); + if (info.getContactEmail() == null || info.getContactEmail().isEmpty()) { + partner.put("contact_email", "0"); } - if (partner.containsKey("remark")){ + if (partner.containsKey("remark")) { partner.remove("remark"); } @@ -212,9 +221,9 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw if (clientMapper.findClientByMoniker(info.getClientMoniker()) != null) { throw new BadRequestException("error.partner.valid.dumplicate_client_moniker"); } - partner.put("source",2);//自主申请 - partner.put("country","AUS");//自主申请 - partner.put("ali_sub_merchant_id",info.getClientMoniker()); + partner.put("source", 2);//自主申请 + partner.put("country", "AUS");//自主申请 + partner.put("ali_sub_merchant_id", info.getClientMoniker()); clientMapper.save(partner); JSONObject clientConfig = new JSONObject(); @@ -222,8 +231,8 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw clientConfig.put("client_pay_type", apply.getString("client_pay_type")); clientConfig.put("client_pay_desc", apply.getString("client_pay_desc")); } - clientConfig.put("client_id",partner.getIntValue("client_id")); - clientConfig.put("client_moniker",info.getClientMoniker()); + clientConfig.put("client_id", partner.getIntValue("client_id")); + clientConfig.put("client_moniker", info.getClientMoniker()); clientConfigService.save(clientConfig); JSONObject client_bd = new JSONObject(); @@ -251,12 +260,12 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw Assert.notNull(apply); - if (info.getClientMoniker()== null || info.getClientMoniker().isEmpty()){ + if (info.getClientMoniker() == null || info.getClientMoniker().isEmpty()) { throw new NotFoundException("clientMoniker can not be null"); } JSONObject client = clientMapper.findClientByMoniker(info.getClientMoniker()); Assert.notNull(client); - clientModifySupport.processClientModify(new SourceModify(manager,client.getString("client_moniker"),2)); + clientModifySupport.processClientModify(new SourceModify(manager, client.getString("client_moniker"), 2)); apply.put("client_id", client.getIntValue("client_id")); apply.put("client_moniker", info.getClientMoniker()); apply.put("apply_approve_result", 2); @@ -269,8 +278,8 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw JSONObject account = clientAccountMapper.findById(accountId); Assert.notNull(account); JSONObject updateObj = new JSONObject(); - updateObj.put("account_id",accountId); - updateObj.put("remark",remark); + updateObj.put("account_id", accountId); + updateObj.put("remark", remark); clientAccountMapper.update(updateObj); } @@ -292,7 +301,7 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw @Override public void notifyBD(String client_apply_id) { JSONObject client = clientApplyMapper.findClientApplicationById(client_apply_id); - publisher.publishEvent(new ClientApplyNotifyBDEvent(this,client)); + publisher.publishEvent(new ClientApplyNotifyBDEvent(this, client)); } @@ -300,4 +309,109 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { this.publisher = applicationEventPublisher; } + + @Override + public void exportApplyPartnerList(JSONObject manager, HttpServletResponse resp) throws Exception{ + PartnerQuery partnerQuery = new PartnerQuery(); + JSONObject params = partnerQuery.toJsonParam(); + if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) { + params.put("bd_user", manager.getString("manager_id")); + } + OutputStream ous = null; + resp.setContentType("application/octet-stream;"); + resp.addHeader("Content-Disposition", "attachment; filename=" + "apply_partner_list.xls"); + ous = resp.getOutputStream(); + HSSFWorkbook wb = new HSSFWorkbook(); + Cell cell = null; + HSSFFont font = wb.createFont(); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); + font.setFontHeightInPoints((short) 10); + CellStyle titleStyle = wb.createCellStyle(); + titleStyle.setFont(font); + HSSFCellStyle style = wb.createCellStyle(); + style.setFillForegroundColor(HSSFColor.RED.index); + style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); + PageList partners = clientApplyMapper.listPartnerApplications(params, new PageBounds(Order.formString("apply_approve_result.asc,create_time.desc"))); + Sheet sheet = wb.createSheet("apply_partner_list"); + sheet.setDefaultColumnWidth(20); + int rowNum = 0; + Row row = sheet.createRow(rowNum); + String[] CommissionTitle = {"Application Time", "Client Moniker", "Company Name", "Short Name", "Contact Person" , "Contact Phone", "Contact Email", "Country","State", "Suburb", "Address", "Company Phone", "Company Website", "Progress", "BD", "Apply Approve Result", "Source"}; + for (int i = 0; i < CommissionTitle.length; i++) { + cell = row.createCell(i, Cell.CELL_TYPE_STRING); + cell.setCellStyle(titleStyle); + cell.setCellValue(CommissionTitle[i]); + } + for (JSONObject partner : partners) { + row = sheet.createRow(++rowNum); + String type = ""; + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(DateFormatUtils.format(partner.getDate("create_time"),"yyyy-MM-dd HH:mm:ss")); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("client_moniker")); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("company_name")); + row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("short_name")); + row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("contact_person")); + row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("contact_phone")); + row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("contact_email")); + row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("country")); + row.createCell(8, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("state")); + row.createCell(9, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("suburb")); + row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("address")); + row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("company_phone")); + row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("company_website")); + row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("remark")); + row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("bd_user_name")); + row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(getApplyResultStatus(partner.getIntValue("apply_approve_result"))); + row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(getSource(partner.getIntValue("apply_approve_result"))); + } + wb.write(ous); + ous.flush(); + } + + public String getApplyResultStatus(int result) { + String status = ""; + switch (result) { + case 0: + status = "待审核"; + break; + case 1: + status = "已提交BD"; + break; + case 2: + status = "BD已通过"; + break; + case 3: + status = "初审拒绝"; + break; + case 4: + status = "BD提交后不通过"; + break; + default: + status = "待审核"; + break; + } + return status; + } + + public String getSource(int result) { + String status = ""; + switch (result) { + case 0: + status = "PC"; + break; + case 1: + status = "公众号菜单"; + break; + case 2: + status = "公众号推送"; + break; + case 3: + status = "小程序申请"; + break; + default: + status = "PC"; + break; + } + return status; + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerApplyController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerApplyController.java index ea9f41539..cf33bad9b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerApplyController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerApplyController.java @@ -18,13 +18,7 @@ import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.validation.Errors; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import java.awt.image.BufferedImage; @@ -164,5 +158,9 @@ public class PartnerApplyController { return clientApply.listBDByOrg(org_id); } - + @RequestMapping(value = "/export_xls", method = RequestMethod.GET) + public void exportApplyPartnerList(HttpServletResponse httpResponse, + @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) throws Exception{ + clientApply.exportApplyPartnerList(manager, httpResponse); + } } diff --git a/src/main/ui/static/payment/partner/templates/partner_application.html b/src/main/ui/static/payment/partner/templates/partner_application.html index 5541bd35e..63ac128bd 100644 --- a/src/main/ui/static/payment/partner/templates/partner_application.html +++ b/src/main/ui/static/payment/partner/templates/partner_application.html @@ -14,6 +14,11 @@ +