From 470f5d191e959bdc87707b6fb41a12f63e47ba7a Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Wed, 18 Apr 2018 19:21:30 +0800 Subject: [PATCH 01/15] fix add app invoice --- .../manage/appclient/core/RetailAppService.java | 2 ++ .../core/impls/RetailAppServiceImp.java | 16 ++++++++++++++++ .../appclient/web/RetailAppController.java | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index c8b5c2ee4..ae43c17d5 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; +import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; @@ -125,4 +126,5 @@ public interface RetailAppService { void changeSurchargeEnable(JSONObject device, UpdateSurchargeDTO updateSurchargeDTO); + JSONObject getInvoiceData(JSONObject device, AppQueryBean appQueryBean) throws Exception; } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 00bd95bb3..872a15a71 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -252,6 +252,22 @@ public class RetailAppServiceImp implements RetailAppService { merchantInfoProvider.changeSurchargeEnable(device,updateSurchargeDTO); } + @Override + public JSONObject getInvoiceData(JSONObject device, AppQueryBean appQueryBean) throws Exception { + String clientType = device.getString("client_type"); + deviceSupport.findRegister(clientType); + int client_id = device.getIntValue("client_id") ; + JSONObject client = clientManager.getClientInfo(client_id); + String timezone = client.getString("timezone"); + appQueryBean.setTimezone(timezone); + JSONObject params = appQueryBean.toParams(); + setAllClientIds(params, client_id); + clientManager.validateClients(client_id, params); + params.put("client_id", client_id); + JSONObject analysis = transactionMapper.analysisTransFlow(params); + return analysis; + } + @Override public void updateClient(JSONObject device, AppClientBean appClientBean) { String clientType = device.getString("client_type"); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index c809d3c40..31ca40aa1 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -15,6 +15,7 @@ import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; import au.com.royalpay.payment.manage.system.core.ClientContractService; +import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.device.advise.AppClientController; import au.com.royalpay.payment.tools.exceptions.BadRequestException; @@ -450,4 +451,9 @@ public class RetailAppController { public void changeQRCodePaySurCharge(@ModelAttribute(RETAIL_DEVICE) JSONObject device, @RequestBody UpdateSurchargeDTO updateSurchargeDTO) { retailAppService.changeSurchargeEnable(device, updateSurchargeDTO); } + + @RequestMapping(value = "/invoice",method = RequestMethod.GET) + public JSONObject getInvoiceData(@ModelAttribute(RETAIL_DEVICE) JSONObject device,AppQueryBean appQueryBean) throws Exception { + return retailAppService.getInvoiceData(device,appQueryBean); + } } From 3f4a2cf9a6839f7b92d941d476d55ee1af1b77e7 Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Fri, 20 Apr 2018 12:09:09 +0800 Subject: [PATCH 02/15] fix partner invoice + settlement log tip --- src/db/modify.sql | 12 ++++++++++ .../impls/PartnerCardDashboardServiceImp.java | 17 +++++++++++--- .../appclient/core/RetailAppService.java | 3 +++ .../core/impls/RetailAppServiceImp.java | 22 +++++++++++++++++++ .../appclient/web/RetailAppController.java | 6 +++++ .../core/impls/TradeLogServiceImpl.java | 14 ++++++++++++ .../impls/CustomerImpressionImplTest.java | 3 ++- 7 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/db/modify.sql b/src/db/modify.sql index cc324e836..71486e620 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -345,3 +345,15 @@ alter table act_app_list ALTER TABLE `sys_clients_apply` MODIFY COLUMN `bd_user` varchar(300) DEFAULT NULL COMMENT '所属BD用户'; + + +ALTER TABLE `pmt_orders` +ADD COLUMN `surcharge_rate` decimal(10,5) NULL AFTER `customer_surcharge`; +ALTER TABLE `pmt_orders` +ADD COLUMN `custom_surcharge_rate` decimal(10,5) NULL AFTER `surcharge_rate`; + +ALTER TABLE `pmt_transactions` +ADD COLUMN `input_amount` decimal(20,2) NULL AFTER `clearing_amount`; + +ALTER TABLE `pmt_transactions` +ADD COLUMN `surcharge_cashback` decimal(10,4) default 0 after `royalpay_surcharge` comment '返现至营销账户'; \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PartnerCardDashboardServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PartnerCardDashboardServiceImp.java index bf8f511a1..387278322 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PartnerCardDashboardServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PartnerCardDashboardServiceImp.java @@ -1,22 +1,22 @@ package au.com.royalpay.payment.manage.analysis.core.impls; -import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi; import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean; import au.com.royalpay.payment.manage.analysis.core.DashboardService; import au.com.royalpay.payment.manage.analysis.core.PartnerCardDashboardService; import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; +import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; +import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.utils.PageListUtils; import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; - import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.stereotype.Service; import org.springframework.util.Assert; @@ -44,7 +44,7 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi @Resource private MerchantInfoProvider merchantInfoProvider; @Resource - private PaymentApi paymentApi; + private LogSettleMailMapper logSettleMailMapper; @Override public JSONObject getCommonAnalysis(String client_moniker) { JSONObject client = clientManager.getClientInfoByMoniker(client_moniker); @@ -140,6 +140,17 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi params.put("client_id", client_id); PageList logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); JSONObject result = PageListUtils.buildPageListResult(logs); + if (query.getPage()==1){ + if (!logs.isEmpty() && logs.size()>0){ + JSONObject sendMailLog = logSettleMailMapper.findByDate(logs.get(0).getDate("clearing_time")); + if (sendMailLog == null) { + result.put("padding",true); + } + if (sendMailLog!=null && sendMailLog.getIntValue("mail_status") != 1) { + result.put("padding",true); + } + } + } return result; } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index ae43c17d5..e7c902375 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -10,6 +10,7 @@ import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; import com.alibaba.fastjson.JSONObject; +import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.util.List; @@ -127,4 +128,6 @@ public interface RetailAppService { void changeSurchargeEnable(JSONObject device, UpdateSurchargeDTO updateSurchargeDTO); JSONObject getInvoiceData(JSONObject device, AppQueryBean appQueryBean) throws Exception; + + void getInvoiceFile(JSONObject device, AppQueryBean appQueryBean, HttpServletResponse httpResponse) throws Exception; } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 872a15a71..6f32535a2 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -31,6 +31,7 @@ import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; +import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport; import au.com.royalpay.payment.tools.device.DeviceSupport; import au.com.royalpay.payment.tools.device.message.AppMessage; @@ -86,6 +87,7 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; /** * Created by yishuqian on 28/03/2017. @@ -142,6 +144,8 @@ public class RetailAppServiceImp implements RetailAppService { @Resource private NoticePartnerMapper noticePartnerMapper; @Resource + private TradeLogService tradeLogService; + @Resource private AppActService appActService; private Map senderMap = new HashMap<>(); @@ -265,9 +269,27 @@ public class RetailAppServiceImp implements RetailAppService { clientManager.validateClients(client_id, params); params.put("client_id", client_id); JSONObject analysis = transactionMapper.analysisTransFlow(params); + BigDecimal total_surcharge = analysis.getBigDecimal("total_surcharge").add(analysis.getBigDecimal("tax_amount")); + analysis.put("total_surcharge",total_surcharge); return analysis; } + @Override + public void getInvoiceFile(JSONObject device, AppQueryBean appQueryBean, HttpServletResponse httpResponse) throws Exception { + String clientType = device.getString("client_type"); + deviceSupport.findRegister(clientType); + int client_id = device.getIntValue("client_id") ; + //JSONObject client = clientManager.getClientInfo(client_id); + TradeLogQuery tradeLogQuery = new TradeLogQuery(); + tradeLogQuery.setDatefrom(appQueryBean.getBegin()); + tradeLogQuery.setDateto(appQueryBean.getEnd()); + if (appQueryBean.getApp_client_ids()==null){ + appQueryBean.setApp_client_ids(String.valueOf(client_id)); + } + tradeLogQuery.setClient_ids(appQueryBean.getApp_client_ids().split(",")); + tradeLogService.exportTransFlow(tradeLogQuery,device,httpResponse); + } + @Override public void updateClient(JSONObject device, AppClientBean appClientBean) { String clientType = device.getString("client_type"); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index 31ca40aa1..68dd52b8f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -45,6 +45,7 @@ import java.util.List; import java.util.Map; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import static au.com.royalpay.payment.tools.CommonConsts.RETAIL_DEVICE; @@ -456,4 +457,9 @@ public class RetailAppController { public JSONObject getInvoiceData(@ModelAttribute(RETAIL_DEVICE) JSONObject device,AppQueryBean appQueryBean) throws Exception { return retailAppService.getInvoiceData(device,appQueryBean); } + + @RequestMapping(value = "/invoice/file",method = RequestMethod.GET) + public void getInvoiceFile(@ModelAttribute(RETAIL_DEVICE) JSONObject device,AppQueryBean appQueryBean,HttpServletResponse httpResponse) throws Exception { + retailAppService.getInvoiceFile(device,appQueryBean,httpResponse); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java index ca4547abc..bbcdb18a6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java @@ -12,6 +12,7 @@ import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.manage.mappers.client.ClientCustomersMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper; +import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper; import au.com.royalpay.payment.manage.mappers.payment.AustracDataMapper; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.RefundAuditionMapper; @@ -129,6 +130,8 @@ public class TradeLogServiceImpl implements TradeLogService { private ManagerCustomerRelationAlipayMapper managerCustomerRelationAlipayMapper; @Resource private ClientCustomersMapper clientCustomersMapper; + @Resource + LogSettleMailMapper logSettleMailMapper; @Resource private OrgManager orgManager; @@ -818,6 +821,17 @@ public class TradeLogServiceImpl implements TradeLogService { new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); JSONObject result = PageListUtils.buildPageListResult(logs); result.put("analysis", transactionMapper.getClientAmountAnalysis(params)); + if (query.getPage()==1){ + if (!logs.isEmpty() && logs.size()>0){ + JSONObject sendMailLog = logSettleMailMapper.findByDate(logs.get(0).getDate("clearing_time")); + if (sendMailLog == null) { + result.put("padding",true); + } + if (sendMailLog!=null && sendMailLog.getIntValue("mail_status") != 1) { + result.put("padding",true); + } + } + } return result; } diff --git a/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java b/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java index bcdf954c7..0a0758101 100644 --- a/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java +++ b/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java @@ -10,6 +10,7 @@ import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; @@ -55,7 +56,7 @@ public class CustomerImpressionImplTest { // } // } - @Test + @Ignore public void excel() { try { From ae8ea53870be271fef9d686133a4391640ff9280 Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Fri, 20 Apr 2018 14:43:17 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E5=95=86=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0suburb=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/manage/merchants/beans/PartnerQuery.java | 12 ++++++++++++ .../payment/manage/mappers/system/ClientMapper.xml | 4 ++++ .../static/payment/partner/templates/partners.html | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/PartnerQuery.java b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/PartnerQuery.java index bf49ecdb6..56e39c370 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/PartnerQuery.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/PartnerQuery.java @@ -19,6 +19,7 @@ public class PartnerQuery { private String searchText; private String client_moniker; private String state; + private String suburb; private String short_name; private String sub_merchant_id; private String org_id; @@ -105,6 +106,9 @@ public class PartnerQuery { if (StringUtils.isNotBlank(state)) { param.put("state", state); } + if (StringUtils.isNotBlank(suburb)) { + param.put("suburb", suburb); + } if (StringUtils.isNotBlank(searchText)) { param.put("search_text", searchText); if (StringUtils.isNotBlank(textType)) { @@ -460,4 +464,12 @@ public class PartnerQuery { public void setMerchant_id(String merchant_id) { this.merchant_id = merchant_id; } + + public String getSuburb() { + return suburb; + } + + public void setSuburb(String suburb) { + this.suburb = suburb; + } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml index f84a21e55..9fdde49bc 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml @@ -100,6 +100,10 @@ and c.short_name like #{short_name_pattern} + + + and c.suburb like #{suburb_pattern} + and ((c.approve_result=4 and c.open_status is null) or (c.approve_result=3 and c.open_status is null) or c.open_status=1 or c.open_status=2 or c.open_status=4) diff --git a/src/main/ui/static/payment/partner/templates/partners.html b/src/main/ui/static/payment/partner/templates/partners.html index 5b97b8e71..ea6f15944 100644 --- a/src/main/ui/static/payment/partner/templates/partners.html +++ b/src/main/ui/static/payment/partner/templates/partners.html @@ -148,6 +148,16 @@ + +
+ +
+ +
+
From 071c05905aebd82af86f413efe0897105d4fbc1d Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Fri, 20 Apr 2018 16:49:56 +0800 Subject: [PATCH 04/15] fix~ --- .../web/PartnerCardDashboardController.java | 7 + .../clearing/core/CleanService.java | 5 + .../clearing/core/impl/CleanServiceImpl.java | 96 +++++++- .../web/CleanLogClientController.java | 7 + .../templates/settlement_transactions.html | 204 +++++++++++----- .../commons/services/clearingDetailService.js | 22 +- .../static/payment/partner/partner-manage.js | 20 +- .../partner/templates/partner_settlement.html | 7 +- .../tradelog/partner-settlement-log.js | 1 + .../templates/partner_settlement_dialog.html | 224 +++++++++++------- .../templates/partner_settlement_logs.html | 5 +- 11 files changed, 436 insertions(+), 162 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerCardDashboardController.java b/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerCardDashboardController.java index 3b51b69b3..74f41b6e5 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerCardDashboardController.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerCardDashboardController.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.text.ParseException; import java.util.List; +import java.util.Map; /** * Created by yishuqian on 20/02/2017. @@ -78,5 +79,11 @@ public class PartnerCardDashboardController { return cleanService.getCleanLogTransactions(detailId, manager); } + @RequestMapping("/settlement_logs/{detailId}/analysis/{channel}") + public Map getDayAndChannelOfAnalysisMap(@PathVariable int detailId, + @PathVariable String channel, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + return cleanService.getDayAndChannelOfAnalysisMap(detailId,channel, manager); + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java index e646cdc64..f4d0e7a41 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java @@ -11,6 +11,7 @@ import java.io.PrintWriter; import java.io.Writer; import java.util.Date; import java.util.List; +import java.util.Map; /** * Created by davep on 2016-08-29. @@ -31,6 +32,8 @@ public interface CleanService { JSONObject getCleanLogTransactions(int detailId, JSONObject manager); + Map getDayAndChannelOfAnalysisMap(int detailId, String channel,JSONObject manager); + JSONObject getCleanLogTransactions(int client_id, String detailId); void settlementCsv(Date dt, HttpServletResponse resp) throws IOException; @@ -60,6 +63,8 @@ public interface CleanService { JSONObject listClearingTransactions(int client_id, String clearingDetailId, JSONObject partner); + Map channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel,JSONObject partner); + void exportListClearingTransactions(int client_id, String clearingDetailId, JSONObject partner, HttpServletResponse resp); List getSettlementMonthReport(int year, int monthOfYear); diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java index 8237ba8bf..1393524d6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java @@ -83,14 +83,9 @@ import java.math.RoundingMode; import java.net.URISyntaxException; import java.text.DecimalFormat; import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Currency; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.Locale; +import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -261,6 +256,19 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider return cleanLog; } + @Override + public Map getDayAndChannelOfAnalysisMap(int detailId,String channel,JSONObject manager) { + JSONObject cleanLog = clearingDetailMapper.findByDetailId(detailId); + if (cleanLog == null) { + throw new NotFoundException(); + } + JSONObject client = clientManager.getClientInfo(cleanLog.getIntValue("client_id")); + Assert.notNull(client, "Client ID invalid"); + checkOrgPermission(manager, client); + + return getDayAnalysisMap(String.valueOf(detailId),channel,client); + } + @Override public JSONObject getCleanLogTransactions(int clientId, String clearingDetailId) { return settlementSupport.listSettlementTransactionsForClient(clientId, clearingDetailId); @@ -642,7 +650,6 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider TimeZoneUtils.switchTimeZone(p, timezone_client, "transaction_time"); }); } - clearClient.put("report", transactions); List channels = clearingDetailAnalysisMapper.listReportChannels(clearClient.getString("clear_detail_id")); JSONObject channelsObj = new JSONObject(); @@ -654,6 +661,68 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider return clearClient; } + @Override + public Map channelAndDayOfAnalysis(int client_id, String clearingDetailId,String channel,JSONObject partner) { + JSONObject client = clientManager.getClientInfo(client_id); + Assert.notNull(client, "Client not exists"); + int parent_client_id = client.getIntValue("parent_client_id"); + + if (client_id != partner.getIntValue("client_id") && parent_client_id != partner.getIntValue("client_id")) { + throw new ForbiddenException("No Permission"); + } + return getDayAnalysisMap(clearingDetailId,channel,client); + } + + private Map getDayAnalysisMap(String clearingDetailId,String channel,JSONObject client){ + List transactions = transactionMapper.listTransactionsOfClearingOrder(Integer.parseInt(clearingDetailId), + new PageBounds(Order.formString("order_id.asc"))); + String timezone_client = client.getString("timezone"); + if(!channel.equals("null")){ + transactions = transactions.stream().filter(t->t.getString("channel").equals(channel)).collect(Collectors.toList()); + } + List dateKeysList = new ArrayList<>(); + dateKeysList.add("transaction_time"); + if (timezone_client == null) { + transactions.parallelStream().forEach(p -> { + TimeZoneUtils.switchTimeZone(p, timezone_client, "transaction_time"); + }); + //TimeZoneUtils.switchTimeZoneToString(transactions,timezone_client,TimeZoneUtils.PATTERN_DATE,dateKeysList); + } + + Map> dayTransactionsMap = transactions.stream().collect(Collectors.groupingBy(x -> x.getString("transaction_time").substring(0,10))); + Map dayAnalysisMap = new TreeMap<>(); + for (Map.Entry> entry : dayTransactionsMap.entrySet()){ + JSONObject analysis = new JSONObject(); + List transactionsOfDay = entry.getValue(); + /*if(entry.getKey().equals("2017-11-20")){ + int i = 0; + }*/ + BigDecimal total_credit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Credit")).filter(t->t.containsKey("clearing_amount")).map(t-> t.getBigDecimal("clearing_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal total_debit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Debit")).filter(t->t.containsKey("clearing_amount")).map(t-> t.getBigDecimal("clearing_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal total_charge_credit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Credit")).filter(t->t.containsKey("total_surcharge")).map(t-> t.getBigDecimal("total_surcharge")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal total_charge_debit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Debit")).filter(t->t.containsKey("total_surcharge")).map(t-> t.getBigDecimal("total_surcharge")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal net_amount_credit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Credit")).filter(t->t.containsKey("settle_amount")).map(t-> t.getBigDecimal("settle_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal net_amount_debit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Debit")).filter(t->t.containsKey("settle_amount")).map(t-> t.getBigDecimal("settle_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal tax_amount_credit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Credit")).filter(t->t.containsKey("tax_amount")).map(t-> t.getBigDecimal("tax_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal tax_amount_debit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Debit")).filter(t->t.containsKey("tax_amount")).map(t-> t.getBigDecimal("tax_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal wechat_charge_credit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Credit")).filter(t->t.containsKey("wechat_charge")).map(t-> t.getBigDecimal("wechat_charge")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal wechat_charge_debit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Debit")).filter(t->t.containsKey("wechat_charge")).map(t-> t.getBigDecimal("wechat_charge")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal royalpay_charge_credit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Credit")).filter(t->t.containsKey("royal_surcharge")).map(t-> t.getBigDecimal("royal_surcharge")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal royalpay_charge_debit = transactionsOfDay.stream().filter(t->t.getString("transaction_type").equals("Debit")).filter(t->t.containsKey("royal_surcharge")).map(t-> t.getBigDecimal("royal_surcharge")).reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal tax_amount = tax_amount_credit.subtract(tax_amount_debit); + analysis.put("total_credit",total_credit.setScale(2,BigDecimal.ROUND_HALF_UP)); + analysis.put("total_debit",total_debit.setScale(2,BigDecimal.ROUND_HALF_UP)); + analysis.put("net_amount",net_amount_credit.subtract(net_amount_debit).setScale(2,BigDecimal.ROUND_HALF_UP)); + analysis.put("tax_amount",tax_amount.setScale(2,BigDecimal.ROUND_HALF_UP)); + analysis.put("total_charge",total_charge_credit.subtract(total_charge_debit).add(tax_amount).setScale(2,BigDecimal.ROUND_HALF_UP)); + analysis.put("gross_amount",total_credit.subtract(total_debit).setScale(2,BigDecimal.ROUND_HALF_UP)); + analysis.put("wechat_charge",wechat_charge_credit.subtract(wechat_charge_debit).setScale(2,BigDecimal.ROUND_HALF_UP)); + analysis.put("royalpay_charge",royalpay_charge_credit.subtract(royalpay_charge_debit).setScale(2,BigDecimal.ROUND_HALF_UP)); + dayAnalysisMap.put(entry.getKey(),analysis); + } + return dayAnalysisMap; + } @Override public void exportListClearingTransactions(int client_id, String clearingDetailId, JSONObject partner, HttpServletResponse resp) { OutputStream ous = null; @@ -815,6 +884,17 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider PageList logs = clearingDetailMapper.listReportsOfSettlementLogs(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("report_date.desc"))); JSONObject result = PageListUtils.buildPageListResult(logs); + if (query.getPage()==1){ + if (!logs.isEmpty() && logs.size()>0){ + JSONObject sendMailLog = logSettleMailMapper.findByDate(logs.get(0).getDate("clearing_time")); + if (sendMailLog == null) { + result.put("padding",true); + } + if (sendMailLog!=null && sendMailLog.getIntValue("mail_status") != 1) { + result.put("padding",true); + } + } + } return result; } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/CleanLogClientController.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/CleanLogClientController.java index 712241f7b..2c59a8b13 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/CleanLogClientController.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/CleanLogClientController.java @@ -13,6 +13,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.text.ParseException; import java.util.List; +import java.util.Map; /** * Created by davep on 2016-08-29. @@ -38,6 +39,12 @@ public class CleanLogClientController { return cleanService.listClearingTransactions(client_id, clearingDetailId, partner); } + @RequestMapping("/{client_id}/settlement_logs/{clearingDetailId}/analysis/{channel}") + public Map channelAndDayOfAnalysis(@PathVariable int client_id, @PathVariable String clearingDetailId, + @PathVariable String channel, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) { + return cleanService.channelAndDayOfAnalysis(client_id, clearingDetailId,channel,partner); + } + @PartnerMapping("/{client_id}/settlement_logs/{clearingDetailId}/export") public void exportListClearingTransactions(@PathVariable int client_id, @PathVariable String clearingDetailId, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse resp) { diff --git a/src/main/ui/static/analysis/templates/settlement_transactions.html b/src/main/ui/static/analysis/templates/settlement_transactions.html index 277fcf8e3..58ebbf6c4 100644 --- a/src/main/ui/static/analysis/templates/settlement_transactions.html +++ b/src/main/ui/static/analysis/templates/settlement_transactions.html @@ -14,87 +14,39 @@
-
-
Analysis
-
-
-
- Rate - -
-
- Total Credit - -
-
- Total Debit - -
-
- Gross Amount - -
- -
-
-
- Total Charge - -
-
- Channel Charge - -
-
- RoyalPay Charge - -
-
- Net Amount - -
-
-
-
- Tax Amount - -
-
-
-
-
+ +
+ + +
+
+
+ Rate + + +
+
+ Total Credit + + +
+
+ Total Debit + + +
+
+ Gross Amount + + +
+ +
+
+
+ Total Charge + + +
+
+ Channel Charge + + +
+
+ RoyalPay Charge + + + +
+
+ Net Amount + + +
+
+
+
+ Tax Amount + +
+
+
+
+ + +
+
+
+ Total Credit + +
+
+ Total Debit + +
+
+ Gross Amount + +
+
+
+
+ Total Charge + +
+
+ Channel Charge + +
+
+ RoyalPay Charge + +
+
+ Net Amount + +
+
+ Tax Amount + +
+
+
+
+
Credits
@@ -162,7 +252,7 @@ - + {{tr.order_id}} @@ -200,7 +290,7 @@ - + {{tr.order_id}} diff --git a/src/main/ui/static/commons/services/clearingDetailService.js b/src/main/ui/static/commons/services/clearingDetailService.js index af223dfd6..da8d7555b 100644 --- a/src/main/ui/static/commons/services/clearingDetailService.js +++ b/src/main/ui/static/commons/services/clearingDetailService.js @@ -4,7 +4,7 @@ define(['../app','decimal'], function (app,Decimal) { 'use strict'; app.factory('clearingDetailService', ['$uibModal', function ($uibModal) { - function openDetail(url, is_partner) { + function openDetail(url, is_partner,client_id,detailId) { $uibModal.open({ templateUrl: '/static/payment/tradelog/templates/partner_settlement_dialog.html', controller: 'clearingDetailCtrl', @@ -12,7 +12,9 @@ define(['../app','decimal'], function (app,Decimal) { detail: ['$http', function ($http) { return $http.get(url); }], - is_partner: is_partner + is_partner: is_partner, + client_id:client_id, + detailId:detailId }, size: 'lg' }) @@ -20,16 +22,26 @@ define(['../app','decimal'], function (app,Decimal) { return { clientClearingDetail: function (client_id, detailId, is_partner) { - openDetail('/client/clean_logs/' + client_id + '/settlement_logs/' + detailId, is_partner); + openDetail('/client/clean_logs/' + client_id + '/settlement_logs/' + detailId, is_partner,client_id,detailId); } } }]); - app.controller('clearingDetailCtrl', ['$scope', 'detail', 'is_partner', function ($scope, detail, is_partner) { - $scope.ctrl = {channel: null}; + app.controller('clearingDetailCtrl', ['$scope', 'detail', 'is_partner','client_id','detailId','$http', function ($scope, detail, is_partner,client_id,detailId,$http) { + $scope.ctrl = {channel: null,day:null}; $scope.report = detail.data; $scope.report.total_charge = Decimal.add($scope.report.total_charge,$scope.report.tax_amount).toFixed(2); + angular.forEach($scope.report.channels,function (e) { + e.total_charge = Decimal.add(e.total_charge,e.tax_amount).toFixed(2); + }); $scope.is_partner = is_partner; + $scope.channelAndDayOfAnalysis = function () { + $http.get('/client/clean_logs/' + client_id + '/settlement_logs/' + detailId+'/analysis/'+$scope.ctrl.channel).then(function (resp) { + $scope.channelAndDayMap = resp.data; + $scope.index = 0; + }) + } + $scope.channelAndDayOfAnalysis(); }]); app.filter('channel_image', function () { return function (channel) { diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index a20f2bb06..549a40736 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -2470,27 +2470,41 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter params.limit = 10; $http.get('/sys/partners/' + clientMoniker + '/lists_settlements', {params: params}).then(function (resp) { $scope.settlementLogs = resp.data.data; + $scope.padding = resp.data.padding; $scope.pagination = resp.data.pagination; }); }; $scope.getClearingTransactions = function (client_id, detail_id) { $uibModal.open({ templateUrl: '/static/analysis/templates/settlement_transactions.html', - controller: 'managerClearingDetailCtrl', + controller: 'managerSettlementDetailCtrl', resolve: { detail: ['$http', '$stateParams', function ($http) { return $http.get('/analysis/partner_card/' + client_id + '/settlement_logs/' + detail_id); - }] + }], + detail_id:detail_id }, size: 'lg' }); }; $scope.chooseLast7Days(); }]); - app.controller('managerClearingDetailCtrl', ['$scope', 'detail', function ($scope, detail) { + app.controller('managerSettlementDetailCtrl', ['$scope', 'detail','detail_id','$http', function ($scope, detail,detail_id,$http) { $scope.ctrl = {channel: null}; + $scope.show = true; $scope.report = detail.data; $scope.report.total_charge = Decimal.add($scope.report.total_charge,$scope.report.tax_amount).toFixed(2); + angular.forEach($scope.report.channels,function (e) { + e.total_charge = Decimal.add(e.tax_amount,e.total_charge).toFixed(2); + }); + + $scope.channelAndDayOfAnalysis = function () { + $http.get('/analysis/partner_card/settlement_logs/' + detail_id+'/analysis/'+$scope.ctrl.channel).then(function (resp) { + $scope.channelAndDayMap = resp.data; + $scope.index = 0; + }) + }; + $scope.channelAndDayOfAnalysis(1); }]); app.controller('productCtrl', ['$scope', '$http', '$uibModal', 'commonDialog', '$state', 'Upload', 'industryMap', function ($scope, $http, $uibModal, commonDialog, $state, Upload, industryMap) { diff --git a/src/main/ui/static/payment/partner/templates/partner_settlement.html b/src/main/ui/static/payment/partner/templates/partner_settlement.html index fbddc060e..dc3fe5cb8 100644 --- a/src/main/ui/static/payment/partner/templates/partner_settlement.html +++ b/src/main/ui/static/payment/partner/templates/partner_settlement.html @@ -76,7 +76,12 @@ - + + {{log.clearing_time|limitTo:10}} +   + + + diff --git a/src/main/ui/static/payment/tradelog/partner-settlement-log.js b/src/main/ui/static/payment/tradelog/partner-settlement-log.js index 226058e06..d7fa5454e 100644 --- a/src/main/ui/static/payment/tradelog/partner-settlement-log.js +++ b/src/main/ui/static/payment/tradelog/partner-settlement-log.js @@ -86,6 +86,7 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) { $http.get('/client/trans_flow/settlement/log', {params: params}).then(function (resp) { $scope.settlementLogs = resp.data.data; $scope.pagination = resp.data.pagination; + $scope.padding = resp.data.padding; $scope.analysis = resp.data.analysis; }); }; diff --git a/src/main/ui/static/payment/tradelog/templates/partner_settlement_dialog.html b/src/main/ui/static/payment/tradelog/templates/partner_settlement_dialog.html index b82ceaebc..65513aaa8 100644 --- a/src/main/ui/static/payment/tradelog/templates/partner_settlement_dialog.html +++ b/src/main/ui/static/payment/tradelog/templates/partner_settlement_dialog.html @@ -6,122 +6,172 @@
-
-
Analysis
-
-
- - - - -
- Total Credit - -
-
- Total Debit - -
-
- Gross Amount - -
+
+ + +
+
+ + + + +
+ Total Credit + + +
+
+ Total Debit + + +
+
+ Gross Amount + + +
-
-
-
- Total Charge - -
-
- Channel Charge - -
-
- RoyalPay Charge - -
-
- Net Amount - -
-
- Tax Amount - -
-
-
-
-
-
Analysis
-
-
-
- Total Credit - -
-
- Total Debit - -
-
- Gross Amount - +
+
+
+ Total Charge + + +
+
+ Channel Charge + + +
+
+ RoyalPay Charge + + +
+
+ Net Amount + + +
+
+ Tax Amount + +
+
+ + + +
+
+
+ Total Credit + +
+
+ Total Debit + +
+
+ Gross Amount + +
+
+
+
+ Total Charge + +
+
+ Channel Charge + +
+
+ RoyalPay Charge + +
+
+ Net Amount + +
+
+ Tax Amount + +
+
-
-
+ +
Credits
@@ -144,7 +194,7 @@ - + {{tr.order_id}} @@ -180,7 +230,7 @@ - + diff --git a/src/main/ui/static/payment/tradelog/templates/partner_settlement_logs.html b/src/main/ui/static/payment/tradelog/templates/partner_settlement_logs.html index 230620ae7..aeeaf8dbf 100644 --- a/src/main/ui/static/payment/tradelog/templates/partner_settlement_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/partner_settlement_logs.html @@ -120,7 +120,10 @@ - + + {{log.clearing_time|limitTo:10}} +   + From 010586e3fd519f0374101120e172cf3f3b32c588 Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Fri, 20 Apr 2018 17:15:06 +0800 Subject: [PATCH 05/15] add~ --- .../static/payment/partner/partner-manage.js | 38 +++++++++++++++++++ .../partner/templates/add_partner.html | 27 +++++++++++++ 2 files changed, 65 insertions(+) diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index a20f2bb06..a010088b4 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -970,6 +970,44 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter } }; + $scope.uploadMerchant_photo1 = function (file) { + if (file != null) { + $scope.logoProgress = {value: 0}; + Upload.upload({ + url: '/attachment/files', + data: {file: file} + }).then(function (resp) { + delete $scope.logoProgress; + $scope.partner.logo_id = resp.data.fileid; + $scope.partner.merchant_photo1 = resp.data.url; + }, function (resp) { + delete $scope.logoProgress; + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, function (evt) { + $scope.logoProgress.value = parseInt(100 * evt.loaded / evt.total); + }) + } + }; + + $scope.uploadMerchant_photo2 = function (file) { + if (file != null) { + $scope.logoProgress = {value: 0}; + Upload.upload({ + url: '/attachment/files', + data: {file: file} + }).then(function (resp) { + delete $scope.logoProgress; + $scope.partner.logo_id = resp.data.fileid; + $scope.partner.merchant_photo2 = resp.data.url; + }, function (resp) { + delete $scope.logoProgress; + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, function (evt) { + $scope.logoProgress.value = parseInt(100 * evt.loaded / evt.total); + }) + } + }; + $scope.getMerchantLocation = function () { $http.get('/sys/partners/' + $scope.partner.client_moniker + '/location').then(function (resp) { $scope.merchant_location = resp.data; diff --git a/src/main/ui/static/payment/partner/templates/add_partner.html b/src/main/ui/static/payment/partner/templates/add_partner.html index 9dbb2a3fd..a16f1bce1 100644 --- a/src/main/ui/static/payment/partner/templates/add_partner.html +++ b/src/main/ui/static/payment/partner/templates/add_partner.html @@ -250,6 +250,33 @@
+
+ +
+
1:  + +
+ + +
+
+
2:  + +
+ + +
+
-
- -
-
1:  - -
- - -
-
-
2:  - -
- - -
-
-
+
Net Amount diff --git a/src/main/ui/static/invoice/invoice_assistant.js b/src/main/ui/static/invoice/invoice_assistant.js index 48fb48cff..b8332ca1a 100644 --- a/src/main/ui/static/invoice/invoice_assistant.js +++ b/src/main/ui/static/invoice/invoice_assistant.js @@ -79,6 +79,10 @@ define(['angular','decimal'], function (angular,decimal) { alert("请选择结束时间"); return; } + /* if(getTime2Time()>30){ + alert("开始时间与结束时间不得超过三十天"); + return; + }*/ params.page = page || $scope.pagination.page || 1; $http.get('/partner/invoice/trans_flow', {params: params}).then(function (resp) { $scope.tradeLogs = resp.data.data; @@ -95,6 +99,14 @@ define(['angular','decimal'], function (angular,decimal) { commonDialog.alert({title: 'Search failed', content: resp.data.message, type: 'error'}); }); }; + /* var getTime2Time = function () { + var time = angular.copy($scope.params); + var from = time.datefrom = $filter('date')(time.datefrom, 'yyyy-MM-dd'); + var to = time.dateto = $filter('date')(time.dateto, 'yyyy-MM-dd'); + var longTime = new Date(to).getTime() - new Date(from).getTime() ; + var day = Math.floor(longTime/(24*60*60*1000)); + return day; + };*/ $scope.export = function (type,page) { var url='/partner/invoice/trans_flow/pdf'; From 8c5b02fc9278be9f12ddf3654163172ddedf3ccd Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Mon, 23 Apr 2018 11:01:58 +0800 Subject: [PATCH 15/15] client postpone --- .../wechatclients/WepayWechatApiImpl.java | 1 + .../manage/task/PostponeClientTask.java | 74 ++++++++++++------- .../mappers/system/ClientRateMapper.xml | 3 +- .../manage/task/PostponeClientTaskTest.java | 25 +++++++ 4 files changed, 77 insertions(+), 26 deletions(-) create mode 100644 src/test/java/au/com/royalpay/payment/manage/task/PostponeClientTaskTest.java diff --git a/src/main/java/au/com/royalpay/payment/manage/support/wechatclients/WepayWechatApiImpl.java b/src/main/java/au/com/royalpay/payment/manage/support/wechatclients/WepayWechatApiImpl.java index 8eef655c9..b111d3676 100644 --- a/src/main/java/au/com/royalpay/payment/manage/support/wechatclients/WepayWechatApiImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/support/wechatclients/WepayWechatApiImpl.java @@ -30,6 +30,7 @@ public class WepayWechatApiImpl extends AbstractMpWechatClientApi implements MpW registerTemplateId("settlement", "HqgkogBUWmfInrS5U84_9p-19LbM0apEuExHW4LF4bM"); registerTemplateId("settlement-check-code", "yaXEOjXFpuipk-DsdxYdd8PnD3bWAgDS5vTKJsrFdR4"); registerTemplateId("daily-green-channel", "vjeNnggHnnRHvBP80lkEEtPk8ouf7JnvrQYDCyxqx4g"); + registerTemplateId("client-postpone", "5eNJ5ZTKWitC1TJClb2coymtNCmOC7d86h0zCrxmGig"); } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java b/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java index 55fca3cc2..98d6fa4de 100644 --- a/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java +++ b/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java @@ -2,18 +2,21 @@ package au.com.royalpay.payment.manage.task; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; +import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; -import au.com.royalpay.payment.manage.tradelog.refund.events.NewRefundReviewEvent; 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.beans.TemplateMessage; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import java.util.Date; import java.util.HashMap; @@ -38,16 +41,26 @@ public class PostponeClientTask { private ClientManager clientManager; @Resource private ClientAccountMapper clientAccountMapper; + @Resource + private ManagerMapper managerMapper; -// @Scheduled(cron = "0 30 8 * * ?") + // @Scheduled(cron = "0 30 8 * * ?") public void checkGreenChannel() { Date now = new Date(); Date tomorrow = DateUtils.addDays(now, 1); + Date yearTomorrow = DateUtils.addYears(tomorrow, 1); + String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd"); List expiryClient = clientRateMapper.getAllExpiry(now); + if(CollectionUtils.isEmpty(expiryClient)){ + return; + } Map expiryClients = new HashMap<>(); expiryClient.forEach(p -> { expiryClients.put(p.getInteger("client_id"), p); + }); + expiryClients.values().forEach(p -> { + List adminAccounts = clientAccountMapper.listAdminAccounts(p.getIntValue("client_id")); List clientRates = clientRateMapper.maxChannelExpiryTime(p.getIntValue("client_id"), null); JSONObject wechatRate = clientRateMapper.latestChannelCleanDays("Wechat", p.getIntValue("client_id")); int cleanDays = 1; @@ -61,7 +74,7 @@ public class PostponeClientTask { o.remove("client_rate_id"); o.put("active_time", tomorrow); o.put("manager_id", 0); - o.put("expiry_time", DateUtils.addYears(tomorrow, 1)); + o.put("expiry_time", yearTomorrow); o.put("create_time", now); o.put("update_time", now); o.put("clean_days", finalCleanDays); @@ -70,28 +83,23 @@ public class PostponeClientTask { clientRateMapper.saveRate(o); }); - }); - - expiryClients.keySet().forEach(p -> { - List adminAccounts = clientAccountMapper.listAdminAccounts(p); adminAccounts.forEach(o -> { - sendClientPostponeNotify(o); + sendClientPostponeNotify(o, expireDate); }); }); - + sendComplianceNotify(expiryClients, expireDate); } - private void sendClientPostponeNotify(JSONObject account) { + private void sendClientPostponeNotify(JSONObject account,String newExpireDate) { JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id")); try { MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(account.getString("wechat_openid")); if (api != null) { - String templateId = api.getTemplateId("refund-audit-notice"); + String templateId = api.getTemplateId("client-postpone"); if (templateId != null) { - // TemplateMessage notice = initMessage(event, operator.getString("display_name"), client, - // event.getRefundOrder(), templateId, wechatOpenid); - // api.sendTemplateMessage(notice); + TemplateMessage notice = initClientMessage(client,newExpireDate,account.getString("wechat_openid"),templateId); + api.sendTemplateMessage(notice); } } } catch (Exception e) { @@ -99,21 +107,37 @@ public class PostponeClientTask { } } - private void sendComplianceNotify(Map clients){ - clients.values().forEach(p->{ + private void sendComplianceNotify(Map clients, String newExpireDate) { + StringBuffer sb = new StringBuffer(); + clients.values().forEach(p -> { + sb.append(p.getString("client_moniker")); + sb.append("、"); + }); + sb.deleteCharAt(sb.length() - 1); + List compliance = managerMapper.listOpenIdsOfCompliances(); + compliance.forEach(p -> { + MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(p); + TemplateMessage notice = initComplianceMessage(sb.toString(), newExpireDate, p, api.getTemplateId("client-postpone")); + api.sendTemplateMessage(notice); }); } - private TemplateMessage initMessage(NewRefundReviewEvent newRefundReviewEvent, String operatorName, JSONObject client, JSONObject review, String templateId, - String wechatOpenid) { - TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, "asd"); - notice.put("first", operatorName + "提交了订单的退款申请,请审核", "#ff0000"); - notice.put("keyword1", review.getString("currency") + newRefundReviewEvent.getRefundOrder().getDoubleValue("amount"), "#ff0000"); - notice.put("keyword2", operatorName, "#0000ff"); - notice.put("keyword3", client.getString("short_name") + "(" + client.getString("client_moniker") + ")", "#0000ff"); - notice.put("keyword4", review.getString("remark") == null ? "无备注" : review.getString("remark"), "#0000FF"); - notice.put("remark", "点击处理", "#000000"); + private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) { + TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null); + notice.put("first", "您好,您的合同费率已到期,根据合同协议系统已自动为您延期1年。", "#ff0000"); + notice.put("keyword1", client.getString("short_name")+"("+client.getString("client_moniker")+")", "#ff0000"); + notice.put("keyword2", newExpiryDate, "#0000ff"); + notice.put("remark", "如有疑问请联系RoyalPay", "#000000"); + return notice; + } + + private TemplateMessage initComplianceMessage(String clients, String newExpiryDate, String wechatOpenid, String templateId) { + TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null); + notice.put("first", "以下商户据合同费率已经自动延期1年", "#ff0000"); + notice.put("keyword1", clients, "#ff0000"); + notice.put("keyword2", newExpiryDate, "#0000ff"); + notice.put("remark", " ", "#000000"); return notice; } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml index f581e3fef..127aeb0e2 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml @@ -105,7 +105,8 @@ cr.client_id , cr.active_time , max(cr.expiry_time) expiry_time , - cr.rate_name + cr.rate_name, + c.client_moniker FROM sys_client_rates cr inner join sys_clients c on c.client_id = cr.client_id and c.is_valid = 1 and (c.approve_result = 1 or c.approve_result = 2) diff --git a/src/test/java/au/com/royalpay/payment/manage/task/PostponeClientTaskTest.java b/src/test/java/au/com/royalpay/payment/manage/task/PostponeClientTaskTest.java new file mode 100644 index 000000000..a23a28093 --- /dev/null +++ b/src/test/java/au/com/royalpay/payment/manage/task/PostponeClientTaskTest.java @@ -0,0 +1,25 @@ +package au.com.royalpay.payment.manage.task; + +import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; + +@SpringBootTest +@ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" }) +@RunWith(SpringRunner.class) +public class PostponeClientTaskTest { + @Resource + private ClientRateMapper clientRateMapper; + @Resource + private PostponeClientTask postponeClientTask; + @Test + public void checkGreenChannel() { + postponeClientTask.checkGreenChannel(); + } +} \ No newline at end of file