From a658c1958fb1bfbbffa1160a3d9ea3990a3f42a4 Mon Sep 17 00:00:00 2001 From: "taylor.dang" Date: Wed, 27 Mar 2019 21:09:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B7=BB=E5=8A=A0pos?= =?UTF-8?q?=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 --- .../mappers/system/ClientDeviceMapper.java | 3 +- .../core/impls/ClientManagerImpl.java | 39 ++++++++++--------- .../web/PartnerManageController.java | 6 +-- .../merchants/web/PartnerViewController.java | 2 +- .../static/payment/partner/partner-manage.js | 7 ++-- .../payment/partner/templates/add_device.html | 37 +++++++++--------- .../partner/templates/partner_devices.html | 2 +- 8 files changed, 49 insertions(+), 52 deletions(-) diff --git a/pom.xml b/pom.xml index 5b0475543..d83acbcda 100644 --- a/pom.xml +++ b/pom.xml @@ -53,11 +53,6 @@ jpinyin 1.1.7 - - com.globalfreepay.payment - payment-core - - au.com.royalpay.payment bestpay-core diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.java index 80f9f8225..cc87aaed2 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.java @@ -31,7 +31,8 @@ public interface ClientDeviceMapper { JSONObject findByClientDevIdAndClientType(@Param("client_dev_id") String clientDevId, @Param("client_type") String clientType); @AutoSql(type = SqlType.SELECT) - JSONObject findByClientDevId(@Param("client_dev_id") String clientDevId); + @AdvanceSelect(addonWhereClause = "is_valid=1") + JSONObject findDeviceInfoByDeviceNo(@Param("client_dev_id") String clientDevId,@Param("dev_type") String devType); PageList listClientDevices(JSONObject params, PageBounds pagination); 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 187ff26dd..aa8b9751c 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 @@ -67,6 +67,7 @@ import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.exceptions.event.WechatExceptionEvent; +import au.com.royalpay.payment.tools.inspiry.core.InspiryPOSFinder; import au.com.royalpay.payment.tools.locale.LocaleSupport; import au.com.royalpay.payment.tools.lock.Locker; import au.com.royalpay.payment.tools.mail.SendMail; @@ -2073,27 +2074,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } @Override - public void addDevice(JSONObject manager, String clientMoniker,JSONObject device) { + @Transactional + public void addDevice(JSONObject manager, String clientMoniker, JSONObject newDevice) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new InvalidShortIdException(); } checkOrgPermission(manager, client); - - String clientDevId = device.getString("client_dev_id"); - JSONObject dev = clientDeviceMapper.findByClientDevId(clientDevId); - if(dev == null){ - throw new NotFoundException("设备不存在"); - } - if (dev.getIntValue("client_id") != client.getIntValue("client_id")) { - if(dev.getIntValue("is_valid") == 1){ - throw new BadRequestException("其他商户正在使用"); - } + String clientDevId = newDevice.getString("client_dev_id"); + JSONObject dev = clientDeviceMapper.findDeviceInfoByDeviceNo(clientDevId, InspiryPOSFinder.INSPIRY_DEVICE_TYPE); + if (dev != null) { + throw new ServerErrorException(clientDevId + "当前设备已被使用"); } - device.put("dev_id",dev.getString("dev_id")); - device.put("client_id",client.getIntValue("client_id")); - device.put("remark",dev.getString("remark")); - clientDeviceMapper.update(device); + newDevice.put("client_id", client.getString("client_id")); + newDevice.put("create_time", new Date()); + clientDeviceMapper.save(newDevice); } @Override @@ -2118,12 +2113,18 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new InvalidShortIdException(); } checkOrgPermission(manager, client); - JSONObject dev = clientDeviceMapper.find(devId); - if (dev.getIntValue("client_id") != client.getIntValue("client_id")) { + JSONObject deviceInfo = clientDeviceMapper.find(devId); + if (deviceInfo.getIntValue("client_id") != client.getIntValue("client_id")) { throw new NotFoundException("设备不存在"); } - dev.put("is_valid", enable); - clientDeviceMapper.update(dev); + if (StringUtils.equals(InspiryPOSFinder.INSPIRY_DEVICE_TYPE, deviceInfo.getString("dev_type"))) { + JSONObject inspiryDevice = clientDeviceMapper.findDeviceInfoByDeviceNo(deviceInfo.getString("client_dev_id"), InspiryPOSFinder.INSPIRY_DEVICE_TYPE); + if (inspiryDevice != null) { + throw new ServerErrorException("当前设备已被使用"); + } + } + deviceInfo.put("is_valid", enable); + clientDeviceMapper.update(deviceInfo); } @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 97487d462..5da10fe4e 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 @@ -456,10 +456,10 @@ public class PartnerManageController { } //给商户新增设备 - @ManagerMapping(value = "/{clientMoniker}/addDevices", method = RequestMethod.POST, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.BD_USER}) + @ManagerMapping(value = "/{clientMoniker}/add_device", method = RequestMethod.POST, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.BD_USER}) public void addDevice(@PathVariable String clientMoniker, @RequestBody JSONObject device, - @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { - clientManager.addDevice(manager, clientMoniker,device); + @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.addDevice(manager, clientMoniker, device); } @ManagerMapping(value = "/{clientMoniker}/devices/{devId}", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.BD_USER}) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java index 0b3af823a..3c232773b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java @@ -201,7 +201,7 @@ public class PartnerViewController { @PartnerMapping(value = "/accounts/{accountId}", method = RequestMethod.DELETE, roles = PartnerRole.ADMIN) @ResponseBody public void disableAccount(@PathVariable String accountId, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) { - if (accountId == account.getString("account_id")) { + if (accountId.equals(account.getString("account_id"))) { throw new BadRequestException("You cannot disable yourself"); } clientManager.disableAccount(null, account.getString("client_moniker"), accountId); diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 99d039abb..a00546187 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -2838,7 +2838,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter /** * 添加设备 */ - $scope.addDevices = function () { + $scope.addDevice = function () { $uibModal.open({ templateUrl: '/static/payment/partner/templates/add_device.html', controller: 'newDeviceDialogCtrl', @@ -2848,7 +2848,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter } } }).result.then(function () { - $scope.listDevices(); + $scope.listDevices(1); }) }; @@ -3002,8 +3002,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }); return; } - - $http.post('/sys/partners/' + clientMoniker + '/addDevices', $scope.device).then(function () { + $http.post('/sys/partners/' + clientMoniker + '/add_device', $scope.device).then(function () { $scope.$close(); }, function (resp) { $scope.errmsg = resp.data.message; diff --git a/src/main/ui/static/payment/partner/templates/add_device.html b/src/main/ui/static/payment/partner/templates/add_device.html index a86ab0240..bb45fc955 100644 --- a/src/main/ui/static/payment/partner/templates/add_device.html +++ b/src/main/ui/static/payment/partner/templates/add_device.html @@ -4,52 +4,53 @@