add cashiers disable、enable

master
luoyang 5 years ago
parent 9b7554900f
commit 04f13e696a

@ -9,7 +9,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId> <artifactId>manage</artifactId>
<version>2.1.6</version> <version>2.1.7</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version> <jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -15,6 +15,8 @@ public interface CashierService {
void updateCashier(JSONObject partner, String cashier_id, CashierBean info); 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 getCashierByCashierId(String cashier_id, JSONObject partner); JSONObject getCashierByCashierId(String cashier_id, JSONObject partner);

@ -4,13 +4,13 @@ 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.CashierOrderService;
import au.com.royalpay.payment.manage.mappers.cashiers.CashierMapper; import au.com.royalpay.payment.manage.mappers.cashiers.CashierMapper;
import au.com.royalpay.payment.manage.mappers.cashiers.CashierOrderMapper; import au.com.royalpay.payment.manage.mappers.cashiers.CashierOrderMapper;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -36,8 +36,10 @@ public class CashierOrderServiceImp implements CashierOrderService {
@Override @Override
public JSONObject listCashierOrders(String cashier_id, JSONObject partner, CashierQueryBean query) { public JSONObject listCashierOrders(String cashier_id, JSONObject partner, CashierQueryBean query) {
JSONObject cashier = cashierMapper.findOne(cashier_id); JSONObject cashier = cashierMapper.findIsValidById(cashier_id);
Assert.notNull(cashier, "cashier not found"); if (cashier == null) {
throw new BadRequestException("Cashier Not Found Or Disabled");
}
String timezone = partner.getJSONObject("client").getString("timezone"); String timezone = partner.getJSONObject("client").getString("timezone");
JSONObject params = query.params(timezone); JSONObject params = query.params(timezone);
params.put("client_id", partner.getIntValue("client_id")); params.put("client_id", partner.getIntValue("client_id"));

@ -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.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
import au.com.royalpay.payment.tools.utils.QRCodeUtils; import au.com.royalpay.payment.tools.utils.QRCodeUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
@ -24,12 +22,11 @@ import org.springframework.stereotype.Service;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
/** /**
* Created by yishuqian on 20/12/2016. * Created by yishuqian on 20/12/2016.
*/ */
@ -77,6 +74,24 @@ public class CashierServiceImp implements CashierService {
cashierMapper.update(cashierUpdate); 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);
if (!isValid) {
cashier.put("wechat_openid", null);
cashier.put("nick_name", null);
cashier.put("headimgurl", null);
cashier.put("phone", null);
cashier.put("photo", null);
}
cashierMapper.update(cashier);
}
@Override @Override
public JSONObject getCashierByCashierId(String cashier_id) { public JSONObject getCashierByCashierId(String cashier_id) {
return cashierMapper.findOne(cashier_id); return cashierMapper.findOne(cashier_id);

@ -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.CashierOrderService;
import au.com.royalpay.payment.manage.cashiers.core.CashierService; import au.com.royalpay.payment.manage.cashiers.core.CashierService;
import au.com.royalpay.payment.manage.permission.manager.PartnerMapping; 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.manage.permission.manager.RequirePartner;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.WxOauthType; 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 au.com.royalpay.payment.tools.permission.wechat.WechatMapping;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -81,5 +81,19 @@ public class CashierManageController {
return cashierOrderService.listCashierOrders(cashier_id, partner, query); 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);
}
} }

@ -1,11 +1,12 @@
package au.com.royalpay.payment.manage.mappers.cashiers; package au.com.royalpay.payment.manage.mappers.cashiers;
import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper;
import com.yixsoft.support.mybatis.autosql.annotations.AutoSql;
import com.yixsoft.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.yixsoft.support.mybatis.autosql.annotations.AdvanceSelect;
import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper;
import com.yixsoft.support.mybatis.autosql.annotations.AutoSql;
import com.yixsoft.support.mybatis.autosql.annotations.SqlType;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -26,6 +27,10 @@ public interface CashierMapper {
@AutoSql(SqlType.SELECT) @AutoSql(SqlType.SELECT)
JSONObject findOne(@Param("cashier_id") String cashier_id); JSONObject findOne(@Param("cashier_id") String cashier_id);
@AutoSql(SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1")
JSONObject findIsValidById(@Param("cashier_id") String cashier_id);
@AutoSql(SqlType.INSERT) @AutoSql(SqlType.INSERT)
void save(JSONObject cashier); void save(JSONObject cashier);

@ -35,7 +35,32 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
app.controller('CashiersCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) { app.controller('CashiersCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) {
$scope.pagination = {}; $scope.pagination = {};
$scope.params = {}; $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) { $scope.loadCashiers = function (page) {
var params = angular.copy($scope.params); var params = angular.copy($scope.params);
params.page = page || $scope.pagination.page || 1; params.page = page || $scope.pagination.page || 1;

@ -1,5 +1,5 @@
<section class="content-header"> <section class="content-header">
<h1><span ng-bind="cashier.name"></span></h1> <h1><span>{{cashier.name}}<span ng-if="!cashier.is_valid" style="color: red">(Disabled)</span></span></h1>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li> <li>
<i class="fa fa-sitemap"></i> Cashiers <i class="fa fa-sitemap"></i> Cashiers

@ -51,24 +51,37 @@
<th>Cashier Code</th> <th>Cashier Code</th>
<th>Wechat</th> <th>Wechat</th>
<th>Create time</th> <th>Create time</th>
<th>Status</th>
<th>Operation</th> <th>Operation</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="cashier in cashiers"> <tr ng-repeat="cashier in cashiers">
<td ng-bind="cashier.name"></td> <td>{{cashier.name}} <span ng-if="!cashier.is_valid" style="color: red">(Disabled)</span></td>
<td ng-bind="cashier.code"></td> <td ng-bind="cashier.code"></td>
<td ng-bind="cashier.nick_name"></td> <td ng-bind="cashier.nick_name"></td>
<td ng-bind="cashier.create_time"></td> <td ng-bind="cashier.create_time"></td>
<td> <td>
<a class="text-primary" style="padding-right: 5px" role="button" title="Edit" <a class="text-primary" ng-if="!cashier.is_valid" role="button" style="padding-right: 5px" title="Detail">
<i class="text-danger fa fa-close"></i>
</a>
<a class="text-primary" ng-if="cashier.is_valid" role="button" style="padding-right: 5px" title="Detail">
<i class="text-success fa fa-check"></i>
</a>
</td>
<td>
<a class="text-primary" ng-if="cashier.is_valid" role="button" style="padding-right: 5px" title="Edit"
ui-sref=".edit({cashier_id:cashier.cashier_id})"> ui-sref=".edit({cashier_id:cashier.cashier_id})">
<i class="fa fa-pencil-square-o"></i> <i class="fa fa-pencil-square-o"></i>
</a> </a>
<a class="text-primary" style="padding-right: 5px" role="button" title="Detail" <span ng-if="cashier.is_valid"> |</span>
<a class="text-primary" ng-if="cashier.is_valid" role="button" style="padding-right: 5px" title="Detail"
ui-sref=".detail({cashier_id:cashier.cashier_id})"> ui-sref=".detail({cashier_id:cashier.cashier_id})">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</a> </a>
<span ng-if="cashier.is_valid"> |</span>
<a class="text-danger text-bold" ng-click="disableCashier(cashier)" ng-if="cashier.is_valid" role="button">Disable</a>
<a class="text-success text-bold" ng-click="enableCashier(cashier)" ng-if="!cashier.is_valid" role="button">Enable</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>

Loading…
Cancel
Save