新增添加pos设备

master
taylor.dang 6 years ago
parent e25bbbbc53
commit a658c1958f

@ -53,11 +53,6 @@
<artifactId>jpinyin</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>com.globalfreepay.payment</groupId>
<artifactId>payment-core</artifactId>
</dependency>
<dependency>
<groupId>au.com.royalpay.payment</groupId>
<artifactId>bestpay-core</artifactId>

@ -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<JSONObject> listClientDevices(JSONObject params, PageBounds pagination);

@ -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

@ -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})

@ -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);

@ -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;

@ -4,52 +4,53 @@
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<form novalidate name="accountForm">
<form novalidate name="deviceForm">
<div class="form-group"
ng-class="{'has-error':accountForm.client_dev_id.$invalid && accountForm.client_dev_id.$dirty}">
ng-class="{'has-error':deviceForm.client_dev_id.$invalid && deviceForm.client_dev_id.$dirty}">
<label class="control-label" for="client_dev_id-input">* 设备编号</label>
<input required class="form-control text-lowercase" id="client_dev_id-input" name="client_dev_id"
ng-model="device.client_dev_id" maxlength="50">
<div ng-messages="accountForm.client_dev_id.$error" ng-if="accountForm.client_dev_id.$dirty">
<div ng-messages="deviceForm.client_dev_id.$error" ng-if="deviceForm.client_dev_id.$dirty">
<p class="small text-danger" ng-message="required">client_dev_id field is required</p>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':accountForm.auth_code.$invalid && accountForm.auth_code.$dirty}">
ng-class="{'has-error':deviceForm.auth_code.$invalid && deviceForm.auth_code.$dirty}">
<label class="control-label" for="auth_code-input">* 设备密钥</label>
<input required class="form-control" id="auth_code-input" name="auth_code"
ng-model="device.auth_code" maxlength="50">
<div ng-messages="accountForm.auth_code.$error" ng-if="accountForm.auth_code.$dirty">
<div ng-messages="deviceForm.auth_code.$error" ng-if="deviceForm.auth_code.$dirty">
<p class="small text-danger" ng-message="required">设备密钥 field is required</p>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':accountForm.client_type.$invalid && accountForm.client_type.$dirty}">
<label class="control-label" for="client_type-input">* 设备类型</label>
<input required class="form-control" id="client_type-input" name="client_type"
ng-model="device.client_type">
<div ng-messages="accountForm.auth_code.$error" ng-if="accountForm.auth_code.$dirty">
<p class="small text-danger" ng-message="required">设备类型 field is required</p>
</div>
<div class="form-group">
<label class="control-label" for="client_type-input">设备类型</label>
<input class="form-control" id="client_type-input" name="client_type"
ng-model="device.client_type" value="inspiry" readonly>
</div>
<div class="form-group"
ng-class="{'has-error':accountForm.version.$invalid && accountForm.version.$dirty}">
ng-class="{'has-error':deviceForm.version.$invalid && deviceForm.version.$dirty}">
<label class="control-label" for="version-input">* version</label>
<input required class="form-control" id="version-input" name="version"
ng-model="device.version">
<div ng-messages="accountForm.auth_code.$error" ng-if="accountForm.auth_code.$dirty">
<div ng-messages="deviceForm.version.$error" ng-if="deviceForm.version.$dirty">
<p class="small text-danger" ng-message="required">version field is required</p>
</div>
</div>
</form>
<div class="form-group">
<label class="control-label" for="remark-input">Remark</label>
<input class="form-control" id="remark-input" name="version"
ng-model="device.remark">
</div>
</div>
</form>
</div>
</div>
</div>
<div class="modal-footer">
<div class="btn-group">
<button class="btn btn-success" type="button" ng-click="save(accountForm)">Submit</button>
<button class="btn btn-success" type="button" ng-click="save(deviceForm)">Submit</button>
</div>
<div class="btn-group">
<button class="btn btn-danger" type="button" ng-click="$dismiss()">Cancel</button>

@ -8,7 +8,7 @@
<button class="btn btn-success" ng-click="listDevices()">
<i class="fa fa-search"></i>
</button>
<button class="btn btn-primary" ng-click="addDevices()">
<button class="btn btn-primary" ng-click="addDevice()">
<i class="fa fa-plus"></i> addDevice
</button>
</div>

Loading…
Cancel
Save