master
dulingling 4 years ago
commit 810d601455

@ -5,11 +5,11 @@
<parent> <parent>
<groupId>au.com.royalpay.payment</groupId> <groupId>au.com.royalpay.payment</groupId>
<artifactId>payment-parent</artifactId> <artifactId>payment-parent</artifactId>
<version>2.2.11</version> <version>2.2.12</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId> <artifactId>manage</artifactId>
<version>2.3.66</version> <version>2.3.67</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>2.4.0</jib-maven-plugin.version> <jib-maven-plugin.version>2.4.0</jib-maven-plugin.version>

@ -14,6 +14,7 @@ import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper; import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor; import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -21,6 +22,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.dom4j.Element; import org.dom4j.Element;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -52,7 +54,7 @@ public class AliforexcelServiceImpl implements AliforexcelService {
private WxPayClient wxPayClient; private WxPayClient wxPayClient;
@Resource @Resource
private SysWxMerchantApplyMapper sysWxMerchantApplyMapper; private SysWxMerchantApplyMapper sysWxMerchantApplyMapper;
private Logger logger = LoggerFactory.getLogger(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
@Resource @Resource
private RoyalThreadPoolExecutor royalThreadPoolExecutor; private RoyalThreadPoolExecutor royalThreadPoolExecutor;
@ -60,7 +62,7 @@ public class AliforexcelServiceImpl implements AliforexcelService {
@Override @Override
public JSONObject listClients(HttpServletResponse httpResponse, JSONObject manager, AliExcel query) { public JSONObject listClients(HttpServletResponse httpResponse, JSONObject manager, AliExcel query) {
OutputStream ous = null; OutputStream ous = null;
try { try (Workbook wb = new HSSFWorkbook()) {
JSONObject params = query.toJsonParam(); JSONObject params = query.toJsonParam();
List<JSONObject> partners = clientMapper.passPartners(params); List<JSONObject> partners = clientMapper.passPartners(params);
httpResponse.setContentType("application/octet-stream;"); httpResponse.setContentType("application/octet-stream;");
@ -69,7 +71,6 @@ public class AliforexcelServiceImpl implements AliforexcelService {
String codedFileName = java.net.URLEncoder.encode(fileName, "UTF-8"); String codedFileName = java.net.URLEncoder.encode(fileName, "UTF-8");
httpResponse.addHeader("Content-Disposition", "attachment; filename=" + codedFileName + query.getDatefrom() + "~" + query.getDateto() + ".xls"); httpResponse.addHeader("Content-Disposition", "attachment; filename=" + codedFileName + query.getDatefrom() + "~" + query.getDateto() + ".xls");
ous = httpResponse.getOutputStream(); ous = httpResponse.getOutputStream();
HSSFWorkbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("支付宝进件专用"); Sheet sheet = wb.createSheet("支付宝进件专用");
sheet.createFreezePane(1, 2); sheet.createFreezePane(1, 2);
sheet.setDefaultColumnWidth((short) 25); sheet.setDefaultColumnWidth((short) 25);
@ -103,6 +104,7 @@ public class AliforexcelServiceImpl implements AliforexcelService {
} catch (IOException e) { } catch (IOException e) {
logger.error(e.getMessage(), e);
} finally { } finally {
IOUtils.closeQuietly(ous); IOUtils.closeQuietly(ous);
} }
@ -167,7 +169,7 @@ public class AliforexcelServiceImpl implements AliforexcelService {
result.put("success_register_merchant", registerSuccessMerchant); result.put("success_register_merchant", registerSuccessMerchant);
result.put("fail_register_merchant", registerFailMerchant); result.put("fail_register_merchant", registerFailMerchant);
result.put("less_info_merchant", lessInfoMerchant); result.put("less_info_merchant", lessInfoMerchant);
logger.info("-------AlipayOnline Gms end----fail_register_merchant" + registerFailMerchant.toString()); logger.info("-------AlipayOnline Gms end----fail_register_merchant{}", registerFailMerchant.toString());
return result; return result;
} }
@ -188,7 +190,7 @@ public class AliforexcelServiceImpl implements AliforexcelService {
params.put("merchant_remark", client.getString("client_moniker")); params.put("merchant_remark", client.getString("client_moniker"));
params.put("website", client.getString("company_website")); params.put("website", client.getString("company_website"));
params.put("merchant_introduction", client.getString("short_name")); params.put("merchant_introduction", client.getString("short_name"));
SubMerchantInfo subMerchantInfo = JSONObject.toJavaObject(params, SubMerchantInfo.class); SubMerchantInfo subMerchantInfo = JSON.toJavaObject(params, SubMerchantInfo.class);
params.put("merchant_id", client.getString("merchant_id")); params.put("merchant_id", client.getString("merchant_id"));
params.put("client_id", client.getString("client_id")); params.put("client_id", client.getString("client_id"));
params.put("create_time", new Date()); params.put("create_time", new Date());
@ -204,7 +206,7 @@ public class AliforexcelServiceImpl implements AliforexcelService {
throw new BadRequestException(elem.elementText("return_msg")); throw new BadRequestException(elem.elementText("return_msg"));
} }
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e);
} }
}); });
}); });

@ -1,12 +1,8 @@
package au.com.royalpay.payment.manage.dev.web; package au.com.royalpay.payment.manage.dev.web;
import au.com.royalpay.payment.channels.alipay.config.AlipayEnvironment;
import au.com.royalpay.payment.channels.alipay.runtime.AlipayClient;
import au.com.royalpay.payment.channels.rpay.runtime.RpayClient;
import au.com.royalpay.payment.channels.wechat.runtime.WxPayClient;
import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.core.PaymentApi;
import au.com.royalpay.payment.core.PaymentDevHelper;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.exceptions.OrderNotExistsException;
import au.com.royalpay.payment.core.mappers.PmtCustomReportMapper; import au.com.royalpay.payment.core.mappers.PmtCustomReportMapper;
import au.com.royalpay.payment.manage.analysis.core.ATOReportService; import au.com.royalpay.payment.manage.analysis.core.ATOReportService;
import au.com.royalpay.payment.manage.analysis.core.DashboardService; import au.com.royalpay.payment.manage.analysis.core.DashboardService;
@ -31,31 +27,23 @@ import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import au.com.royalpay.payment.tools.utils.PdfUtils; import au.com.royalpay.payment.tools.utils.PdfUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils; import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import au.com.royalpay.payment.tools.utils.XmlFormatUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.dom4j.Element;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
@ -68,7 +56,6 @@ import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.net.URISyntaxException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
@ -81,7 +68,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/dev") @RequestMapping("/dev")
public class TestController { public class TestController {
private Logger logger = LoggerFactory.getLogger(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
@Resource @Resource
private OrderMapper orderMapper; private OrderMapper orderMapper;
@Resource @Resource
@ -103,12 +90,6 @@ public class TestController {
@Resource @Resource
private PaymentApi paymentApi; private PaymentApi paymentApi;
@Resource @Resource
private WxPayClient wxPayClient;
@Resource
private AlipayClient alipayClient;
@Resource
private RpayClient rpayClient;
@Resource
private TradeLogService tradeLogService; private TradeLogService tradeLogService;
@Resource @Resource
private RetailAppService retailAppService; private RetailAppService retailAppService;
@ -124,16 +105,13 @@ public class TestController {
private SysClientLegalPersonMapper sysClientLegalPersonMapper; private SysClientLegalPersonMapper sysClientLegalPersonMapper;
@Resource @Resource
private TradeSecureService tradeSecureService; private TradeSecureService tradeSecureService;
private final static String EMAIL = "lily.tao@royalpay.com.au,bella.sun@royalpay.com.au,astro.dai@royalpay.com.au,taylor.dang@royalpay.com.au";
@Resource @Resource
private DashboardService dashboardService; private DashboardService dashboardService;
@Resource @Resource
private SynchronizedScheduler synchronizedScheduler; private PaymentDevHelper paymentDevHelper;
@Resource @Resource
private PmtCustomReportMapper pmtCustomReportsMapper; private PmtCustomReportMapper pmtCustomReportsMapper;
@Resource
private MongoTemplate mongoTemplate;
@ManagerMapping(value = "/{clientMoniker}/export/agreepdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR}) @ManagerMapping(value = "/{clientMoniker}/export/agreepdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR})
public void exportAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, HttpServletResponse httpResponse) throws Exception { public void exportAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, HttpServletResponse httpResponse) throws Exception {
@ -268,7 +246,7 @@ public class TestController {
String orderChannel = StringUtils.defaultIfEmpty(order.getString("order_channel"), order.getString("channel")); String orderChannel = StringUtils.defaultIfEmpty(order.getString("order_channel"), order.getString("channel"));
paymentApi.checkOrderStatus(order.getString("order_id"), orderChannel, true); paymentApi.checkOrderStatus(order.getString("order_id"), orderChannel, true);
} catch (Exception e) { } catch (Exception e) {
logger.error("fix transaction error:" + order.getString("order_id")); logger.error("fix transaction error:{}", order.getString("order_id"));
} }
} }
@ -280,7 +258,7 @@ public class TestController {
String orderChannel = StringUtils.defaultIfEmpty(order.getString("order_channel"), order.getString("channel")); String orderChannel = StringUtils.defaultIfEmpty(order.getString("order_channel"), order.getString("channel"));
paymentApi.checkOrderStatus(order.getString("order_id"), orderChannel, true); paymentApi.checkOrderStatus(order.getString("order_id"), orderChannel, true);
} catch (Exception e) { } catch (Exception e) {
logger.error("fix transaction error:" + order.getString("order_id")); logger.error("fix transaction error:{}", order.getString("order_id"));
} }
} }
List<JSONObject> refunds = refundMapper.listConfirmedRefundsWithNoTransactions(); List<JSONObject> refunds = refundMapper.listConfirmedRefundsWithNoTransactions();
@ -290,71 +268,17 @@ public class TestController {
} }
@ManagerMapping(value = "/orders/{orderId}/detail", method = RequestMethod.GET, role = ManagerRole.DEVELOPER) @ManagerMapping(value = "/orders/{orderId}/detail", method = RequestMethod.GET, role = ManagerRole.DEVELOPER)
public JSONObject checkOrderDetail(@PathVariable String orderId) throws URISyntaxException, IOException { public JSONObject checkOrderDetail(@PathVariable String orderId) {
JSONObject order = orderMapper.find(orderId);
if (order == null) {
throw new OrderNotExistsException();
}
String channel = StringUtils.defaultIfEmpty(order.getString("order_channel"), order.getString("channel"));
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
switch (channel) { res.put("xml", paymentDevHelper.devCheckOrder(orderId));
case "Wechat":
Element elem = wxPayClient.checkOrderStatus(orderId, order.getString("merchant_id"), order.getString("sub_merchant_id"));
String xmlStr = XmlFormatUtils.formatXml(elem);
res.put("xml", xmlStr);
break;
case "Alipay":
elem = alipayClient.checkRetailOrderStatusByOrderId(orderId, AlipayEnvironment.getEnv().getAlipayRetailMerchant().getPid());
xmlStr = XmlFormatUtils.formatXml(elem);
res.put("xml", xmlStr);
break;
case "AlipayOnline":
elem = alipayClient.checkOnlineOrderStatusByOrderId(orderId, AlipayEnvironment.getEnv().getAlipayOnlineMerchant().getPid());
xmlStr = XmlFormatUtils.formatXml(elem);
res.put("xml", xmlStr);
break;
case "Rpay":
JSONObject orderInfo = rpayClient.queryOrderStatus(orderId);
String rpayjson = JSON.toJSONString(orderInfo, SerializerFeature.PrettyFormat);
res.put("xml", rpayjson);
break;
default:
throw new BadRequestException("Not Support channel:" + channel);
}
return res; return res;
} }
@ManagerMapping(value = "/order_refunds/{refundId}/detail", method = RequestMethod.GET, role = ManagerRole.DEVELOPER) @ManagerMapping(value = "/order_refunds/{refundId}/detail", method = RequestMethod.GET, role = ManagerRole.DEVELOPER)
public JSONObject checkRefundDetail(@PathVariable String refundId) { public JSONObject checkRefundDetail(@PathVariable String refundId) {
JSONObject refundOrder = refundMapper.findByOutRefundId(refundId);
if (refundOrder == null) {
throw new BadRequestException("退款单不存在");
}
JSONObject order = orderMapper.find(refundOrder.getString("order_id"));
Assert.notNull(order, "order not exists");
String channel = order.getString("order_channel");
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
TradeType type = TradeType.fromGatewayNumber(order.getIntValue("gateway")); res.put("xml", paymentDevHelper.devCheckRefund(refundId));
switch (channel) {
case "Wechat":
Element elem = wxPayClient.checkRefundStatus(refundId, order.getString("merchant_id"), order.getString("sub_merchant_id"));
String xml = XmlFormatUtils.formatXml(elem);
res.put("xml", xml);
break;
case "Alipay":
elem = alipayClient.retailRefund(type, refundOrder.getBigDecimal("refund_exchange_rate"), refundOrder, AlipayEnvironment.getEnv().getAlipayRetailMerchant().getPid());
String xmlStr = XmlFormatUtils.formatXml(elem);
res.put("xml", xmlStr);
break;
case "AlipayOnline":
elem = alipayClient.onlineRefund(refundOrder, AlipayEnvironment.getEnv().getAlipayOnlineMerchant().getPid(), type == TradeType.GATEWAY_H5);
xmlStr = XmlFormatUtils.formatXml(elem);
res.put("xml", xmlStr);
break;
default:
throw new BadRequestException("Not Support channel:" + channel);
}
return res; return res;
} }
@ -403,17 +327,6 @@ public class TestController {
clientManager.updateAllPartnerPassword("PINE"); clientManager.updateAllPartnerPassword("PINE");
} }
// @ManagerMapping(value = "/getPineAccoutPasswd", method = RequestMethod.GET, role = ManagerRole.DEVELOPER)
// public List<JSONObject> getPineAccountPasswd() {
// Query query = new Query();
// List<TestMerchantAccountInfo> accountInfos = mongoTemplate.find(query,TestMerchantAccountInfo.class);
// List<JSONObject> accounts = new ArrayList<>();
// for (TestMerchantAccountInfo accountInfo : accountInfos) {
// accounts.add(accountInfo.toJSON());
// }
// return accounts;
// }
@ManagerMapping(value = "/secure/hanyin_reports/{date}", role = ManagerRole.DEVELOPER, method = RequestMethod.GET) @ManagerMapping(value = "/secure/hanyin_reports/{date}", role = ManagerRole.DEVELOPER, method = RequestMethod.GET)
public void downloadHanyinSecureReports(@PathVariable String date, @RequestParam(defaultValue = "false") boolean upload, HttpServletResponse resp) { public void downloadHanyinSecureReports(@PathVariable String date, @RequestParam(defaultValue = "false") boolean upload, HttpServletResponse resp) {
tradeSecureService.manualDownloadHanyinSecureReport(DateTime.parse(date).toDate(), upload, resp); tradeSecureService.manualDownloadHanyinSecureReport(DateTime.parse(date).toDate(), upload, resp);
@ -530,20 +443,7 @@ public class TestController {
@ManagerMapping(value = "/custom_declare_check/{reportId}/detail", method = RequestMethod.GET, role = ManagerRole.DEVELOPER) @ManagerMapping(value = "/custom_declare_check/{reportId}/detail", method = RequestMethod.GET, role = ManagerRole.DEVELOPER)
public JSONObject checkCustomDeclareOrderDetail(@PathVariable String reportId) { public JSONObject checkCustomDeclareOrderDetail(@PathVariable String reportId) {
JSONObject report = pmtCustomReportsMapper.findCustomReport(reportId); String declareResp = paymentDevHelper.devQueryCustomsReport(reportId);
if (report == null || report.isEmpty()) {
throw new NotFoundException("Report Not Exists");
}
JSONObject order = orderMapper.find(report.getString("order_id"));
String declareResp;
if (StringUtils.equals("Wechat", report.getString("channel"))) {
declareResp = XmlFormatUtils.formatXml(wxPayClient.declareCustomQuery(order.getString("merchant_id"), report, null, false));
} else if (StringUtils.equals("Alipay", report.getString("channel"))) {
declareResp = XmlFormatUtils.formatXml(alipayClient.queryCustomStatus(order.getString("merchant_id"), report, null, false));
} else {
throw new BadRequestException("Invalid Channel:" + report.getString("channel"));
}
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
res.put("xml", declareResp); res.put("xml", declareResp);
return res; return res;
@ -585,18 +485,19 @@ public class TestController {
public void sendSecurePaySettleFile(@RequestParam String dateStr) { public void sendSecurePaySettleFile(@RequestParam String dateStr) {
tradeSecureService.sendSecurePaySettleFile(dateStr); tradeSecureService.sendSecurePaySettleFile(dateStr);
} }
@GetMapping(value = "/securepay/invoice/file") @GetMapping(value = "/securepay/invoice/file")
public void sendSecurePayInvoiceFile() { public void sendSecurePayInvoiceFile() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
//获取前一个月第一天 //获取前一个月第一天
Calendar calendar1 = Calendar.getInstance(); Calendar calendar1 = Calendar.getInstance();
calendar1.add(Calendar.MONTH, -1); calendar1.add(Calendar.MONTH, -1);
calendar1.set(Calendar.DAY_OF_MONTH,1); calendar1.set(Calendar.DAY_OF_MONTH, 1);
String firstDay = sdf.format(calendar1.getTime()); String firstDay = sdf.format(calendar1.getTime());
//获取前一个月最后一天 //获取前一个月最后一天
Calendar calendar2 = Calendar.getInstance(); Calendar calendar2 = Calendar.getInstance();
calendar2.set(Calendar.DAY_OF_MONTH, 0); calendar2.set(Calendar.DAY_OF_MONTH, 0);
String lastDay = sdf.format(calendar2.getTime()); String lastDay = sdf.format(calendar2.getTime());
tradeSecureService.sendSecurePayInvoiceFile(firstDay,lastDay); tradeSecureService.sendSecurePayInvoiceFile(firstDay, lastDay);
} }
} }

Loading…
Cancel
Save