From 0d50ab284c6d7b8c4eed408a6a6f8c36f678eac8 Mon Sep 17 00:00:00 2001 From: luoyang Date: Wed, 12 Dec 2018 14:08:42 +0800 Subject: [PATCH 01/13] =?UTF-8?q?add=20=E5=85=B3=E9=97=AD=E6=B8=85?= =?UTF-8?q?=E7=AE=97=E8=BE=93=E5=85=A5=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/merchants/core/ClientManager.java | 2 +- .../core/impls/ClientManagerImpl.java | 13 ++++++- .../web/PartnerManageController.java | 2 +- .../static/payment/partner/partner-manage.js | 38 ++++++++++++++----- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 82976ea57..314881b9f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -271,7 +271,7 @@ public interface ClientManager { void updateAppClient(JSONObject account,int client_id, AppClientBean appClientBean); - void setSkipClearing(JSONObject account,String clientMoniker, Boolean skip_clearing); + void setSkipClearing(JSONObject account,String clientMoniker, Boolean skip_clearing,String remark); void enableGatewayUpgrade(JSONObject account,String clientMoniker, boolean gatewayUpgrade); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index bc15a15cf..71a63d93e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -3234,12 +3234,23 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override @Transactional - public void setSkipClearing(JSONObject account, String clientMoniker, Boolean skip_clearing) { + public void setSkipClearing(JSONObject account, String clientMoniker, Boolean skip_clearing,String remark) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new InvalidShortIdException(); } clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "skip_clearing", skip_clearing)); + + if (!skip_clearing) { + if ("".equals(remark) || remark==null){ + throw new ServerErrorException("请填写关闭清算原因"); + } + JSONObject clientConfig = clientConfigMapper.find(client.getIntValue("client_id")); + clientConfig.put("skip_settle_remark", remark); + clientConfigMapper.update(clientConfig); + } + + client.put("skip_clearing", skip_clearing); if (client.getString("rpay_enterprise_id") != null) { rpayApi.switchMerchantSettle(client); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 7bb29b70d..a39bd8f1d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -367,7 +367,7 @@ public class PartnerManageController { @ManagerMapping(value = "/{clientMoniker}/skip_clearing", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF}) public void skipClearing(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject skip_clearing) { - clientManager.setSkipClearing(manager,clientMoniker, skip_clearing.getBooleanValue("skip_clearing")); + clientManager.setSkipClearing(manager,clientMoniker, skip_clearing.getBooleanValue("skip_clearing"),skip_clearing.getString("remark")); } @ManagerMapping(value = "/{clientMoniker}/settle_hour", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.SERVANT, ManagerRole.FINANCIAL_STAFF}) diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 6a11acef0..42072fd12 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -1887,7 +1887,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.loadSubClients(); }]); - app.controller('partnerRatesCtrl', ['$scope', '$rootScope', '$http', '$uibModal', 'commonDialog', function ($scope, $rootScope, $http, $uibModal, commonDialog) { + app.controller('partnerRatesCtrl', ['$scope', '$rootScope', '$http', '$uibModal', 'commonDialog','$sce', function ($scope, $rootScope, $http, $uibModal, commonDialog,$sce) { $scope.bankCtrl = {edit: true, rate_name: 'Wechat'}; $scope.init = {skip_clearing:false,tax_in_surcharge:false,customer_tax_free:false}; $scope.getBankAccount = function () { @@ -1906,19 +1906,39 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }) }); }; + $scope.skipClearing = function (skipClearing) { if (!$scope.init.skip_clearing) { $scope.init.skip_clearing = true; return; } - commonDialog.confirm({ - title: 'Warning', - content: 'This operation will switch skip clearing status. Are you sure?' - }).then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', {skip_clearing: skipClearing}).then(function (resp) { - $scope.getBankAccount(); - }); - }) + if (!skipClearing) { + commonDialog.confirm({ + title: 'Warning', + content: 'This operation will switch skip clearing status. Are you sure?' + }).then(function () { + commonDialog.inputText({title: '请输入关闭跳过清算的原因'}).then(function (text) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', { + skip_clearing: skipClearing, + remark: text + }).then(function (resp) { + $scope.getBankAccount(); + }); + }); + }) + }else{ + commonDialog.confirm({ + title: 'Warning', + content: 'This operation will switch skip clearing status. Are you sure?', + // contentHtml: $sce.trustAsHtml('This operation will switch skip clearing status. Are you sure?') + }).then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', {skip_clearing: skipClearing}).then(function (resp) { + $scope.getBankAccount(); + }); + }) + } + + }; $scope.taxInSurcharge = function (taxInSurcharge) { if (!$scope.init.tax_in_surcharge) { From 543327f0ff893caaa02d1b12055f95312d624075 Mon Sep 17 00:00:00 2001 From: "james.zhao" Date: Thu, 13 Dec 2018 18:57:08 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E9=A3=8E=E6=8E=A7=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=8D=95=E5=A2=9E=E5=8A=A0=E7=A6=81=E7=94=A8=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../riskbusiness/core/RiskBusinessService.java | 2 ++ .../core/impl/RiskBusinessServiceImpl.java | 8 ++++++++ .../riskbusiness/web/RiskBusinessController.java | 5 +++++ .../mappers/riskbusiness/RiskEventMapper.xml | 3 +++ src/main/ui/static/analysis/risk_business.js | 14 ++++++++++++++ .../analysis/templates/riskEvent_detail.html | 3 +++ 6 files changed, 35 insertions(+) diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java index 74a62881f..88168752b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java @@ -126,6 +126,8 @@ public interface RiskBusinessService { */ JSONObject getRiskEventMaterialsRemark(String riskId); + void banRiskEvent(String riskId); + JSONObject riskEventMaterialPass(JSONObject params, JSONObject manager); JSONObject updateIsSendClient(String riskId); diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java index 22f4494ac..5b418e5b0 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java @@ -980,6 +980,14 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo return result; } + @Override + public void banRiskEvent(String riskId) { + JSONObject params = new JSONObject(); + params.put("risk_id",riskId); + params.put("is_valid",0); + riskEventMapper.update(params); + } + @Transactional @Override public JSONObject riskEventMaterialPass(JSONObject params, JSONObject manager) { diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java index b589de9fb..ef501dec0 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java @@ -151,6 +151,11 @@ public class RiskBusinessController { riskBusinessService.sendUrgeEmail(risk_id); } + @RequestMapping(value = "/ban/{risk_id}",method = RequestMethod.DELETE) + public void banEvent(@PathVariable String risk_id){ + riskBusinessService.banRiskEvent(risk_id); + } + @GetMapping(value = "/partners") public List getPartners(PartnerQuery partnerQuery) { JSONObject param = partnerQuery.toJsonParam(); diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml index e188bec19..5ce07e53d 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml @@ -51,6 +51,7 @@ ON sc.client_id = scb.client_id + re.is_valid = 1 AND re.risk_id = #{risk_id} @@ -175,6 +176,7 @@ ON re.risk_id = ro.risk_id + re.is_valid = 1 AND re.risk_id = #{risk_id} @@ -257,6 +259,7 @@ ) ro ON re.risk_id = ro.risk_id + re.is_valid = 1 AND re.risk_id = #{risk_id} diff --git a/src/main/ui/static/analysis/risk_business.js b/src/main/ui/static/analysis/risk_business.js index 29aa25c7c..9e4c5a1c8 100644 --- a/src/main/ui/static/analysis/risk_business.js +++ b/src/main/ui/static/analysis/risk_business.js @@ -292,6 +292,20 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], orderChannel = null; } + $scope.deleteRiskEvent = function () { + commonDialog.confirm({ + title: 'Delete This Risk Event', + content: 'Are you sure to delete this risk event?' + }).then(function () { + $http.delete('/risk/business/ban/' + $scope.riskEvent.risk_id).then(function () { + $state.go('analysis_monitoring.risk_business'); + commonDialog.alert({title: 'Delete', content: 'Risk Event Already Disabled', type: 'error'}); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }) + }) + }; + /** * order_ids在指定位置换行 * @param str diff --git a/src/main/ui/static/analysis/templates/riskEvent_detail.html b/src/main/ui/static/analysis/templates/riskEvent_detail.html index 08917465a..229b61246 100644 --- a/src/main/ui/static/analysis/templates/riskEvent_detail.html +++ b/src/main/ui/static/analysis/templates/riskEvent_detail.html @@ -9,6 +9,9 @@ +
+ +
From 28ab73c4254c7d23b5924169d95825c67ba13c0f Mon Sep 17 00:00:00 2001 From: "james.zhao" Date: Fri, 14 Dec 2018 14:16:32 +0800 Subject: [PATCH 03/13] fix bug --- .../manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java index 5b418e5b0..b6065a86a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java @@ -335,7 +335,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo } private void setRiskOrders(JSONObject params){ - if(StringUtils.isNotBlank(params.getString("order_ids"))){ + if(StringUtils.isNotBlank(params.getString("real_order_ids"))){ String riskId = params.getString("risk_id"); String orderIds = params.getString("real_order_ids"); for(String orderId : orderIds.split(",")){ From fcd07f15a98ddd8c380e41f58be2a0a42476a47b Mon Sep 17 00:00:00 2001 From: yangkai Date: Mon, 17 Dec 2018 20:30:14 +0800 Subject: [PATCH 04/13] init coupon processors --- .../mappers/log/CouponAccuessLogMapper.java | 8 + .../CtripCouponOnlyLogProcessor.java | 194 +++++++++++++ .../CtripCouponProvideProcessor.java | 266 ++++++++++++++++++ 3 files changed, 468 insertions(+) create mode 100644 src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/CouponAccuessLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/CouponAccuessLogMapper.java index 8f62c7c2b..cb60bf3df 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/log/CouponAccuessLogMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/CouponAccuessLogMapper.java @@ -30,4 +30,12 @@ public interface CouponAccuessLogMapper { List findCouponByOrderId(@Param("order_id") String order_id); PageList getCouponAccuessLog(@Param("client_id")int client_id, @Param("keyword")String keyword, PageBounds pageBounds); + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "is_valid = 0") + List findAccuessLogByOrderId(@Param("order_id") String order_id, PageBounds pageBounds); + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "is_valid = 1") + List findUsedCouponByOrderIdList(@Param("order_id") String order_id); } diff --git a/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java new file mode 100644 index 000000000..c11c56ba5 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java @@ -0,0 +1,194 @@ +package au.com.royalpay.payment.manage.processors; + +import au.com.royalpay.payment.core.PaymentApi; +import au.com.royalpay.payment.core.beans.PreOrderRequest; +import au.com.royalpay.payment.core.beans.coupon.CouponInfo; +import au.com.royalpay.payment.core.events.PaymentFinishedEvent; +import au.com.royalpay.payment.core.events.RefundSendEvent; +import au.com.royalpay.payment.core.processors.PaymentProcessor; +import au.com.royalpay.payment.manage.mappers.log.CouponAccuessLogMapper; +import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.env.PlatformEnvironment; +import au.com.royalpay.payment.tools.env.SysConfigManager; +import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; +import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; +import cn.yixblog.platform.http.HttpRequestGenerator; +import cn.yixblog.platform.http.HttpRequestResult; +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.Order; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.util.UriComponentsBuilder; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@Service +public class CtripCouponOnlyLogProcessor implements PaymentProcessor { + + // todo 重构逻辑 + private org.slf4j.Logger logger = LoggerFactory.getLogger(getClass()); + + + private static final String COUPON_ID = "CTRIP_COUPON_ONLY_LOG"; + + @Value("${app.customer.host}") + private String CUSTOMER_HOST; + + @Value("${customer.app.appid}") + private String CUSTOMER_APP_ID; + + @Value("${customer.app.auth-code}") + private String CUSTOMER_AUTH_CODE; + + @Resource + private MerchantInfoProvider merchantInfoProvider; + + @Resource + private SysConfigManager sysConfigManager; + + @Resource + private CouponAccuessLogMapper payCouponAccuessLogMapper; + @Resource + private PaymentApi paymentApi; + @Override + public String processorId() { + return COUPON_ID + "_USE"; + } + + @Override + public void handleBeforeOrderSending(PreOrderRequest paymentInfo, JSONObject order) { + JSONObject tmpEle = paymentInfo.getTmpEle(); + if (tmpEle == null) { + return; + } + if (StringUtils.isEmpty(tmpEle.getString("ctrip_coupon_id"))) { + return; + } + if (!isOnlyLogMerchant(order.getIntValue("client_id"))) { + return; + } + JSONObject couponInfo = getPreOrderCoupon(tmpEle.getString("ctrip_coupon_id"), order.getIntValue("client_id")); + if (couponInfo == null) { + return; + } + BigDecimal payFee = paymentInfo.getTotalFee(); + BigDecimal exchange = paymentApi.channelApi(paymentInfo.getChannel()).queryExchangeRateDecimal(paymentInfo.getClientId()); + if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + payFee = CurrencyAmountUtils.scale(payFee.divide(exchange,2, BigDecimal.ROUND_HALF_UP), PlatformEnvironment.getEnv().getForeignCurrency()); + } + BigDecimal couponCondition = couponInfo.getBigDecimal("condition") == null ? BigDecimal.ZERO + : couponInfo.getBigDecimal("condition"); + if (payFee.compareTo(couponCondition) < 0) { + return; + } + JSONObject couponAccuessLog = new JSONObject(); + couponAccuessLog.put("client_id",order.getIntValue("client_id")); + couponAccuessLog.put("customer_openid","创建订单时无"); + couponAccuessLog.put("creation_date",new Date()); + couponAccuessLog.put("order_id",order.getString("order_id")); + couponAccuessLog.put("coupon_id","CTRIP_"+tmpEle.getString("ctrip_coupon_id")); + //携程满减 + if (StringUtils.equals(couponInfo.getString("type"), "31")) { + BigDecimal actureAmount = couponInfo.getBigDecimal("acture_amount"); + if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + actureAmount = CurrencyAmountUtils.scale(couponInfo.getBigDecimal("acture_amount").multiply(exchange), PlatformEnvironment.getEnv().getForeignCurrency()); + } + couponAccuessLog.put("coupon_deal_amount", actureAmount); + } + //携程折扣 + if (StringUtils.equals(couponInfo.getString("type"), "32")) { + BigDecimal couponDiscount = couponInfo.getBigDecimal("discount").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_HALF_UP); + BigDecimal couponDealAmount = CurrencyAmountUtils.scale(couponDiscount.multiply(paymentInfo.getTotalFee()), PlatformEnvironment.getEnv().getForeignCurrency()); + couponAccuessLog.put("coupon_deal_amount", couponDealAmount); + } + couponAccuessLog.put("currency", order.getString("currency")); + couponAccuessLog.put("min_pay_amount", couponCondition); + payCouponAccuessLogMapper.save(couponAccuessLog); + } + + @Override + public void handleAfterOrderPaid(PaymentFinishedEvent finishedEvent) { + JSONObject order = finishedEvent.getOrder(); + String orderId = order.getString("order_id"); + List accuessCouponLogs = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId, new PageBounds(Order.formString("last_update_date.desc"))); + if (accuessCouponLogs != null&&accuessCouponLogs.size()>0) { + if (!isOnlyLogMerchant(order.getIntValue("client_id"))) { + return; + } + JSONObject accuessCouponLog = accuessCouponLogs.get(0); + String couponLogId = accuessCouponLog.getString("coupon_id"); + logger.info("订单 [" + orderId + "]成功使用Ctrip卡券=======>[" + couponLogId + "]"); + accuessCouponLog.put("is_valid", 1); + accuessCouponLog.put("last_update_date", new Date()); + accuessCouponLog.put("customer_openid",order.getString("customer_id")); + + payCouponAccuessLogMapper.update(accuessCouponLog); + } + } + + @Override + public void registerCoupon(JSONObject client, String customerOpenId, String channel, List coupons) { + return; + } + + @Override + public void handleAfterRefund(RefundSendEvent event) { + //do nothing + JSONObject refundOrder = event.getRefundOrder(); + String orderId = refundOrder.getString("order_id"); + List accuessCouponLogs = payCouponAccuessLogMapper.findUsedCouponByOrderIdList(orderId); + if (accuessCouponLogs != null&& accuessCouponLogs.size()>0) { + if (!isOnlyLogMerchant(refundOrder.getIntValue("client_id"))) { + return; + } + JSONObject accuessCouponLog = accuessCouponLogs.get(0); + accuessCouponLog.put("is_valid", 0); + accuessCouponLog.put("last_update_date", new Date()); + accuessCouponLog.put("refund_id",refundOrder.getString("refund_id")); + payCouponAccuessLogMapper.update(accuessCouponLog); + } + } + + @Override + public String registerBanner(JSONObject client, String channel) { + return null; + } + + // 使用券的信息 + private JSONObject getPreOrderCoupon(String couponLogId,int clientId) { + JSONObject client = merchantInfoProvider.getClientInfo(clientId); + String timestamp = System.currentTimeMillis() + ""; + String base = CUSTOMER_APP_ID + timestamp + CUSTOMER_AUTH_CODE; + String sign = DigestUtils.sha256Hex(base).toLowerCase(); + String uri = UriComponentsBuilder.fromHttpUrl(CUSTOMER_HOST + "coupon/" + couponLogId + "/couponLogInfo").queryParam("appid", CUSTOMER_APP_ID) + .queryParam("timestamp", timestamp).queryParam("sign", sign).queryParam("client_moniker", client.getString("client_moniker")).toUriString(); + HttpRequestGenerator gen = new HttpRequestGenerator(uri, RequestMethod.GET); + try { + HttpRequestResult result = gen.execute(); + if (result.isSuccess()) { + return result.getResponseContentJSONObj(); + } + } catch (Exception ignored) { + logger.error("积分商城优惠券 [" + couponLogId + "]使用失败"); + ignored.printStackTrace(); + } + return null; + } + + private boolean isOnlyLogMerchant(int clientId) { + JSONObject client = merchantInfoProvider.getClientInfo(clientId); + JSONObject sysConfig = sysConfigManager.getSysConfig(); + if (sysConfig.getString("ctrip_coupon_only_log_merchant_list").contains(client.getString("client_moniker"))) { + return true; + } + return false; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java new file mode 100644 index 000000000..1354d7813 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java @@ -0,0 +1,266 @@ +package au.com.royalpay.payment.manage.processors; + +import au.com.royalpay.payment.core.PaymentApi; +import au.com.royalpay.payment.core.TransactionService; +import au.com.royalpay.payment.core.beans.PaymentQueryResult; +import au.com.royalpay.payment.core.beans.PreOrderRequest; +import au.com.royalpay.payment.core.beans.coupon.CouponInfo; +import au.com.royalpay.payment.core.events.PaymentFinishedEvent; +import au.com.royalpay.payment.core.events.RefundSendEvent; +import au.com.royalpay.payment.core.mappers.PmtOrderMapper; +import au.com.royalpay.payment.core.processors.PaymentProcessor; +import au.com.royalpay.payment.manage.mappers.log.CouponAccuessLogMapper; +import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.env.PlatformEnvironment; +import au.com.royalpay.payment.tools.env.SysConfigManager; +import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; +import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; +import cn.yixblog.platform.http.HttpRequestGenerator; +import cn.yixblog.platform.http.HttpRequestResult; +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.Order; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.util.UriComponentsBuilder; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@Service +public class CtripCouponProvideProcessor implements PaymentProcessor { + + // todo 重构逻辑 + private org.slf4j.Logger logger = LoggerFactory.getLogger(getClass()); + + + private static final String COUPON_ID = "CTRIP_COUPON"; + + @Value("${app.customer.host}") + private String CUSTOMER_HOST; + + @Value("${customer.app.appid}") + private String CUSTOMER_APP_ID; + + @Value("${customer.app.auth-code}") + private String CUSTOMER_AUTH_CODE; + + @Resource + private MerchantInfoProvider merchantInfoProvider; + @Resource + private SysConfigManager sysConfigManager; + @Resource + private CouponAccuessLogMapper payCouponAccuessLogMapper; + @Resource + private PaymentApi paymentApi; + @Resource + private PmtOrderMapper pmtOrderMapper; + @Resource + private TransactionService transactionService; + @Override + public String processorId() { + return COUPON_ID + "_USE"; + } + + @Override + public void handleBeforeOrderSending(PreOrderRequest paymentInfo, JSONObject order) { + /*if (order.getIntValue("client_id") != 9) { + return; + }*/ + JSONObject tmpEle = paymentInfo.getTmpEle(); + if (tmpEle == null) { + return; + } + if (StringUtils.isEmpty(tmpEle.getString("ctrip_coupon_id"))) { + return; + } + logger.info("tmpEle:" + tmpEle.toJSONString()); + if (isOnlyLogMerchant(order.getIntValue("client_id"))) { + return; + } + JSONObject couponInfo = getPreOrderCoupon(tmpEle.getString("ctrip_coupon_id"), order.getIntValue("client_id")); + if (couponInfo == null) { + return; + } + BigDecimal payFee = paymentInfo.getTotalFee(); + BigDecimal exchange = paymentApi.channelApi(paymentInfo.getChannel()).queryExchangeRateDecimal(paymentInfo.getClientId()); + if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + payFee = CurrencyAmountUtils.scale(payFee.divide(exchange,2, BigDecimal.ROUND_HALF_UP), PlatformEnvironment.getEnv().getForeignCurrency()); + } + BigDecimal couponCondition = couponInfo.getBigDecimal("condition") == null ? BigDecimal.ZERO + : couponInfo.getBigDecimal("condition"); + if (payFee.compareTo(couponCondition) < 0) { + return; + } + JSONObject couponAccuessLog = new JSONObject(); + couponAccuessLog.put("client_id",order.getIntValue("client_id")); + couponAccuessLog.put("customer_openid","创建订单时无"); + couponAccuessLog.put("creation_date",new Date()); + couponAccuessLog.put("order_id",order.getString("order_id")); + couponAccuessLog.put("coupon_id","CTRIP_"+tmpEle.getString("ctrip_coupon_id")); + BigDecimal currentDiscount = paymentInfo.getDiscount(); + //携程满减 + if (StringUtils.equals(couponInfo.getString("type"), "31")) { + BigDecimal actureAmount = couponInfo.getBigDecimal("acture_amount"); + if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + actureAmount = CurrencyAmountUtils.scale(couponInfo.getBigDecimal("acture_amount").multiply(exchange), PlatformEnvironment.getEnv().getForeignCurrency()); + } + paymentInfo.setDiscount(currentDiscount.add(actureAmount)); + couponAccuessLog.put("coupon_deal_amount", actureAmount); + } + //携程折扣 + if (StringUtils.equals(couponInfo.getString("type"), "32")) { + BigDecimal couponDiscount = couponInfo.getBigDecimal("discount").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_HALF_UP); + BigDecimal couponDealAmount = CurrencyAmountUtils.scale(couponDiscount.multiply(paymentInfo.getTotalFee()), PlatformEnvironment.getEnv().getForeignCurrency()); + paymentInfo.setDiscount(currentDiscount.add(couponDealAmount)); + couponAccuessLog.put("coupon_deal_amount", couponDealAmount); + } + couponAccuessLog.put("currency", order.getString("currency")); + couponAccuessLog.put("min_pay_amount", couponCondition); + payCouponAccuessLogMapper.save(couponAccuessLog); + + JSONObject updateOrder = new JSONObject(); + BigDecimal customerPay = paymentInfo.getUserPayAmount(); + updateOrder.put("customer_payment_amount", customerPay); + BigDecimal couponDiscount = paymentInfo.getDiscount(); + updateOrder.put("coupon_payment_amount", couponDiscount); + updateOrder.put("order_id", paymentInfo.getOrderId()); + + pmtOrderMapper.update(updateOrder); + + order.put("customer_payment_amount", customerPay); + order.put("coupon_payment_amount", couponDiscount); + } + + @Override + public void handleAfterOrderPaid(PaymentFinishedEvent finishedEvent) { + JSONObject order = finishedEvent.getOrder(); + /*if (order.getIntValue("client_id") != 9) { + return; + }*/ + String orderId = order.getString("order_id"); + List accuessCouponLogs = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId, new PageBounds(Order.formString("last_update_date.desc"))); + if (accuessCouponLogs != null&&accuessCouponLogs.size()>0) { + if (isOnlyLogMerchant(order.getIntValue("client_id"))) { + return; + } + JSONObject accuessCouponLog = accuessCouponLogs.get(0); + String couponLogId = accuessCouponLog.getString("coupon_id"); + logger.info("订单 [" + orderId + "]成功使用Ctrip卡券=======>[" + couponLogId + "]"); + + //传入流水 + JSONObject useCoupontrans = new JSONObject(); + useCoupontrans.put("org_id", order.getIntValue("org_id")); + useCoupontrans.put("system_transaction_id", accuessCouponLog.getString("accuess_id")); + useCoupontrans.put("order_id", order.getString("order_id")); + useCoupontrans.put("client_id", order.getIntValue("client_id")); + useCoupontrans.put("transaction_currency", order.getString("currency")); + if (StringUtils.equals(order.getString("currency"), "CNY")) { + useCoupontrans.put("cny_amount", accuessCouponLog.getBigDecimal("coupon_deal_amount")); + } + useCoupontrans.put("clearing_currency", PlatformEnvironment.getEnv().getForeignCurrency()); + useCoupontrans.put("clearing_amount", accuessCouponLog.getBigDecimal("coupon_deal_amount")); + useCoupontrans.put("transaction_amount", accuessCouponLog.getBigDecimal("coupon_deal_amount")); + useCoupontrans.put("exchange_rate", finishedEvent.getExchangeRate()); + useCoupontrans.put("channel", order.getString("channel")); + useCoupontrans.put("transaction_type", "Credit"); + PaymentQueryResult pay = finishedEvent.getPaymentQueryResult(); + useCoupontrans.put("transaction_time", pay.getPayTime()); + useCoupontrans.put("clearing_status", 0); + useCoupontrans.put("system_generate", 1); + useCoupontrans.put("remark", "Ctrip Coupon from Customer:" + couponLogId); + accuessCouponLog = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId,new PageBounds(Order.formString("last_update_date.desc"))).get(0); + if (accuessCouponLog != null) { + transactionService.saveTransaction(useCoupontrans); + accuessCouponLog.put("is_valid", 1); + accuessCouponLog.put("last_update_date", new Date()); + accuessCouponLog.put("transaction_id", useCoupontrans.getString("transaction_id")); + accuessCouponLog.put("customer_openid",order.getString("customer_id")); + payCouponAccuessLogMapper.update(accuessCouponLog); + } + + } + } + + @Override + public void registerCoupon(JSONObject client, String customerOpenId, String channel, List coupons) { + return; + } + + @Override + public void handleAfterRefund(RefundSendEvent event) { + //do nothing + JSONObject refundOrder = event.getRefundOrder(); + /*if (refundOrder.getIntValue("client_id") != 9) { + return; + }*/ + logger.info("积分商城携程优惠券开始退款"); + String orderId = refundOrder.getString("order_id"); + List accuessCouponLogs = payCouponAccuessLogMapper.findUsedCouponByOrderIdList(orderId); + if (accuessCouponLogs != null&& accuessCouponLogs.size()>0) { + if (isOnlyLogMerchant(refundOrder.getIntValue("client_id"))) { + return; + } + JSONObject accuessCouponLog = accuessCouponLogs.get(0); + JSONObject trans = transactionService.findTransaction(accuessCouponLog.getString("transaction_id")); + if (trans != null) { + logger.info("正在退款的券的初始信息" + trans.toJSONString()); + trans.remove("transaction_id"); + trans.put("transaction_type", "Debit"); + String coupon_id = accuessCouponLog.getString("coupon_id"); + trans.put("refund_id", refundOrder.getString("refund_id")); + trans.put("transaction_time", new Date()); + trans.put("remark", "Refund for Customer Ctrip Coupon:" + coupon_id); + logger.info("正在退款的券的信息" + trans.toJSONString()); + transactionService.saveTransaction(trans); + logger.error("订单[" + orderId + "]发送全额退款,携程优惠券【" + coupon_id + "】转为Debit"); + accuessCouponLog.put("transaction_refund_id", trans.getString("transaction_id")); + accuessCouponLog.put("refund_id", refundOrder.getString("refund_id")); + accuessCouponLog.put("is_valid", 0); + accuessCouponLog.put("last_update_date", new Date()); + payCouponAccuessLogMapper.update(accuessCouponLog); + } + } + } + + @Override + public String registerBanner(JSONObject client, String channel) { + return null; + } + + // 使用券的信息 + private JSONObject getPreOrderCoupon(String couponLogId,int clientId) { + JSONObject client = merchantInfoProvider.getClientInfo(clientId); + String timestamp = System.currentTimeMillis() + ""; + String base = CUSTOMER_APP_ID + timestamp + CUSTOMER_AUTH_CODE; + String sign = DigestUtils.sha256Hex(base).toLowerCase(); + String uri = UriComponentsBuilder.fromHttpUrl(CUSTOMER_HOST + "coupon/" + couponLogId + "/couponLogInfo").queryParam("appid", CUSTOMER_APP_ID) + .queryParam("timestamp", timestamp).queryParam("sign", sign).queryParam("client_moniker", client.getString("client_moniker")).toUriString(); + HttpRequestGenerator gen = new HttpRequestGenerator(uri, RequestMethod.GET); + try { + HttpRequestResult result = gen.execute(); + if (result.isSuccess()) { + return result.getResponseContentJSONObj(); + } + } catch (Exception ignored) { + logger.error("积分商城优惠券 [" + couponLogId + "]使用失败"); + ignored.printStackTrace(); + } + return null; + } + + private boolean isOnlyLogMerchant(int clientId) { + JSONObject client = merchantInfoProvider.getClientInfo(clientId); + JSONObject sysConfig = sysConfigManager.getSysConfig(); + if (sysConfig.getString("ctrip_coupon_only_log_merchant_list").contains(client.getString("client_moniker"))) { + return true; + } + return false; + } +} From cbf474e01a9ffd859fdf338c07d8b7b7ffcd5f8f Mon Sep 17 00:00:00 2001 From: yangkai Date: Tue, 18 Dec 2018 18:13:28 +0800 Subject: [PATCH 05/13] cb_bankpay --- .../sysconfig/core/SysPaymentConfig.java | 11 +++ .../core/impls/SysPaymentConfigImpl.java | 34 +++++++++ .../sysconfig/web/SysConfigController.java | 19 +++-- .../system/SysPaymentConfigMapper.java | 25 ++++++ .../manage/merchants/core/ClientManager.java | 7 ++ .../core/impls/ClientManagerImpl.java | 76 ++++++++++++++----- .../web/PartnerManageController.java | 15 ++++ .../manage/organizations/beans/OrgInfo.java | 18 +++++ .../mappers/system/SysPaymentConfigMapper.xml | 20 +++++ .../organizations/templates/new_org.html | 24 ++++++ .../organizations/templates/org_detail.html | 16 ++++ .../ui/static/config/sysconfigs/sysconfigs.js | 49 ++++++++++++ .../templates/payment_bankpay_config.html | 40 ++++++++++ .../sysconfigs/templates/sysconfig.html | 4 +- .../static/payment/partner/partner-manage.js | 25 ++++++ .../templates/partner_bankaccounts.html | 1 + .../partner/templates/partner_new_rate.html | 24 ++++++ .../templates/partner_payment_info.html | 30 ++++++++ .../ui/static/templates/payment/v1/payment.js | 16 +++- 19 files changed, 425 insertions(+), 29 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/SysPaymentConfig.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.java create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.xml create mode 100644 src/main/ui/static/config/sysconfigs/templates/payment_bankpay_config.html diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/SysPaymentConfig.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/SysPaymentConfig.java new file mode 100644 index 000000000..412a9a1f3 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/SysPaymentConfig.java @@ -0,0 +1,11 @@ +package au.com.royalpay.payment.manage.management.sysconfig.core; + +import com.alibaba.fastjson.JSONObject; + +import java.util.List; + +public interface SysPaymentConfig { + List getPaymentChannel(); + + void updatePaymentChannel(JSONObject manager, String channel, int type); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java new file mode 100644 index 000000000..11623dbda --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java @@ -0,0 +1,34 @@ +package au.com.royalpay.payment.manage.management.sysconfig.core.impls; + +import au.com.royalpay.payment.manage.management.sysconfig.core.SysPaymentConfig; +import au.com.royalpay.payment.manage.mappers.system.RateMapper; +import au.com.royalpay.payment.manage.mappers.system.SysPaymentConfigMapper; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import com.alibaba.fastjson.JSONObject; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +@Service +public class SysPaymentConfigImpl implements SysPaymentConfig { + @Resource + private SysPaymentConfigMapper sysPaymentConfigMapper; + + @Override + public List getPaymentChannel() { + return sysPaymentConfigMapper.selectAll(); + } + + @Override + public void updatePaymentChannel(JSONObject manager, String channel, int type) { + JSONObject paymentConfig = sysPaymentConfigMapper.find(channel, type); + if (paymentConfig == null) { + throw new BadRequestException("不存在该快捷通道"); + } + Date lastUpdateTime = new Date(); + sysPaymentConfigMapper.updatePaymentConfig(channel, type, lastUpdateTime, manager.getString("display_name"), false); + sysPaymentConfigMapper.updatePaymentConfig(channel, type, lastUpdateTime, manager.getString("display_name"), true); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/web/SysConfigController.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/web/SysConfigController.java index 6aaea6373..1575ca76d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/web/SysConfigController.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/web/SysConfigController.java @@ -1,17 +1,15 @@ package au.com.royalpay.payment.manage.management.sysconfig.web; import au.com.royalpay.payment.manage.management.sysconfig.core.ClearDateManager; +import au.com.royalpay.payment.manage.management.sysconfig.core.SysPaymentConfig; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import com.alibaba.fastjson.JSONObject; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -27,6 +25,8 @@ public class SysConfigController { private SysConfigManager sysConfigManager; @Resource private ClearDateManager clearDateManager; + @Resource + private SysPaymentConfig sysPaymentConfig; @ManagerMapping(value = "/base", method = RequestMethod.GET) public JSONObject getBaseConfig() { @@ -48,8 +48,13 @@ public class SysConfigController { clearDateManager.setMonthClearDays(monthPattern, days); } + @ManagerMapping(value = "/payment/config", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.FINANCIAL_STAFF, ManagerRole.OPERATOR}) + public List selectPaymentChannel() { + return sysPaymentConfig.getPaymentChannel(); + } - public static void main(String[] args) { - System.out.println("asd".equals(null)); + @ManagerMapping(value = "/payment/{channel}/config/{type}", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.FINANCIAL_STAFF, ManagerRole.OPERATOR}) + public void updatePaymentChannel(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String channel, @PathVariable int type) { + sysPaymentConfig.updatePaymentChannel(manager, channel, type); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.java new file mode 100644 index 000000000..04d707498 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.java @@ -0,0 +1,25 @@ +package au.com.royalpay.payment.manage.mappers.system; + +import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect; +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import com.alibaba.fastjson.JSONObject; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +@AutoMapper(tablename = "sys_payment_config",pkName = "channel") +public interface SysPaymentConfigMapper { + @AutoSql(type = SqlType.SELECT) + List selectAll(); + + @AutoSql(type = SqlType.SELECT) + JSONObject find(@Param(value = "channel_id") String channel, @Param(value = "type") int type); + + void updatePaymentConfig(@Param(value = "channel_id") String channel, @Param(value = "type") int type, @Param(value = "last_update_date")Date lastUpdateDate, + @Param(value = "last_update_by")String lastUpdateBy, @Param(value = "is_valid") boolean is_valid); + + JSONObject findOne(@Param(value = "type") int type); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 314881b9f..4bbc970ee 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -369,4 +369,11 @@ public interface ClientManager { JSONObject comListPartnerSelection(JSONObject manager, PartnerQuery query); List getClientBySimpleQuery(JSONObject param); + + void switchPaymentConfig(String clientMoniker, HttpServletResponse response) throws IOException; + + @Transactional + void switchCBBankLink(JSONObject manager, String clientMoniker, boolean allow); + + String cbBankPayLink(String clientMoniker); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 71a63d93e..8cefec8eb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -27,25 +27,7 @@ import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper; import au.com.royalpay.payment.manage.mappers.risk.RiskAttentionMerchantsMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientAuditProcessMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; -import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper; -import au.com.royalpay.payment.manage.mappers.system.MailSendMapper; -import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper; -import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; -import au.com.royalpay.payment.manage.mappers.system.OrgMapper; -import au.com.royalpay.payment.manage.mappers.system.PermissionPartnerModuleMapper; -import au.com.royalpay.payment.manage.mappers.system.SysRpayMerchantApplyMapper; -import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper; +import au.com.royalpay.payment.manage.mappers.system.*; import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder; import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo; import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; @@ -313,6 +295,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private PermissionPartnerManagerImpl permissionPartnerManagerImpl; @Resource private RiskAttentionMerchantsMapper riskAttentionMerchantsMapper; + @Resource + private SysPaymentConfigMapper sysPaymentConfigMapper; @Resource private SmsSender smsSender; @@ -445,6 +429,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid String yeepayQrcodeUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/yeepay/partners/" + client.getString("client_moniker") + "/jump/app"); client.put("yeepayQrcodeUrl", QRCodeUtils.qrcodeImageCode(yeepayQrcodeUrl, 250, true)); } + if (client.getString("cb_bankpay_url") != null) { + String cbBankPayQrcodeUrl = PlatformEnvironment.getEnv().concatUrl("/sys/partners/" + client.getString("client_moniker") + "/cb_bankpay/link"); + client.put("cbBankPayQrcodeUrl", QRCodeUtils.qrcodeImageCode(cbBankPayQrcodeUrl, 250, true)); + } return client; } @@ -1627,6 +1615,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkAddRate(config, "hf", "hf_rate_value", org, "min_hf_rate"); checkAddRate(config, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate"); checkAddRate(config, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); + checkAddRate(config, "CB_BankPay", "min_cb_bankpay_value", org, "min_cb_bankpay_rate"); configNewClientRate(config, clientId, "Wechat", "wechat_rate_value", org, "min_wechat_rate"); configNewClientRate(config, clientId, "Alipay", "alipay_rate_value", org, "min_alipay_rate"); @@ -1636,6 +1625,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid configNewClientRate(config, clientId, "hf", "hf_rate_value", org, "min_hf_rate"); configNewClientRate(config, clientId, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate"); configNewClientRate(config, clientId, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); + configNewClientRate(config, clientId, "CB_BankPay", "cb_bankpay_rate_value", org, "min_cb_bankpay_rate"); //todo 暂不更新Rpay+ 费率信息 rpayApi.modifySurchargeConfig(client); @@ -4268,6 +4258,50 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid return PageListUtils.buildPageListResult(partners); } + @Override + public void switchPaymentConfig(String clientMoniker, HttpServletResponse response) throws IOException { + JSONObject client = clientMapper.findClientByMoniker(clientMoniker); + if (client == null) { + throw new BadRequestException("partner code is not exists!"); + } + JSONObject paymentConfig = sysPaymentConfigMapper.findOne(1); + if (paymentConfig == null) { + throw new BadRequestException("服务商未开启快捷支付"); + } + response.sendRedirect(String.format(PlatformEnvironment.getEnv().concatUrl(paymentConfig.getString("path")), clientMoniker)); + } + + @Override + public void switchCBBankLink(JSONObject manager, String clientMoniker, boolean allow) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + checkOrgPermission(manager, client); + if (StringUtils.isEmpty(client.getString("cb_bankpay_url"))) { + String longUrl = PlatformEnvironment.getEnv().concatUrl("/sys/partners/" + client.getString("client_moniker") + "/cb_bankpay/link"); + String cb_bankpay_url = getCBBankShortLink(longUrl); + client.put("cb_bankpay_url", cb_bankpay_url); + client.put("enable_cb_bankpay_link", allow); + clientMapper.update(client); + } else { + client.put("enable_cb_bankpay_link", allow); + clientMapper.update(client); + } + } + + @Override + public String cbBankPayLink(String clientMoniker) { + JSONObject client = clientMapper.findClientByMoniker(clientMoniker); + if (client == null) { + throw new BadRequestException("partner code is not exists!"); + } + JSONObject paymentConfig = sysPaymentConfigMapper.findOne(1); + if (paymentConfig == null) { + throw new BadRequestException("服务商未开启快捷支付"); + } + return String.format(PlatformEnvironment.getEnv().concatUrl(paymentConfig.getString("path")), clientMoniker); + } private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) { TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null); @@ -4292,4 +4326,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid }).start(); } + private String getCBBankShortLink(String longUrl) { + MpWechatApi api = mpWechatApiProvider.getNewPaymentApi(); + return api.registerShortUrl(longUrl); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index a39bd8f1d..654263a3c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -621,4 +621,19 @@ public class PartnerManageController { return clientManager.comListPartnerSelection(manager, query); } + + @RequestMapping(value = "/{clientMoniker}/cb_bankpay/link", method = RequestMethod.GET) + public void switchPaymentWay(@PathVariable String clientMoniker, HttpServletResponse response) throws IOException { + clientManager.switchPaymentConfig(clientMoniker, response); + } + + @ManagerMapping(value = "/{clientMoniker}/cb_bankpay", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) + public void switchCBBankPayLinkPermission(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.switchCBBankLink(manager, clientMoniker, pass.getBooleanValue("allow")); + } + + @RequestMapping(value = "/{clientMoniker}/jump/link", method = RequestMethod.GET) + public String jumpCBBankPayLink(@PathVariable String clientMoniker) { + return clientManager.cbBankPayLink(clientMoniker); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java index 772911b27..e65588da3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java @@ -30,6 +30,7 @@ public class OrgInfo { private Double jd_rate_value; private Double hf_rate_value; private Double yeepay_rate_value; + private Double cb_bankpay_rate_value; private int is_valid; private String search_text; private int page = 1; @@ -44,6 +45,7 @@ public class OrgInfo { private Double min_alipayonline_rate; private Double min_hf_rate; private Double min_yeepay_rate; + private Double min_cb_bankpay_rate; private String state; private String senior_parent_org_id; @@ -341,4 +343,20 @@ public class OrgInfo { public void setMin_yeepay_rate(Double min_yeepay_rate) { this.min_yeepay_rate = min_yeepay_rate; } + + public Double getCb_bankpay_rate_value() { + return cb_bankpay_rate_value; + } + + public void setCb_bankpay_rate_value(Double cb_bankpay_rate_value) { + this.cb_bankpay_rate_value = cb_bankpay_rate_value; + } + + public Double getMin_cb_bankpay_rate() { + return min_cb_bankpay_rate; + } + + public void setMin_cb_bankpay_rate(Double min_cb_bankpay_rate) { + this.min_cb_bankpay_rate = min_cb_bankpay_rate; + } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.xml new file mode 100644 index 000000000..6b270ceed --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.xml @@ -0,0 +1,20 @@ + + + + + update sys_payment_config + SET is_valid = #{is_valid},last_update_by = #{last_update_by},last_update_date = #{last_update_date} + + type = #{type} + + and channel_id = #{channel_id} + + + and channel_id != #{channel_id} + + + + + \ No newline at end of file diff --git a/src/main/ui/static/config/organizations/templates/new_org.html b/src/main/ui/static/config/organizations/templates/new_org.html index a9d931c59..564056750 100644 --- a/src/main/ui/static/config/organizations/templates/new_org.html +++ b/src/main/ui/static/config/organizations/templates/new_org.html @@ -203,6 +203,18 @@
+
+ +
+
+ + % +
+
+
@@ -291,6 +303,18 @@
+
+ +
+
+ + % +
+
+
%
+
+ +
+ + % +
+
@@ -236,6 +243,15 @@ % +
+ +
+ + % +
+
diff --git a/src/main/ui/static/config/sysconfigs/sysconfigs.js b/src/main/ui/static/config/sysconfigs/sysconfigs.js index bb71c95ce..a8a32ea2a 100644 --- a/src/main/ui/static/config/sysconfigs/sysconfigs.js +++ b/src/main/ui/static/config/sysconfigs/sysconfigs.js @@ -13,6 +13,10 @@ define(['angular', 'uiRouter'], function (angular) { url: '/basic', templateUrl: '/static/config/sysconfigs/templates/basic.html', controller: 'basicConfigCtrl' + }).state('sysconfig.payment_bankpay_config', { + url: '/payment', + templateUrl: '/static/config/sysconfigs/templates/payment_bankpay_config.html', + controller: 'paymentChannelConfigCtrl' }).state('permission', { url: '/permission', templateUrl: '/static/config/sysconfigs/templates/permission_config.html', @@ -66,6 +70,51 @@ define(['angular', 'uiRouter'], function (angular) { }]); + app.controller('paymentChannelConfigCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) { + $scope.loadPaymentChannel = function () { + $scope.cb_bankpay_channel = null; + $scope.pay_channel = null; + $scope.cb_bankpay = []; + $scope.pay = []; + $http.get('/sysconfig/payment/config').then(function (resp) { + resp.data.forEach(function (channel) { + if (channel.type === 1) { + if (channel.is_valid) { + $scope.cb_bankpay_channel = channel.channel_id; + } + $scope.cb_bankpay.push(channel); + } + if (channel.type === 2) { + if (channel.is_valid) { + $scope.pay_channel = channel.channel_id; + } + $scope.pay.push(channel); + } + + }) + }) + }; + $scope.loadPaymentChannel(); + $scope.updatePaymentConfig = function (type,channel) { + if (channel == null) { + commonDialog.alert({type: 'error', title: 'Error', content: '支付通道不能为空'}); + return; + } + commonDialog.confirm({ + title: 'Confirm', + content: '你确定要将支付通道更改为:' + channel + }).then(function () { + $http.put('/sysconfig/payment/'+ channel + '/config/' + type).then(function (resp) { + commonDialog.alert({type: 'success', title: 'Success', content: '修改成功'}); + $scope.loadPaymentChannel(); + }, function (resp) { + commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message}); + $scope.loadPaymentChannel(); + }); + }) + } + }]); + app.controller('servantsConfigCtrl', ['$scope','$http','commonDialog', function ($scope,$http,commonDialog) { $scope.ctrl={}; $scope.loadServants = function () { diff --git a/src/main/ui/static/config/sysconfigs/templates/payment_bankpay_config.html b/src/main/ui/static/config/sysconfigs/templates/payment_bankpay_config.html new file mode 100644 index 000000000..da1e8d5e6 --- /dev/null +++ b/src/main/ui/static/config/sysconfigs/templates/payment_bankpay_config.html @@ -0,0 +1,40 @@ +
+

Basic Config

+ +
+ +
+
+
+
+
+
+
+
+ + + + +
+
+
+
+
+
+
+
diff --git a/src/main/ui/static/config/sysconfigs/templates/sysconfig.html b/src/main/ui/static/config/sysconfigs/templates/sysconfig.html index 970daaa5e..d48cbb4c3 100644 --- a/src/main/ui/static/config/sysconfigs/templates/sysconfig.html +++ b/src/main/ui/static/config/sysconfigs/templates/sysconfig.html @@ -35,10 +35,10 @@ - + diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 42072fd12..d6ba7be9a 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -1318,6 +1318,16 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'}); } }; + $scope.copyCBBankPayLink = function() { + var e=document.getElementById("cpcbbankpay"); + e.select(); + var successful = document.execCommand("Copy"); + if (successful) { + commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'}); + }else { + commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'}); + } + }; $scope.loadPartnerPaymentInfo = function () { $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { $scope.paymentInfo = resp.data; @@ -1624,6 +1634,21 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }) }; + $scope.toggleCBBankPayLink = function () { + if (!$scope.paymentInfo) { + return; + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cb_bankpay', {allow: $scope.paymentInfo.enable_cb_bankpay_link}).then(function () { + $scope.loadPartnerPaymentInfo(); + }, function (resp) { + commonDialog.alert({ + title: 'Failed to change cb_bankpay permission status', + content: resp.data.message, + type: 'error' + }); + }) + }; + $scope.toggleGatewayEmailNotice = function (channel) { if (!$scope.paymentInfo) { return; diff --git a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html index 5385003d5..7ebdd521d 100644 --- a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html +++ b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html @@ -173,6 +173,7 @@
  • HFpay
  • Rpay+
  • Yeepay
  • +
  • CB_BankPay
  • diff --git a/src/main/ui/static/payment/partner/templates/partner_new_rate.html b/src/main/ui/static/payment/partner/templates/partner_new_rate.html index f9400f322..3402bd481 100644 --- a/src/main/ui/static/payment/partner/templates/partner_new_rate.html +++ b/src/main/ui/static/payment/partner/templates/partner_new_rate.html @@ -183,6 +183,30 @@ + +
    + +
    +
    + +
    %
    +
    +
    +
    + No more than 5.0% +
    +
    + No less than 0.6% +
    +
    + Required Field +
    +
    + +
    +
    +
    + +
    + +
    +
    @@ -394,6 +400,30 @@ +
    +
    CB Bank Payment
    +
    +
    + +
    + + +
    +
    + + +
    +   仅支持微信客户端扫描 +
    +
    +
    +
    +
    Retail In Store Payment(App, WePayLite, Albert)
    diff --git a/src/main/ui/static/templates/payment/v1/payment.js b/src/main/ui/static/templates/payment/v1/payment.js index 781f43f4b..cedcc0887 100644 --- a/src/main/ui/static/templates/payment/v1/payment.js +++ b/src/main/ui/static/templates/payment/v1/payment.js @@ -62,7 +62,21 @@ $(function () { updatePrice(); } }); - + $('.cb_bankpay').click(function () { + $.ajax({ + url: '/sys/partners/' + window.client_moniker + '/jump/link', + method: 'GET', + success: function (res) { + location.href = res; + }, + error: function (resp) { + var config = { + template: resp + }; + showWeuiDialog(config); + } + }) + }); $('#key_B').bind('touchstart', function () { backspace(); }); From 1796a7fd3e17baec17a72d91bd744484bce78835 Mon Sep 17 00:00:00 2001 From: yangkai Date: Tue, 18 Dec 2018 19:25:03 +0800 Subject: [PATCH 06/13] fix --- .../payment/manage/merchants/core/impls/ClientManagerImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 8cefec8eb..220fe6366 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1232,7 +1232,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public void switchChannelPermission(JSONObject manager, String clientMoniker, String channel, boolean allow) { for (PaymentChannelApi channelApi : channels) { - if (channelApi.channel().equalsIgnoreCase(channel)) { + if (channelApi.channel().equalsIgnoreCase(channel) || "CB_BankPay".equalsIgnoreCase(channel)) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new NotFoundException("Client Not Exists"); @@ -1541,6 +1541,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (PaymentChannelApi channel : channels) { rates.addAll(merchantInfoProvider.listClientRates(clientId, new Date(), channel.channel(), includingInactive)); } + rates.addAll(merchantInfoProvider.listClientRates(clientId, new Date(), "CB_BankPay", includingInactive)); if (!rates.isEmpty()) { try { for (JSONObject rate : rates) { From 4886dd214e68ab8665b29d836d8838a2dcbc8a26 Mon Sep 17 00:00:00 2001 From: yangkai Date: Tue, 18 Dec 2018 20:35:30 +0800 Subject: [PATCH 07/13] fix --- .../sysconfig/core/impls/SysPaymentConfigImpl.java | 12 ++++++------ ...ConfigMapper.java => SysChannelConfigMapper.java} | 5 ++--- .../merchants/core/impls/ClientManagerImpl.java | 6 +++--- ...ntConfigMapper.xml => SysChannelConfigMapper.xml} | 6 +++--- 4 files changed, 14 insertions(+), 15 deletions(-) rename src/main/java/au/com/royalpay/payment/manage/mappers/system/{SysPaymentConfigMapper.java => SysChannelConfigMapper.java} (84%) rename src/main/resources/au/com/royalpay/payment/manage/mappers/system/{SysPaymentConfigMapper.xml => SysChannelConfigMapper.xml} (82%) diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java index 11623dbda..67d7af1ef 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/SysPaymentConfigImpl.java @@ -2,7 +2,7 @@ package au.com.royalpay.payment.manage.management.sysconfig.core.impls; import au.com.royalpay.payment.manage.management.sysconfig.core.SysPaymentConfig; import au.com.royalpay.payment.manage.mappers.system.RateMapper; -import au.com.royalpay.payment.manage.mappers.system.SysPaymentConfigMapper; +import au.com.royalpay.payment.manage.mappers.system.SysChannelConfigMapper; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import com.alibaba.fastjson.JSONObject; import org.springframework.stereotype.Service; @@ -14,21 +14,21 @@ import java.util.List; @Service public class SysPaymentConfigImpl implements SysPaymentConfig { @Resource - private SysPaymentConfigMapper sysPaymentConfigMapper; + private SysChannelConfigMapper sysChannelConfigMapper; @Override public List getPaymentChannel() { - return sysPaymentConfigMapper.selectAll(); + return sysChannelConfigMapper.selectAll(); } @Override public void updatePaymentChannel(JSONObject manager, String channel, int type) { - JSONObject paymentConfig = sysPaymentConfigMapper.find(channel, type); + JSONObject paymentConfig = sysChannelConfigMapper.find(channel, type); if (paymentConfig == null) { throw new BadRequestException("不存在该快捷通道"); } Date lastUpdateTime = new Date(); - sysPaymentConfigMapper.updatePaymentConfig(channel, type, lastUpdateTime, manager.getString("display_name"), false); - sysPaymentConfigMapper.updatePaymentConfig(channel, type, lastUpdateTime, manager.getString("display_name"), true); + sysChannelConfigMapper.updatePaymentConfig(channel, type, lastUpdateTime, manager.getString("display_name"), false); + sysChannelConfigMapper.updatePaymentConfig(channel, type, lastUpdateTime, manager.getString("display_name"), true); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.java similarity index 84% rename from src/main/java/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.java rename to src/main/java/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.java index 04d707498..2d4eb5549 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.java @@ -1,6 +1,5 @@ package au.com.royalpay.payment.manage.mappers.system; -import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.SqlType; @@ -10,8 +9,8 @@ import org.apache.ibatis.annotations.Param; import java.util.Date; import java.util.List; -@AutoMapper(tablename = "sys_payment_config",pkName = "channel") -public interface SysPaymentConfigMapper { +@AutoMapper(tablename = "cb_channel_config",pkName = "channel_id") +public interface SysChannelConfigMapper { @AutoSql(type = SqlType.SELECT) List selectAll(); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 220fe6366..124e10295 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -296,7 +296,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Resource private RiskAttentionMerchantsMapper riskAttentionMerchantsMapper; @Resource - private SysPaymentConfigMapper sysPaymentConfigMapper; + private SysChannelConfigMapper sysChannelConfigMapper; @Resource private SmsSender smsSender; @@ -4265,7 +4265,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new BadRequestException("partner code is not exists!"); } - JSONObject paymentConfig = sysPaymentConfigMapper.findOne(1); + JSONObject paymentConfig = sysChannelConfigMapper.findOne(1); if (paymentConfig == null) { throw new BadRequestException("服务商未开启快捷支付"); } @@ -4297,7 +4297,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new BadRequestException("partner code is not exists!"); } - JSONObject paymentConfig = sysPaymentConfigMapper.findOne(1); + JSONObject paymentConfig = sysChannelConfigMapper.findOne(1); if (paymentConfig == null) { throw new BadRequestException("服务商未开启快捷支付"); } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.xml similarity index 82% rename from src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.xml rename to src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.xml index 6b270ceed..a7bc1b1af 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysPaymentConfigMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/SysChannelConfigMapper.xml @@ -1,8 +1,8 @@ - + - update sys_payment_config + update cb_channel_config SET is_valid = #{is_valid},last_update_by = #{last_update_by},last_update_date = #{last_update_date} type = #{type} @@ -15,6 +15,6 @@ \ No newline at end of file From 28a74d89e57bdc5007879ba7cc957b4d64471f0b Mon Sep 17 00:00:00 2001 From: yangkai Date: Tue, 18 Dec 2018 21:02:31 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E6=B3=A8=E9=87=8Arpay+=E8=B4=B9=E7=8E=87?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/manage/merchants/core/impls/ClientManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 124e10295..393c7587e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1628,7 +1628,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid configNewClientRate(config, clientId, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); configNewClientRate(config, clientId, "CB_BankPay", "cb_bankpay_rate_value", org, "min_cb_bankpay_rate"); //todo 暂不更新Rpay+ 费率信息 - rpayApi.modifySurchargeConfig(client); + //rpayApi.modifySurchargeConfig(client); } From 67a6e7cb1681348f8347098ca0449870c3802aca Mon Sep 17 00:00:00 2001 From: yangkai Date: Tue, 18 Dec 2018 22:12:54 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E6=B3=A8=E9=87=8Ahf=E3=80=81yeepay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchants/core/impls/ClientManagerImpl.java | 8 ++++---- .../partner/templates/partner_bankaccounts.html | 4 ++-- .../payment/partner/templates/partner_new_rate.html | 12 ++++++------ .../partner/templates/partner_payment_info.html | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 393c7587e..4f2179824 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1613,9 +1613,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkAddRate(config, "AlipayOnline", "alipayonline_rate_value", org, "min_alipayonline_rate"); checkAddRate(config, "Bestpay", "bestpay_rate_value", org, "min_bestpay_rate"); checkAddRate(config, "jd", "jd_rate_value", org, "min_jd_rate"); - checkAddRate(config, "hf", "hf_rate_value", org, "min_hf_rate"); +// checkAddRate(config, "hf", "hf_rate_value", org, "min_hf_rate"); checkAddRate(config, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate"); - checkAddRate(config, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); +// checkAddRate(config, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); checkAddRate(config, "CB_BankPay", "min_cb_bankpay_value", org, "min_cb_bankpay_rate"); configNewClientRate(config, clientId, "Wechat", "wechat_rate_value", org, "min_wechat_rate"); @@ -1623,9 +1623,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid configNewClientRate(config, clientId, "AlipayOnline", "alipayonline_rate_value", org, "min_alipayonline_rate"); configNewClientRate(config, clientId, "Bestpay", "bestpay_rate_value", org, "min_bestpay_rate"); configNewClientRate(config, clientId, "jd", "jd_rate_value", org, "min_jd_rate"); - configNewClientRate(config, clientId, "hf", "hf_rate_value", org, "min_hf_rate"); +// configNewClientRate(config, clientId, "hf", "hf_rate_value", org, "min_hf_rate"); configNewClientRate(config, clientId, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate"); - configNewClientRate(config, clientId, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); +// configNewClientRate(config, clientId, "Yeepay", "yeepay_rate_value", org, "min_yeepay_rate"); configNewClientRate(config, clientId, "CB_BankPay", "cb_bankpay_rate_value", org, "min_cb_bankpay_rate"); //todo 暂不更新Rpay+ 费率信息 //rpayApi.modifySurchargeConfig(client); diff --git a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html index 7ebdd521d..2f51eed68 100644 --- a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html +++ b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html @@ -170,9 +170,9 @@
  • Alipay(Online)
  • Bestpay
  • JDpay
  • -
  • HFpay
  • +
  • Rpay+
  • -
  • Yeepay
  • +
  • CB_BankPay
  • diff --git a/src/main/ui/static/payment/partner/templates/partner_new_rate.html b/src/main/ui/static/payment/partner/templates/partner_new_rate.html index 3402bd481..0fbebc5f0 100644 --- a/src/main/ui/static/payment/partner/templates/partner_new_rate.html +++ b/src/main/ui/static/payment/partner/templates/partner_new_rate.html @@ -112,7 +112,7 @@
    -
    @@ -134,7 +134,7 @@
    -
    + -->
    @@ -160,7 +160,7 @@
    -
    @@ -182,18 +182,18 @@
    - + -->
    - +
    %
    -
    +
    No more than 5.0%
    diff --git a/src/main/ui/static/payment/partner/templates/partner_payment_info.html b/src/main/ui/static/payment/partner/templates/partner_payment_info.html index d4a73fa01..164a898f3 100644 --- a/src/main/ui/static/payment/partner/templates/partner_payment_info.html +++ b/src/main/ui/static/payment/partner/templates/partner_payment_info.html @@ -211,7 +211,7 @@
    -
    +
    @@ -351,7 +351,7 @@

    -
    +
    From 7b1464b547b7caf62dfae5fe7ab331c14246ec98 Mon Sep 17 00:00:00 2001 From: yangkai Date: Tue, 18 Dec 2018 22:19:16 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=B8=ADhf=E3=80=81yeepay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/organizations/templates/new_org.html | 16 ++++++++-------- .../organizations/templates/org_detail.html | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/ui/static/config/organizations/templates/new_org.html b/src/main/ui/static/config/organizations/templates/new_org.html index 564056750..023fb7319 100644 --- a/src/main/ui/static/config/organizations/templates/new_org.html +++ b/src/main/ui/static/config/organizations/templates/new_org.html @@ -179,7 +179,7 @@ -
    @@ -190,8 +190,8 @@ %
    - -
    --> +
    @@ -279,7 +279,7 @@
    -
    @@ -290,8 +290,8 @@ %
    - -
    --> +
    diff --git a/src/main/ui/static/config/organizations/templates/org_detail.html b/src/main/ui/static/config/organizations/templates/org_detail.html index 23fa55abc..df2f98844 100644 --- a/src/main/ui/static/config/organizations/templates/org_detail.html +++ b/src/main/ui/static/config/organizations/templates/org_detail.html @@ -152,7 +152,7 @@ %
    -
    +
    @@ -225,7 +225,7 @@ %
    -
    @@ -242,7 +242,7 @@ id="min_yeepay_rate_input" name="min_yeepay_rate" max="100" min="0"> %
    -
    +
    -->
    From cde509499531a4296d4d008c42b1d3749493d1c6 Mon Sep 17 00:00:00 2001 From: yangkai Date: Tue, 18 Dec 2018 22:29:38 +0800 Subject: [PATCH 11/13] fix --- .../manage/merchants/core/ClientManager.java | 2 ++ .../merchants/core/impls/ClientManagerImpl.java | 17 ++++++++++++++++- .../merchants/web/PartnerManageController.java | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 4bbc970ee..c1ca75c61 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -376,4 +376,6 @@ public interface ClientManager { void switchCBBankLink(JSONObject manager, String clientMoniker, boolean allow); String cbBankPayLink(String clientMoniker); + + void switchPaymentConfigPC(String clientMoniker, HttpServletResponse response) throws IOException; } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 4f2179824..a809bffdb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -4280,7 +4280,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } checkOrgPermission(manager, client); if (StringUtils.isEmpty(client.getString("cb_bankpay_url"))) { - String longUrl = PlatformEnvironment.getEnv().concatUrl("/sys/partners/" + client.getString("client_moniker") + "/cb_bankpay/link"); + String longUrl = PlatformEnvironment.getEnv().concatUrl("/sys/partners/" + client.getString("client_moniker") + "/cb_bankpay/link/pc"); String cb_bankpay_url = getCBBankShortLink(longUrl); client.put("cb_bankpay_url", cb_bankpay_url); client.put("enable_cb_bankpay_link", allow); @@ -4304,6 +4304,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid return String.format(PlatformEnvironment.getEnv().concatUrl(paymentConfig.getString("path")), clientMoniker); } + @Override + public void switchPaymentConfigPC(String clientMoniker, HttpServletResponse response) throws IOException { + JSONObject client = clientMapper.findClientByMoniker(clientMoniker); + if (client == null) { + throw new BadRequestException("partner code is not exists!"); + } + JSONObject paymentConfig = sysChannelConfigMapper.findOne(1); + if (paymentConfig == null) { + throw new BadRequestException("服务商未开启快捷支付"); + } + String path = paymentConfig.getString("path"); + path = path.replaceAll("app","pc"); + response.sendRedirect(String.format(PlatformEnvironment.getEnv().concatUrl(path), clientMoniker)); + } + private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) { TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null); notice.put("first", "您好,您的合同费率已到期,根据合同协议系统已自动为您延期1年。", "#ff0000"); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 654263a3c..3b9dcdb6d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -636,4 +636,9 @@ public class PartnerManageController { public String jumpCBBankPayLink(@PathVariable String clientMoniker) { return clientManager.cbBankPayLink(clientMoniker); } + + @RequestMapping(value = "/{clientMoniker}/cb_bankpay/link/pc", method = RequestMethod.GET) + public void switchPaymentWayPC(@PathVariable String clientMoniker, HttpServletResponse response) throws IOException { + clientManager.switchPaymentConfigPC(clientMoniker, response); + } } From 6b68f0c56357112d100bc48a65bd4ea62b112038 Mon Sep 17 00:00:00 2001 From: yangkai Date: Wed, 19 Dec 2018 16:40:11 +0800 Subject: [PATCH 12/13] =?UTF-8?q?bd=E6=8F=90=E6=88=90=E4=B8=8B=E8=BD=BD&bd?= =?UTF-8?q?=E6=8F=90=E6=88=90=E6=9F=A5=E8=AF=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/bdprize/core/BDPrizeService.java | 4 + .../core/impls/BDPrizeServiceImpl.java | 268 ++++++++++++++---- .../manage/bdprize/web/BDPrizeController.java | 7 + .../FinancialLeaderPrizeLogMapper.java | 19 ++ .../FinancialBDPrizeRecordMapper.xml | 6 +- src/main/ui/static/config/bdprize/bdprize.js | 3 + .../bdprize/templates/bd_prize_root.html | 10 +- 7 files changed, 262 insertions(+), 55 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/financial/FinancialLeaderPrizeLogMapper.java diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/BDPrizeService.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/BDPrizeService.java index ad7970323..5ee09d9b7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/BDPrizeService.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/BDPrizeService.java @@ -8,6 +8,8 @@ import org.springframework.transaction.annotation.Transactional; import com.alibaba.fastjson.JSONObject; +import javax.servlet.http.HttpServletResponse; + /** * Created by yixian on 2017-02-07. */ @@ -40,4 +42,6 @@ public interface BDPrizeService { void deleteCommConfig(String config_id); void updateBdKpiConfig(List configs, JSONObject manager)throws ParseException; + + void exportCommissionMonth(String month, HttpServletResponse response) throws Exception; } diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java index 98b16f2b1..741b3b17c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java @@ -5,12 +5,7 @@ import au.com.royalpay.payment.manage.bdprize.core.BDPrizeService; import au.com.royalpay.payment.manage.bdprize.support.BDPrizeCalculator; import au.com.royalpay.payment.manage.bdprize.support.impls.BDPrizeCalculatorDefaultImpl; import au.com.royalpay.payment.manage.bdprize.support.impls.DefaultClientWithBDAwayDeterminor; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDCommissionConfigMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeDetailMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeLogMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeRecordMapper; -import au.com.royalpay.payment.manage.mappers.financial.FinancialBDRateConfigMapper; +import au.com.royalpay.payment.manage.mappers.financial.*; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; @@ -27,6 +22,11 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.*; import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +34,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.io.OutputStream; import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -44,6 +45,7 @@ import java.util.GregorianCalendar; import java.util.List; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; /** * Created by yixian on 2017-02-07. @@ -74,6 +76,8 @@ public class BDPrizeServiceImpl implements BDPrizeService { @Resource private FinancialBDCommissionConfigMapper financialBDCommissionConfigMapper; + @Resource + private FinancialLeaderPrizeLogMapper financialLeaderPrizeLogMapper; @Value("${app.backup-app:false}") private boolean backupSystem; @@ -239,54 +243,88 @@ public class BDPrizeServiceImpl implements BDPrizeService { // cityPrizeLog.put("total_prize", total_prize); // } // report.put("cityPrizeLogs", cityPrizeLog); - + List leaderPrizeLog = financialLeaderPrizeLogMapper.listLeaderPrizeLog(report.getString("record_id")); + if (leaderPrizeLog.size() > 0) { + for (JSONObject prizeLog : leaderPrizeLog) { + if (prizeLog.getIntValue("bd_type") == 3) { + report.put("sydneyPrizeLog", prizeLog); + } + if (prizeLog.getIntValue("bd_type") == 4) { + report.put("directPrizeLogs", prizeLog); + } + if (prizeLog.getIntValue("bd_type") == 5) { + report.put("ngDepartmentPrizeLog", prizeLog); + } + } + return report; + } //bd_type=3 悉尼分公司经理 悉尼销售组和大客户组流水提成 - - JSONObject sydneyPrizeLog = new JSONObject(); - BigDecimal sydneyAmount = transactionMapper.TotalAmountForSydneyGMPrize(monthDate.getYear(), monthDate.getMonthOfYear()); - sydneyPrizeLog.put("total_amount",sydneyAmount); - JSONObject sydneyGMRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, sydneyAmount.toString(), 3); - if (sydneyGMRate == null) { - sydneyPrizeLog.put("total_prize", 0.00); - } else { - BigDecimal sydney_commission_rate = new BigDecimal(sydneyGMRate.getString("commission_rate")); - BigDecimal total_prize = sydneyAmount.multiply(sydney_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); - sydneyPrizeLog.put("total_prize", total_prize); + if (!locker.lock(report.getString("record_id"), 300_000)) { + throw new ServerErrorException("Processing task, wait for a moment"); } - report.put("sydneyPrizeLog", sydneyPrizeLog); - - - //COO & NJ commission - JSONObject params = new JSONObject(); - params.put("begin", TimeZoneUtils.beginDate(TimeZoneUtils.getFirstDay(monthDate.toString()))); - params.put("end", TimeZoneUtils.getPerFirstDayOfMonth(TimeZoneUtils.getLastDay(monthDate.toString()))); - BigDecimal totalprize = transactionAnalysisMapper.analysisTotalAmount(params); + try { + List prizeLogList = new ArrayList<>(); + JSONObject sydneyPrizeLog = new JSONObject(); + BigDecimal sydneyAmount = transactionMapper.TotalAmountForSydneyGMPrize(monthDate.getYear(), monthDate.getMonthOfYear()); + sydneyPrizeLog.put("total_amount",sydneyAmount); + sydneyPrizeLog.put("bd_type", 3); + JSONObject sydneyGMRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, sydneyAmount.toString(), 3); + if (sydneyGMRate == null) { + sydneyPrizeLog.put("total_prize", 0.00); + } else { + BigDecimal sydney_commission_rate = new BigDecimal(sydneyGMRate.getString("commission_rate")); + BigDecimal total_prize = sydneyAmount.multiply(sydney_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); + sydneyPrizeLog.put("total_prize", total_prize); + } + report.put("sydneyPrizeLog", sydneyPrizeLog); + prizeLogList.add(sydneyPrizeLog); + + + //COO & NJ commission + JSONObject params = new JSONObject(); + params.put("begin", TimeZoneUtils.beginDate(TimeZoneUtils.getFirstDay(monthDate.toString()))); + params.put("end", TimeZoneUtils.getPerFirstDayOfMonth(TimeZoneUtils.getLastDay(monthDate.toString()))); + BigDecimal totalprize = transactionAnalysisMapper.analysisTotalAmount(params); + + JSONObject directPrizeLogs = new JSONObject(); + directPrizeLogs.put("total_amount", totalprize); + directPrizeLogs.put("bd_type", 4); + JSONObject rate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 4); + if (rate == null) { + directPrizeLogs.put("total_prize", 0.00); + } else { + BigDecimal _commission_rate = new BigDecimal(rate.getString("commission_rate")); + BigDecimal _total_amount = new BigDecimal(directPrizeLogs.getString("total_amount")); + BigDecimal total_prize = _total_amount.multiply(_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); + directPrizeLogs.put("total_prize", total_prize); + } + report.put("directPrizeLogs", directPrizeLogs); + prizeLogList.add(directPrizeLogs); + + JSONObject ngDepartmentPrizeLog = new JSONObject(); + ngDepartmentPrizeLog.put("total_amount", totalprize); + ngDepartmentPrizeLog.put("bd_type", 5); + JSONObject ngRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 5); + if (ngRate == null) { + ngDepartmentPrizeLog.put("total_prize", 0.00); + } else { + BigDecimal ng_commission_rate = new BigDecimal(ngRate.getString("commission_rate")); + BigDecimal ng_total_prize = totalprize.multiply(ng_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); + ngDepartmentPrizeLog.put("total_prize", ng_total_prize); + } + report.put("ngDepartmentPrizeLog", ngDepartmentPrizeLog); + prizeLogList.add(ngDepartmentPrizeLog); - JSONObject directPrizeLogs = new JSONObject(); - directPrizeLogs.put("total_amount", totalprize); - JSONObject rate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 4); - if (rate == null) { - directPrizeLogs.put("total_prize", 0.00); - } else { - BigDecimal _commission_rate = new BigDecimal(rate.getString("commission_rate")); - BigDecimal _total_amount = new BigDecimal(directPrizeLogs.getString("total_amount")); - BigDecimal total_prize = _total_amount.multiply(_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); - directPrizeLogs.put("total_prize", total_prize); + for (JSONObject prizeLog : prizeLogList) { + prizeLog.put("record_id", report.getString("record_id")); + prizeLog.put("create_time", new Date()); + financialLeaderPrizeLogMapper.save(prizeLog); + } + return report; + } finally { + locker.unlock(report.getString("record_id")); } - report.put("directPrizeLogs", directPrizeLogs); - JSONObject ngDepartmentPrizeLog = new JSONObject(); - ngDepartmentPrizeLog.put("total_amount", totalprize); - JSONObject ngRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 5); - if (ngRate == null) { - ngDepartmentPrizeLog.put("total_prize", 0.00); - } else { - BigDecimal ng_commission_rate = new BigDecimal(ngRate.getString("commission_rate")); - BigDecimal ng_total_prize = totalprize.multiply(ng_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN); - ngDepartmentPrizeLog.put("total_prize", ng_total_prize); - } - report.put("ngDepartmentPrizeLog", ngDepartmentPrizeLog); - return report; } @Override @@ -469,4 +507,136 @@ public class BDPrizeServiceImpl implements BDPrizeService { financialBDConfigMapper.updateBDConfig(config); } } + + @Override + public void exportCommissionMonth(String month, HttpServletResponse resp) throws Exception { + OutputStream ous = null; + JSONObject report = findReport(month); + if (report != null) { + List logs = (List) report.get("logs"); + resp.setContentType("application/octet-stream;"); + resp.addHeader("Content-Disposition", "attachment; filename=" + "BD_Commission_Info_" + month + ".xls"); + ous = resp.getOutputStream(); + HSSFWorkbook wb = new HSSFWorkbook(); + Cell cell = null; + HSSFFont font = wb.createFont(); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); + font.setFontHeightInPoints((short) 10); + CellStyle titleStyle = wb.createCellStyle(); + titleStyle.setFont(font); + HSSFCellStyle style = wb.createCellStyle(); + //设置背景颜色 + style.setFillForegroundColor(HSSFColor.RED.index); + //solid 填充 foreground 前景色 + style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); + Sheet sheet = wb.createSheet("BD_Commission_Info_" + month); + sheet.setDefaultColumnWidth(20); + int rowNum = 0; + Row row = sheet.createRow(rowNum); + //bd and manager + String[] BDTitle = {"BD Name","KPI", "BD Level", "Transaction Amount", "Total Commission","Send Commission", "Hold prize", "Prize Type"}; + for (int i = 0; i < BDTitle.length; i++) { + cell = row.createCell(i, Cell.CELL_TYPE_STRING); + cell.setCellStyle(titleStyle); + cell.setCellValue(BDTitle[i]); + } + for (JSONObject log : logs) { + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(log.getString("bd_name")); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("kpi_amount")==null?BigDecimal.ZERO.toPlainString():log.getBigDecimal("kpi_amount").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(financialBdLevel(log.getIntValue("bd_level"))); + row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("total_amount").toPlainString()); + row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("total_prize").toPlainString()); + row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("send_prize").toPlainString()); + row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("hold_prize").toPlainString()); + if (log.getIntValue("prize_type") == 0) { + row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue("BD"); + } + if (log.getIntValue("prize_type") == 1) { + row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue("Group"); + } + if (!log.getBoolean("is_valid")) { + for (int i = 0; i <= 7; i++) { + row.getCell(i).setCellStyle(style); + } + } + } + //analysis + String[] analysisTitle = {"month", "Total Commission", "Total Send", "Total Hold", "Total Fund"}; + row = sheet.createRow(++rowNum); + for (int i = 0; i < analysisTitle.length; i++) { + cell = row.createCell(i, Cell.CELL_TYPE_STRING); + cell.setCellStyle(titleStyle); + cell.setCellValue(analysisTitle[i]); + } + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(month); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(report.getBigDecimal("total_prize").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(report.getBigDecimal("total_send_prize").toPlainString()); + row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(report.getBigDecimal("total_hold_prize").toPlainString()); + row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(report.getBigDecimal("total_donation").toPlainString()); + //channel + String[] channelTitle = {"channel", "BD Total Commission", "BD Total Send", "BD Total Hold", "BD Total Fund"}; + row = sheet.createRow(++rowNum); + for (int i = 0; i < channelTitle.length; i++) { + cell = row.createCell(i, Cell.CELL_TYPE_STRING); + cell.setCellStyle(titleStyle); + cell.setCellValue(channelTitle[i]); + } + for (String channel: channels) { + JSONObject channelReport = report.getJSONObject(channel + "Report"); + if (channelReport != null) { + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(channel); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(channelReport.getBigDecimal("total_prize").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(channelReport.getBigDecimal("total_send_prize").toPlainString()); + row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(channelReport.getBigDecimal("total_hold_prize").toPlainString()); + row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(channelReport.getBigDecimal("total_donation").toPlainString()); + } + } + //Sydney GM & COO & NJ commission + String[] GMTitle = {"name", "Transaction Amount", "Total Commission"}; + row = sheet.createRow(++rowNum); + for (int i = 0; i < GMTitle.length; i++) { + cell = row.createCell(i, Cell.CELL_TYPE_STRING); + cell.setCellStyle(titleStyle); + cell.setCellValue(GMTitle[i]); + } + JSONObject sydneyPrizeLog = report.getJSONObject("sydneyPrizeLog"); + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue("Sydney GM"); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(sydneyPrizeLog.getBigDecimal("total_amount").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(sydneyPrizeLog.getBigDecimal("total_prize").toPlainString()); + + JSONObject ngDepartmentPrizeLog = report.getJSONObject("ngDepartmentPrizeLog"); + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue("NJ Department"); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(ngDepartmentPrizeLog.getBigDecimal("total_amount").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(ngDepartmentPrizeLog.getBigDecimal("total_prize").toPlainString()); + + JSONObject directPrizeLogs = report.getJSONObject("directPrizeLogs"); + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue("COO"); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(directPrizeLogs.getBigDecimal("total_amount").toPlainString()); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(directPrizeLogs.getBigDecimal("total_prize").toPlainString()); + + wb.write(ous); + ous.flush(); + } + } + + private String financialBdLevel (int level) { + switch (level) { + case 0: + return "Leader"; + case 1: + return "Junior"; + case 2: + return "Intermediate"; + case 3: + return "Senior"; + default: + return "Unknown"; + } + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/web/BDPrizeController.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/web/BDPrizeController.java index e3e75e552..d817e993e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/web/BDPrizeController.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/web/BDPrizeController.java @@ -15,10 +15,12 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.io.IOException; import java.text.ParseException; import java.util.List; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; /** * Created by yixian on 2017-02-07. @@ -97,4 +99,9 @@ public class BDPrizeController { public void updatKpiConfig(@PathVariable String month , @RequestBody List info , @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) throws ParseException { bdPrizeService.updateBdKpiConfig(info,manager); } + + @ManagerMapping(value = "/commission/export/{month}",method = RequestMethod.GET, role = {ManagerRole.SALES_MANAGER, ManagerRole.FINANCIAL_STAFF,ManagerRole.DIRECTOR, ManagerRole.ADMIN}) + public void exportCommissionMonth(@PathVariable String month, HttpServletResponse response) throws Exception { + bdPrizeService.exportCommissionMonth(month, response); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/financial/FinancialLeaderPrizeLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/financial/FinancialLeaderPrizeLogMapper.java new file mode 100644 index 000000000..c52de5f97 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/financial/FinancialLeaderPrizeLogMapper.java @@ -0,0 +1,19 @@ +package au.com.royalpay.payment.manage.mappers.financial; + +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import com.alibaba.fastjson.JSONObject; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@AutoMapper(tablename = "financial_leader_prize_log", pkName = "leader_prize_log") +public interface FinancialLeaderPrizeLogMapper { + + @AutoSql(type = SqlType.SELECT) + List listLeaderPrizeLog(@Param(value = "record_id") String record_id); + + @AutoSql(type = SqlType.INSERT) + void save(JSONObject prizeLog); +} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/financial/FinancialBDPrizeRecordMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/financial/FinancialBDPrizeRecordMapper.xml index 24f56ef19..a62886d13 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/financial/FinancialBDPrizeRecordMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/financial/FinancialBDPrizeRecordMapper.xml @@ -11,7 +11,8 @@ r.*,l.kpi_amount, sum(total_prize) total_prize, sum(send_prize) total_send_prize, - sum(total_donation) total_donation + sum(total_donation) total_donation, + sum(hold_prize) total_hold_prize FROM financial_bd_prize_records r INNER JOIN financial_bd_prize_log l ON l.record_id = r.record_id WHERE r.month = #{month} @@ -20,7 +21,8 @@ SELECT sum(total_prize) total_prize, sum(send_prize) total_send_prize, - sum(total_donation) total_donation + sum(total_donation) total_donation, + sum(hold_prize) total_hold_prize FROM financial_bd_prize_log WHERE record_id = #{record_id} AND channel = #{channel} diff --git a/src/main/ui/static/config/bdprize/bdprize.js b/src/main/ui/static/config/bdprize/bdprize.js index c44b807b9..b5d76ee4e 100644 --- a/src/main/ui/static/config/bdprize/bdprize.js +++ b/src/main/ui/static/config/bdprize/bdprize.js @@ -141,6 +141,9 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) { } } }) + }; + $scope.exportCommission = function (monModal) { + location.href = '/sys/bd_prize/commission/export/' + monModal; } }]); app.controller('bdRateConfigCtrl', ['$scope', '$http', 'rates', function ($scope, $http, rates) { diff --git a/src/main/ui/static/config/bdprize/templates/bd_prize_root.html b/src/main/ui/static/config/bdprize/templates/bd_prize_root.html index e39214443..c7e5c591d 100644 --- a/src/main/ui/static/config/bdprize/templates/bd_prize_root.html +++ b/src/main/ui/static/config/bdprize/templates/bd_prize_root.html @@ -49,18 +49,20 @@
    - From 2c1e895a57784459d74aa175cee722fcc9dc5028 Mon Sep 17 00:00:00 2001 From: yangkai Date: Wed, 19 Dec 2018 17:50:07 +0800 Subject: [PATCH 13/13] =?UTF-8?q?cb=5Fbankpay=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/ui/static/payment/partner/partner-manage.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index d6ba7be9a..64372f1d9 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -2112,6 +2112,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.rate.hf_rate_value = parseFloat($scope.sysRateConfig.t1.HFpay); $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t1.Rpay); $scope.rate.yeepay_rate_value = parseFloat($scope.sysRateConfig.t1.Yeepay); + $scope.rate.cb_bankpay_rate_value = parseFloat($scope.sysRateConfig.t1.CB_Bankpay); $scope.rate.transaction_fee = 0; break; } @@ -2124,6 +2125,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.rate.hf_rate_value = parseFloat($scope.sysRateConfig.t2.HFpay); $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t2.Rpay); $scope.rate.yeepay_rate_value = parseFloat($scope.sysRateConfig.t2.Yeepay); + $scope.rate.cb_bankpay_rate_value = parseFloat($scope.sysRateConfig.t2.CB_Bankpay); $scope.rate.transaction_fee = 0; break; } @@ -2136,6 +2138,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.rate.hf_rate_value = parseFloat($scope.sysRateConfig.t3.HFpay); $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t3.Rpay); $scope.rate.yeepay_rate_value = parseFloat($scope.sysRateConfig.t3.Yeepay); + $scope.rate.cb_bankpay_rate_value = parseFloat($scope.sysRateConfig.t3.CB_Bankpay); $scope.rate.transaction_fee = 0; break; }