临时提交
This commit is contained in:
parent
2f03f23288
commit
b65b3c9528
|
@ -32,12 +32,6 @@ public class ServiceUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static void assertion(boolean flag, ServiceCode code) {
|
||||
if (flag) {
|
||||
throw new ServiceException(code.getMsg(), code.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertion(ValidateResult result) {
|
||||
if (result.isError()) {
|
||||
throw new ServiceException(result.getMsg(), result.getCode());
|
||||
|
|
|
@ -68,4 +68,9 @@ public interface DeviceValidator {
|
|||
* @param userId 用户ID
|
||||
*/
|
||||
boolean isAgent(DeviceVO device, Long userId);
|
||||
|
||||
/**
|
||||
* 判断判断设备是否有正在使用中的订单
|
||||
*/
|
||||
boolean hasUsingBill(Long deviceId);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.ruoyi.common.enums.UserType;
|
|||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.*;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.iot.domain.IotDeviceInfo;
|
||||
import com.ruoyi.iot.domain.response.CommandResponse;
|
||||
import com.ruoyi.iot.enums.IotHttpStatus;
|
||||
|
@ -1393,7 +1394,8 @@ public class DeviceServiceImpl implements DeviceService
|
|||
public int unbind(Long deviceId) {
|
||||
DeviceVO device = deviceMapper.selectSmDeviceByDeviceId(deviceId);
|
||||
ServiceUtil.assertion(device == null || device.getDeleted(), "设备不存在");
|
||||
ServiceUtil.assertion(DeviceStatus.USING.getStatus().equals(device.getStatus()), "设备正在使用中,无法解除绑定");
|
||||
// 判断是否有正在使用中的订单
|
||||
ServiceUtil.assertion(deviceValidator.hasUsingBill(device.getDeviceId()), "当前设备有正在使用中的订单,请关闭后重试");
|
||||
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
int updateCount = deviceMapper.unbindStore(deviceId);
|
||||
|
|
|
@ -15,6 +15,9 @@ import com.ruoyi.ss.device.service.DeviceValidator;
|
|||
import com.ruoyi.ss.model.domain.enums.ModelTag;
|
||||
import com.ruoyi.ss.store.service.StoreValidator;
|
||||
import com.ruoyi.ss.suit.service.SuitValidator;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillType;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -37,6 +40,9 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato
|
|||
@Autowired
|
||||
private SuitValidator suitValidator;
|
||||
|
||||
@Autowired
|
||||
private TransactionBillService transactionBillService;
|
||||
|
||||
/**
|
||||
* 设备编号是否存在
|
||||
*
|
||||
|
@ -204,4 +210,17 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato
|
|||
}
|
||||
return Objects.equals(device.getAgentId(), userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasUsingBill(Long deviceId) {
|
||||
if (deviceId == null) {
|
||||
return false;
|
||||
}
|
||||
TransactionBillQuery query = new TransactionBillQuery();
|
||||
query.setDeviceId(deviceId);
|
||||
query.setType(TransactionBillType.RECHARGE.getType());
|
||||
query.setIsUsing(true);
|
||||
int count = transactionBillService.selectSimpleCount(query);
|
||||
return count > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1341,9 +1341,9 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
// 尝试设备清零时长、电量
|
||||
if (withDevice) {
|
||||
if (SuitFeeType.COUNT.getType().equals(order.getSuitFeeType())) {
|
||||
deviceService.resetEle(device, true);
|
||||
deviceService.resetEle(device, false);
|
||||
} else if(SuitFeeType.TIME.getType().equals(order.getSuitFeeType())){
|
||||
deviceService.resetTime(device, true);
|
||||
deviceService.resetTime(device, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user