|
@@ -2,10 +2,17 @@ package com.xy.controller;
|
|
|
|
|
|
import com.xy.annotate.RestMappingController;
|
|
|
import com.xy.dto.DeviceInfoDto;
|
|
|
+import com.xy.dto.MercMiniDeviceDto;
|
|
|
+import com.xy.dto.be.MercDto;
|
|
|
+import com.xy.entity.DeviceInfo;
|
|
|
+import com.xy.enums.MercStatus;
|
|
|
import com.xy.service.DeviceInfoService;
|
|
|
+import com.xy.service.DeviceInfoServiceImpl;
|
|
|
+import com.xy.service.be.MercFeignService;
|
|
|
import com.xy.utils.MercAuthUtils;
|
|
|
import com.xy.utils.PageBean;
|
|
|
import com.xy.utils.R;
|
|
|
+import com.xy.utils.enums.DictSonEnum;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -13,10 +20,11 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- *小程序-设备
|
|
|
+ * 小程序-设备
|
|
|
* </p>
|
|
|
*
|
|
|
* @author hechunping
|
|
@@ -29,6 +37,10 @@ public class MercMiniDeviceController {
|
|
|
|
|
|
private final DeviceInfoService deviceInfoService;
|
|
|
|
|
|
+ private final MercFeignService mercFeignService;
|
|
|
+
|
|
|
+ private final DeviceInfoServiceImpl deviceInfoServiceImpl;
|
|
|
+
|
|
|
@ApiOperation("商户设备首页统计")
|
|
|
@PostMapping("mercHomeStatistical")
|
|
|
public R<DeviceInfoDto.MercHomeStatisticalVO> mercHomeStatistical(@RequestBody @Valid DeviceInfoDto.MercHomeQueryDTO dto) {
|
|
@@ -56,4 +68,33 @@ public class MercMiniDeviceController {
|
|
|
dto.setMercId(MercAuthUtils.getMercId());
|
|
|
return deviceInfoService.dataCount(dto);
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("active")
|
|
|
+ @ApiOperation("激活设备")
|
|
|
+ public R active(@RequestBody MercMiniDeviceDto.Active active) {
|
|
|
+ Long mercId = MercAuthUtils.getMercId();
|
|
|
+ //商户是否已通过审核
|
|
|
+ MercDto.Vo mercInfo = mercFeignService.obj(new MercDto.ListDTO().setId(mercId)).getData();
|
|
|
+ if (!mercInfo.getStatus().equals(MercStatus.APPROVED)) {
|
|
|
+ return R.fail("商户未通过审核");
|
|
|
+ }
|
|
|
+ //机器是否已授权给该商户
|
|
|
+ DeviceInfoDto.Vo deviceInfo = deviceInfoService.obj(new DeviceInfoDto.Obj().setDeviceId(active.getDeviceId())).getData();
|
|
|
+ if (!deviceInfo.getMercId().equals(mercId)) {
|
|
|
+ return R.fail("机器未授权给商户");
|
|
|
+ }
|
|
|
+ //机器是否冻结
|
|
|
+ if (deviceInfo.getFreezeStatus().equals(Integer.valueOf(DictSonEnum.DEVICE_FREEZE_STATUS_2.getKey()))) {
|
|
|
+ return R.fail("机器已冻结");
|
|
|
+ }
|
|
|
+ //激活设备
|
|
|
+ DeviceInfo updateDeviceInfo = new DeviceInfo()
|
|
|
+ .setDeviceId(active.getDeviceId())
|
|
|
+ .setActiveState(Integer.valueOf(DictSonEnum.DEVICE_ACTIVE_STATUS_1.getKey()))
|
|
|
+ .setBusyState(Integer.valueOf(DictSonEnum.DEVICE_BUSY_STATUS_1.getKey()))
|
|
|
+ .setActiveTime(LocalDateTime.now())
|
|
|
+ .setShowStatus(true);
|
|
|
+ deviceInfoServiceImpl.updateById(updateDeviceInfo);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
}
|