diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java index 8d2e9e53..807b008a 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java @@ -41,12 +41,15 @@ public class SmUser extends BaseEntity @Excel(name = "用户名称") @ApiModelProperty("用户名称") @NotNull(message = "用户名称不允许为空", groups = {ValidGroup.Create.class}) + @JsonView(JsonViewProfile.App.class) + @Sensitive(desensitizedType = DesensitizedType.USERNAME) private String userName; /** 用户昵称 */ @Excel(name = "用户昵称") @ApiModelProperty("用户昵称") @JsonView(JsonViewProfile.App.class) + @Sensitive(desensitizedType = DesensitizedType.USERNAME) private String nickName; /** 用户邮箱 */ diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java index 9c548a72..b7f289b3 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java @@ -1,7 +1,6 @@ package com.ruoyi.common.utils.collection; import com.ruoyi.common.utils.DateUtils; -import org.apache.poi.ss.formula.functions.T; import java.math.BigDecimal; import java.time.LocalDate; @@ -177,4 +176,11 @@ public class CollectionUtils extends org.springframework.util.CollectionUtils { public static BigDecimal sumDecimal(Collection collection, Function decimalMapper) { return collection.stream().map(decimalMapper).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); } + + public static T getFirst(List list) { + if (isEmpty(list)) { + return null; + } + return list.get(0); + } } 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 047ee503..f53747fc 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 @@ -103,4 +103,9 @@ public interface DeviceValidator { * 校验分成 */ void checkBonus(DeviceVO device); + + /** + * 校验分成 + */ + void checkBonus(Long deviceId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java index e36d00fb..36ec3326 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java @@ -44,6 +44,7 @@ import com.ruoyi.ss.record.time.service.IRecordTimeService; import com.ruoyi.ss.record.time.service.RecordTimeConverter; import com.ruoyi.ss.store.domain.StoreVo; import com.ruoyi.ss.store.service.StoreService; +import com.ruoyi.ss.storeStaff.service.StoreStaffValidator; import com.ruoyi.ss.suit.domain.enums.SuitFeeType; import com.ruoyi.ss.timeBill.domain.TimeBillQuery; import com.ruoyi.ss.timeBill.domain.TimeBillVO; @@ -139,6 +140,9 @@ public class DeviceServiceImpl implements DeviceService @Autowired private UserValidator userValidator; + @Autowired + private StoreStaffValidator storeStaffValidator; + /** * 查询设备 * @@ -230,6 +234,7 @@ public class DeviceServiceImpl implements DeviceService // 后校验 DeviceVO vo = this.selectById(data.getDeviceId()); + deviceAssembler.assembleBonusList(vo); deviceValidator.afterCheck(vo); // 更新套餐关联 @@ -1212,6 +1217,9 @@ public class DeviceServiceImpl implements DeviceService int updateCount = deviceMapper.bind(device.getDeviceId(), storeId, userId); ServiceUtil.assertion(updateCount != 1, "当前设备信息已变更,请刷新后重试"); + // 校验分成 + deviceValidator.checkBonus(device.getDeviceId()); + // 记录绑定记录 int record = smDeviceBindRecordService.record(userId, device.getDeviceId(), BindRecordType.BIND, BindRecordUserType.MCH); ServiceUtil.assertion(record != 1, "添加绑定记录失败"); @@ -1221,7 +1229,6 @@ public class DeviceServiceImpl implements DeviceService int changeType = userService.changeType(userId, UserType.MCH); ServiceUtil.assertion(changeType != 1, "修改用户类型失败"); } - return updateCount; }); 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 4981c78c..e160526e 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 @@ -12,6 +12,7 @@ import com.ruoyi.ss.device.domain.DeviceBO; import com.ruoyi.ss.device.domain.DeviceQuery; import com.ruoyi.ss.device.domain.enums.DeviceServiceMode; import com.ruoyi.ss.device.domain.vo.DeviceVO; +import com.ruoyi.ss.device.service.DeviceAssembler; import com.ruoyi.ss.device.service.DeviceService; import com.ruoyi.ss.device.service.DeviceValidator; import com.ruoyi.ss.store.service.StoreValidator; @@ -50,6 +51,9 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato @Autowired private ISmUserService userService; + @Autowired + private DeviceAssembler deviceAssembler; + /** * 设备编号是否存在 * @@ -275,8 +279,18 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato // 不允许分成小于0 for (Bonus bonus : device.getBonusList()) { - ServiceUtil.assertion(bonus.getPoint() == null, "设备%s的分成比例不允许为空", device.getDeviceNo()); - ServiceUtil.assertion(bonus.getPoint().compareTo(BigDecimal.ZERO) < 0, "设备%s的分成比例不允许小于0", device.getDeviceNo()); + ServiceUtil.assertion(bonus.getPoint() == null, "设备%s的%s分成比例不允许为空", device.getDeviceNo(), bonus.getArrivalName()); + ServiceUtil.assertion(bonus.getPoint().compareTo(BigDecimal.ZERO) < 0, "设备%s的%s分成比例不允许小于0", device.getDeviceNo(), bonus.getArrivalName()); } } + + @Override + public void checkBonus(Long deviceId) { + if (deviceId == null) { + return; + } + DeviceVO device = deviceService.selectById(deviceId); + deviceAssembler.assembleBonusList(device); + this.checkBonus(device); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreBO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreBO.java index 9caadd94..ce40ac77 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreBO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreBO.java @@ -118,4 +118,11 @@ public class StoreBO extends Store { bo.setUseOutTime(getUseOutTime()); return bo; } + + /** + * 店铺员工修改店铺 + */ + public StoreBO filterUpdateByAppStaff() { + return this.filterUpdateByApp(); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreQuery.java index 15b36715..4aa48d84 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreQuery.java @@ -3,6 +3,7 @@ package com.ruoyi.ss.store.domain; import com.ruoyi.common.core.domain.ValidGroup; import com.ruoyi.common.valid.EnumValid; import com.ruoyi.ss.store.domain.enums.StoreGroupBy; +import com.ruoyi.ss.storeStaff.domain.StoreStaffQuery; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -46,4 +47,13 @@ public class StoreQuery extends Store { @ApiModelProperty("关键词") private String keyword; + + @ApiModelProperty("是否在员工信息中(根据员工信息筛选时使用)") + private Boolean inStaff; + + @ApiModelProperty("员工用户ID") + private Long staffUserId; + + @ApiModelProperty("员工权限") + private String staffPermission; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/mapper/StoreMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/store/mapper/StoreMapper.xml index 2ecc9613..dbd570b2 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/mapper/StoreMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/mapper/StoreMapper.xml @@ -76,6 +76,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item} + + and ss.store_id + not + in () + + + + + + select distinct sss.store_id + from ss_store_staff sss + + and sss.user_id = #{query.staffUserId} + + and find_in_set(#{query.staffPermission}, sss.permissions) + +