|
@@ -12,9 +12,11 @@ import com.xy.device.EnumAlgorithmPayConfig;
|
|
|
import com.xy.device.EnumDeviceAlgorithmChargingHistoryStatus;
|
|
|
import com.xy.device.EnumDeviceAlgorithmChargingType;
|
|
|
import com.xy.dto.DeviceAlgorithmChargingDto;
|
|
|
+import com.xy.dto.DeviceInfoDto;
|
|
|
import com.xy.entity.DeviceAlgorithmCharging;
|
|
|
import com.xy.entity.DeviceAlgorithmChargingHistory;
|
|
|
import com.xy.entity.SysDictRedis;
|
|
|
+import com.xy.error.CommRuntimeException;
|
|
|
import com.xy.mapper.DeviceAlgorithmChargingMapper;
|
|
|
import com.xy.utils.DataTime;
|
|
|
import com.xy.utils.Emptys;
|
|
@@ -24,6 +26,9 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
@@ -47,6 +52,30 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
|
|
|
private DeviceAlgorithmChargingHistoryServiceImpl deviceAlgorithmChargingHistoryService;
|
|
|
|
|
|
+ private DeviceInfoService deviceInfoService;
|
|
|
+
|
|
|
+ @PostMapping("check")
|
|
|
+ @ApiOperation("检查")
|
|
|
+ public R check(@RequestBody @Validated DeviceAlgorithmChargingDto.Check check) {
|
|
|
+ DeviceInfoDto.Vo deviceInfo = deviceInfoService.obj(new DeviceInfoDto.Obj().setDeviceId(check.getDeviceId())).getData();
|
|
|
+ List<DeviceAlgorithmCharging> deviceAlgorithmChargings = list(new LambdaQueryWrapper<DeviceAlgorithmCharging>()
|
|
|
+ .eq(DeviceAlgorithmCharging::getDeviceId, deviceInfo.getDeviceId())
|
|
|
+ .eq(DeviceAlgorithmCharging::getAlgorithmId, deviceInfo.getAlgorithmId())
|
|
|
+ .in(DeviceAlgorithmCharging::getTimeout, Arrays.asList(DataTime.getSring("yyyyMM"), -1))
|
|
|
+ );
|
|
|
+ if (!Emptys.check(deviceAlgorithmChargings)) {
|
|
|
+ throw new CommRuntimeException("设备欠费,请充值");
|
|
|
+ }
|
|
|
+ int size = 0;
|
|
|
+ for (DeviceAlgorithmCharging deviceAlgorithmCharging : deviceAlgorithmChargings) {
|
|
|
+ size += deviceAlgorithmCharging.getUnusedSize();
|
|
|
+ }
|
|
|
+ if (size == 0) {
|
|
|
+ throw new CommRuntimeException("设备欠费,请充值");
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@ApiOperation("购买")
|
|
|
public R pay(DeviceAlgorithmChargingDto.Pay pay) {
|