From 288bf599c7a497bf83a22fdffe152644e93ac5c2 Mon Sep 17 00:00:00 2001 From: "taylor.dang" Date: Fri, 12 Jul 2019 09:59:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E9=87=8F=E5=BC=80=E9=80=9ACBPAY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../manage/dev/web/TestController.java | 34 +++++++++++++++++++ .../manage/mappers/system/ClientMapper.java | 2 ++ .../core/impls/ClientManagerImpl.java | 5 ++- .../manage/mappers/system/ClientMapper.xml | 34 ++++++++++++++----- 5 files changed, 65 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index c927011f5..66e00f2be 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ UTF-8 1.1.2 - 1.1.12 + 1.1.13 diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java index 76d1a4419..691df38f6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java @@ -27,7 +27,10 @@ import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.system.core.TradeSecureService; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; +import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.defines.TradeType; +import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.http.HttpUtils; @@ -125,6 +128,8 @@ public class TestController implements ApplicationEventPublisherAware { @Resource private SysConfigManager sysConfigManager; @Resource + private MpWechatApiProvider mpWechatApiProvider; + @Resource private TradeSecureService tradeSecureService; private final static String EMAIL = "lily.tao@royalpay.com.au,bella.sun@royalpay.com.au,astro.dai@royalpay.com.au,taylor.dang@royalpay.com.au"; @@ -466,4 +471,33 @@ public class TestController implements ApplicationEventPublisherAware { public void initClientPayType(@RequestParam int begin,@RequestParam int end) { aliforexcelService.initClientPayType(begin,end); } + + @PutMapping(value = "/open/cb_bankpay") + public void switchCBBankPayLinkPermission() { + List merchants = clientMapper.listNeedOpenCbpayMerchant(); + merchants.forEach(mch -> { + JSONObject client = clientMapper.findClientByMonikerAll(mch.getString("client_moniker")); + if (client == null) { + throw new InvalidShortIdException(); + } + if (StringUtils.isEmpty(client.getString("cb_bankpay_url"))) { + 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", true); + client.put("enable_cb_bankpay", true); + clientMapper.update(client); + } else { + client.put("enable_cb_bankpay_link", true); + clientMapper.update(client); + } + }); + } + + private String getCBBankShortLink(String longUrl) { + MpWechatApi api = mpWechatApiProvider.getNewPaymentApi(); + return api.registerShortUrl(longUrl); + } + + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java index 7ef02be41..2e2d9d93b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java @@ -38,6 +38,8 @@ public interface ClientMapper { @AutoSql(type = SqlType.SELECT) JSONObject findClientByMonikerAll(@Param("client_moniker") String clientMoniker); + List listNeedOpenCbpayMerchant(); + @AutoSql(type = SqlType.SELECT) @AdvanceSelect(addonWhereClause = "is_valid=1") List getClientBySubMerchantId(@Param("sub_merchant_id") String subMerchantId); 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 c0f5384ca..523f6837e 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 @@ -103,7 +103,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.RequestMethod; import org.thymeleaf.context.Context; import org.thymeleaf.spring4.SpringTemplateEngine; -import sun.misc.BASE64Encoder; import javax.annotation.PostConstruct; import javax.annotation.Resource; @@ -5173,8 +5172,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid KeyPair keyPairGen = RSACrypt.generateKeyPairs(); RSAPublicKey publicKey = (RSAPublicKey) keyPairGen.getPublic(); RSAPrivateKey privateKey = (RSAPrivateKey) keyPairGen.getPrivate(); - key.put("public_key", new BASE64Encoder().encode(publicKey.getEncoded())); - key.put("private_key", new BASE64Encoder().encode(privateKey.getEncoded())); + key.put("public_key", Base64.encodeBase64String(publicKey.getEncoded())); + key.put("private_key", Base64.encodeBase64String(privateKey.getEncoded())); return key; } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml index 69e9ae903..0d53d156e 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml @@ -555,11 +555,11 @@ fbc.bd_type, sum( a.proportion ) clients_month FROM - ( + sys_client_bd a + INNER JOIN ( SELECT bd_id, - max( create_time ) create_time, - proportion + max( create_time ) create_time FROM sys_client_bd WHERE @@ -581,9 +581,12 @@ GROUP BY bd_id, client_id - ) a + ) b ON a.bd_id = b.bd_id + AND a.create_time = b.create_time INNER JOIN financial_bd_config c ON a.bd_id = c.manager_id INNER JOIN financial_bd_config fbc ON fbc.manager_id = c.bd_group + WHERE + a.is_valid = 1 GROUP BY fbc.bd_group ORDER BY @@ -596,11 +599,11 @@ fbc.bd_type, sum( a.proportion ) clients_yesterday FROM - ( + sys_client_bd a + INNER JOIN ( SELECT bd_id, - max( create_time ) create_time, - proportion + max( create_time ) create_time FROM sys_client_bd WHERE @@ -622,9 +625,12 @@ GROUP BY bd_id, client_id - ) a + ) b ON a.bd_id = b.bd_id + AND a.create_time = b.create_time INNER JOIN financial_bd_config c ON a.bd_id = c.manager_id INNER JOIN financial_bd_config fbc ON fbc.manager_id = c.bd_group + WHERE + a.is_valid = 1 GROUP BY fbc.bd_group ORDER BY @@ -643,4 +649,16 @@ + +