Merge branch 'develop'

# Conflicts:
#	pom.xml
#	src/main/ui/static/payment/partner/templates/partners.html
#	src/test/java/au/com/royalpay/payment/manage/citypartner/core/impls/GatewayApplicationMerchantDemoTest.java
master
luoyang 5 years ago
commit 17b5075d94

@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.4.6</version>
<version>1.4.7</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -100,4 +100,12 @@ public interface TransactionAnalysisMapper {
BigDecimal getCnyAmount(JSONObject params);
List<JSONObject> getOneDayOrgMerchantSaleList(JSONObject params);
List<JSONObject> getRpIndustryEchartsData(@Param("from") String from, @Param("to") String to, @Param("industry") String industry,
@Param("bd_user") String bdUser);
PageList<JSONObject> getTopRpIndustryData(@Param("transDate") String transDate,
@Param("industry") String industry,
PageBounds pageBounds,
@Param("bd_user") String bdUser);
}

@ -2,6 +2,9 @@ package au.com.royalpay.payment.manage.dataAnalysis.core;
import com.alibaba.fastjson.JSONObject;
import java.text.ParseException;
import java.util.List;
/**
* @Author lvjian
* @Date 2018/6/28 18:40
@ -32,4 +35,8 @@ public interface DataAnalysisService {
* @return
*/
JSONObject getCnyAmount(JSONObject params, JSONObject response);
List<JSONObject> getRpIndustryEchartsData(String from, String to, String industry,String managerId) throws ParseException;
JSONObject getRpTop20IndustryData(String industry, String transDate, int page, String managerId);
}

@ -2,13 +2,17 @@ package au.com.royalpay.payment.manage.dataAnalysis.core;
import au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
/**
@ -62,4 +66,17 @@ public class DataAnalysisServiceImpl implements DataAnalysisService {
response.put("cny_amount", transactionAnalysisMapper.getCnyAmount(params));
return response;
}
@Override
public List<JSONObject> getRpIndustryEchartsData(String from, String to, String industry, String managerId) throws ParseException {
Date modifyTo = DateUtils.addDays(DateUtils.parseDate(to, "yyyy-MM-dd"), 1);
return transactionAnalysisMapper.getRpIndustryEchartsData(from, DateFormatUtils.format(modifyTo, "yyyy-MM-dd HH:mm:ss"), industry, managerId);
}
@Override
public JSONObject getRpTop20IndustryData(String industry, String transDate, int page, String managerId) {
PageList<JSONObject> logs = transactionAnalysisMapper.getTopRpIndustryData(transDate, industry,
new PageBounds(page, 20), managerId);
return PageListUtils.buildPageListResult(logs);
}
}

@ -1,16 +1,18 @@
package au.com.royalpay.payment.manage.dev.web;
import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService;
import au.com.royalpay.payment.manage.dataAnalysis.core.DataAnalysisService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping("/analysis")
@ -18,6 +20,8 @@ public class AnalysisController {
@Resource
private BDAnalysisService bdAnalysisService;
@Resource
private DataAnalysisService dataAnalysisService;
@GetMapping("/report/bd/sales")
@ -25,4 +29,27 @@ public class AnalysisController {
Date newDate = new SimpleDateFormat("yyyy-MM-dd").parse(date);
bdAnalysisService.generateReport(DateFormatUtils.format(newDate, "yyyy-MM-dd"));
}
@GetMapping("/rp_industry/echarts")
public List<JSONObject> rpIndustryEchartsData(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,
@RequestParam("from") String from,
@RequestParam("to") String to,
@RequestParam(value = "industry",defaultValue = "0") String industry) throws ParseException{
String managerId = null;
if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) {
managerId = manager.getString("manager_id");
}
return dataAnalysisService.getRpIndustryEchartsData(from, to, industry, managerId);
}
@GetMapping("/rp_industry/top_data")
public JSONObject rpTop20IndustryData(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestParam(value = "industry", defaultValue = "0") String industry,
@RequestParam("trans_date") String transDate,
@RequestParam("page") int page) {
String managerId = null;
if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) {
managerId = manager.getString("manager_id");
}
return dataAnalysisService.getRpTop20IndustryData(industry, transDate, page, managerId);
}
}

@ -1084,5 +1084,80 @@
org.org_id
</select>
<!-- <select id="getRpIndustryEchartsData" resultType="com.alibaba.fastjson.JSONObject">-->
<!-- SELECT-->
<!-- DATE_FORMAT( t.transaction_time, '%Y-%m-%d' ) AS trans_date,-->
<!-- nullif( sum( IF ( t.transaction_type = 'Credit', t.clearing_amount,- t.clearing_amount ) ), 0 ) AS total_amount,-->
<!-- nullif( COUNT( DISTINCT t.order_id, IF ( t.transaction_type = 'Credit', TRUE, NULL ) ), 0 ) AS orders-->
<!-- FROM-->
<!-- pmt_transactions t-->
<!-- <if test="industry != null and industry!=0">-->
<!-- <bind name="industry" value="industry+'%'"/>-->
<!-- INNER JOIN sys_clients c ON c.client_id = t.client_id-->
<!-- AND c.is_valid = 1-->
<!-- AND c.royalpayindustry like #{industry}-->
<!-- </if>-->
<!-- WHERE-->
<!-- t.transaction_time >= #{from}-->
<!-- AND t.transaction_time &lt; #{to}-->
<!-- AND t.channel != 'Settlement'-->
<!-- AND t.channel != 'System'-->
<!-- AND t.system_generate = 0-->
<!-- GROUP BY-->
<!-- trans_date-->
<!-- </select>-->
<select id="getRpIndustryEchartsData" resultType="com.alibaba.fastjson.JSONObject">
SELECT
sum(so.total) as total_amount,
sum(so.orders) as orders,
DATE_FORMAT(so.date, '%Y-%m-%d' ) as trans_date
FROM
statistics_customer_order so
inner JOIN sys_clients c ON so.client_id = c.client_id
AND c.is_valid = 1
<if test="industry != null and industry!=0">
<bind name="industry" value="industry+'%'"/>
AND c.royalpayindustry like #{industry}
</if>
and so.date >= #{from}
and so.date &lt; #{to}
and so.client_id!=0
<if test="bd_user!=null">
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
(d.end_date is null or date(d.end_date)&gt;= now()) and
d.is_valid=1
</if>
GROUP BY
trans_date
order by trans_date asc
</select>
<select id="getTopRpIndustryData" resultType="com.alibaba.fastjson.JSONObject">
SELECT
sum(so.total) as total_amount,
sum(so.orders) as orders,
DATE_FORMAT(so.date, '%Y-%m-%d' ) as trans_date,
c.client_moniker,
c.short_name
FROM
statistics_customer_order so
inner JOIN sys_clients c ON so.client_id = c.client_id
AND c.is_valid = 1
<if test="industry != null and industry!=0">
<bind name="industry" value="industry+'%'"/>
AND c.royalpayindustry like #{industry}
</if>
and so.date= #{transDate}
and so.client_id!=0
<if test="bd_user!=null">
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
(d.end_date is null or date(d.end_date)&gt;= now()) and
d.is_valid=1
</if>
GROUP BY
so.client_id
order by total_amount desc
</select>
</mapper>

@ -385,6 +385,11 @@ margin-bottom: 10%;"/>
<i class="fa fa-area-chart"></i> <span>CBBank渠道交易统计</span>
</a>
</li>
<li ui-sref-active="active" ng-if="(currentUser.org_id==null || currentUser.org_id==1)">
<a ui-sref="analysis_industry" ui-sref-opts="{reload:true}">
<i class="fa fa-area-chart"></i> <span>RP商户类别交易统计</span>
</a>
</li>
</ul>
</li>

@ -22,6 +22,10 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts'], function (angul
url: '/cbbanktrans_analysis',
templateUrl: '/static/analysis/templates/cbbank_channel_trans_analysis.html',
controller: 'cbbankTransAnalysisCtrl'
}).state('analysis_industry', {
url: '/analysis/transaction/industry',
templateUrl: '/static/analysis/transaction/templates/industry_analysis_transaction.html',
controller: 'industryTransCtrl'
})
}]);
@ -437,5 +441,165 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts'], function (angul
};
$scope.chooseLast7Days();
}]);
app.controller('industryTransCtrl', ['$scope', '$http', '$filter', 'chartParser', function ($scope, $http, $filter, chartParser) {
$scope.params = {industry: 0};
$scope.today = new Date();
$scope.pagination = {limit:20};
$scope.loadRoyalpayindustry = function () {
$http.get('/static/data/royalpayindustry.json').then(function (resp) {
$scope.royalpayindustry = resp.data;
var selectAll = {
"label": "All",
"mccCode": "0",
"children":{}
};
$scope.royalpayindustry.unshift(selectAll);
})
};
$scope.loadRoyalpayindustry();
$scope.onRoyalPayIndustrySelect = function (selectedItem) {
$scope.params.royalpay_label = selectedItem.label;
$scope.params.industry = selectedItem.mccCode;
$scope.doAnalysis();
};
$scope.chooseToday = function () {
$scope.params.from = $scope.params.to = new Date();
$scope.doAnalysis();
};
$scope.chooseYesterday = function () {
var yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
$scope.params.from = $scope.params.to = yesterday;
$scope.doAnalysis();
};
$scope.chooseLast7Days = function () {
$scope.params.to = new Date();
var day = new Date();
day.setDate(day.getDate() - 7);
$scope.params.from = day;
$scope.doAnalysis();
};
$scope.thisMonth = function () {
$scope.params.to = new Date();
var monthBegin = new Date();
monthBegin.setDate(1);
$scope.params.from = monthBegin;
$scope.doAnalysis();
};
$scope.lastMonth = function () {
var monthFinish = new Date();
monthFinish.setDate(0);
$scope.params.to = monthFinish;
var monthBegin = new Date();
monthBegin.setDate(0);
monthBegin.setDate(1);
$scope.params.from = monthBegin;
$scope.doAnalysis();
};
var amountAnalysis = {
chart: {
tooltip: {
trigger: 'axis',
formatter: '{b}:AUD {c}'
},
yAxis: {
type: 'value',
name: '交易金额(AUD)'
},
color: colors
},
xAxis: {
basic: {
type: 'category',
boundaryGap: false
},
key: 'trans_date'
},
series: [
{
basic: {type: 'line', label: {normal: {show: true}}, showAllSymbols: true},
column: {key: 'total_amount'}
}
]
};
var ordersAnalysis = {
chart: {
tooltip: {
trigger: 'axis',
formatter: '{b}:AUD {c}'
},
yAxis: {
type: 'value',
name: '订单数'
},
color: colors
},
xAxis: {
basic: {
type: 'category',
boundaryGap: false
},
key: 'trans_date'
},
series: [
{
basic: {type: 'line', label: {normal: {show: true}}, showAllSymbols: true},
column: {key: 'orders'}
}
]
};
$scope.doAnalysis = function () {
$scope.future_loading = true;
var params = angular.copy($scope.params);
if (params.from) {
params.from = $filter('date')(params.from, 'yyyy-MM-dd');
}
if (params.to) {
params.to = $filter('date')(params.to, 'yyyy-MM-dd');
}
delete params.royalpay_label;
$http.get('/analysis/rp_industry/echarts', {params: params}).then(function (resp) {
$scope.analysisData = resp.data;
$scope.amountAnalysis = chartParser.parse(amountAnalysis, resp.data);
$scope.ordersAnalysis = chartParser.parse(ordersAnalysis, resp.data);
$scope.future_loading = false;
$scope.chooseDay = $filter('date')($scope.params.from, 'yyyy-MM-dd');
$scope.loadTopTransPartners(1);
});
};
$scope.thisMonth();
$scope.loadTopTransPartners = function (page) {
var requestParams = angular.copy($scope.params);
if (requestParams.from) {
requestParams.from = $filter('date')(requestParams.from, 'yyyy-MM-dd');
}
if (requestParams.to) {
requestParams.to = $filter('date')(requestParams.to, 'yyyy-MM-dd');
}
requestParams.trans_date = $scope.chooseDay || requestParams.from;
requestParams.page = page || $scope.pagination.page || 1;
$http.get('/analysis/rp_industry/top_data', {params: requestParams}).then(function (resp) {
$scope.pagination = resp.data.pagination;
$scope.partners = resp.data.data;
});
};
$scope.choseDayEchart = function (chart) {
chart.on('click', function (params) {
var trans_date = $scope.analysisData[params.dataIndex].trans_date;
$scope.chooseDay = trans_date;
$scope.loadTopTransPartners(1);
})
};
}]);
return app;
});
});

@ -0,0 +1,155 @@
<style>
.cen table {
text-align: center;
}
.cen table th {
text-align: center;
}
</style>
<section class="content">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li ui-sref-active="active">
<a style="font-size: 30px;">RP商户类别交易趋势统计</a>
</li>
</ul>
<div class="tab-content">
<div class="row">
<div class="col-sm-12">
<div class="box box-warning">
<div class="box-header">
<div class="form-horizontal">
<div class="form-group col-xs-12">
<label class="control-label col-xs-4 col-sm-2">Date Range</label>
<div class="col-sm-10">
<div class="form-control-static form-inline">
<div style="display: inline-block">
<input class="form-control" id="date-from-input" ng-model="params.from"
uib-datepicker-popup size="15" placeholder="From"
is-open="dateBegin.open" ng-click="dateBegin.open=true"
datepicker-options="{maxDate:params.end}">
</div>
<div style="display: inline-block;margin: 0 10px;">
~
</div>
<div style="display: inline-block">
<input class="form-control" id="date-to-input" ng-model="params.to"
uib-datepicker-popup size="15" placeholder="To"
is-open="dateTo.open" ng-click="dateTo.open=true"
datepicker-options="{minDate:params.begin,maxDate:today}">
</div>
<div style="display: inline-block">
<input style="margin-left: 20px;"
class="form-control" id="royalpayindustry"
name="royalpayindustry" readonly
ng-value="params.industry|partner_royalpay_industry"
multi-level-select-popup="royalpayindustry"
on-select="onRoyalPayIndustrySelect($selected)"
chose-one-level="true">
</div>
</div>
<div class="form-control-static form-inline">
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseToday()">Today</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseYesterday()">Yesterday</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseLast7Days()">Last 7 Days</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm" ng-click="thisMonth()">This
Month</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm" ng-click="lastMonth()">Last
Month</a>
</div>
<button class="btn btn-success" type="button" ng-click="doAnalysis()">
<i class="fa fa-search"></i>
</button>
</div>
</div>
</div>
<div class="col-xs-12" style="text-align: center">
<loadingbar ng-if="future_loading"></loadingbar>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row cen">
<div class="col-sm-12">
<div class="box">
<div class="box-header with-border">
<span style="font-weight: 900;" ng-if="params.royalpay_label">[{{params.royalpay_label}}]</span>
行业总交易量</div>
<div class="box-body">
<div class="chart" echarts="amountAnalysis" style="height: 300px"
chart-setter="choseDayEchart($chart)"
ng-class="{nodata:amountAnalysis.nodata}"></div>
<div class="chart" echarts="ordersAnalysis" style="height: 300px"
chart-setter="choseDayEchart($chart)"
ng-class="{nodata:ordersAnalysis.nodata}"></div>
</div>
</div>
</div>
</div>
<div class="row cen" ng-if="chooseDay">
<div class="col-sm-12">
<div class="box">
<div class="box-header with-border">
[<span style="font-weight: 900;">{{chooseDay}}{{params.royalpay_label}}</span>]
行业Top交易额商户列表</div>
<div class="box-body">
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Client Moniker</th>
<th>Short Name</th>
<th>Total Amount</th>
<th>Orders</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="partner in partners">
<td ng-bind="partner.client_moniker"></td>
<td ng-bind="partner.short_name"></td>
<td ng-bind="partner.total_amount|currency:''"></td>
<td ng-bind="partner.orders"></td>
</tr>
</tbody>
</table>
</div>
<div class="box-footer">
<uib-pagination class="pagination"
total-items="pagination.totalCount"
boundary-links="true"
ng-model="pagination.page"
items-per-page="pagination.limit"
max-size="10"
ng-change="loadTopTransPartners()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="row">
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total Pages:{{pagination.totalPages}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>

@ -203,6 +203,16 @@
</div>
</a>
</div>
<div ng-if="(currentUser.org_id==null || currentUser.org_id==1)" class="col-sm-2 col-xs-6">
<a ui-sref="analysis_industry" ui-sref-opts="{reload:true}">
<div class="description-block">
<img src="/static/images/main_menu/transaction_original_statistics.png"/>
<div class="description-text">
<span class="description-text">RP商户类别交易统计</span>
</div>
</div>
</a>
</div>
</div>
</div>
<div class="list-group" ng-if="role=='riskmanager'">

@ -1,199 +0,0 @@
package au.com.royalpay.payment.manage.citypartner.core.impls;
import au.com.royalpay.payment.manage.citypartner.core.CityPartnerPrizeService;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.security.*;
import static au.com.royalpay.payment.tools.codec.RSACrypt.loadPrivateKey;
/**
* Created by wangning on 09/01/2018.
*/
@SpringBootTest
public class CityPartnerPrizeServiceImplTest {
static String PRIKEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCdIiy3fFUrZx4X0aIU37PGzViqG03yRDprSk2tqhORnAiZL3sLNFsjmy2FR4+84bksp2VxIc+rMot+4iFIAmpK50t6qj2Fz7sOO5DMSN0pRN9flIqQ1RFKYnIQN+BymfJ9bXbMN2aN+sbfZzZRTAZPtJuES9JIrmUDi4NwNeqBSjhflUqlyYx3ejMx2CrxHAS+35W5fAK88e//9SQiMdKHzNPFl4vXtCMqTY7Mk7febLfsG0aaRVMM/QOeT57sszB3Wib3wUFi9xGsqdqLi0skAWc4QmOGOoue7uvieghFWZXETfFN/K3wSz5TzVS55ma2u3KOkn8/M4E7J96RHzAPAgMBAAECggEAet+ueA0RzM7mCVo0lH4Z5uvM2bhgS4Ju7Fc+Rv8oLkUFtEQcw7Y9TqqZ/g7np5wbYX/FI6J88jKkQqQxwk2hMNGNhG57jZfTfl217QlNaGgjBGrzsC3tR22UJHqNWRBpPwvKSgdIet4PhcMABrKcfNeOhPWFirBU7WC7d5OxvUdA3oCnZXZ7nGxgyX06actjb3GhIUybi4DJosCY3NkBsUXWLh45Kmm8IfJv29cd+VrIBn5i1+mMd6hECmiN03ToH9dc3o1aS4YGJirvkf1q1oiJJMT7exacuZiTrRfUh+NIemm8oaBYJj9PMcy5PEtS/ZyJe7jzDEnbV71i5dnkAQKBgQDhXej3o3KyvP9h/nwH/gifK/Urai0u/SB6CScb8c0xzHoQhomjNaaHHKX82j8zDYMvg7yNWHEo5WdCEcenvjO4OWkbhL9brBJnpN5QyfPtjijUh/8PFNKu/NP0PISkFjuAOp+LVgMRgrfQL/wu1/zp6jgsAXckauUIBNITZPTWrwKBgQCyffLy1Cc1tSovzXchty7TLU49IzNZQ3keMEy8MWw6YFS5PGUSEixtjvsAuzoYMg6w7F/LxK8jMfOcDPza1AJUQIByXPoZs4jm31j6EPjPYP+ocQ04Ji+OOcbR5TOlFamNMnjQNlTqpEmNYpQcKp8AOyGm0dSMHe7YUKqzaymUoQKBgQDNQ4aL/s/aIjAM5ge8E9FwgE4GY+eRc7Wf0TRQzHSTVeUbph44jAYH67z3RyTm7/i7TyZuKs6ua/sXfzA1BRUARzIHgWn1Kg19Xvmp5bcJeECSCufxqYqXHOpD+tboyOMa0Mo903JqAYA/22S6mbjeqJjO4+rLPZ0rJ5DbX0ltOwKBgA+3rYwaiHVfRZ69/g6W/eWUqL4TenMS0PiKkkdEJt6hGvTQz6methDTtWCkHAKDbe3ActMTt8RmoqgMMLvoTWgz4duwOknHGHgUFNa4ZeCFDx47Dknyet+QUOSsxTZ1SN/pIOBc2G9tFhkAJECytBumGVmCQrAv9pdPyyhPeHLhAoGATvtEmi3oYPQtoy8qDEhI8wCXrrKIZh2a7ahRjt8B056HZ26EjalKg2Yz+5WTRbS6Bgr8ZN+12wRl7CbjWyr+loOEsMTjAuJoxGDo9bm936IqvmwVlEdLkOoMoFnJY6OFiVqWmLIXHr56+z2ShryZVPc59gdLxNRA+ZJMF5kY27s=";
private final String IMG_AGGREGATE_FILE = "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=95272786,3986826432&fm=26&gp=0.jpg";
@Resource
private CityPartnerPrizeService cityPartnerPrizeService;
@Test
public void generateAgent() throws Exception {
}
@Test
public void generate() throws Exception {
cityPartnerPrizeService.generate("2017-06");
}
@Test
public void applicationMerchant() throws Exception {
JSONObject companyInfo = new JSONObject() {{
put("company_name", "gateway partner test1");
put("short_name", "gateway partner test1");
put("store_name", "gateway partner test1");
put("business_name", "gateway partner test1");
put("business_structure", "Company");
put("acn", "123456789");
put("company_phone", "123456789");
put("logo_url", "http://n.sinaimg.cn/sinacn15/435/w640h595/20181010/403e-hkrzvkw4936423.jpg");
}};
JSONObject contactInfo = new JSONObject() {{
put("contact_person", "person1");
put("contact_phone", "1231231");
put("contact_email", "1qq@qq.com");
put("contact_job", "Direct");
put("address", "测试住址1");
put("suburb", "测试区1");
put("postcode", "测试code1");
put("state", "测试state1");
put("country", "AU");
put("registered_address", "测试住址2");
put("registered_suburb", "测试区2");
put("registered_postcode", "测试code2");
put("registered_state", "测试state2");
put("timezone", "Australia/West");
}};
JSONObject ClientLegalConfig = new JSONObject() {{
put("legal_representative_person", "person2");
put("legal_representative_phone", "1231231");
put("legal_representative_email", "1qq@qq.com");
put("legal_representative_job", "Direct");
}};
JSONObject clientPayConfig = new JSONObject() {{
put("client_pay_type", "2");
put("client_pay_desc", "201");
put("royalpay_industry", "10001");
put("company_photo", "https://c-ssl.duitang.com/uploads/item/201812/10/20181210170153_xPUVk.jpeg");
put("store_photo", "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3199241964,979639112&fm=26&gp=0.jpg");
put("company_website", "https://11.com");
}};
JSONObject settleConfig = new JSONObject() {{
put("swift_code", "2");
put("bsb_no", "033385");
put("account_no", "21213131");
put("account_name", "dasdasdasd");
put("clean_days", "2");
put("wechat_rate", "1.2");
put("alipay_rate", "1.2");
put("alipay_online_rate", "1.2");
put("transaction_fee", "0");
put("active_time", "2020-02-06 00:00:00");
put("expire_time", "2021-02-06 00:00:00");
}};
JSONObject complianceInfo = new JSONObject() {{
put("id_type", "pastport");
put("id_title", "Direct");
put("id_title_description", "test");
put("bank_statement", "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=820350352,1683018569&fm=26&gp=0.jpg");
put("certificate_of_registration", "http://i2.w.yun.hjfile.cn/doc/201404/00662ef619754b749200eecdf3671c3a.jpg");
put("id_file", "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2284543896,2456565772&fm=26&gp=0.jpg");
put("utility_bill", "http://i0.sinaimg.cn/ent/v/2009-08-22/U2389P28T3D2664490F346DT20090822015510.JPG");
}};
JSONObject params = new JSONObject() {{
put("apply_id", "orgapply1");
put("notify_url", "http://127.0.0.1:9002/sys/partners/7CMV/qrcode");
put("company_info", companyInfo);
put("contact_info", contactInfo);
put("legal_info", ClientLegalConfig);
put("pay_info", clientPayConfig);
put("settle_info", settleConfig);
put("compliance_file_info", complianceInfo);
}};
String originUrl = "http://127.0.0.1:5000/api/v1.0/org_gateway/partner/AXLCEXDDMB/merchant/application";
String url = addSignUrl(originUrl, params, PRIKEY);
HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.POST);
gen.setJSONEntity(params);
gen.setTimeout(10000);
HttpRequestResult result = gen.execute();
if (result.isSuccess()) {
System.out.println(result.getResponseContentJSONObj().toJSONString());
}else {
System.out.println(result.getResponseContentString());
}
}
@Test
public void queryMerchantStatus() throws Exception{
String partnerCode = "PHQ3";
String originUrl = "http://127.0.0.1:5000/api/v1.0/org_gateway/partner/AXLCEXDDMB/merchant/" + partnerCode + "/status";
String url = addSignUrl(originUrl, null, PRIKEY);
HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.GET);
HttpRequestResult result = gen.execute();
if (result.isSuccess()) {
System.out.println(result.getResponseContentJSONObj().toJSONString());
}else {
System.out.println(result.getResponseContentString());
}
}
@Test
public void updateFile() throws Exception{
String originUrl = "http://127.0.0.1:5000/api/v1.0/org_gateway/partner/AXLCEXDDMB/attachment/files";
String url = addSignUrl(originUrl, null, PRIKEY);
File file = new File("/Users/luoyang/Downloads/banner_eshop.jpg");
InputStream stream = new FileInputStream(file);
HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.POST);
gen.setTimeout(10000);
gen.initFileEntity().attachFile("file", "banner_eshop.jpg", stream);
HttpRequestResult result = gen.execute();
if (result.isSuccess()) {
System.out.println(result.getResponseContentJSONObj().toJSONString());
}else {
System.out.println(result.getResponseContentString());
}
}
private String sign(byte[] source, String privateKey) {
try {
PrivateKey priKey = loadPrivateKey(new ByteArrayInputStream(privateKey.getBytes(StandardCharsets.UTF_8)));
Signature signature = Signature.getInstance("SHA256withRSA");
signature.initSign(priKey);
signature.update(source);
byte[] signed = signature.sign();
return Base64.encodeBase64URLSafeString(signed);
} catch (NoSuchAlgorithmException | SignatureException | InvalidKeyException e) {
//shall never happen
throw new ServerErrorException(e);
}
}
private String addSignUrl(String originUrl, JSONObject params, String priKey) {
if (params == null) {
params = new JSONObject();
}
String nonceStr = RandomStringUtils.random(15, true, true);
params.put("url", originUrl);
params.put("sign_type", "RSA2");
params.put("nonce_str", nonceStr);
String signStr = sign(JSONObject.toJSONBytes(params, SerializerFeature.MapSortField), priKey);
originUrl += ("?nonce_str=" + nonceStr);
originUrl += "&sign_type=RSA2";
originUrl += "&sign=" + signStr;
return originUrl;
}
}
Loading…
Cancel
Save