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