master
yuan 7 years ago
parent 3b2718e6fe
commit 7b563647f4

@ -0,0 +1,26 @@
package au.com.royalpay.payment.manage.mappers.system;
import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import javax.validation.constraints.Max;
import java.util.List;
/**
* Created by yixian on 2017-03-14.
*/
@AutoMapper(tablename = "sys_wx_merchant_apply",pkName = "merchant_app_id")
public interface SysWxMerchantApplyMapper {
@AutoSql(type = SqlType.SELECT)
List<JSONObject> listWxMerchantApplices(@Param("client_id") int client_id);
@AutoSql(type = SqlType.INSERT)
void insertWxMerchantApply(JSONObject params);
@AutoSql(type = SqlType.UPDATE)
void updateWxMerchantApply(JSONObject params);
}

@ -0,0 +1,162 @@
package au.com.royalpay.payment.manage.merchants.beans;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
/**
* Created by yuan on 2018/1/19.
*/
public class SubMerchantIdApply {
@NotBlank(message = "error.payment.valid.param_missing")
@Length(max = 50)
@JSONField(name = "company_name")
private String merchant_name;
@NotBlank(message = "error.payment.valid.param_missing")
@Length(max = 20)
@JSONField(name = "short_name")
private String merchant_shortname;
@NotBlank(message = "error.payment.valid.param_missing")
@Length(max = 20)
@JSONField(name = "company_phone")
private String office_phone;
@JSONField(name = "contact_person")
private String contact_name;
private String contact_phone;
private String contact_email;
@NotBlank(message = "error.payment.valid.param_missing")
@JSONField(name = "industry")
private String business_category;
@NotBlank(message = "error.payment.valid.param_missing")
@Length(max = 20)
@JSONField(name = "remark")
private String merchant_remark;
@JSONField(name = "company_website")
private String website;
@NotBlank(message = "error.payment.valid.param_missing")
@Length(min = 10, max = 256)
@JSONField(name = "description")
private String merchant_introduction;
public JSONObject insertObject() {
JSONObject params = new JSONObject();
if(StringUtils.isNotEmpty(merchant_name)){
params.put("merchant_name",merchant_name);
}
if(StringUtils.isNotEmpty(merchant_shortname)){
params.put("merchant_shortname",merchant_shortname);
}
if(StringUtils.isNotEmpty(office_phone)){
params.put("office_phone",office_phone);
}
if(StringUtils.isNotEmpty(contact_name)){
params.put("contact_name",contact_name);
}
if(StringUtils.isNotEmpty(contact_phone)){
params.put("contact_phone",contact_phone);
}
if(StringUtils.isNotEmpty(contact_email)){
params.put("contact_email",contact_email);
}
if(StringUtils.isNotEmpty(business_category)){
params.put("business_category",business_category);
}
if(StringUtils.isNotEmpty(merchant_remark)){
params.put("merchant_remark",merchant_remark);
}
if(StringUtils.isNotEmpty(website)){
params.put("website",website);
}
if(StringUtils.isNotEmpty(merchant_introduction)){
params.put("merchant_introduction",merchant_introduction);
}
return params;
}
public SubMerchantIdApply() {
}
public String getMerchant_name() {
return this.merchant_name;
}
public void setMerchant_name(String merchant_name) {
this.merchant_name = merchant_name;
}
public String getMerchant_shortname() {
return this.merchant_shortname;
}
public void setMerchant_shortname(String merchant_shortname) {
this.merchant_shortname = merchant_shortname;
}
public String getOffice_phone() {
return this.office_phone;
}
public void setOffice_phone(String office_phone) {
this.office_phone = office_phone;
}
public String getContact_name() {
return this.contact_name;
}
public void setContact_name(String contact_name) {
this.contact_name = contact_name;
}
public String getContact_phone() {
return this.contact_phone;
}
public void setContact_phone(String contact_phone) {
this.contact_phone = contact_phone;
}
public String getContact_email() {
return this.contact_email;
}
public void setContact_email(String contact_email) {
this.contact_email = contact_email;
}
public String getBusiness_category() {
return this.business_category;
}
public void setBusiness_category(String business_category) {
this.business_category = business_category;
}
public String getMerchant_remark() {
return this.merchant_remark;
}
public void setMerchant_remark(String merchant_remark) {
this.merchant_remark = merchant_remark;
}
public String getMerchant_introduction() {
return this.merchant_introduction;
}
public void setMerchant_introduction(String merchant_introduction) {
this.merchant_introduction = merchant_introduction;
}
public String getWebsite() {
return this.website;
}
public void setWebsite(String website) {
this.website = website;
}
}

@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.merchants.core;
import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo;
import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.merchants.beans.*;
@ -266,4 +267,8 @@ public interface ClientManager {
void setWeekendDelay(int clientId, boolean delay);
List<JSONObject> listSubMerchantIdApplys(JSONObject manager, String clientMoniker);
void subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager);
void clearCacheSubMerchantIdApplices(String clientMoniker);
}

@ -2,6 +2,8 @@ package au.com.royalpay.payment.manage.merchants.core.impls;
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.channels.wechat.runtime.WxPayClient;
import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo;
import au.com.royalpay.payment.core.PaymentChannelApi;
import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
@ -54,6 +56,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@ -135,6 +138,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private MpPaymentApi mpPaymentApi;
@Resource
private SignInAccountService signInAccountService;
@Resource
private WxPayClient wxPayClient;
@Resource
private ManagerMapper managerMapper;
@ -152,6 +157,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Resource
private ClientAuditProcessMapper clientAuditProcessMapper;
@Resource
private SysWxMerchantApplyMapper sysWxMerchantApplyMapper;
@Resource
private SpringTemplateEngine thymeleaf;
@ -2924,7 +2932,51 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
@Override
@Cacheable(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker")
public List<JSONObject> listSubMerchantIdApplys(JSONObject manager, String clientMoniker) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
List<JSONObject> applices = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"));
if(!applices.isEmpty()){
return applices;
}else {
if(StringUtils.isNotEmpty(client.getString("sub_merchant_id")) && StringUtils.isNotEmpty(client.getString("merchant_id"))){
Element elem = wxPayClient.querySubMerchant(client.getString("merchant_id"),client.getString("sub_merchant_id"));
String applicesXml = XmlFormatUtils.formatXml(elem);
if(applicesXml != null){
return null;
}
}
}
return null;
}
@Override
@CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker")
public void clearCacheSubMerchantIdApplices(String clientMoniker) {
}
@Override
@CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker")
public void subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
if(!StringUtils.isNotEmpty(client.getString("merchant_id"))){
throw new BadRequestException("无Merchant_id");
}
JSONObject params = subMerchantApply.insertObject();
SubMerchantInfo subMerchantInfo = JSONObject.toJavaObject(params,SubMerchantInfo.class);
params.put("merchant_id",client.getString("merchant_id"));
params.put("client_id",client.getString("client_id"));
params.put("create_time",new Date());
params.put("operator",manager.getString("manager_id"));
Element elem = wxPayClient.subMerchantApplication(client.getString("merchant_id"),subMerchantInfo);
String applicesXml = XmlFormatUtils.formatXml(elem);
params.put("sub_merchant_id",applicesXml);
sysWxMerchantApplyMapper.insertWxMerchantApply(params);
clearCacheSubMerchantIdApplices(clientMoniker);
}
}

@ -482,4 +482,14 @@ public class PartnerManageController {
public void localMerchantPermission(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.switchPermission(manager, clientMoniker, "local_merchant", pass.getBooleanValue("allow"));
}
@ManagerMapping(value = "/{clientMoniker}/list_sub_applices",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN})
public List<JSONObject> listSubMerchantIdApplys(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.listSubMerchantIdApplys(manager,clientMoniker);
}
@ManagerMapping(value = "/{clientMoniker}/sub_apply",method = RequestMethod.POST,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN})
public void subMerchantApplication(@PathVariable String clientMoniker, @RequestBody SubMerchantIdApply subMerchantIdApply, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.subMerchantApplication(clientMoniker,subMerchantIdApply,manager);
}
}

@ -30,6 +30,56 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
{code: 2, label: 'Manager'},
{code: 3, label: 'Cashier'}
];
var wxMerchantIndustries = [
{
"label": "鞋包服饰",
"value": "343"
},
{
"label": "机票行业",
"value": "493"
},
{
"label": "文具/办公用品",
"value": "492"
},
{
"label": "酒店行业",
"value": "491"
},
{
"label": "教育行业",
"value": "490"
},
{
"label": "国际物流",
"value": "489"
},
{
"label": "数码电器",
"value": "488"
},
{
"label": "母婴",
"value": "487"
},
{
"label": "化妆品",
"value": "486"
},
{
"label": "食品",
"value": "485"
},
{
"label": "综合商城",
"value": "484"
},
{
"label": "其它货物贸易行业",
"value": "494"
}
];
var app = angular.module('partnerManageApp', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ui.select', 'ngFileUpload']);
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('partners', {
@ -2526,13 +2576,11 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
}
}
}]);
app.controller('subMerchantIdApplicaitonsCtrl', ['$scope', '$http', '$uibModal','$state', 'industryMap', function ($scope, $http, $uibModal, $state, industryMap) {
$scope.industries = industryMap.configs();
app.controller('subMerchantIdApplicaitonsCtrl', ['$scope', '$http', '$uibModal','$state', function ($scope, $http, $uibModal, $state) {
$scope.loadSubMerchantInfos = function () {
/* $http.get('/client/product/' + $scope.partner.client_moniker + '/list', {params: params}).then(function (resp) {
$scope.subMerchantInfos = resp.data.data;
});*/
$http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_sub_applices', {params: {}}).then(function (resp) {
$scope.subMerchantInfos = resp.data;
});
};
$scope.applySubMerchantId = function () {
$uibModal.open({
@ -2547,9 +2595,30 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
$scope.loadSubMerchantInfos();
})
};
$scope.loadSubMerchantInfos();
}]);
app.controller('applySubMerchantIdCtrl', ['$scope', '$http', '$uibModal','$state','subMerchantInfo', 'industryMap', function ($scope, $http, $uibModal, $state, subMerchantInfo,industryMap) {
app.controller('applySubMerchantIdCtrl', ['$scope', '$http', '$uibModal','$state','subMerchantInfo', '$filter', function ($scope, $http, $uibModal, $state, subMerchantInfo,$filter) {
$scope.wxIndustries = angular.copy(wxMerchantIndustries);
$scope.subMerchantInfo = angular.copy(subMerchantInfo);
$scope.subMerchantInfo.industry = $filter('wxindustries')($scope.subMerchantInfo.industry);
$scope.saveAppliy = function (form) {
$scope.errmsg = null;
if (form.$invalid) {
angular.forEach(form, function (item, key) {
if (key.indexOf('$') < 0) {
item.$dirty = true;
}
});
return;
}
$http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker+ '/sub_apply', $scope.subMerchantInfo).then(function () {
alert("Success");
$scope.$close();
$state.reload();
}, function (resp) {
$scope.errmsg = resp.data.message;
})
}
}]);
app.filter('bdOrg', function () {
return function (bdUsers, org_id) {
@ -2594,5 +2663,38 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
return bdUsers;
}
});
app.filter('wxindustries', function () {
return function (value) {
switch (value + '') {
case '327':
return '343';
case '339':
return '493';
case '337':
return '492';
case '328':
return '491';
case '362':
case '361':
case '363':
case '329':
return '490';
case '330':
return '489';
case '332':
return '487';
case '334':
return '486';
case '335':
return '485';
case '336':
return '484';
case '338':
case '358':
return '494'
}
}
});
return app;
});

@ -1,30 +1,31 @@
<div class="content">
<form novalidate name="form">
<form novalidate name="subForm">
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">Apply Sub Merchant Id</div>
<div class="panel-body">
<div class="alert alert-danger" ng-if="errmsg" ng-bind="errmsg"></div>
<div class="form-horizontal">
<div class="form-group"
ng-class="{'has-error':form.merchant_name.$invalid && form.merchant_name.$dirty}">
ng-class="{'has-error':subForm.merchant_name.$invalid && subForm.merchant_name.$dirty}">
<label class="control-label col-sm-3" for="merchant_name_input">* Merchant Name</label>
<div class="col-sm-8">
<input class="form-control" ng-model="subMerchantInfo.company_name"
type="text" name="merchant_name" id="merchant_name_input" required maxlength="50">
<div ng-messages="form.merchant_name.$error" ng-if="form.merchant_name.$dirty">
<div ng-messages="subForm.merchant_name.$error" ng-if="subForm.merchant_name.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
<p class="small text-danger" ng-message="maxlength">Length is more than 50</p>
</div>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':form.merchant_shortname.$invalid && form.merchant_shortname.$dirty}">
ng-class="{'has-error':subForm.merchant_shortname.$invalid && subForm.merchant_shortname.$dirty}">
<label class="control-label col-sm-3" for="merchant_shortname_input">* Merchant Short Name</label>
<div class="col-sm-8">
<input class="form-control" ng-model="subMerchantInfo.short_name"
type="text" name="merchant_shortname" id="merchant_shortname_input" required maxlength="50">
<div ng-messages="form.merchant_shortname.$error" ng-if="form.merchant_shortname.$dirty">
<div ng-messages="subForm.merchant_shortname.$error" ng-if="subForm.merchant_shortname.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
<p class="small text-danger" ng-message="maxlength">Length is more than 50</p>
</div>
@ -32,31 +33,43 @@
</div>
<div class="form-group"
ng-class="{'has-error':form.business_category.$invalid && form.business_category.$dirty}">
ng-class="{'has-error':subForm.business_category.$invalid && subForm.business_category.$dirty}">
<label class="control-label col-sm-3" for="business_category_input">* Business Category</label>
<div class="col-sm-8">
<select class="form-control" name="business_category"
ng-model="subMerchantInfo.industry"
id="business_category_input" required
ng-options="industry.value as industry.label for industry in industries">
ng-options="industry.value as industry.label for industry in wxIndustries">
<option value="">Please Choose</option>
</select>
<div ng-messages="form.business_category.$error" ng-if="form.business_category.$dirty">
<div ng-messages="subForm.business_category.$error" ng-if="subForm.business_category.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
</div>
</div>
<div ng-messages="form.business_category.$error" ng-if="form.business_category.$dirty">
<div ng-messages="subForm.business_category.$error" ng-if="subForm.business_category.$dirty">
<p class="small text-danger" ng-message="maxLength">More than 50</p>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':form.merchant_remark.$invalid && form.merchant_remark.$dirty}">
ng-class="{'has-error':subForm.website.$invalid && subForm.website.$dirty}">
<label class="control-label col-sm-3" for="website_input">* Website</label>
<div class="col-sm-8">
<input class="form-control" ng-model="subMerchantInfo.company_website"
type="text" name="website" id="website_input" required>
<div ng-messages="subForm.website.$error" ng-if="subForm.website.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
</div>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':subForm.merchant_remark.$invalid && subForm.merchant_remark.$dirty}">
<label class="control-label col-sm-3" for="merchant_remark_input">* Merchant Remark</label>
<div class="col-sm-8">
<input class="form-control" ng-model="subMerchantInfo.remark"
type="text" name="merchant_remark" id="merchant_remark_input" required maxlength="20">
<div ng-messages="form.merchant_remark.$error" ng-if="form.merchant_remark.$dirty">
type="text" name="merchant_remark" id="merchant_remark_input" maxlength="20" required>
<div ng-messages="subForm.merchant_remark.$error" ng-if="subForm.merchant_remark.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
<p class="small text-danger" ng-message="maxlength">Length is more than 20</p>
</div>
@ -64,12 +77,12 @@
</div>
<div class="form-group"
ng-class="{'has-error':form.merchant_introduction.$invalid && form.merchant_introduction.$dirty}">
ng-class="{'has-error':subForm.merchant_introduction.$invalid && subForm.merchant_introduction.$dirty}">
<label class="control-label col-sm-3" for="merchant_introduction_input">* Merchant Introduction</label>
<div class="col-sm-8">
<input class="form-control" ng-model="subMerchantInfo.description"
type="text" name="merchant_introduction" id="merchant_introduction_input" required maxlength="256" MINLENGTH="10">
<div ng-messages="form.merchant_introduction.$error" ng-if="form.merchant_introduction.$dirty">
<div ng-messages="subForm.merchant_introduction.$error" ng-if="subForm.merchant_introduction.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
<p class="small text-danger" ng-message="maxlength">Length is more than 256</p>
<p class="small text-danger" ng-message="minlength">Length is less than 10</p>
@ -121,8 +134,8 @@
<!--</div>-->
<!--end 商品二维码-->
<div class="btn-group margin-bottom margin-top">
<button ng-disabled="goodForm.$dirty&&goodForm.$invalid" class="btn btn-success" type="button"
ng-click="save(goodForm)">Save
<button ng-disabled="subForm.$dirty&&subForm.$invalid" class="btn btn-success" type="button"
ng-click="saveAppliy(subForm)">Save
</button>
</div>
</div>

@ -15,8 +15,8 @@
<div class="box-header">
<h3 class="box-title">List of Sub Merchant Id</h3>
</div>
<div class="box-body">
<ul class="list-group col-sm-6">
<div class="box-body col-sm-6" ng-repeat="id_apply in subMerchantInfos">
<ul class="list-group">
<li class="list-group-item list-group-item-success">
Sub Merchant Id
<span style="float: right" ng-bind="id_apply.sub_merchant_id"></span>

Loading…
Cancel
Save