|
|
|
@ -1,12 +1,8 @@
|
|
|
|
|
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.PaymentDevHelper;
|
|
|
|
|
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.manage.analysis.core.ATOReportService;
|
|
|
|
|
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.connections.mpsupport.MpWechatApi;
|
|
|
|
|
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.exceptions.BadRequestException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
|
|
|
|
|
import au.com.royalpay.payment.tools.http.HttpUtils;
|
|
|
|
|
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
|
|
|
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.TimeZoneUtils;
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.XmlFormatUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.dom4j.Element;
|
|
|
|
|
import org.joda.time.DateTime;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.validation.Errors;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
@ -68,7 +56,6 @@ import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
@ -81,7 +68,7 @@ import java.util.List;
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/dev")
|
|
|
|
|
public class TestController {
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
@Resource
|
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
|
@Resource
|
|
|
|
@ -103,12 +90,6 @@ public class TestController {
|
|
|
|
|
@Resource
|
|
|
|
|
private PaymentApi paymentApi;
|
|
|
|
|
@Resource
|
|
|
|
|
private WxPayClient wxPayClient;
|
|
|
|
|
@Resource
|
|
|
|
|
private AlipayClient alipayClient;
|
|
|
|
|
@Resource
|
|
|
|
|
private RpayClient rpayClient;
|
|
|
|
|
@Resource
|
|
|
|
|
private TradeLogService tradeLogService;
|
|
|
|
|
@Resource
|
|
|
|
|
private RetailAppService retailAppService;
|
|
|
|
@ -124,16 +105,13 @@ public class TestController {
|
|
|
|
|
private SysClientLegalPersonMapper sysClientLegalPersonMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
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
|
|
|
|
|
private DashboardService dashboardService;
|
|
|
|
|
@Resource
|
|
|
|
|
private SynchronizedScheduler synchronizedScheduler;
|
|
|
|
|
private PaymentDevHelper paymentDevHelper;
|
|
|
|
|
@Resource
|
|
|
|
|
private PmtCustomReportMapper pmtCustomReportsMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private MongoTemplate mongoTemplate;
|
|
|
|
|
|
|
|
|
|
@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 {
|
|
|
|
@ -268,7 +246,7 @@ public class TestController {
|
|
|
|
|
String orderChannel = StringUtils.defaultIfEmpty(order.getString("order_channel"), order.getString("channel"));
|
|
|
|
|
paymentApi.checkOrderStatus(order.getString("order_id"), orderChannel, true);
|
|
|
|
|
} 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"));
|
|
|
|
|
paymentApi.checkOrderStatus(order.getString("order_id"), orderChannel, true);
|
|
|
|
|
} 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();
|
|
|
|
@ -290,71 +268,17 @@ public class TestController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ManagerMapping(value = "/orders/{orderId}/detail", method = RequestMethod.GET, role = ManagerRole.DEVELOPER)
|
|
|
|
|
public JSONObject checkOrderDetail(@PathVariable String orderId) throws URISyntaxException, IOException {
|
|
|
|
|
JSONObject order = orderMapper.find(orderId);
|
|
|
|
|
if (order == null) {
|
|
|
|
|
throw new OrderNotExistsException();
|
|
|
|
|
}
|
|
|
|
|
String channel = StringUtils.defaultIfEmpty(order.getString("order_channel"), order.getString("channel"));
|
|
|
|
|
public JSONObject checkOrderDetail(@PathVariable String orderId) {
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
switch (channel) {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
res.put("xml", paymentDevHelper.devCheckOrder(orderId));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ManagerMapping(value = "/order_refunds/{refundId}/detail", method = RequestMethod.GET, role = ManagerRole.DEVELOPER)
|
|
|
|
|
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();
|
|
|
|
|
TradeType type = TradeType.fromGatewayNumber(order.getIntValue("gateway"));
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
res.put("xml", paymentDevHelper.devCheckRefund(refundId));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -403,17 +327,6 @@ public class TestController {
|
|
|
|
|
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)
|
|
|
|
|
public void downloadHanyinSecureReports(@PathVariable String date, @RequestParam(defaultValue = "false") boolean upload, HttpServletResponse 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)
|
|
|
|
|
public JSONObject checkCustomDeclareOrderDetail(@PathVariable String reportId) {
|
|
|
|
|
JSONObject report = pmtCustomReportsMapper.findCustomReport(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"));
|
|
|
|
|
}
|
|
|
|
|
String declareResp = paymentDevHelper.devQueryCustomsReport(reportId);
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
res.put("xml", declareResp);
|
|
|
|
|
return res;
|
|
|
|
@ -585,18 +485,19 @@ public class TestController {
|
|
|
|
|
public void sendSecurePaySettleFile(@RequestParam String dateStr) {
|
|
|
|
|
tradeSecureService.sendSecurePaySettleFile(dateStr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/securepay/invoice/file")
|
|
|
|
|
public void sendSecurePayInvoiceFile() {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
//获取前一个月第一天
|
|
|
|
|
Calendar calendar1 = Calendar.getInstance();
|
|
|
|
|
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());
|
|
|
|
|
//获取前一个月最后一天
|
|
|
|
|
Calendar calendar2 = Calendar.getInstance();
|
|
|
|
|
calendar2.set(Calendar.DAY_OF_MONTH, 0);
|
|
|
|
|
String lastDay = sdf.format(calendar2.getTime());
|
|
|
|
|
tradeSecureService.sendSecurePayInvoiceFile(firstDay,lastDay);
|
|
|
|
|
tradeSecureService.sendSecurePayInvoiceFile(firstDay, lastDay);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|