diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/dashboard/BillCountVo.java b/smart-switch-service/src/main/java/com/ruoyi/ss/dashboard/BillCountVo.java index b2cc4d1c..1dd3b749 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/dashboard/BillCountVo.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/dashboard/BillCountVo.java @@ -33,6 +33,9 @@ public class BillCountVo { @ApiModelProperty("时间(小时)") private Integer createHour; // 时间(小时) + @ApiModelProperty("店铺id") + private Long storeId; + @ApiModelProperty("充值金额(收入)") private BigDecimal recharge; // 充值金额 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDevice.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDevice.java index b9488adb..e7a33bbd 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDevice.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDevice.java @@ -73,11 +73,6 @@ public class SmDevice extends BaseEntity @Past(message = "激活时间必须是过去的某个时间", groups = {ValidGroup.Create.class, ValidGroup.Update.class, ValidGroup.FrontUpdate.class}) private Date activationTime; - /** 剩余电量(度) */ - @Excel(name = "剩余电量", readConverterExp = "度=") - @ApiModelProperty("剩余电量") - private BigDecimal surplusElectriQuantity; - @Excel(name = "总用电量") @ApiModelProperty("总用电量(KWH)") private BigDecimal totalElectriQuantity; @@ -111,22 +106,11 @@ public class SmDevice extends BaseEntity @Min(value = 0, message = "电压不允许小于0", groups = {ValidGroup.Create.class, ValidGroup.Update.class, ValidGroup.FrontUpdate.class}) private BigDecimal voltage; - /** 所属商户ID */ - @Excel(name = "所属商户ID") - @ApiModelProperty("所属商户ID") - @NotNull(message = "商户不允许为空", groups = {ValidGroup.Create.class, ValidGroup.Update.class}) - private Long userId; - /** 用户昵称 */ @Excel(name = "用户昵称") @ApiModelProperty("用户昵称") private String nickName; - @Excel(name = "电费单价(元/度)") - @ApiModelProperty("电费单价(元/度)") - @Min(value = 0, message = "电费单价不允许小于0", groups = {ValidGroup.Create.class, ValidGroup.Update.class, ValidGroup.FrontUpdate.class}) - private BigDecimal price; - @Excel(name = "欠费断电") @ApiModelProperty("断电方式:0欠费不断电,1欠费立即断电") @EnumValid( @@ -154,9 +138,6 @@ public class SmDevice extends BaseEntity @ApiModelProperty("房租到期提醒方式") private String noticeWay; - @ApiModelProperty("是否由用户承担服务费") - private Boolean tenantBearServiceFee; - @ApiModelProperty("上次拉取设备信息的时间") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date lastPullTime; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDeviceCountVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDeviceCountVO.java index 7d7a256e..a9a7cb53 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDeviceCountVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDeviceCountVO.java @@ -1,5 +1,6 @@ package com.ruoyi.ss.device.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** @@ -8,6 +9,12 @@ import lombok.Data; */ @Data public class SmDeviceCountVO { + @ApiModelProperty("店铺id") private Long storeId; + + @ApiModelProperty("商户id") + private Long userId; + + @ApiModelProperty("数量") private Integer count; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDeviceQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDeviceQuery.java index 27237652..bef943ac 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDeviceQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/SmDeviceQuery.java @@ -1,6 +1,8 @@ package com.ruoyi.ss.device.domain; import com.ruoyi.common.valid.EnumValid; +import com.ruoyi.ss.device.domain.enums.DeviceGroupBy; +import com.ruoyi.ss.device.domain.enums.DeviceGroupByTable; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -13,15 +15,6 @@ import java.util.List; @Data public class SmDeviceQuery extends SmDevice { - @ApiModelProperty("租户id") - private Long tenantId; - - @ApiModelProperty("是否默认设备") - private Boolean isDefault; - - @ApiModelProperty("租户名称") - private String tenantName; - @ApiModelProperty("设备id列表") private List deviceIds; @@ -45,12 +38,26 @@ public class SmDeviceQuery extends SmDevice { @ApiModelProperty("分组字段") @EnumValid( - clazz = SmDeviceQuery.class, + clazz = DeviceGroupBy.class, method = "name", message = "非法的分组字段" ) private String groupBy; + @ApiModelProperty("分组表字段") + @EnumValid( + clazz = DeviceGroupByTable.class, + method = "name", + message = "非法的分组表字段" + ) + private String groupByTable; + @ApiModelProperty("设备编号列表") private List deviceNos; + + @ApiModelProperty("所属商户ID") + private Long userId; + + @ApiModelProperty("商户id列表") + private List userIds; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceGroupBy.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceGroupBy.java index 0d0d312b..f02c58c0 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceGroupBy.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceGroupBy.java @@ -6,5 +6,6 @@ package com.ruoyi.ss.device.domain.enums; * 2024/4/30 */ public enum DeviceGroupBy { - store_id, // 店铺id + store_id, // 店铺id + user_id, // 商户id } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceGroupByTable.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceGroupByTable.java new file mode 100644 index 00000000..573dfe3f --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceGroupByTable.java @@ -0,0 +1,12 @@ +package com.ruoyi.ss.device.domain.enums; + +/** + * @author wjh + * 2024/5/7 + */ +public enum DeviceGroupByTable { + + sd, // 设备表 + ss // 店铺表 + +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceOutageWay.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceOutageWay.java index 26abcfd6..fc7a1db1 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceOutageWay.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/enums/DeviceOutageWay.java @@ -14,8 +14,8 @@ import java.util.Objects; @Getter public enum DeviceOutageWay { - NOT_OUTAGE("0", "欠费不断电"), - IMMEDIATE("1", "欠费立即断电"); + NOT_OUTAGE("0", "到时不断电"), + IMMEDIATE("1", "到时立即断电"); private final String value; private final String msg; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/vo/SmDeviceVo.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/vo/SmDeviceVo.java index 3209ba89..c8bc4753 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/vo/SmDeviceVo.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/vo/SmDeviceVo.java @@ -2,7 +2,9 @@ package com.ruoyi.ss.device.domain.vo; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonView; +import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.JsonViewProfile; +import com.ruoyi.common.core.domain.ValidGroup; import com.ruoyi.ss.device.domain.DeviceView; import com.ruoyi.ss.device.domain.SmDevice; import com.ruoyi.ss.suit.domain.SuitVo; @@ -10,6 +12,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.constraints.NotNull; import java.time.LocalTime; import java.util.List; @@ -35,6 +38,7 @@ public class SmDeviceVo extends SmDevice { private String userName; @ApiModelProperty("图片") + @JsonView(JsonViewProfile.App.class) private String picture; @ApiModelProperty("型号标签列表") @@ -53,4 +57,7 @@ public class SmDeviceVo extends SmDevice { @JsonView(JsonViewProfile.App.class) @JsonFormat(pattern = "HH:mm", timezone = "GMT+8") private LocalTime storeBusinessTimeEnd; + + @ApiModelProperty("所属商户ID") + private Long userId; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/SmDeviceMapper.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/SmDeviceMapper.java index 86554f0e..e2049949 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/SmDeviceMapper.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/SmDeviceMapper.java @@ -89,18 +89,17 @@ public interface SmDeviceMapper List selectSimpleList(SmDeviceQuery dto); /** - * 设备绑定商户 + * 设备绑定店铺 * @param deviceId 设备id - * @param userId 商户id + * @param storeId 店铺id */ - int bindLandlord(@Param("deviceId") Long deviceId, @Param("userId") Long userId); + int bindStore(@Param("deviceId") Long deviceId, @Param("storeId") Long storeId); /** * 解绑商户 * @param deviceId 设备id - * @param userId 商户id */ - int unbindLandlord(@Param("deviceId") Long deviceId, @Param("userId") Long userId); + int unbindStore(@Param("deviceId") Long deviceId); /** * 根据MAC查询设备 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/SmDeviceMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/SmDeviceMapper.xml index 7da8cbb4..bd62a8a4 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/SmDeviceMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/SmDeviceMapper.xml @@ -5,9 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - @@ -21,12 +19,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and sd.status = #{status} and sd.user_name like concat('%', #{userName}, '%') and sd.nick_name like concat('%', #{nickName}, '%') - and sd.user_id = #{userId} + and su.user_id = #{userId} and sd.store_id = #{storeId} and sd.device_id = #{deviceId} - and sdt.tenant_id = #{tenantId} - and sdt.is_default = #{isDefault} - and su.nick_name like concat('%', #{tenantName}, '%') and sd.expire_day = #{expireDay} and sd.device_id in @@ -42,10 +37,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - and sd.user_id is not null + and sd.store_id is not null - and sd.user_id is null + and sd.store_id is null @@ -54,73 +49,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item} + + and ss.user_id in + + #{item} + + and sd.deleted = false and sd.deleted = #{deleted} - - - - - + - group by sd.device_id order by sd.create_time desc - - select - sd.*, - sm.model_name model, - sm.tags model_tags, - ss.name store_name, - landlord.user_name user_name - from sm_device sd - left join sm_user landlord on landlord.user_id = sd.user_id - left join sm_model sm on sm.model_id = sd.model_id - left join sm_store ss on ss.store_id = sd.store_id - - @@ -156,6 +124,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item} and sd.deleted = false + group by sd.store_id @@ -165,16 +134,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -189,26 +169,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" model_id, mac, activation_time, - surplus_electri_quantity, total_electri_quantity, online_status, status, real_time_power, electricity, voltage, - user_id, nick_name, create_by, create_time, update_by, update_time, remark, - price, outage_way, wifi, enable_expire_notice, notice_way, - tenant_bear_service_fee, deleted, last_pull_time, expire_day, @@ -222,26 +198,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{modelId}, #{mac}, #{activationTime}, - #{surplusElectriQuantity}, #{totalElectriQuantity}, #{onlineStatus}, #{status}, #{realTimePower}, #{electricity}, #{voltage}, - #{userId}, #{nickName}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark}, - #{price}, #{outageWay}, #{wifi}, #{enableExpireNotice}, #{noticeWay}, - #{tenantBearServiceFee}, #{deleted}, #{lastPullTime}, #{expireDay}, @@ -275,32 +247,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" model_id = #{modelId}, mac = #{mac}, activation_time = #{activationTime}, - surplus_electri_quantity = #{surplusElectriQuantity}, total_electri_quantity = #{totalElectriQuantity}, online_status = #{onlineStatus}, `status` = #{status}, real_time_power = #{realTimePower}, electricity = #{electricity}, voltage = #{voltage}, - user_id = #{userId}, nick_name = #{nickName}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, remark = #{remark}, - price = #{price}, outage_way = #{outageWay}, expire_date = #{expireDate}, wifi = #{wifi}, enable_expire_notice = #{enableExpireNotice}, notice_way = #{noticeWay}, - tenant_bear_service_fee = #{tenantBearServiceFee}, deleted = #{deleted}, last_pull_time = #{lastPullTime}, expire_day = #{expireDay}, init_reading = #{initReading}, power_status = #{powerStatus}, + expire_time = #{expireTime}, where device_id = #{deviceId} @@ -314,16 +283,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update sm_device - set user_id = #{userId} - where device_id = #{deviceId} and user_id is null + set store_id = #{storeId} + where device_id = #{deviceId} and store_id is null - + update sm_device - set user_id = null - where device_id = #{deviceId} and user_id = #{userId} + set user_id = null, + store_id = null + where device_id = #{deviceId} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceAssembler.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceAssembler.java index db3885c0..a6b771c8 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceAssembler.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceAssembler.java @@ -19,12 +19,6 @@ public interface DeviceAssembler { */ void assembleTenant(List list); - /** - * 设置设备分组 - * @param device - */ - void setStore(SmDevice device); - /** * 拼接套餐列表 * @param list diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceAssemblerImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceAssemblerImpl.java index a982e28c..59d71e6b 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceAssemblerImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceAssemblerImpl.java @@ -53,20 +53,6 @@ public class DeviceAssemblerImpl implements DeviceAssembler { } device.setTenantIds(tenants.stream().map(SmDeviceTenant::getTenantId).collect(Collectors.toList())); } - - } - - @Override - public void setStore(SmDevice device) { - // 商户的默认店铺 - if (device.getUserId() != null && device.getStoreId() == null) { - StoreVo defaultStore = smDeviceGroupService.selectDefaultStore(device.getUserId()); - if (defaultStore == null) { -// defaultStore = smDeviceGroupService.insertDefaultStore(device.getUserId()); - ServiceUtil.assertion(defaultStore == null, "该用户没有默认店铺"); - } - device.setStoreId(defaultStore.getStoreId()); - } } /** diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceValidator.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceValidator.java index 933d730c..73dee4ba 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceValidator.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceValidator.java @@ -15,4 +15,10 @@ public interface DeviceValidator { */ boolean isExistNo(List deviceNos); + /** + * 判断设备是否属于指定用户 + * @param deviceId 设备id + * @param userId 用户id + */ + boolean isBelong(Long deviceId, Long userId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/ISmDeviceService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/ISmDeviceService.java index 690f2ca5..eacd84a1 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/ISmDeviceService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/ISmDeviceService.java @@ -79,32 +79,6 @@ public interface ISmDeviceService */ boolean addTime(Long deviceId, BigDecimal num); - /** - * 租户绑定设备 - * @param deviceId 设备id - */ - boolean tenantBind(Long tenantId, Long deviceId); - - /** - * 租户解绑设备 - * @param userId 租户id - * @param deviceId 设备id - */ - boolean tenantUnbind(Long userId, Long deviceId); - - /** - * 获取用户的默认设备 - * @param userId 用户id - */ - public SmDeviceVo selectDefaultDevice(Long userId); - - /** - * 设置用户默认设备 - * @param tenantId 租户id - * @param deviceId 设备id - */ - boolean setDefaultDevice(Long tenantId, Long deviceId); - /** * 逻辑删除 */ @@ -129,30 +103,20 @@ public interface ISmDeviceService */ void pullDeviceInfo(List deviceIds); - /** - * 通过设备id绑定设备 - * 设备第一次绑定为商户 - * 其他时候绑定为租户 - * @param userId 用户id - * @param deviceId 设备id - */ - boolean bind(Long userId, Long deviceId); - /** * 通过mac绑定设备 * 设备第一次绑定为商户 * 其他时候绑定为租户 - * @param userId 用户id - * @param mac 设备mac + * @param storeId 店铺ID + * @param deviceNo 设备编号(SN) */ - boolean bind(Long userId, String mac); + boolean bind(Long storeId, String deviceNo); /** * 商户解绑设备 - * @param userId 用户id * @param deviceId 设备id */ - boolean landlordUnbind(Long userId, Long deviceId); + boolean unbindStore(Long deviceId); /** * 通过mac查询设备 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/SmDeviceServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/SmDeviceServiceImpl.java index 2f3088bc..3ad08d71 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/SmDeviceServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/SmDeviceServiceImpl.java @@ -18,6 +18,8 @@ import com.ruoyi.ss.deviceTenant.mapper.SmDeviceTenantMapper; import com.ruoyi.ss.deviceTenant.service.ISmDeviceTenantService; import com.ruoyi.ss.resetRecord.domain.SmResetRecord; import com.ruoyi.ss.resetRecord.service.ISmResetRecordService; +import com.ruoyi.ss.store.domain.StoreVo; +import com.ruoyi.ss.store.service.IStoreService; import com.ruoyi.ss.user.domain.SmUserVo; import com.ruoyi.ss.user.mapper.SmUserMapper; import com.ruoyi.iot.domain.IotDeviceInfo; @@ -27,6 +29,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionTemplate; @@ -79,6 +82,9 @@ public class SmDeviceServiceImpl implements ISmDeviceService @Autowired private TransactionTemplate transactionTemplate; + @Autowired + private IStoreService storeService; + @Value("${debug}") private Boolean debug; @@ -143,7 +149,6 @@ public class SmDeviceServiceImpl implements ISmDeviceService device.setElectricity(deviceInfo.getA()); device.setVoltage(deviceInfo.getV()); device.setRealTimePower(deviceInfo.getP()); - device.setSurplusElectriQuantity(deviceInfo.getM()); // 剩余电量 device.setTotalElectriQuantity(deviceInfo.getW()); // 电量 } } else { @@ -162,9 +167,6 @@ public class SmDeviceServiceImpl implements ISmDeviceService public int insertSmDevice(SmDevice data) { this.validate(data, false); - - deviceAssembler.setStore(data); // 商户分组 - data.setCreateTime(DateUtils.getNowDate()); data.setStatus(DeviceStatus.NORMAL.getStatus()); return smDeviceMapper.insertSmDevice(data); @@ -202,7 +204,7 @@ public class SmDeviceServiceImpl implements ISmDeviceService LoginUser loginUser = SecurityUtils.getLoginUser(); if (update) { ServiceUtil.assertion(smDevice.getDeviceId() == null, "参数错误:设备id不允许为空"); - SmDevice device = smDeviceMapper.selectSmDeviceByDeviceId(smDevice.getDeviceId()); + SmDeviceVo device = smDeviceMapper.selectSmDeviceByDeviceId(smDevice.getDeviceId()); ServiceUtil.assertion(device == null || device.getDeleted(), "设备" + smDevice.getDeviceId() + "不存在"); if (LoginType.FRONT.equals(loginUser.getLoginType())) { ServiceUtil.assertion(!Objects.equals(device.getUserId(), loginUser.getUserId()), "这不是您的设备"); @@ -288,19 +290,22 @@ public class SmDeviceServiceImpl implements ISmDeviceService } @Override - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) public boolean addTime(Long deviceId, BigDecimal num) { - ServiceUtil.assertion(num.compareTo(BigDecimal.ZERO) < 0, "增加的时长不允许小于0"); SmDeviceVo device = smDeviceMapper.selectSmDeviceByDeviceId(deviceId); ServiceUtil.assertion(device == null, "设备不存在"); ServiceUtil.assertion(!StringUtils.hasText(device.getMac()), "设备MAC号为空"); + ServiceUtil.assertion(DeviceStatus.FIXING.getStatus().equals(device.getStatus()), "设备正在维修中,无法使用"); // 更新数据库时长 int updateCount = smDeviceMapper.addTime(deviceId, num); ServiceUtil.assertion(updateCount != 1, "增加时长失败,请刷新后重试"); + // 修改状态为使用中 + changeStatus(deviceId, DeviceStatus.USING); + // 物联网设备增加时长 boolean rechargeResult = iotService.recharge(device.getMac(), num); ServiceUtil.assertion(!rechargeResult, "设备充值失败"); @@ -311,53 +316,11 @@ public class SmDeviceServiceImpl implements ISmDeviceService return true; } - @Override - @Transactional - public boolean tenantBind(Long tenantId, Long deviceId) { - // 校验 - ServiceUtil.assertion(tenantId == null || deviceId == null, "参数错误"); - ServiceUtil.assertion(smDeviceTenantService.selectIsBind(tenantId, deviceId), "用户与该设备已经绑定,无需重复绑定"); - - SmDeviceVo device = smDeviceMapper.selectSmDeviceByDeviceId(deviceId); - ServiceUtil.assertion(device == null || device.getDeleted(), "待绑定的设备不存在"); - ServiceUtil.assertion(device.getUserId() == null, "该设备还未绑定商户,请先绑定商户"); - - SmUserVo user = smUserMapper.selectSmUserByUserId(tenantId); - ServiceUtil.assertion(user == null, "用户不存在"); - - // 执行绑定 - SmDeviceTenant deviceTenant = new SmDeviceTenant(); - deviceTenant.setTenantId(tenantId); - deviceTenant.setDeviceId(deviceId); - int insertCount = smDeviceTenantService.insertSmDeviceTenant(deviceTenant); - ServiceUtil.assertion(insertCount != 1 , "绑定失败,请刷新后重试"); - - // 设置为默认设备 - setDefaultDevice(tenantId, deviceId); - - return true; - } - - @Override - @Transactional - public boolean tenantUnbind(Long tenantId, Long deviceId) { - // 判断是否已绑定 - ServiceUtil.assertion(!smDeviceTenantService.selectIsBind(tenantId, deviceId), "用户尚未绑定该设备,无法解绑"); - - // 执行解绑 - int deleteCount = smDeviceTenantService.unBind(tenantId, deviceId); - ServiceUtil.assertion(deleteCount != 1, "设备解绑失败,请刷新后重试"); - - // 若解绑的设备为默认设备,则设置新的默认设备 - SmDeviceVo defaultDevice = selectDefaultDevice(tenantId); - if (defaultDevice == null) { - List deviceList = this.selectTenantDeviceList(tenantId); - if (!CollectionUtils.isEmpty(deviceList)) { - setDefaultDevice(tenantId, deviceList.get(0).getDeviceId()); - } - } - - return true; + private int changeStatus(Long deviceId, DeviceStatus status) { + SmDevice device = new SmDevice(); + device.setDeviceId(deviceId); + device.setStatus(status.getStatus()); + return smDeviceMapper.updateSmDevice(device); } /** @@ -370,7 +333,6 @@ public class SmDeviceServiceImpl implements ISmDeviceService return Collections.emptyList(); } SmDeviceQuery dto = new SmDeviceQuery(); - dto.setTenantId(tenantId); dto.setDeleted(false); List list = smDeviceMapper.selectSmDeviceList(dto); assembleDeviceInfo(list); @@ -380,39 +342,6 @@ public class SmDeviceServiceImpl implements ISmDeviceService return list; } - @Override - public SmDeviceVo selectDefaultDevice(Long tenantId) { - if (tenantId == null) { - return null; - } - SmDeviceQuery dto = new SmDeviceQuery(); - dto.setTenantId(tenantId); - dto.setIsDefault(true); - dto.setDeleted(false); - List list = smDeviceMapper.selectSmDeviceList(dto); - assembleDeviceInfo(list); - if (CollectionUtils.isEmpty(list)) { - return null; - } - return list.get(0); - } - - @Override - @Transactional - public boolean setDefaultDevice(Long tenantId, Long deviceId) { - SmDeviceVo device = smDeviceMapper.selectSmDeviceByDeviceId(deviceId); - ServiceUtil.assertion(device == null || device.getDeleted(), "设备不存在"); - - deviceAssembler.assembleTenant(Collections.singletonList(device)); - ServiceUtil.assertion(!device.getTenantIds().contains(tenantId), "该用户不是这个设备的租户"); - SmUserVo user = smUserMapper.selectSmUserByUserId(tenantId); - ServiceUtil.assertion(user == null, "用户不存在"); - - int updateCount = smDeviceTenantMapper.setDefault(tenantId, deviceId); - ServiceUtil.assertion(updateCount == 0, "设置默认设备失败"); - return true; - } - @Override public boolean logicDel(List deviceIds) { this.validatePreLogicDelete(deviceIds); @@ -497,7 +426,6 @@ public class SmDeviceServiceImpl implements ISmDeviceService SmDevice data = new SmDevice(); data.setDeviceId(device.getDeviceId()); if (deviceInfo != null) { - data.setSurplusElectriQuantity(deviceInfo.getM()); data.setLastPullTime(deviceInfo.getAt()); data.setTotalElectriQuantity(deviceInfo.getW()); data.setPowerStatus(deviceInfo.getS()); @@ -529,37 +457,26 @@ public class SmDeviceServiceImpl implements ISmDeviceService @Override @Transactional - public boolean bind(Long userId, Long deviceId) { - ServiceUtil.assertion(userId == null || deviceId == null, "绑定设备参数错误"); - - SmDeviceVo device = smDeviceMapper.selectSmDeviceByDeviceId(deviceId); - ServiceUtil.assertion(device == null || device.getDeleted(), "设备不存在"); - - if (device.getUserId() == null) { - // 商户为空,绑定商户 - this.bindLandlord(userId, deviceId); - } else { - // 绑定租户 - this.tenantBind(userId, deviceId); - } - return true; - } - - @Override - @Transactional - public boolean bind(Long userId, String mac) { + public boolean bind(Long storeId, String deviceNo) { // 判断设备是否存在 - SmDeviceVo device = selectByMac(mac); + SmDeviceVo device = selectByDeviceNo(deviceNo); + ServiceUtil.assertion(device == null, "设备未录入"); + ServiceUtil.assertion(device.getStoreId() != null, "该设备已被绑定"); - // 不存在则新增 - if (device == null || device.getDeleted()) { - device = new SmDeviceVo(); - device.setMac(mac); - this.insertSmDevice(device); - } + // 查询店铺 + StoreVo store = storeService.selectSmStoreById(storeId); + ServiceUtil.assertion(store == null, "店铺不存在"); - // 绑定 - return bind(userId, device.getDeviceId()); + // 绑定店铺 + int updateCount = smDeviceMapper.bindStore(device.getDeviceId(), storeId); + ServiceUtil.assertion(updateCount != 1, "当前设备信息已变更,请刷新后重试"); + + // 记录设备绑定 + scheduledExecutorService.schedule(() -> { + smDeviceBindRecordService.record(store.getUserId(), device.getDeviceId()); + }, 0, TimeUnit.SECONDS); + + return true; } /** @@ -597,6 +514,7 @@ public class SmDeviceServiceImpl implements ISmDeviceService SmDevice form = new SmDevice(); form.setDeviceId(deviceId); form.setExpireTime(now); + form.setStatus(DeviceStatus.NORMAL.getStatus()); smDeviceMapper.updateSmDevice(form); // TODO 物联网设备归零 @@ -614,19 +532,6 @@ public class SmDeviceServiceImpl implements ISmDeviceService return true; } - /** - * 判断设备是否还有租户 - * @param deviceId - * @return - */ - private boolean hasTenant(Long deviceId) { - if (deviceId == null) { - return false; - } - List tenantList = smDeviceTenantService.selectByDeviceId(deviceId); - return !CollectionUtils.isEmpty(tenantList); - } - /** * 设备是否已经被绑定 * @@ -639,7 +544,7 @@ public class SmDeviceServiceImpl implements ISmDeviceService return false; } SmDeviceVo device = smDeviceMapper.selectSimpleSmDeviceByMac(mac); - return device != null && device.getUserId() != null; + return device != null && device.getStoreId() != null; } /** @@ -658,7 +563,7 @@ public class SmDeviceServiceImpl implements ISmDeviceService } /** - * 查询各店铺的设备数量,并分组 + * 查询各店铺的设备数量,并店铺 * * @param storeIds 店铺id */ @@ -675,7 +580,7 @@ public class SmDeviceServiceImpl implements ISmDeviceService } /** - * 条件查询数量,并分组 + * 条件查询数量,并店铺 * * @param query 查询条件 * @param keyMapper 键值的映射 @@ -731,8 +636,15 @@ public class SmDeviceServiceImpl implements ISmDeviceService return 0; } try { - smDevice.setCreateTime(DateUtils.getNowDate()); - return smDeviceMapper.insertSmDevice(smDevice); + Integer result = transactionTemplate.execute(status -> { + SmDeviceVo byMac = selectByMac(smDevice.getMac()); + if (byMac == null) { + smDevice.setCreateTime(DateUtils.getNowDate()); + return smDeviceMapper.insertSmDevice(smDevice); + } + return 0; + }); + return result == null ? 0 : result; } catch (Exception e) { log.error("add init device error: {}", e.getMessage()); return 0; @@ -741,42 +653,16 @@ public class SmDeviceServiceImpl implements ISmDeviceService @Override @Transactional - public boolean landlordUnbind(Long userId, Long deviceId) { + public boolean unbindStore(Long deviceId) { SmDeviceVo device = smDeviceMapper.selectSmDeviceByDeviceId(deviceId); ServiceUtil.assertion(device == null || device.getDeleted(), "设备不存在"); - ServiceUtil.assertion(!Objects.equals(device.getUserId(), userId), "您不是该设备的商户"); + ServiceUtil.assertion(DeviceStatus.USING.getStatus().equals(device.getStatus()), "设备正在使用中,无法解除绑定"); - deviceAssembler.assembleTenant(Collections.singletonList(device)); - ServiceUtil.assertion(!CollectionUtils.isEmpty(device.getTenantIds()), "该设备还有租户绑定,无法解除绑定"); - - int updateCount = smDeviceMapper.unbindLandlord(deviceId, userId); + int updateCount = smDeviceMapper.unbindStore(deviceId); ServiceUtil.assertion(updateCount != 1, "当前设备信息已变更,请刷新后重试"); return true; } - // 绑定商户 - @Transactional - public void bindLandlord(Long userId, Long deviceId) { - ServiceUtil.assertion(userId == null || deviceId == null, "商户绑定设备参数错误"); - - SmUserVo user = smUserMapper.selectSmUserByUserId(userId); - - int updateCount = smDeviceMapper.bindLandlord(deviceId, userId); - ServiceUtil.assertion(updateCount != 1, "当前设备信息已变更,请刷新后重试"); - - // 更新设备分组 - SmDevice device = new SmDevice(); - device.setDeviceId(deviceId); - device.setUserId(userId); - deviceAssembler.setStore(device); - smDeviceMapper.updateSmDevice(device); - - // 记录设备绑定 - scheduledExecutorService.schedule(()-> { - smDeviceBindRecordService.record(userId, deviceId); - },0, TimeUnit.SECONDS); - } - /** * 设备绑定SN码 * diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceValidatorImpl.java index 7b206800..ba468e2b 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceValidatorImpl.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; import java.util.HashSet; import java.util.List; +import java.util.Objects; /** * @author wjh @@ -39,4 +40,19 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato query.setDeviceNos(deviceNos); return deviceService.selectCount(query) == new HashSet<>(deviceNos).size(); } + + /** + * 判断设备是否属于指定用户 + * + * @param deviceId 设备id + * @param userId 用户id + */ + @Override + public boolean isBelong(Long deviceId, Long userId) { + if (deviceId == null) { + return false; + } + SmDeviceVo device = deviceService.selectSmDeviceByDeviceId(deviceId); + return device != null && Objects.equals(device.getUserId(), userId); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/domain/SmMeterReadingRecord.java b/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/domain/SmMeterReadingRecord.java index 08144e4a..05d26099 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/domain/SmMeterReadingRecord.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/domain/SmMeterReadingRecord.java @@ -28,10 +28,6 @@ public class SmMeterReadingRecord extends BaseEntity @Excel(name = "用户id") private Long userId; - /** 抄表时剩余电量 */ - @Excel(name = "抄表时剩余电量") - private BigDecimal surplusElectriQuantity; - /** 抄表时总用电量 */ @Excel(name = "抄表时总用电量") private BigDecimal totalElectriQuantity; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/mapper/SmMeterReadingRecordMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/mapper/SmMeterReadingRecordMapper.xml index 2b42b1c2..dc7e483e 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/mapper/SmMeterReadingRecordMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/mapper/SmMeterReadingRecordMapper.xml @@ -8,7 +8,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - @@ -24,7 +23,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" smrr.record_id, smrr.device_id, smrr.user_id, - smrr.surplus_electri_quantity, smrr.total_electri_quantity, smrr.create_time, smrr.used_electri_quantity @@ -124,7 +122,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" record_id, device_id, user_id, - surplus_electri_quantity, total_electri_quantity, create_time, used_electri_quantity, @@ -133,7 +130,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{recordId}, #{deviceId}, #{userId}, - #{surplusElectriQuantity}, #{totalElectriQuantity}, #{createTime}, #{usedElectriQuantity}, @@ -142,12 +138,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - insert into sm_meter_reading_record(device_id, user_id, surplus_electri_quantity, total_electri_quantity, create_time, used_electri_quantity) + insert into sm_meter_reading_record(device_id, user_id, total_electri_quantity, create_time, used_electri_quantity) #{i.deviceId}, #{i.userId}, - #{i.surplusElectriQuantity}, #{i.totalElectriQuantity}, #{i.createTime}, #{i.usedElectriQuantity}, @@ -160,7 +155,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" device_id = #{deviceId}, user_id = #{userId}, - surplus_electri_quantity = #{surplusElectriQuantity}, total_electri_quantity = #{totalElectriQuantity}, create_time = #{createTime}, used_electri_quantity = #{usedElectriQuantity}, diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/service/SmMeterReadingRecordServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/service/SmMeterReadingRecordServiceImpl.java index 3ff30d57..9f41c346 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/service/SmMeterReadingRecordServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/meterReadingRecord/service/SmMeterReadingRecordServiceImpl.java @@ -155,7 +155,6 @@ public class SmMeterReadingRecordServiceImpl implements ISmMeterReadingRecordSer record.setDeviceId(device.getDeviceId()); record.setUserId(device.getUserId()); record.setTotalElectriQuantity(deviceInfo == null ? device.getTotalElectriQuantity() : deviceInfo.getW()); - record.setSurplusElectriQuantity(deviceInfo == null ? device.getSurplusElectriQuantity() : deviceInfo.getM()); record.setCreateTime(now); if (history == null || history.getTotalElectriQuantity() == null) { record.setUsedElectriQuantity(deviceInfo == null ? device.getTotalElectriQuantity() : deviceInfo.getW()); diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/IStoreService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/IStoreService.java index a3ea8838..d7484de1 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/IStoreService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/IStoreService.java @@ -114,4 +114,9 @@ public interface IStoreService * 查询店铺映射表 */ Map selectMap(StoreQuery query, Function keyMapper); + + /** + * ids查询列表 + */ + List selectSmStoreListByIds(List ids); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreAssemblerImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreAssemblerImpl.java index 031ead2d..9f91ff6a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreAssemblerImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreAssemblerImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.ss.store.service.impl; import com.ruoyi.common.utils.CollectionUtils; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.ss.dashboard.BillCountVo; import com.ruoyi.ss.device.domain.SmDeviceCountVO; import com.ruoyi.ss.device.domain.SmDeviceQuery; import com.ruoyi.ss.device.domain.enums.DeviceGroupBy; @@ -9,12 +11,20 @@ import com.ruoyi.ss.device.domain.enums.DeviceStatus; import com.ruoyi.ss.device.service.ISmDeviceService; import com.ruoyi.ss.store.domain.StoreVo; import com.ruoyi.ss.store.service.StoreAssembler; +import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery; +import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillGroupBy; +import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus; +import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillType; +import com.ruoyi.ss.transactionBill.service.TransactionBillService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -27,6 +37,9 @@ public class StoreAssemblerImpl implements StoreAssembler { @Autowired private ISmDeviceService deviceService; + @Autowired + private TransactionBillService transactionBillService; + /** * 拼接设备数量 * @@ -68,7 +81,7 @@ public class StoreAssemblerImpl implements StoreAssembler { } /** - * TODO 拼接本月收入 + * 拼接本月收入 * * @param list */ @@ -77,13 +90,29 @@ public class StoreAssemblerImpl implements StoreAssembler { if (CollectionUtils.isEmptyElement(list)) { return; } + + TransactionBillQuery query = new TransactionBillQuery(); + LocalDate now = LocalDate.now(); + query.setGroupBy(TransactionBillGroupBy.store_id.name()); + query.setStoreIds(list.stream().map(StoreVo::getStoreId).filter(Objects::nonNull).distinct().collect(Collectors.toList())); + query.setStatus(TransactionBillStatus.SUCCESS.getStatus()); + query.setType(TransactionBillType.RECHARGE.getType()); + query.setMonth(now.getMonthValue()); + query.setYear(now.getYear()); + Map map = transactionBillService.selectCountMap(query, BillCountVo::getStoreId); + for (StoreVo store : list) { - store.setMonthIncome(BigDecimal.ZERO); + BillCountVo count = map.get(store.getStoreId()); + if (count != null) { + store.setMonthIncome(count.getRecharge()); + } else { + store.setMonthIncome(BigDecimal.ZERO); + } } } /** - * TODO 拼接本日收入 + * 拼接本日收入 * * @param list */ @@ -92,8 +121,22 @@ public class StoreAssemblerImpl implements StoreAssembler { if (CollectionUtils.isEmptyElement(list)) { return; } + + TransactionBillQuery query = new TransactionBillQuery(); + query.setGroupBy(TransactionBillGroupBy.store_id.name()); + query.setStoreIds(list.stream().map(StoreVo::getStoreId).filter(Objects::nonNull).distinct().collect(Collectors.toList())); + query.setStatus(TransactionBillStatus.SUCCESS.getStatus()); + query.setType(TransactionBillType.RECHARGE.getType()); + query.setCreateDate(DateUtils.getNowDate()); + Map map = transactionBillService.selectCountMap(query, BillCountVo::getStoreId); + for (StoreVo store : list) { - store.setTodayIncome(BigDecimal.ZERO); + BillCountVo count = map.get(store.getStoreId()); + if (count != null) { + store.setTodayIncome(count.getRecharge()); + } else { + store.setTodayIncome(BigDecimal.ZERO); + } } } @@ -107,8 +150,23 @@ public class StoreAssemblerImpl implements StoreAssembler { if (CollectionUtils.isEmptyElement(list)) { return; } + TransactionBillQuery query = new TransactionBillQuery(); + LocalDate lastMonth = LocalDate.now().plusMonths(-1); + query.setGroupBy(TransactionBillGroupBy.store_id.name()); + query.setStoreIds(list.stream().map(StoreVo::getStoreId).filter(Objects::nonNull).distinct().collect(Collectors.toList())); + query.setStatus(TransactionBillStatus.SUCCESS.getStatus()); + query.setType(TransactionBillType.RECHARGE.getType()); + query.setMonth(lastMonth.getMonthValue()); + query.setYear(lastMonth.getYear()); + Map map = transactionBillService.selectCountMap(query, BillCountVo::getStoreId); + for (StoreVo store : list) { - store.setLastMonthIncome(BigDecimal.ZERO); + BillCountVo count = map.get(store.getStoreId()); + if (count != null) { + store.setLastMonthIncome(count.getRecharge()); + } else { + store.setLastMonthIncome(BigDecimal.ZERO); + } } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreServiceImpl.java index 4d546cb5..93bd299c 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreServiceImpl.java @@ -130,23 +130,10 @@ public class StoreServiceImpl implements IStoreService @Override public List listCount(StoreQuery query) { - List list = new ArrayList<>(); - - // 查询全部设备数据 - SmDeviceQuery deviceDto = new SmDeviceQuery(); - deviceDto.setUserId(query.getUserId()); - int count = smDeviceService.selectCount(deviceDto); - StoreVo all = new StoreVo(); - all.setDeviceCount(count); - all.setName("全部"); - list.add(all); - // 查询各各店铺的设备数据 List storeList = storeMapper.selectSmStoreList(query); storeAssembler.assembleDeviceCount(storeList); - list.addAll(storeList); - - return list; + return storeList; } @Override @@ -282,6 +269,21 @@ public class StoreServiceImpl implements IStoreService return list.stream().collect(Collectors.toMap(keyMapper, item -> item)); } + /** + * ids查询列表 + * + * @param ids + */ + @Override + public List selectSmStoreListByIds(List ids) { + if (CollectionUtils.isEmptyElement(ids)) { + return Collections.emptyList(); + } + StoreQuery query = new StoreQuery(); + query.setStoreIds(ids); + return selectSmStoreList(query); + } + /** * 通用查询数量 * diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java index 4fe71c59..3702760c 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java @@ -67,4 +67,7 @@ public class TransactionBillQuery extends TransactionBill { @ApiModelProperty("状态列表") private List statusList; + + @ApiModelProperty("店铺ID列表") + private List storeIds; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/enums/TransactionBillGroupBy.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/enums/TransactionBillGroupBy.java index 419b8500..17644724 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/enums/TransactionBillGroupBy.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/enums/TransactionBillGroupBy.java @@ -17,4 +17,5 @@ public enum TransactionBillGroupBy { create_date, create_hour, create_year_month, + store_id } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.java index 6f41e679..e76bdfc1 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.java @@ -71,13 +71,6 @@ public interface TransactionBillMapper */ List selectCount(TransactionBillQuery dto); - /** - * 修改支付方式 - * @param billId 订单id - * @param payType 支付方式 - */ - int updatePayType(@Param("billId") Long billId, @Param("payType") Long payType, @Param("accountNo") String accountNo); - /** * 充值成功 * @param billId 订单id diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml index 6aa55d2a..549d9b18 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml @@ -81,6 +81,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item} + + and stb.store_id in + + #{item} + + where su.wx_open_id = #{openId} and su.del_flag = '0' - group by su.user_id