Merge remote-tracking branch 'origin/develop' into develop

master
yixian 5 years ago
commit 61d247a7e2

@ -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;
}

@ -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<JSONObject> 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;
}
}

@ -164,5 +164,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);
}
}

@ -689,8 +689,8 @@
COUNT(DISTINCT o.customer_id) AS customers,
o.channel AS channel,
ifnull(SUM(if(t.transaction_type = 'Credit', t.clearing_amount, 0)), 0) AS total,
ifnull(SUM(if(t.refund_id>0, t.clearing_amount, 0)), 0) AS refund_amount,
SUM(if(t.refund_id>0, 1, 0)) AS refund_orders,
ifnull(SUM(if(t.transaction_type = 'Debit', t.clearing_amount, 0)), 0) AS refund_amount,
SUM(if(t.transaction_type = 'Debit', 1, 0)) AS refund_orders,
round(SUM(if(t.transaction_type='Credit',t.clearing_amount,0))/COUNT(DISTINCT o.customer_id),2) single_amount
FROM pmt_transactions t
INNER JOIN pmt_orders o ON o.order_id = t.order_id

@ -14,6 +14,11 @@
<button class="btn btn-primary" type="button" ng-click="loadPartners(1)"><i
class="fa fa-search"></i></button>
</div>
<div class="form-group" style="float: right">
<a role="button" class="btn-group btn btn-warning"
type="button" ng-href="/partners/application/export_xls" target="_blank"><i
class="fa fa-download"></i>自助申请商户导出</a>
</div>
</div>
</div>

Loading…
Cancel
Save