From 88021a718c026e7d0b896c1ed78f5f288fe93658 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Tue, 24 Apr 2018 09:29:15 +0800 Subject: [PATCH] add common sub_merchant_id --- .../dev/core/CommonSubMerchantIdService.java | 13 +++ .../impl/CommonSubMerchantIdServiceImpl.java | 41 +++++++++ .../manage/dev/web/TestController.java | 47 ++++++++-- .../payment/CommonSubMerchantIdMapper.java | 26 ++++++ .../payment/CommonSubMerchantIdMapper.xml | 11 +++ .../ui/static/config/devtools/devtools.js | 52 +++++++++++ .../templates/common_sub_merchant_id.html | 88 +++++++++++++++++++ .../templates/new_common_sub_merchant_id.html | 24 +++++ .../config/devtools/templates/root.html | 4 + 9 files changed, 298 insertions(+), 8 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/dev/core/CommonSubMerchantIdService.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/dev/core/impl/CommonSubMerchantIdServiceImpl.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/payment/CommonSubMerchantIdMapper.java create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/payment/CommonSubMerchantIdMapper.xml create mode 100644 src/main/ui/static/config/devtools/templates/common_sub_merchant_id.html create mode 100644 src/main/ui/static/config/devtools/templates/new_common_sub_merchant_id.html diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/core/CommonSubMerchantIdService.java b/src/main/java/au/com/royalpay/payment/manage/dev/core/CommonSubMerchantIdService.java new file mode 100644 index 000000000..ad10d7707 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/dev/core/CommonSubMerchantIdService.java @@ -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); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/CommonSubMerchantIdServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/CommonSubMerchantIdServiceImpl.java new file mode 100644 index 000000000..9a37efaf5 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/CommonSubMerchantIdServiceImpl.java @@ -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); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java index 909d067e0..c82f44858 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java @@ -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.wechat.runtime.WxPayClient; 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.OrderNotExistsException; import au.com.royalpay.payment.manage.analysis.core.PlatformClearService; 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.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.mappers.customers.CustomerEncourageMoneyUseLogMapper; 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.RefundMapper; import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper; 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.tools.CommonConsts; import au.com.royalpay.payment.tools.defines.TradeType; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.http.HttpUtils; 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.TimeZoneUtils; import au.com.royalpay.payment.tools.utils.XmlFormatUtils; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.serializer.SerializerFeature; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; + import org.apache.commons.lang3.time.DateFormatUtils; import org.dom4j.Element; import org.slf4j.Logger; @@ -42,12 +47,14 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.util.Assert; 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.File; import java.io.IOException; @@ -56,6 +63,11 @@ import java.net.URISyntaxException; import java.util.Date; 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. */ @@ -100,7 +112,10 @@ public class TestController implements ApplicationEventPublisherAware { private ApplicationEventPublisher publisher; @Resource 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}) public void exportAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, HttpServletResponse httpResponse) throws Exception { httpResponse.setContentType("application/pdf"); @@ -371,4 +386,20 @@ public class TestController implements ApplicationEventPublisherAware { 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); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/CommonSubMerchantIdMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/CommonSubMerchantIdMapper.java new file mode 100644 index 000000000..fb4e3ce18 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/CommonSubMerchantIdMapper.java @@ -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 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); +} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/CommonSubMerchantIdMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/CommonSubMerchantIdMapper.xml new file mode 100644 index 000000000..5d053be8f --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/CommonSubMerchantIdMapper.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/src/main/ui/static/config/devtools/devtools.js b/src/main/ui/static/config/devtools/devtools.js index d636bc2a7..5d34fa182 100644 --- a/src/main/ui/static/config/devtools/devtools.js +++ b/src/main/ui/static/config/devtools/devtools.js @@ -51,6 +51,10 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { url: '/phone_top_up', templateUrl: '/static/config/devtools/templates/phone_top_up.html', 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) { @@ -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; }); \ No newline at end of file diff --git a/src/main/ui/static/config/devtools/templates/common_sub_merchant_id.html b/src/main/ui/static/config/devtools/templates/common_sub_merchant_id.html new file mode 100644 index 000000000..75bda0f08 --- /dev/null +++ b/src/main/ui/static/config/devtools/templates/common_sub_merchant_id.html @@ -0,0 +1,88 @@ +
+

Sub Merchant ID

+ +
+ +
+
+
+
+
+
+
+
+ + +
+
+ +
+ +
+
+ +
+ + +
+
+

Common Sub Merchant ID List

+
+ +
+ + + + + + + + + + + + + + +
Sub Merchat IDMerchat IDOperation
+ +
+
+ +
+ + +
+ +
+
+
diff --git a/src/main/ui/static/config/devtools/templates/new_common_sub_merchant_id.html b/src/main/ui/static/config/devtools/templates/new_common_sub_merchant_id.html new file mode 100644 index 000000000..3e432fffe --- /dev/null +++ b/src/main/ui/static/config/devtools/templates/new_common_sub_merchant_id.html @@ -0,0 +1,24 @@ +
+

New Common Sub Merchant ID

+
+
+
+
+
+
+
+
+
+ + +
+
+ +
+
+
+
+
+
+
+
diff --git a/src/main/ui/static/config/devtools/templates/root.html b/src/main/ui/static/config/devtools/templates/root.html index 6e18a1a0d..b5f72da42 100644 --- a/src/main/ui/static/config/devtools/templates/root.html +++ b/src/main/ui/static/config/devtools/templates/root.html @@ -67,6 +67,10 @@ Phone Top Up + + + Common Sub Merchant ID +