diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java index b70e97a8f..490359c5a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java @@ -10,6 +10,7 @@ import au.com.royalpay.payment.channels.yeepay.runtime.YeePayClient; import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.OrderNotExistsException; +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.PlatformClearService; import au.com.royalpay.payment.manage.appclient.core.RetailAppService; @@ -25,6 +26,7 @@ import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.manage.pos.datasource.ReadOnlyConnection; import au.com.royalpay.payment.manage.system.core.TradeSecureService; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; import au.com.royalpay.payment.tools.CommonConsts; @@ -55,6 +57,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.util.Assert; +import org.springframework.util.MimeTypeUtils; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; @@ -65,8 +68,10 @@ import javax.validation.Valid; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.io.OutputStream; import java.math.BigDecimal; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; @@ -88,6 +93,8 @@ public class TestController implements ApplicationEventPublisherAware { @Resource private ClientMapper clientMapper; @Resource + private ATOReportService atoReportService; + @Resource private NotifyErrorLogMapper notifyErrorLogMapper; @Value("${app.agreetemplate.classic.path}") private String pdfPath; @@ -470,8 +477,8 @@ public class TestController implements ApplicationEventPublisherAware { } @ManagerMapping(value = "/register/alipayOnlineGms", role = ManagerRole.DEVELOPER, method = RequestMethod.GET) - public JSONObject registerRangeAlipayOnlineMerchant(@RequestParam int start,@RequestParam int end) { - return aliforexcelService.registerRangeAlipayOnlineMerchant(start,end); + public JSONObject registerRangeAlipayOnlineMerchant(@RequestParam int start, @RequestParam int end) { + return aliforexcelService.registerRangeAlipayOnlineMerchant(start, end); } @ManagerMapping(value = "/register/alipayGms", role = ManagerRole.DEVELOPER, method = RequestMethod.POST) @@ -495,8 +502,8 @@ public class TestController implements ApplicationEventPublisherAware { } @ManagerMapping(value = "/init/client_pay_type", role = ManagerRole.DEVELOPER, method = RequestMethod.GET) - public void initClientPayType(@RequestParam int begin,@RequestParam int end) { - aliforexcelService.initClientPayType(begin,end); + public void initClientPayType(@RequestParam int begin, @RequestParam int end) { + aliforexcelService.initClientPayType(begin, end); } @PutMapping(value = "/open/cb_bankpay") @@ -538,4 +545,17 @@ public class TestController implements ApplicationEventPublisherAware { }); } + @GetMapping("/reports/ato_reports/royalpay_ato_report_{year}.bttps") + @ReadOnlyConnection + public void downloadATOReport(@PathVariable String year, HttpServletResponse resp) throws IOException { + DateTime from = DateTime.parse(year + "-07-01"); + DateTime to = from.plusYears(1).plusDays(-1); + String atoReport = atoReportService.exportBTTPSFile(from.toDate(), to.toDate()); + resp.setContentType(MimeTypeUtils.APPLICATION_OCTET_STREAM_VALUE); + try (OutputStream out = resp.getOutputStream()) { + out.write(atoReport.getBytes(StandardCharsets.UTF_8)); + out.flush(); + } + } + }