add common sub_merchant_id

master
wangning 7 years ago
parent baec160c2d
commit 88021a718c

@ -0,0 +1,13 @@
package au.com.royalpay.payment.manage.dev.core;
import com.alibaba.fastjson.JSONObject;
/**
* Created by yuan on 2017/9/18.
*/
public interface CommonSubMerchantIdService {
void save(JSONObject record);
void disable(String sub_merchant_id);
}

@ -0,0 +1,41 @@
package au.com.royalpay.payment.manage.dev.core.impl;
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.manage.dev.core.CommonSubMerchantIdService;
import au.com.royalpay.payment.manage.mappers.payment.CommonSubMerchantIdMapper;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class CommonSubMerchantIdServiceImpl implements CommonSubMerchantIdService {
@Resource
private CommonSubMerchantIdMapper commonSubMerchantIdMapper;
@Resource
private MpPaymentApi mpPaymentApi;
@Override
public void save(JSONObject record) {
WeChatPayConfig.Merchant availableMerchant = mpPaymentApi.determineMerchant(record.getString("sub_merchant_id"));
if(availableMerchant == null){
throw new BadRequestException("未检索到对应的商户号,请验证子商户号是否正确");
}
record.put("merchant_id",availableMerchant.getMerchantId());
commonSubMerchantIdMapper.save(record);
}
@Override
public void disable(String sub_merchant_id) {
JSONObject record = new JSONObject();
record.put("sub_merchant_id",sub_merchant_id);
record.put("is_valid",false);
commonSubMerchantIdMapper.update(record);
}
}

@ -5,34 +5,39 @@ import au.com.royalpay.payment.channels.bestpay.runtime.BestPayClient;
import au.com.royalpay.payment.channels.jd.runtime.JDClient; import au.com.royalpay.payment.channels.jd.runtime.JDClient;
import au.com.royalpay.payment.channels.wechat.runtime.WxPayClient; import au.com.royalpay.payment.channels.wechat.runtime.WxPayClient;
import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.core.PaymentApi;
import au.com.royalpay.payment.core.PaymentChannelApi;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.exceptions.OrderNotExistsException; import au.com.royalpay.payment.core.exceptions.OrderNotExistsException;
import au.com.royalpay.payment.manage.analysis.core.PlatformClearService; import au.com.royalpay.payment.manage.analysis.core.PlatformClearService;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService; import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
import au.com.royalpay.payment.manage.dev.bean.Message; import au.com.royalpay.payment.manage.dev.bean.Message;
import au.com.royalpay.payment.manage.dev.bean.SendWechatMessage; import au.com.royalpay.payment.manage.dev.bean.SendWechatMessage;
import au.com.royalpay.payment.manage.dev.core.CommonSubMerchantIdService;
import au.com.royalpay.payment.manage.dev.core.WechatMessageService; import au.com.royalpay.payment.manage.dev.core.WechatMessageService;
import au.com.royalpay.payment.manage.mappers.customers.CustomerEncourageMoneyUseLogMapper; import au.com.royalpay.payment.manage.mappers.customers.CustomerEncourageMoneyUseLogMapper;
import au.com.royalpay.payment.manage.mappers.log.NotifyErrorLogMapper; import au.com.royalpay.payment.manage.mappers.log.NotifyErrorLogMapper;
import au.com.royalpay.payment.manage.mappers.payment.CommonSubMerchantIdMapper;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.payment.RefundMapper; import au.com.royalpay.payment.manage.mappers.payment.RefundMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.defines.TradeType; import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import au.com.royalpay.payment.tools.utils.PdfUtils; import au.com.royalpay.payment.tools.utils.PdfUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils; import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import au.com.royalpay.payment.tools.utils.XmlFormatUtils; import au.com.royalpay.payment.tools.utils.XmlFormatUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.dom4j.Element; import org.dom4j.Element;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -42,12 +47,14 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.ModelAttribute;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -56,6 +63,11 @@ import java.net.URISyntaxException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
/** /**
* Created by yixian on 2016-07-06. * Created by yixian on 2016-07-06.
*/ */
@ -100,7 +112,10 @@ public class TestController implements ApplicationEventPublisherAware {
private ApplicationEventPublisher publisher; private ApplicationEventPublisher publisher;
@Resource @Resource
private WechatMessageService wechatMessageService; private WechatMessageService wechatMessageService;
@Resource
private CommonSubMerchantIdMapper commonSubMerchantIdMapper;
@Resource
private CommonSubMerchantIdService commonSubMerchantIdService;
@ManagerMapping(value = "/{clientMoniker}/export/agreepdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR}) @ManagerMapping(value = "/{clientMoniker}/export/agreepdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR})
public void exportAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, HttpServletResponse httpResponse) throws Exception { public void exportAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, HttpServletResponse httpResponse) throws Exception {
httpResponse.setContentType("application/pdf"); httpResponse.setContentType("application/pdf");
@ -371,4 +386,20 @@ public class TestController implements ApplicationEventPublisherAware {
wechatMessageService.sendMessageByOpenId(sendWechatMessage); wechatMessageService.sendMessageByOpenId(sendWechatMessage);
} }
@RequestMapping(value = "/common_sub_merchant_id", method = RequestMethod.GET)
public JSONObject listCommonSubMerchantId(@RequestParam(required = false) String sub_merchant_id,@RequestParam(defaultValue = "true") boolean is_valid, @RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int limit) {
return PageListUtils.buildPageListResult(commonSubMerchantIdMapper.list(is_valid,sub_merchant_id,new PageBounds(page,limit)));
}
@RequestMapping(value = "/common_sub_merchant_id", method = RequestMethod.POST)
public void addCommonSubMerchantId(@RequestBody JSONObject sub_merchant_id) {
commonSubMerchantIdService.save(sub_merchant_id.getJSONObject("params"));
}
@RequestMapping(value = "/common_sub_merchant_id/{sub_merchant_id}", method = RequestMethod.PUT)
public void addCommonSubMerchantId(@PathVariable String sub_merchant_id) {
commonSubMerchantIdService.disable(sub_merchant_id);
}
} }

@ -0,0 +1,26 @@
package au.com.royalpay.payment.manage.mappers.payment;
import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Create by yixian at 2017-12-05 23:13
*/
@AutoMapper(tablename = "pmt_sub_merchant_id", pkName = "sub_merchant_id")
public interface CommonSubMerchantIdMapper {
@AutoSql(type = SqlType.SELECT)
PageList<JSONObject> list(@Param("is_valid") boolean is_valid, @Param("sub_merchant_id") String sub_merchant_id, PageBounds pagination);
@AutoSql(type = SqlType.INSERT)
void save(JSONObject record);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject record);
}

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.payment.CommonSubMerchantIdMapper">
<select id="list" resultType="com.alibaba.fastjson.JSONObject">
select * from pmt_sub_merchant_id
where is_valid = #{is_valid}
<if test="sub_merchant_id!=null">
and sub_merchant_id = #{sub_merchant_id}
</if>
</select>
</mapper>

@ -51,6 +51,10 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
url: '/phone_top_up', url: '/phone_top_up',
templateUrl: '/static/config/devtools/templates/phone_top_up.html', templateUrl: '/static/config/devtools/templates/phone_top_up.html',
controller: 'phonetopupCtrl' controller: 'phonetopupCtrl'
}).state('devtools.common_sub_merchant_id', {
url: '/common_sub_merchant_id',
templateUrl: '/static/config/devtools/templates/common_sub_merchant_id.html',
controller: 'commonSubMerchantIdCtrl'
}); });
}]); }]);
app.controller('devManualRefundCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) { app.controller('devManualRefundCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) {
@ -302,5 +306,53 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}) })
} }
}]); }]);
app.controller('commonSubMerchantIdCtrl', ['$scope', '$http', '$uibModal', function ($scope, $http, $uibModal) {
$scope.pagination = {};
$scope.params = {};
$scope.loadSubMerchantId = function (page) {
var params = angular.copy($scope.params);
params.page = page || $scope.pagination.page || 1;
if(!params.sub_merchant_id){
delete params.sub_merchant_id;
}
$http.get('/dev/common_sub_merchant_id',{params: params}).then(function (resp) {
$scope.subMerchantIdList= resp.data.data;
$scope.pagination = resp.data.pagination;
});
};
$scope.loadSubMerchantId(1);
$scope.save = function () {
$uibModal.open({
templateUrl: '/static/config/devtools/templates/new_common_sub_merchant_id.html',
controller: 'newCommonSubMerchantIdCtrl'
}).result.then(function () {
})
}
$scope.disable = function (sub_merchant_id) {
$http.put('/dev/common_sub_merchant_id/'+sub_merchant_id).then(function (resp) {
alert("success");
$scope.loadSubMerchantId(1);
},function (resp) {
alert(resp.data.message);
});
}
}]);
app.controller('newCommonSubMerchantIdCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.params = {};
$scope.saveSubMerchantId = function () {
var params = angular.copy($scope.params);
$http.post('/dev/common_sub_merchant_id',{params: params}).then(function (resp) {
alert("保存成功");
},function (resp) {
alert(resp.data.message);
});
};
}]);
return app; return app;
}); });

@ -0,0 +1,88 @@
<section class="content-header">
<h1>Sub Merchant ID</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">Sub Merchant ID</li>
</ol>
</section>
<div class="content">
<div class="row">
<div class="col-sm-12">
<div class="box-solid">
<div class="box box-warning">
<div class="box-header">
<div class="form-inline">
<div class="form-group">
<label class="control-label" for="sub_merchant_id-search">Sub Merchant Id</label>
<input class="form-control" id="sub_merchant_id-search" ng-model="params.sub_merchant_id">
</div>
<div class="form-group">
<button class="btn btn-primary" type="button" ng-click="loadSubMerchantId(1)"><i
class="fa fa-search"></i></button>
</div>
<div class="form-group">
<a role="button" class="btn btn-info pull-right" ng-click="save()"
title="New Activity">
<i class="fa fa-plus"></i>
New
</a>
</div>
</div>
</div>
</div>
<div class="box">
<div class="box-header">
<h3 class="box-title">Common Sub Merchant ID List</h3>
</div>
<div class="box-body no-padding table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Sub Merchat ID</th>
<th>Merchat ID</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="merchantId in subMerchantIdList">
<td ng-bind="merchantId.sub_merchant_id"></td>
<td ng-bind="merchantId.merchant_id"></td>
<td ng-click="disable(merchantId.sub_merchant_id)">
<i class="text-danger fa fa-close ng-scope" ng-if="!act.is_valid"></i>
</td>
</tbody>
</table>
</div>
<div class="box-footer" ng-if="subMerchantIdList.length">
<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="loadSubMerchantId()"
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>

@ -0,0 +1,24 @@
<section class="content-header">
<h1>New Common Sub Merchant ID</h1>
</section>
<div class="content">
<div class="row">
<div class="col-sm-12">
<div class="box-solid">
<div class="box box-warning">
<div class="box-header">
<form role="form" style="margin:0px auto;width: 50%">
<div class="form-group">
<label>Sub Merchant ID</label>
<input ng-model="params.sub_merchant_id" class="form-control" type="text" />
</div>
<div class="form-group">
<button class="btn btn-primary btn-block" ng-click="saveSubMerchantId()">save</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>

@ -67,6 +67,10 @@
<i class="fa fa-envelope"></i> <i class="fa fa-envelope"></i>
Phone Top Up Phone Top Up
</a> </a>
<a class="btn btn-app" role="button" ui-sref=".common_sub_merchant_id">
<i class="fa fa-envelope"></i>
Common Sub Merchant ID
</a>
</div> </div>
</div> </div>
</section> </section>

Loading…
Cancel
Save