diff --git a/src/main/java/au/com/royalpay/payment/manage/support/cms/core/AppStyleService.java b/src/main/java/au/com/royalpay/payment/manage/support/cms/core/AppStyleService.java new file mode 100644 index 000000000..3b83a79f5 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/support/cms/core/AppStyleService.java @@ -0,0 +1,15 @@ +package au.com.royalpay.payment.manage.support.cms.core; + +import com.alibaba.fastjson.JSONObject; + +public interface AppStyleService { + JSONObject listAppStyleGroup(int page, int limit); + + JSONObject getAppStyleByStyleId(String style_id); + + void switchGroupByStyleId(String style_id); + + void addAppStyle(String style_id, JSONObject appStyleGroup); + + void updateAppStyleByStyleId(String style_id, String originStyleId, JSONObject appStyleGroup); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/support/cms/core/Impl/AppStyleServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/support/cms/core/Impl/AppStyleServiceImpl.java new file mode 100644 index 000000000..dee97a580 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/support/cms/core/Impl/AppStyleServiceImpl.java @@ -0,0 +1,101 @@ +package au.com.royalpay.payment.manage.support.cms.core.Impl; + +import au.com.royalpay.payment.manage.support.cms.core.AppStyleService; +import au.com.royalpay.payment.tools.exceptions.ServerErrorException; +import cn.yixblog.platform.http.HttpRequestGenerator; +import cn.yixblog.platform.http.HttpRequestResult; +import com.alibaba.fastjson.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.io.IOException; +import java.net.URISyntaxException; + +@Service +public class AppStyleServiceImpl implements AppStyleService { + + @Value("${app.cms.host}") + private String cmsHost; + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Override + public JSONObject listAppStyleGroup(int page, int limit) { + String url = concatUrl("/app/style_group"); + HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.GET).addQueryString("page", page + "").addQueryString("limit", limit + ""); + try { + HttpRequestResult res = gen.execute(); + if (res.isSuccess()) { + return res.getResponseContentJSONObj(); + } + } catch (URISyntaxException | IOException e) { + logger.error(e.getMessage(), e); + } + throw new ServerErrorException("Failed to request CMS"); + } + + @Override + public JSONObject getAppStyleByStyleId(String style_id) { + String url = concatUrl("/app/style_group/" + style_id); + HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.GET); + try { + HttpRequestResult res = gen.execute(); + if (res.isSuccess()) { + return res.getResponseContentJSONObj(); + } + } catch (URISyntaxException | IOException e) { + logger.error(e.getMessage(), e); + } + throw new ServerErrorException("Failed to request CMS"); + } + + @Override + public void switchGroupByStyleId(String style_id) { + String url = concatUrl("/app/style_group/" + style_id); + try { + HttpRequestResult res = new HttpRequestGenerator(url, RequestMethod.PUT).execute(); + if (res.isSuccess()) { + return; + } + } catch (URISyntaxException e) { + logger.error(e.getMessage(), e); + } + throw new ServerErrorException("Failed to request CMS"); + } + + @Override + public void addAppStyle(String style_id, JSONObject appStyleGroup) { + String url = concatUrl("/app/style_group"); + try { + HttpRequestResult gen = new HttpRequestGenerator(url, RequestMethod.POST).addQueryString("style_id", style_id).setJSONEntity(appStyleGroup).execute(); + if (gen.isSuccess()) { + return; + } + } catch (URISyntaxException e) { + logger.error(e.getMessage(), e); + } + throw new ServerErrorException("Failed to request CMS"); + } + + @Override + public void updateAppStyleByStyleId(String style_id, String originStyleId, JSONObject appStyleGroup) { + String url = concatUrl("/app/style_group/" + style_id + "/style"); + try { + HttpRequestResult gen = new HttpRequestGenerator(url, RequestMethod.PUT).addQueryString("originStyleId", originStyleId).setJSONEntity(appStyleGroup).execute(); + if (gen.isSuccess()) { + return; + } + } catch (URISyntaxException e) { + logger.error(e.getMessage(), e); + } + throw new ServerErrorException("Failed to request CMS"); + } + + private String concatUrl(String uri) { + String host = cmsHost.endsWith("/") ? cmsHost.substring(0, cmsHost.length() - 1) : cmsHost; + uri = uri.startsWith("/") ? uri.substring(1) : uri; + return host + "/" + uri; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/support/cms/web/AppStyleController.java b/src/main/java/au/com/royalpay/payment/manage/support/cms/web/AppStyleController.java new file mode 100644 index 000000000..2ea0a87e0 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/support/cms/web/AppStyleController.java @@ -0,0 +1,42 @@ +package au.com.royalpay.payment.manage.support.cms.web; + + +import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.manage.support.cms.core.AppStyleService; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import com.alibaba.fastjson.JSONObject; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +@RestController +@ManagerMapping(value = "/app/cms/app_style", role = {ManagerRole.SITE_MANAGER}) +public class AppStyleController { + @Resource + private AppStyleService appStyleService; + + @RequestMapping(value = "/style_group", method = RequestMethod.GET) + public JSONObject listAppStyleGroup(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) { + return appStyleService.listAppStyleGroup(page, limit); + } + + @RequestMapping(value = "/style_group/{style_id}", method = RequestMethod.GET) + public JSONObject getAppStyleByStyleId(@PathVariable String style_id) { + return appStyleService.getAppStyleByStyleId(style_id); + } + + @RequestMapping(value = "/style_group/{style_id}", method = RequestMethod.PUT) + public void switchGroupByStyleId(@PathVariable String style_id) { + appStyleService.switchGroupByStyleId(style_id); + } + + @RequestMapping(value = "/style_group", method = RequestMethod.POST) + public void addOneGroupAppStyle(@RequestParam String style_id, @RequestBody JSONObject appStyleGroup) { + appStyleService.addAppStyle(style_id, appStyleGroup); + } + + @RequestMapping(value = "/style_group/{style_id}/style", method = RequestMethod.PUT) + public void updateAppStyleByStyleId(@PathVariable String style_id,@RequestParam String originStyleId, @RequestBody JSONObject appStyleGroup) { + appStyleService.updateAppStyleByStyleId(style_id, originStyleId, appStyleGroup); + } +} diff --git a/src/main/ui/static/cms/cms.js b/src/main/ui/static/cms/cms.js index 3ab730034..156cda39b 100644 --- a/src/main/ui/static/cms/cms.js +++ b/src/main/ui/static/cms/cms.js @@ -4,6 +4,67 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angular) { 'use strict'; var app = angular.module('cms', ['ui.router','ng.uditor']); + var style = [ + { + "style_key":"settlement", + "style_value":"" + }, + { + "style_key":"home_select", + "style_value":"" + }, + { + "style_key":"activity_gray", + "style_value":"" + }, + { + "style_key":"activity_select", + "style_value":"" + }, + { + "style_key":"mess_gray", + "style_value":"" + }, + { + "style_key":"mess_select", + "style_value":"" + }, + { + "style_key":"my_select", + "style_value":"" + }, + { + "style_key":"transaction", + "style_value":"" + }, + { + "style_key":"statistics", + "style_value":"" + }, + { + "style_key":"marketing_account", + "style_value":"" + }, + { + "style_key":"usergroup", + "style_value":"" + }, + { + "style_key":"coupon", + "style_value":"" + }, + { + "style_key":"rpbill", + "style_value":"" + }, + { + "style_key":"invoice_assistant", + "style_value":"" + }, + { + "style_key":"home_gray", + "style_value":"" + }]; app.config(['$stateProvider', function ($stateProvider) { $stateProvider.state('cms', { url: '/cms', @@ -38,7 +99,41 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu }).state('cms.phone_top_up', { url: '/phone_top_up', controller: 'CmsPhonetopupCtrl', - templateUrl: '/static/cms/templates/phone_top_up.html' + templateUrl: '/static/cms/templates/phone_top_up.html', + }).state('cms.app_style',{ + url: '/app_style', + controller: 'cmsAppStyleListCtrl', + templateUrl: '/static/cms/templates/app_style.html', + }).state('cms.app_style.app_style_preview',{ + url: '/{style_id}/preview', + controller: 'cmsAppStylePreviewCtrl', + templateUrl: '/static/cms/templates/app_style_preview.html', + resolve: { + appStyles: ['$http', '$stateParams', function ($http, $stateParams) { + return $http.get('/app/cms/app_style/style_group/' + $stateParams.style_id); + }] + } + }).state('cms.app_style.app_style_save',{ + url: '/save', + controller: 'cmsAppStyleSaveCtrl', + templateUrl: '/static/cms/templates/app_style_config.html', + resolve: { + style: function () { + return angular.copy(style); + } + } + }).state('cms.app_style.app_style_edit',{ + url: '/{style_id}/edit', + controller: 'cmsAppStyleEditCtrl', + templateUrl: '/static/cms/templates/app_style_config.html', + resolve: { + appStyles: ['$http', '$stateParams', function ($http, $stateParams) { + return $http.get('/app/cms/app_style/style_group/' + $stateParams.style_id); + }], + style: function () { + return angular.copy(style); + } + } }) }]); app.controller('cmsRootCtrl', ['$scope', function ($scope) { @@ -140,6 +235,142 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu $scope.article = article.data; }]); + app.controller('cmsAppStyleListCtrl', ['$scope', '$http', '$uibModal', function ($scope, $http, $uibModal) { + $scope.pagination = {}; + $scope.appStyleGroupList = function (page) { + var params = $scope.queryParams || {}; + params.page = page || $scope.pagination.page || 1; + $http.get('/app/cms/app_style/style_group', {params: params}).then(function (resp) { + $scope.appStyleGroups = resp.data.data; + $scope.pagination = resp.data.pagination; + }) + }; + $scope.appStyleGroupList(1); + }]); + + app.controller('cmsAppStylePreviewCtrl', ['$scope', '$http', 'appStyles', function ($scope, $http, appStyles) { + $scope.appStyles = appStyles.data.data; + }]); + + app.controller('cmsAppStyleEditCtrl', ['$scope', '$http', '$state','commonDialog', 'appStyles', 'style', function ($scope, $http, $state, commonDialog, appStyles, style) { + $scope.ctrl = {sending: false, flag: false, originStyleId: angular.copy(appStyles.data.data[0].style_id)}; + $scope.entity={}; + $scope.style = angular.copy(style); + $scope.entity.appStyle = angular.copy(appStyles.data.data); + $scope.params = {style_id: angular.copy(appStyles.data.data[0].style_id)}; + $scope.appStyleList = function() { + var styleKeyStr = ""; + $scope.entity.appStyle.forEach(function(item){ + styleKeyStr += item.style_key + ","; + }); + $scope.style.forEach(function(item){ + if (styleKeyStr.indexOf(item.style_key) < 0) { + $scope.entity.appStyle.push({"style_key": item.style_key,"style_value":""}); + } + }) + }; + $scope.appStyleList(); + $scope.addSpecOption = function() { + $scope.entity.appStyle.push({}); + + }; + + // 删除规格选项 + $scope.delSpecOption = function(index) { + $scope.entity.appStyle.splice(index, 1); + + }; + + $scope.saveOneGroupAppStyle = function() { + if ($scope.params.style_id == "" || $scope.params.style_id == null) { + $scope.errmsg = "title不能为空"; + return; + } + var item = ""; + for (var i=0;i<$scope.entity.appStyle.length;i++) { + item = $scope.entity.appStyle[i]; + if (item.style_value == "" || item.style_value == null) { + $scope.errmsg = "value不能为空"; + return; + } + if (item.style_value.substr(0,4).toLowerCase() != "http" && + item.style_value.substr(0,5).toLowerCase() != "https") { + $scope.errmsg = "value必须以http或者https开头"; + return; + } + + } + $scope.ctrl.sending = true; + $http.put('/app/cms/app_style/style_group/' + $scope.params.style_id + '/style?originStyleId=' + $scope.ctrl.originStyleId, $scope.entity).then(function(){ + $scope.ctrl.sending = false; + $state.go('cms.app_style.app_style_preview',{style_id: $scope.params.style_id}); + }, function (resp) { + $scope.ctrl.sending = false; + $scope.errmsg = resp.data.message; + }) + } + $scope.toggleAppStyleIsValid = function(styleId) { + if (styleId) { + commonDialog.confirm({ + title: '确认操作', + content: '当前操作将发布title为:' +styleId +"的app图标,是否确认?" + }).then(function () { + $http.put('/app/cms/app_style/style_group/' + styleId).then(function () { + $state.reload(); + }) + }) + } + } + }]); + app.controller('cmsAppStyleSaveCtrl', ['$scope', '$http', '$state', 'style', function ($scope, $http, $state, style) { + $scope.ctrl = {sending: false, flag: true}; + $scope.entity={}; + $scope.entity.appStyle = angular.copy(style); + $scope.params = {style_id: ""}; + $scope.addSpecOption = function() { + $scope.entity.appStyle.push({}); + + }; + + // 删除规格选项 + $scope.delSpecOption = function(index) { + console.log(index) + $scope.entity.appStyle.splice(index, 1); + + }; + + $scope.saveOneGroupAppStyle = function() { + if ($scope.params.style_id == "" || $scope.params.style_id == null) { + $scope.errmsg = "title不能为空"; + return; + } + var item = ""; + for (var i=0;i<$scope.entity.appStyle.length;i++) { + item = $scope.entity.appStyle[i]; + if (item.style_value == "" || item.style_value == null) { + $scope.errmsg = "value不能为空"; + return; + } + if (item.style_value.substr(0,4).toLowerCase() != "http" && + item.style_value.substr(0,5).toLowerCase() != "https") { + $scope.errmsg = "value必须以http或者https开头"; + return; + } + + } + $scope.ctrl.sending = true; + $http.post('/app/cms/app_style/style_group?style_id=' + $scope.params.style_id, $scope.entity).then(function(){ + $scope.ctrl.sending = false; + $state.go('cms.app_style.app_style_preview', {style_id: $scope.params.style_id}); + }, function (resp) { + $scope.ctrl.sending = false; + $scope.errmsg = resp.data.message; + }) + }; + $scope.checkStyleValue = function () { + + } + }]); app.filter('topUpType', function () { return function (status) { switch (status + '') { diff --git a/src/main/ui/static/cms/templates/app_style.html b/src/main/ui/static/cms/templates/app_style.html new file mode 100644 index 000000000..613b0f19d --- /dev/null +++ b/src/main/ui/static/cms/templates/app_style.html @@ -0,0 +1,65 @@ +
+
+

APP_STYLE

+ +
+
+
+ +
+
+
+ + + + + + + + + + + + + + + +
TitlePublishedOperation
+ + + + + + +
+
+ +
+
+
\ No newline at end of file diff --git a/src/main/ui/static/cms/templates/app_style_config.html b/src/main/ui/static/cms/templates/app_style_config.html new file mode 100644 index 000000000..694d761c9 --- /dev/null +++ b/src/main/ui/static/cms/templates/app_style_config.html @@ -0,0 +1,67 @@ +
+
+

APP_STYLE

+ +
+
+
+
+
+
+
+ + +
+ +
+
+ + + + + +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
KeyValue
+ + + +
+
+ +
+
+
\ No newline at end of file diff --git a/src/main/ui/static/cms/templates/app_style_preview.html b/src/main/ui/static/cms/templates/app_style_preview.html new file mode 100644 index 000000000..7ab0f756a --- /dev/null +++ b/src/main/ui/static/cms/templates/app_style_preview.html @@ -0,0 +1,46 @@ +
+
+

APP_STYLE

+ +
+
+ +
+
+ + + + + + + + + + + + + + + +
TitleStyle_KeyStyle_Value
+
+
+
+
\ No newline at end of file diff --git a/src/main/ui/static/cms/templates/cms_root.html b/src/main/ui/static/cms/templates/cms_root.html index 69e7b8911..0040caa6b 100644 --- a/src/main/ui/static/cms/templates/cms_root.html +++ b/src/main/ui/static/cms/templates/cms_root.html @@ -26,6 +26,9 @@
App广告页
+
+ App图标 +
话费充值
diff --git a/src/main/ui/static/payment/partner/templates/partner_new_rate.html b/src/main/ui/static/payment/partner/templates/partner_new_rate.html index c93460d5f..2452a150d 100644 --- a/src/main/ui/static/payment/partner/templates/partner_new_rate.html +++ b/src/main/ui/static/payment/partner/templates/partner_new_rate.html @@ -184,6 +184,30 @@ +
+ +
+
+ +
%
+
+
+
+ No more than 2.2% +
+
+ No less than 0.6% +
+
+ Required Field +
+
+ +
+
+
diff --git a/src/main/ui/static/risk/templates/attention_merchants.html b/src/main/ui/static/risk/templates/attention_merchants.html index b618f4f6b..d3ddfdf66 100644 --- a/src/main/ui/static/risk/templates/attention_merchants.html +++ b/src/main/ui/static/risk/templates/attention_merchants.html @@ -67,7 +67,7 @@ {{client.bank_account_no}} {{client.contact_person}} {{client.contact_phone}} - {{client.last_update_date}} + {{client.creation_date}} {{client.remark}}