diff --git a/pom.xml b/pom.xml index de1e4497a..e004f1438 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ UTF-8 1.1.2 - 1.0.12 + 1.0.13 diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/core/AliforexcelService.java b/src/main/java/au/com/royalpay/payment/manage/dev/core/AliforexcelService.java index 4fc7a3ab7..aab8939e8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/core/AliforexcelService.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/core/AliforexcelService.java @@ -9,5 +9,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; public interface AliforexcelService { - JSONObject listClients(HttpServletResponse httpResponse,JSONObject manager, AliExcel query); + JSONObject listClients(HttpServletResponse httpResponse, JSONObject manager, AliExcel query); + + JSONObject registerAlipayOnlineMerchant(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/AliforexcelServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/AliforexcelServiceImpl.java index 639d14987..f98883406 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/AliforexcelServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/AliforexcelServiceImpl.java @@ -1,26 +1,41 @@ package au.com.royalpay.payment.manage.dev.core.impl; +import au.com.royalpay.payment.channels.alipay.config.AlipayConfig; +import au.com.royalpay.payment.channels.alipay.config.AlipayEnvironment; +import au.com.royalpay.payment.channels.alipay.runtime.AlipayClient; +import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.manage.dev.bean.AliExcel; import au.com.royalpay.payment.manage.dev.core.AliforexcelService; +import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import com.alibaba.fastjson.JSONObject; +import com.yeepay.shade.org.apache.commons.lang3.StringUtils; import org.apache.commons.io.IOUtils; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; +import org.dom4j.Element; import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; +import java.security.InvalidParameterException; +import java.util.ArrayList; import java.util.List; @Service public class AliforexcelServiceImpl implements AliforexcelService { @Resource private ClientMapper clientMapper; + @Resource + private TransactionMapper transactionMapper; + @Resource + private AlipayClient alipayClient; @Override public JSONObject listClients(HttpServletResponse httpResponse,JSONObject manager, AliExcel query) { @@ -75,4 +90,69 @@ public class AliforexcelServiceImpl implements AliforexcelService { return null; } + @Override + public JSONObject registerAlipayOnlineMerchant() { + JSONObject result = new JSONObject(); + List needRegisterMerchant = new ArrayList<>(); + List registerSuccessMerchant = new ArrayList<>(); + List registerFailMerchant = new ArrayList<>(); + List lessInfoMerchant = new ArrayList<>(); + List useAlipayOnlineMerchant = transactionMapper.useAlipayOnlineClients(); + for (int clientId : useAlipayOnlineMerchant) { + JSONObject client = clientMapper.findClient(clientId); + if (!client.getBooleanValue("is_valid")) { + continue; + } + try { + needRegisterMerchant.add(client.getString("client_moniker")); + checkPartnerInfo(client); + } catch (InvalidParameterException e) { + JSONObject exception = new JSONObject(); + exception.put("client_moniker", client.getString("client_moniker")); + exception.put("return_msg", e.getMessage()); + lessInfoMerchant.add(exception); + continue; + } + AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant(); + Element resultElement = alipayClient.registerOnlineGmsPortal(mch.getPid(), client); + if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { + JSONObject exception = new JSONObject(); + exception.put("client_moniker", client.getString("client_moniker")); + exception.put("return_msg", resultElement.elementText("error")); + registerFailMerchant.add(exception); + continue; + } + Element responseElement = resultElement.element("response").element("alipay"); + if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) { + JSONObject exception = new JSONObject(); + exception.put("client_moniker", client.getString("client_moniker")); + exception.put("return_msg", resultElement.elementText("error")); + registerFailMerchant.add(exception); + continue; + } + registerSuccessMerchant.add(client.getString("client_moniker")); + } + result.put("need_register_merchant", needRegisterMerchant); + result.put("success_register_merchant", registerSuccessMerchant); + result.put("fail_register_merchant", registerFailMerchant); + result.put("less_info_merchant", lessInfoMerchant); + return result; + } + + private void checkPartnerInfo(JSONObject client) { + if (client == null) { + throw new InvalidShortIdException(); + } + if (!client.containsKey("company_website") || StringUtils.isBlank(client.getString("company_website"))) { + throw new InvalidParameterException("Website cannot be empty "); + } + if (StringUtils.isBlank(client.getString("business_structure"))) { + throw new InvalidParameterException("Business Structure can't be null"); + } + + if (StringUtils.isBlank(client.getString("alipayindustry"))) { + throw new InvalidParameterException("Alipay Industry can't be null"); + } + } + } 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 b2a5dcaba..7b6b889d9 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 @@ -449,4 +449,9 @@ public class TestController implements ApplicationEventPublisherAware { public void downloadHanyinSecureReports(@PathVariable String date) { tradeSecureService.uploadSecureReport(DateTime.parse(date).toDate()); } + + @ManagerMapping(value = "/register/alipayOnlineGms", role = ManagerRole.DEVELOPER, method = RequestMethod.POST) + public JSONObject registerAlipayOnlineMerchant() { + return aliforexcelService.registerAlipayOnlineMerchant(); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java index b1b95225d..997831791 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java @@ -157,4 +157,6 @@ public interface TransactionMapper { List getClientOrderByTransactionTime(JSONObject params); List getLastDaytransAmount(JSONObject params); + + List useAlipayOnlineClients(); } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml index d2319f3f7..5e1284444 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml @@ -1208,4 +1208,9 @@ AND transaction_time < #{dateto} GROUP BY channel + + + SELECT DISTINCT client_id FROM pmt_transactions + WHERE channel='AlipayOnline' + diff --git a/src/main/ui/static/config/devtools/devtools.js b/src/main/ui/static/config/devtools/devtools.js index 009e3dcc5..871d99bc2 100644 --- a/src/main/ui/static/config/devtools/devtools.js +++ b/src/main/ui/static/config/devtools/devtools.js @@ -67,6 +67,10 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { url: '/rpayupdate', templateUrl: '/static/config/devtools/templates/rpayupdate.html', controller: 'rpayupdateCtrl' + }).state('devtools.registerAlipayOnlineMerchant', { + url: '/registerAlipayOnlineMerchant', + templateUrl: '/static/config/devtools/templates/registerAlipayOnlineMerchant.html', + controller: 'registerAlipayOnlineMerchantCtrl' }) }]); app.controller('devManualRefundCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) { @@ -404,6 +408,26 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }]); + app.controller('registerAlipayOnlineMerchantCtrl', ['$scope', '$http','$filter', function ($scope, $http,$filter) { + $scope.selecttotal = true; + + $scope.registerOnlineGMS = function () { + $scope.totalhide = true; + $scope.selecttotal = false; + $http.post('/dev/register/alipayOnlineGms').then(function (resp) { + $scope.totalhide = false; + $scope.selecttotal = true; + $scope.need_register_merchant = resp.data.need_register_merchant.toString(); + $scope.success_register_merchant = resp.data.success_register_merchant.toString(); + $scope.fail_register_merchant = resp.data.fail_register_merchant; + $scope.less_info_merchant = resp.data.less_info_merchant(); + }, function (resp) { + alert(resp.data.message); + }) + } + + }]); + return app; }); \ No newline at end of file diff --git a/src/main/ui/static/config/devtools/templates/registerAlipayOnlineMerchant.html b/src/main/ui/static/config/devtools/templates/registerAlipayOnlineMerchant.html new file mode 100644 index 000000000..f8ecbc6bd --- /dev/null +++ b/src/main/ui/static/config/devtools/templates/registerAlipayOnlineMerchant.html @@ -0,0 +1,59 @@ + +批量支付宝线上报备 + + + Basic Config + + Dev Tools + 批量支付宝线上报备 + + + + + register 请稍后 + + + 需要报备的商户编码 + + + 成功报备的商户编码 + + + 注册失败的商户编码 + + + + client_moniker + 失败原因 + + + + + + {{client.client_moniker}} + + + + + + + + 缺少信息的商户编码 + + + + client_moniker + 缺少信息 + + + + + + {{client.client_moniker}} + + + + + + + \ No newline at end of file