From 3b2718e6fe7c1e0d62f31bf8e92119c8fc41b557 Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Thu, 18 Jan 2018 17:01:36 +0800 Subject: [PATCH 1/4] fix~ --- .../manage/merchants/core/ClientManager.java | 2 + .../core/impls/ClientManagerImpl.java | 5 + .../static/payment/partner/partner-manage.js | 29 ++++ .../templates/apply_sub_merchant_id.html | 131 ++++++++++++++++++ .../partner/templates/partner_detail.html | 3 + .../templates/sub_merchant_id_apply.html | 57 ++++++++ 6 files changed, 227 insertions(+) create mode 100644 src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html create mode 100644 src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 7f29c5718..6b63cfb9a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -264,4 +264,6 @@ public interface ClientManager { void validRefundPwd(JSONObject account, String pwd); void setWeekendDelay(int clientId, boolean delay); + + List listSubMerchantIdApplys(JSONObject manager, String clientMoniker); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 1b1b54812..2ccdff4ed 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -2922,4 +2922,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } } + + @Override + public List listSubMerchantIdApplys(JSONObject manager, String clientMoniker) { + return null; + } } diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index a4fab9761..030e2a776 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -109,6 +109,10 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter url: '/partner_product', templateUrl: 'static/payment/product/templates/product.html', controller: 'productCtrl' + }).state('partners.detail.sub_merchant_applicaitons', { + url: '/sub_merchant_applicaitons', + templateUrl: 'static/payment/partner/templates/sub_merchant_id_apply.html', + controller: 'subMerchantIdApplicaitonsCtrl' }); }]); app.controller('partnerListCtrl', ['$scope', '$sce', '$http', '$filter', '$uibModal', 'businessStructuresMap', 'industryMap', 'stateMap', 'sectorMap', 'countryMap', @@ -2522,6 +2526,31 @@ 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(); + $scope.loadSubMerchantInfos = function () { + /* $http.get('/client/product/' + $scope.partner.client_moniker + '/list', {params: params}).then(function (resp) { + $scope.subMerchantInfos = resp.data.data; + + });*/ + }; + $scope.applySubMerchantId = function () { + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/apply_sub_merchant_id.html', + controller: 'applySubMerchantIdCtrl', + resolve: { + subMerchantInfo:function () { + return $scope.partner; + } + } + }).result.then(function () { + $scope.loadSubMerchantInfos(); + }) + }; + }]); + app.controller('applySubMerchantIdCtrl', ['$scope', '$http', '$uibModal','$state','subMerchantInfo', 'industryMap', function ($scope, $http, $uibModal, $state, subMerchantInfo,industryMap) { + $scope.subMerchantInfo = angular.copy(subMerchantInfo); + }]); app.filter('bdOrg', function () { return function (bdUsers, org_id) { if (org_id) { diff --git a/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html b/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html new file mode 100644 index 000000000..85fecea34 --- /dev/null +++ b/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html @@ -0,0 +1,131 @@ +
+
+
+
+
+
Apply Sub Merchant Id
+
+
+
+ +
+ +
+

Required Field

+

Length is more than 50

+
+
+
+
+ +
+ +
+

Required Field

+

Length is more than 50

+
+
+
+ +
+ +
+ +
+

Required Field

+
+
+
+

More than 50

+
+
+ +
+ +
+ +
+

Required Field

+

Length is more than 20

+
+
+
+ +
+ +
+ +
+

Required Field

+

Length is more than 256

+

Length is less than 10

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + + + + + + + +
+ +
+
+
+
+
\ No newline at end of file diff --git a/src/main/ui/static/payment/partner/templates/partner_detail.html b/src/main/ui/static/payment/partner/templates/partner_detail.html index 0e9956049..c17ba2bb9 100644 --- a/src/main/ui/static/payment/partner/templates/partner_detail.html +++ b/src/main/ui/static/payment/partner/templates/partner_detail.html @@ -238,6 +238,9 @@
  • Product
  • +
  • + Sub Merchant Id Applicaitons +
  • diff --git a/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html b/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html new file mode 100644 index 000000000..4f50cfb50 --- /dev/null +++ b/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html @@ -0,0 +1,57 @@ +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +

    List of Sub Merchant Id

    +
    +
    +
      +
    • + Sub Merchant Id + +
    • +
    • + Apply Time + +
    • +
    • + Merchant Short Name + +
    • +
    • + Business Category + +
    • +
    • + Description + +
    • + + +
    • + Operator + +
    • + +
    +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file From 7b563647f4b0bbb88c2042c07ced25473f01efef Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Wed, 24 Jan 2018 11:34:43 +0800 Subject: [PATCH 2/4] fix~ --- .../system/SysWxMerchantApplyMapper.java | 26 +++ .../merchants/beans/SubMerchantIdApply.java | 162 ++++++++++++++++++ .../manage/merchants/core/ClientManager.java | 5 + .../core/impls/ClientManagerImpl.java | 52 ++++++ .../web/PartnerManageController.java | 10 ++ .../static/payment/partner/partner-manage.js | 116 ++++++++++++- .../templates/apply_sub_merchant_id.html | 45 +++-- .../templates/sub_merchant_id_apply.html | 4 +- 8 files changed, 395 insertions(+), 25 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/system/SysWxMerchantApplyMapper.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/beans/SubMerchantIdApply.java diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysWxMerchantApplyMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysWxMerchantApplyMapper.java new file mode 100644 index 000000000..44400c1fa --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysWxMerchantApplyMapper.java @@ -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 listWxMerchantApplices(@Param("client_id") int client_id); + + @AutoSql(type = SqlType.INSERT) + void insertWxMerchantApply(JSONObject params); + + @AutoSql(type = SqlType.UPDATE) + void updateWxMerchantApply(JSONObject params); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/SubMerchantIdApply.java b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/SubMerchantIdApply.java new file mode 100644 index 000000000..317eaa981 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/SubMerchantIdApply.java @@ -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; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 6b63cfb9a..6eeed77bb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -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 listSubMerchantIdApplys(JSONObject manager, String clientMoniker); + + void subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager); + + void clearCacheSubMerchantIdApplices(String clientMoniker); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 2ccdff4ed..e2a89cde3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -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 listSubMerchantIdApplys(JSONObject manager, String clientMoniker) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + List 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); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index f9d090a2c..888c0cec1 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -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 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); + } } diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 030e2a776..b1e09d2e3 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -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; }); \ No newline at end of file diff --git a/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html b/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html index 85fecea34..56d6401a3 100644 --- a/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html +++ b/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html @@ -1,30 +1,31 @@
    -
    +
    Apply Sub Merchant Id
    +
    + ng-class="{'has-error':subForm.merchant_name.$invalid && subForm.merchant_name.$dirty}">
    -
    +

    Required Field

    Length is more than 50

    + ng-class="{'has-error':subForm.merchant_shortname.$invalid && subForm.merchant_shortname.$dirty}">
    -
    +

    Required Field

    Length is more than 50

    @@ -32,31 +33,43 @@
    + ng-class="{'has-error':subForm.business_category.$invalid && subForm.business_category.$dirty}">
    -
    +

    Required Field

    -
    +

    More than 50

    + ng-class="{'has-error':subForm.website.$invalid && subForm.website.$dirty}"> + +
    + +
    +

    Required Field

    +
    +
    +
    + +
    -
    + type="text" name="merchant_remark" id="merchant_remark_input" maxlength="20" required> +

    Required Field

    Length is more than 20

    @@ -64,12 +77,12 @@
    + ng-class="{'has-error':subForm.merchant_introduction.$invalid && subForm.merchant_introduction.$dirty}">
    -
    +

    Required Field

    Length is more than 256

    Length is less than 10

    @@ -121,8 +134,8 @@
    -
    diff --git a/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html b/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html index 4f50cfb50..1ddefd3c6 100644 --- a/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html +++ b/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html @@ -15,8 +15,8 @@

    List of Sub Merchant Id

    -
    -
      +
      +
      • Sub Merchant Id From 511faafdda3c6c255e202f33cf0e02ad9684f208 Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Mon, 29 Jan 2018 16:44:32 +0800 Subject: [PATCH 3/4] fix~ --- .../system/SysWxMerchantApplyMapper.java | 5 +- .../merchants/beans/SubMerchantIdApply.java | 12 +++ .../manage/merchants/core/ClientManager.java | 2 + .../core/impls/ClientManagerImpl.java | 73 ++++++++++++++----- .../web/PartnerManageController.java | 5 ++ .../static/payment/partner/partner-manage.js | 8 +- .../templates/apply_sub_merchant_id.html | 20 +++++ .../templates/sub_merchant_id_apply.html | 4 +- 8 files changed, 103 insertions(+), 26 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysWxMerchantApplyMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysWxMerchantApplyMapper.java index 44400c1fa..496860b2e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysWxMerchantApplyMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysWxMerchantApplyMapper.java @@ -5,6 +5,7 @@ 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 com.github.miemiedev.mybatis.paginator.domain.PageBounds; import org.apache.ibatis.annotations.Param; import javax.validation.constraints.Max; @@ -16,11 +17,9 @@ import java.util.List; @AutoMapper(tablename = "sys_wx_merchant_apply",pkName = "merchant_app_id") public interface SysWxMerchantApplyMapper { @AutoSql(type = SqlType.SELECT) - List listWxMerchantApplices(@Param("client_id") int client_id); + List listWxMerchantApplices(@Param("client_id") int client_id, PageBounds pageBounds); @AutoSql(type = SqlType.INSERT) void insertWxMerchantApply(JSONObject params); - @AutoSql(type = SqlType.UPDATE) - void updateWxMerchantApply(JSONObject params); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/SubMerchantIdApply.java b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/SubMerchantIdApply.java index 317eaa981..4d1a843a4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/SubMerchantIdApply.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/SubMerchantIdApply.java @@ -17,6 +17,10 @@ public class SubMerchantIdApply { @JSONField(name = "company_name") private String merchant_name; @NotBlank(message = "error.payment.valid.param_missing") + @Length(max = 10) + @JSONField(name = "merchant_id") + private String merchant_id; + @NotBlank(message = "error.payment.valid.param_missing") @Length(max = 20) @JSONField(name = "short_name") private String merchant_shortname; @@ -84,6 +88,14 @@ public class SubMerchantIdApply { return this.merchant_name; } + public String getMerchant_id() { + return merchant_id; + } + + public void setMerchant_id(String merchant_id) { + this.merchant_id = merchant_id; + } + public void setMerchant_name(String merchant_name) { this.merchant_name = merchant_name; } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 6eeed77bb..291fa155b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -270,5 +270,7 @@ public interface ClientManager { void subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager); + List listMerchantIds(String clientMoniker,JSONObject manager); + void clearCacheSubMerchantIdApplices(String clientMoniker); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index e2a89cde3..941eda037 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1,6 +1,7 @@ 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.config.WechatPayEnvironment; 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; @@ -2938,25 +2939,36 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - List applices = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id")); + checkOrgPermission(manager, client); + List applices = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"),new PageBounds(Order.formString("create_time.desc"))); 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; - } + JSONObject object = new JSONObject(); + object.put("sub_merchant_id",elem.elementText("sub_mch_id_0")); + object.put("client_id",client.getInteger("client_id")); + object.put("merchant_name",elem.elementText("merchant_name_0")); + object.put("merchant_shortname",elem.elementText("merchant_shortname_0")); + object.put("office_phone",elem.elementText("office_phone_0")); + object.put("contact_name",elem.elementText("contact_name_0")); + object.put("contact_email",elem.elementText("contact_email_0")); + object.put("contact_phone",elem.elementText("contact_phone_0")); + object.put("business_category",elem.elementText("business_category_0")); + object.put("merchant_remark",elem.elementText("merchant_remark_0")); + object.put("website",elem.elementText("website_0")); + object.put("merchant_introduction",elem.elementText("merchant_introduction_0")); + object.put("merchant_id",client.getString("merchant_id")); + object.put("create_time",new Date()); + object.put("operator",manager.getString("display_name")); + sysWxMerchantApplyMapper.insertWxMerchantApply(object); + List applyQuery = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"),new PageBounds(Order.formString("create_time.desc"))); + return applyQuery; } } 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) { @@ -2964,19 +2976,42 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - if(!StringUtils.isNotEmpty(client.getString("merchant_id"))){ - throw new BadRequestException("无Merchant_id"); - } + checkOrgPermission(manager, client); 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); + params.put("operator",manager.getString("display_name")); + Element elem = wxPayClient.subMerchantApplication(subMerchantApply.getMerchant_id(),subMerchantInfo); + String sub_merchant_id = elem.elementText("sub_mch_id"); + if(StringUtils.isNotEmpty(sub_merchant_id)){ + params.put("sub_merchant_id",sub_merchant_id); + sysWxMerchantApplyMapper.insertWxMerchantApply(params); + clearCacheSubMerchantIdApplices(clientMoniker); + }else { + throw new BadRequestException(); + } + } + + @Override + public List listMerchantIds(String clientMoniker,JSONObject manager) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + checkOrgPermission(manager, client); + List list = new ArrayList<>(); + for (WeChatPayConfig.Merchant mch : WechatPayEnvironment.getEnv().getWechatMerchantConfigs()){ + JSONObject merchantIds = new JSONObject(); + merchantIds.put("merchant_id",mch.getMerchantId()); + list.add(merchantIds); + } + return list; + } + + @Override + @CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker") + public void clearCacheSubMerchantIdApplices(String clientMoniker) { } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 888c0cec1..8928e732f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -492,4 +492,9 @@ public class PartnerManageController { public void subMerchantApplication(@PathVariable String clientMoniker, @RequestBody SubMerchantIdApply subMerchantIdApply, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { clientManager.subMerchantApplication(clientMoniker,subMerchantIdApply,manager); } + + @ManagerMapping(value = "/{clientMoniker}/get_merchant_ids",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN}) + public List getMerchantIds(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + return clientManager.listMerchantIds(clientMoniker,manager); + } } diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index b1e09d2e3..f019de6eb 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -2589,7 +2589,10 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter resolve: { subMerchantInfo:function () { return $scope.partner; - } + }, + merchantIds: ['$http', '$stateParams', function ($http) { + return $http.get('/sys/partners/'+ $scope.partner.client_moniker +'/get_merchant_ids'); + }] } }).result.then(function () { $scope.loadSubMerchantInfos(); @@ -2597,9 +2600,10 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }; $scope.loadSubMerchantInfos(); }]); - app.controller('applySubMerchantIdCtrl', ['$scope', '$http', '$uibModal','$state','subMerchantInfo', '$filter', function ($scope, $http, $uibModal, $state, subMerchantInfo,$filter) { + app.controller('applySubMerchantIdCtrl', ['$scope', '$http', '$uibModal','$state','subMerchantInfo', '$filter','merchantIds', function ($scope, $http, $uibModal, $state, subMerchantInfo,$filter,merchantIds) { $scope.wxIndustries = angular.copy(wxMerchantIndustries); $scope.subMerchantInfo = angular.copy(subMerchantInfo); + $scope.merchantIds = merchantIds.data; $scope.subMerchantInfo.industry = $filter('wxindustries')($scope.subMerchantInfo.industry); $scope.saveAppliy = function (form) { $scope.errmsg = null; diff --git a/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html b/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html index 56d6401a3..66183d6cc 100644 --- a/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html +++ b/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html @@ -19,6 +19,26 @@
    + +
    + +
    + +
    +

    Required Field

    +
    +
    +
    +

    More than 50

    +
    +
    +
    diff --git a/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html b/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html index 1ddefd3c6..22b23a645 100644 --- a/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html +++ b/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html @@ -18,8 +18,8 @@
    • - Sub Merchant Id - + Sub Merchant Id +
    • Apply Time From 86d07c5f69ffeca3b85210bbc171703cc073b810 Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Tue, 30 Jan 2018 15:38:14 +0800 Subject: [PATCH 4/4] fix~ --- .../manage/merchants/core/ClientManager.java | 2 +- .../core/impls/ClientManagerImpl.java | 11 +- .../web/PartnerManageController.java | 4 +- .../static/payment/partner/partner-manage.js | 101 ++++++++++++++---- .../templates/apply_sub_merchant_id.html | 7 +- .../templates/sub_merchant_id_apply.html | 98 +++++++++++------ 6 files changed, 161 insertions(+), 62 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 291fa155b..c093b50cc 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -268,7 +268,7 @@ public interface ClientManager { List listSubMerchantIdApplys(JSONObject manager, String clientMoniker); - void subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager); + String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager); List listMerchantIds(String clientMoniker,JSONObject manager); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 941eda037..8751ce9e4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -2962,8 +2962,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid object.put("merchant_id",client.getString("merchant_id")); object.put("create_time",new Date()); object.put("operator",manager.getString("display_name")); - sysWxMerchantApplyMapper.insertWxMerchantApply(object); - List applyQuery = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"),new PageBounds(Order.formString("create_time.desc"))); + List applyQuery = new ArrayList<>(); + applyQuery.add(object); return applyQuery; } } @@ -2971,7 +2971,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } @Override @CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker") - public void subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager) { + public String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new InvalidShortIdException(); @@ -2979,7 +2979,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkOrgPermission(manager, client); JSONObject params = subMerchantApply.insertObject(); SubMerchantInfo subMerchantInfo = JSONObject.toJavaObject(params,SubMerchantInfo.class); - params.put("merchant_id",client.getString("merchant_id")); + params.put("merchant_id",subMerchantApply.getMerchant_id()); params.put("client_id",client.getString("client_id")); params.put("create_time",new Date()); params.put("operator",manager.getString("display_name")); @@ -2990,8 +2990,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid sysWxMerchantApplyMapper.insertWxMerchantApply(params); clearCacheSubMerchantIdApplices(clientMoniker); }else { - throw new BadRequestException(); + throw new BadRequestException(elem.elementText("return_msg")); } + return sub_merchant_id; } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 8928e732f..2c15a63f2 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -489,8 +489,8 @@ public class PartnerManageController { } @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); + public String subMerchantApplication(@PathVariable String clientMoniker, @RequestBody SubMerchantIdApply subMerchantIdApply, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + return clientManager.subMerchantApplication(clientMoniker,subMerchantIdApply,manager); } @ManagerMapping(value = "/{clientMoniker}/get_merchant_ids",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN}) diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index f019de6eb..619fee907 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -32,51 +32,51 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter ]; var wxMerchantIndustries = [ { - "label": "鞋包服饰", + "label": "鞋包服饰|Shoes&Garments", "value": "343" }, { - "label": "机票行业", + "label": "机票行业|Air Ticket", "value": "493" }, { - "label": "文具/办公用品", + "label": "文具/办公用品|Stationery/office supplies", "value": "492" }, { - "label": "酒店行业", + "label": "酒店行业|Hotel Industry", "value": "491" }, { - "label": "教育行业", + "label": "教育行业|Education Industry", "value": "490" }, { - "label": "国际物流", + "label": "国际物流|Logistics", "value": "489" }, { - "label": "数码电器", + "label": "数码电器|Digital appliance", "value": "488" }, { - "label": "母婴", + "label": "母婴|Maternal and infant", "value": "487" }, { - "label": "化妆品", + "label": "化妆品|Cosmetics", "value": "486" }, { - "label": "食品", + "label": "食品|Food", "value": "485" }, { - "label": "综合商城", + "label": "综合商城|Comprehensive mall", "value": "484" }, { - "label": "其它货物贸易行业", + "label": "其它货物贸易行业|Other trade industry", "value": "494" } ]; @@ -2576,12 +2576,24 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter } } }]); - app.controller('subMerchantIdApplicaitonsCtrl', ['$scope', '$http', '$uibModal','$state', function ($scope, $http, $uibModal, $state) { + app.controller('subMerchantIdApplicaitonsCtrl', ['$scope', '$http', '$uibModal','$state','commonDialog', function ($scope, $http, $uibModal, $state,commonDialog) { $scope.loadSubMerchantInfos = function () { $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_sub_applices', {params: {}}).then(function (resp) { $scope.subMerchantInfos = resp.data; }); }; + $scope.useSubMerchantId = function (sub_merchant_id) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', {sub_merchant_id: sub_merchant_id}).then(function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Wechat Sub Merchant ID successfully', + type: 'success' + }); + $state.reload(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + }); + } $scope.applySubMerchantId = function () { $uibModal.open({ templateUrl: '/static/payment/partner/templates/apply_sub_merchant_id.html', @@ -2600,7 +2612,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }; $scope.loadSubMerchantInfos(); }]); - app.controller('applySubMerchantIdCtrl', ['$scope', '$http', '$uibModal','$state','subMerchantInfo', '$filter','merchantIds', function ($scope, $http, $uibModal, $state, subMerchantInfo,$filter,merchantIds) { + app.controller('applySubMerchantIdCtrl', ['$scope', '$http', '$uibModal','$state','subMerchantInfo', '$filter','merchantIds','commonDialog', function ($scope, $http, $uibModal, $state, subMerchantInfo,$filter,merchantIds,commonDialog) { $scope.wxIndustries = angular.copy(wxMerchantIndustries); $scope.subMerchantInfo = angular.copy(subMerchantInfo); $scope.merchantIds = merchantIds.data; @@ -2615,10 +2627,34 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }); return; } - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker+ '/sub_apply', $scope.subMerchantInfo).then(function () { - alert("Success"); + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker+ '/sub_apply', $scope.subMerchantInfo).then(function (resp) { + $scope.apply_sub_merchant_id = resp.data; $scope.$close(); - $state.reload(); + if(subMerchantInfo.sub_merchant_id != null){ + commonDialog.confirm({title:'Confirm',content:'已申请成功,是否确认使用'}).then(function () { + $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', {sub_merchant_id: $scope.apply_sub_merchant_id}).then(function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Wechat Sub Merchant ID successfully', + type: 'success' + }); + $state.reload(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + }); + }) + }else { + $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', {sub_merchant_id: $scope.apply_sub_merchant_id}).then(function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Apply Success And Modify Wechat Sub Merchant ID successfully', + type: 'success' + }); + $state.reload(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + }); + } }, function (resp) { $scope.errmsg = resp.data.message; }) @@ -2640,7 +2676,17 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter return bdUsers; } }); - + app.filter('wxMerchants', function () { + return function (values) { + var industry = ''; + angular.forEach(wxMerchantIndustries, function (wxMerchant) { + if (wxMerchant.value == values) { + industry = wxMerchant.label; + } + }); + return industry; + } + }); app.filter('bdOrgSelect', function () { return function (bdUsers, params) { var org_id; @@ -2700,5 +2746,24 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter } } }); + + app.filter('cut', function () { + return function (value, wordwise, max, tail) { + if (!value) return ''; + + max = parseInt(max, 10); + if (!max) return value; + if (value.length <= max) return value; + + value = value.substr(0, max); + if (wordwise) { + var lastspace = value.lastIndexOf(' '); + if (lastspace != -1) { + value = value.substr(0, lastspace); + } + } + return value + (tail || ' …'); + }; + }); return app; }); \ No newline at end of file diff --git a/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html b/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html index 66183d6cc..4db9ba2a4 100644 --- a/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html +++ b/src/main/ui/static/payment/partner/templates/apply_sub_merchant_id.html @@ -5,7 +5,6 @@
      Apply Sub Merchant Id
      -
      @@ -76,13 +75,13 @@
      + type="url" name="website" id="website_input" required>

      Required Field

      - +
      @@ -155,7 +154,7 @@
      diff --git a/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html b/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html index 22b23a645..4c02dd91b 100644 --- a/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html +++ b/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html @@ -1,9 +1,39 @@ +
      +

      + Sub Merchant Id : {{partner.sub_merchant_id}} + +

      +
      +