diff --git a/src/main/java/au/com/royalpay/payment/manage/cashiers/core/CashierService.java b/src/main/java/au/com/royalpay/payment/manage/cashiers/core/CashierService.java index 4dce3cc07..433fc86c2 100644 --- a/src/main/java/au/com/royalpay/payment/manage/cashiers/core/CashierService.java +++ b/src/main/java/au/com/royalpay/payment/manage/cashiers/core/CashierService.java @@ -15,6 +15,8 @@ public interface CashierService { void updateCashier(JSONObject partner, String cashier_id, CashierBean info); + void changeCashierValidStatus(JSONObject partner, String cashier_id,boolean isValid); + JSONObject getCashierByCashierId(String cashier_id); JSONObject getCashierByCashierId(String cashier_id, JSONObject partner); diff --git a/src/main/java/au/com/royalpay/payment/manage/cashiers/core/impls/CashierServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/cashiers/core/impls/CashierServiceImp.java index c6c18a1da..b7a5862cd 100644 --- a/src/main/java/au/com/royalpay/payment/manage/cashiers/core/impls/CashierServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/cashiers/core/impls/CashierServiceImp.java @@ -11,12 +11,10 @@ import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.QRCodeUtils; - import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; - import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.StringRedisTemplate; @@ -24,12 +22,11 @@ import org.springframework.stereotype.Service; import org.springframework.ui.Model; import org.springframework.util.Assert; +import javax.annotation.Resource; import java.math.BigDecimal; import java.util.Date; import java.util.concurrent.TimeUnit; -import javax.annotation.Resource; - /** * Created by yishuqian on 20/12/2016. */ @@ -77,6 +74,17 @@ public class CashierServiceImp implements CashierService { cashierMapper.update(cashierUpdate); } + @Override + public void changeCashierValidStatus(JSONObject partner, String cashier_id,boolean isValid) { + JSONObject cashier = cashierMapper.findOne(cashier_id); + Assert.notNull(cashier, "cashier not found"); + if (partner.getIntValue("client_id") != cashier.getIntValue("client_id")) { + throw new ForbiddenException("You have no permission!"); + } + cashier.put("is_valid", isValid); + cashierMapper.update(cashier); + } + @Override public JSONObject getCashierByCashierId(String cashier_id) { return cashierMapper.findOne(cashier_id); diff --git a/src/main/java/au/com/royalpay/payment/manage/cashiers/web/CashierManageController.java b/src/main/java/au/com/royalpay/payment/manage/cashiers/web/CashierManageController.java index 161d3e465..ec457eb38 100644 --- a/src/main/java/au/com/royalpay/payment/manage/cashiers/web/CashierManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/cashiers/web/CashierManageController.java @@ -5,10 +5,10 @@ import au.com.royalpay.payment.manage.cashiers.beans.CashierQueryBean; import au.com.royalpay.payment.manage.cashiers.core.CashierOrderService; import au.com.royalpay.payment.manage.cashiers.core.CashierService; import au.com.royalpay.payment.manage.permission.manager.PartnerMapping; -import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.manage.permission.manager.RequirePartner; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.connections.mpsupport.beans.WxOauthType; +import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.permission.wechat.WechatMapping; import com.alibaba.fastjson.JSONObject; import org.springframework.stereotype.Controller; @@ -81,5 +81,19 @@ public class CashierManageController { return cashierOrderService.listCashierOrders(cashier_id, partner, query); } + @PartnerMapping(value = "/{cashier_id}/disable", method = RequestMethod.PUT,roles = {PartnerRole.ADMIN,PartnerRole.MANAGER}) + @ResponseBody + public void deleteVipCustomer(@PathVariable String cashier_id, + @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) { + cashierService.changeCashierValidStatus(partner, cashier_id, false); + } + + @PartnerMapping(value = "/{cashier_id}/enable", method = RequestMethod.PUT,roles = {PartnerRole.ADMIN,PartnerRole.MANAGER}) + @ResponseBody + public void enableVipCustomer(@PathVariable String cashier_id, + @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) { + cashierService.changeCashierValidStatus(partner, cashier_id, true); + } + } diff --git a/src/main/ui/static/payment/cashiers/cashier-manage.js b/src/main/ui/static/payment/cashiers/cashier-manage.js index 5982e122c..828c938d5 100644 --- a/src/main/ui/static/payment/cashiers/cashier-manage.js +++ b/src/main/ui/static/payment/cashiers/cashier-manage.js @@ -35,7 +35,32 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS app.controller('CashiersCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) { $scope.pagination = {}; $scope.params = {}; - + $scope.disableCashier = function (cashier) { + commonDialog.confirm({ + title: 'Disable Cashier', + content: 'Are you sure to disable' + cashier.name + '?' + }).then(function () { + $http.put('/partner/cashiers/' + cashier.cashier_id + '/disable').then(function (resp) { + commonDialog.alert({title: 'Success', content: 'Disable cashier successfully', type: 'success'}); + $scope.loadCashiers(1); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }) + }) + }; + $scope.enableCashier = function (cashier) { + commonDialog.confirm({ + title: 'Enable Cashier', + content: 'Are you sure to enable' + cashier.name + '?' + }).then(function () { + $http.put('/partner/cashiers/' + cashier.cashier_id + '/enable').then(function (resp) { + commonDialog.alert({title: 'Success', content: 'Enable cashier successfully', type: 'success'}); + $scope.loadCashiers(1); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }) + }) + }; $scope.loadCashiers = function (page) { var params = angular.copy($scope.params); params.page = page || $scope.pagination.page || 1; @@ -226,4 +251,4 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS }]); return app; -}); \ No newline at end of file +}); diff --git a/src/main/ui/static/payment/cashiers/templates/cashier_detail.html b/src/main/ui/static/payment/cashiers/templates/cashier_detail.html index 70a84c5d8..5af7f6371 100644 --- a/src/main/ui/static/payment/cashiers/templates/cashier_detail.html +++ b/src/main/ui/static/payment/cashiers/templates/cashier_detail.html @@ -1,5 +1,5 @@
-

+

{{cashier.name}}(Disabled)