add 批量报备支付宝线上商户

master
luoyang 5 years ago
parent 4b7fdec4de
commit e1d01a3a9f

@ -13,7 +13,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.1.2</jib-maven-plugin.version>
<docker-image.version>1.0.6</docker-image.version>
<docker-image.version>1.0.7</docker-image.version>
</properties>
<dependencies>

@ -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();
}

@ -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<String> needRegisterMerchant = new ArrayList<>();
List<String> registerSuccessMerchant = new ArrayList<>();
List<JSONObject> registerFailMerchant = new ArrayList<>();
List<JSONObject> lessInfoMerchant = new ArrayList<>();
List<Integer> 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");
}
}
}

@ -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();
}
}

@ -157,4 +157,6 @@ public interface TransactionMapper {
List<JSONObject> getClientOrderByTransactionTime(JSONObject params);
List<JSONObject> getLastDaytransAmount(JSONObject params);
List<Integer> useAlipayOnlineClients();
}

@ -1208,4 +1208,9 @@
AND transaction_time &lt; #{dateto}
GROUP BY channel
</select>
<select id="useAlipayOnlineClients" resultType="java.lang.Integer">
SELECT DISTINCT client_id FROM pmt_transactions
WHERE channel='AlipayOnline'
</select>
</mapper>

@ -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;
});

@ -0,0 +1,59 @@
<section class="content-header">
<h1>批量支付宝线上报备</h1>
<ol class="breadcrumb">
<li>
<i class="fa fa-cog"></i> Basic Config
</li>
<li><a ui-sref="^">Dev Tools</a></li>
<li class="active">批量支付宝线上报备</li>
</ol>
</section>
<section class="content">
<div class="box">
<button class="btn btn-primary" ng-click="registerOnlineGMS()">register</button> <label ng-hide="selecttotal" style="padding-left: 30px">请稍后</label>
</div>
<div class="row" ng-if="need_register_merchant">
<span>需要报备的商户编码</span><p ng-bind="need_register_merchant"></p>
</div>
<div class="row" ng-if="success_register_merchant">
<span>成功报备的商户编码</span><p ng-bind="success_register_merchant"></p>
</div>
<div class="box-body table-responsive" ng-if="fail_register_merchant">
<span>注册失败的商户编码</span>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>client_moniker</th>
<th>失败原因</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="client in fail_register_merchant">
<td>
{{client.client_moniker}}
</td>
<td ng-bind="client.return_msg"></td>
</tr>
</tbody>
</table>
</div>
<div class="box-body table-responsive" ng-if="less_info_merchant">
<span>缺少信息的商户编码</span>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>client_moniker</th>
<th>缺少信息</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="client in less_info_merchant">
<td>
{{client.client_moniker}}
</td>
<td ng-bind="client.return_msg"></td>
</tr>
</tbody>
</table>
</div>
</section>
Loading…
Cancel
Save