diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java index 056b9981..18e62367 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java @@ -80,4 +80,9 @@ public class CacheConstants * 待插入的命令日志 */ public static final String INSERT_COMMAND_LOG = "insert_command_log"; + + /** + * 充值渠道名称列表 + */ + public static final String CHANNEL_NAME_LIST = "channel_name_list"; } 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 09ac249c..c986e941 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 @@ -1,5 +1,16 @@ package com.ruoyi.common.core.domain.entity; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import org.springframework.format.annotation.DateTimeFormat; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonView; import com.ruoyi.common.annotation.Excel; @@ -8,17 +19,9 @@ import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.JsonViewProfile; import com.ruoyi.common.core.domain.ValidGroup; import com.ruoyi.common.enums.DesensitizedType; + import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; /** * 普通用户信息对象 sm_user @@ -131,6 +134,8 @@ public class SmUser extends BaseEntity @ApiModelProperty("服务费费率") @JsonView(JsonViewProfile.App.class) + @NotNull(message = "服务费费率不允许为空", groups = {ValidGroup.Create.class}) + @Min(value = 0, message = "服务费费率不能小于0") private BigDecimal serviceRate; @ApiModelProperty("是否设备管理员") @@ -144,11 +149,14 @@ public class SmUser extends BaseEntity @Excel(name = "提现服务费收取类型:1-百分比抽成,2-每笔提现收取") @ApiModelProperty("提现服务费收取类型:1-百分比抽成,2-每笔提现收取") @JsonView(JsonViewProfile.App.class) + @NotNull(message = "提现服务费收取类型不允许为空", groups = {ValidGroup.Create.class}) private String withdrawServiceType; @Excel(name = "提现服务费费") @ApiModelProperty("提现服务费费") @JsonView(JsonViewProfile.App.class) + @NotNull(message = "提现服务费费不允许为空", groups = {ValidGroup.Create.class}) + @Min(value = 0, message = "提现服务费费不能小于0") private BigDecimal withdrawServiceRate; @Excel(name = "真实姓名") @@ -214,6 +222,8 @@ public class SmUser extends BaseEntity @Excel(name = "代理商服务费比例") @ApiModelProperty("代理商服务费比例") @JsonView(JsonViewProfile.AppMch.class) + @NotNull(message = "代理商服务费比例不允许为空", groups = {ValidGroup.Create.class}) + @Min(value = 0, message = "代理商服务费比例不能小于0") private BigDecimal agentServiceRate; @Excel(name = "到账延迟时间", readConverterExp = "小=时") @@ -253,4 +263,10 @@ public class SmUser extends BaseEntity @Excel(name = "所属应用ID") @ApiModelProperty("所属应用ID") private Long appId; + + @Excel(name = "VIP服务费") + @ApiModelProperty("VIP服务费") + @NotNull(message = "VIP服务费不允许为空", groups = {ValidGroup.Create.class}) + @Min(value = 0, message = "VIP服务费不能小于0") + private BigDecimal vipServiceRate; } diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/config/ConfigKey.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/config/ConfigKey.java index 01e59ae4..772e301a 100644 --- a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/config/ConfigKey.java +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/config/ConfigKey.java @@ -1,10 +1,10 @@ package com.ruoyi.system.domain.enums.config; +import java.util.Objects; + import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.Objects; - /** * 配置项枚举 * @author wjh @@ -27,7 +27,8 @@ public enum ConfigKey { RISK_WITHDRAW_COUNT("risk.withdraw.count", "累计风险次数"), RISK_WITHDRAW_ENABLED("risk.withdraw.enabled", "是否开启提现风控"), LOGIN_WITH_PHONE("login.with.phone", "登录是否需要手机号"), - MCH_HELP_CLASSIFY("mch.help.classify", "商户帮助分类"); + MCH_HELP_CLASSIFY("mch.help.classify", "商户帮助分类"), + VIP_SERVICE_FEE_RATE("vip.service.fee.rate", "VIP服务费费率"); private final String key; private final String msg; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusConverter.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusConverter.java index 3f29992e..a8e65848 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusConverter.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusConverter.java @@ -1,14 +1,15 @@ package com.ruoyi.ss.bonus.service; +import java.util.List; + import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.ss.bonus.domain.Bonus; import com.ruoyi.ss.device.domain.vo.DeviceVO; +import com.ruoyi.ss.store.domain.StoreVo; import com.ruoyi.ss.storeStaff.domain.StoreStaffVO; import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO; import com.ruoyi.ss.vipOrder.domain.VipOrderVO; -import java.util.List; - /** * @author wjh * 2024/8/20 @@ -24,6 +25,11 @@ public interface BonusConverter { */ List toPoList(VipOrderVO order); + /** + * 转为分成数据 + */ + List toPoListByVip(StoreVo store, List staffList, boolean isPlatform); + /** * 转为分成数据 * @param device 设备 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusConverterImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusConverterImpl.java index 5c35cb36..c0fbf15c 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusConverterImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusConverterImpl.java @@ -1,5 +1,17 @@ package com.ruoyi.ss.bonus.service.impl; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.utils.collection.CollectionUtils; @@ -14,25 +26,15 @@ import com.ruoyi.ss.channel.domain.enums.ChannelType; 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.store.domain.StoreVo; +import com.ruoyi.ss.store.service.StoreService; import com.ruoyi.ss.storeStaff.domain.StoreStaffVO; import com.ruoyi.ss.storeStaff.service.StoreStaffService; import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO; -import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.UserAssembler; import com.ruoyi.ss.user.service.UserService; import com.ruoyi.ss.vipOrder.domain.VipOrderVO; import com.ruoyi.system.service.ISysDeptService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.Stream; /** * @author wjh @@ -59,6 +61,9 @@ public class BonusConverterImpl implements BonusConverter { @Autowired private UserAssembler userAssembler; + @Autowired + private StoreService storeService; + @Override public List toPoList(SysDept platform, DeviceVO device, List staffList) { @@ -111,7 +116,7 @@ public class BonusConverterImpl implements BonusConverter { continue; } - Bonus staffBonus = this.toPo(staff); + Bonus staffBonus = this.toPo(staff, staff.getPoint()); if (staffBonus != null) { result.add(staffBonus); point = point.subtract(staffBonus.getPoint()); @@ -130,12 +135,12 @@ public class BonusConverterImpl implements BonusConverter { return result; } - private Bonus toPo(StoreStaffVO staff) { + private Bonus toPo(StoreStaffVO staff, BigDecimal point) { String staffAncestors = Stream.of(staff.getMchId(), staff.getUserId()) .filter(Objects::nonNull) .map(Object::toString) .collect(Collectors.joining(",")); - return this.toPo(staff.getUserId(), staff.getUserName(), staff.getPoint(), staffAncestors, BonusArrivalType.STAFF); + return this.toPo(staff.getUserId(), staff.getUserName(), point, staffAncestors, BonusArrivalType.STAFF); } @Override @@ -143,38 +148,12 @@ public class BonusConverterImpl implements BonusConverter { if (order == null) { return Collections.emptyList(); } - SmUserVO mch = userService.selectSmUserByUserId(order.getMchId()); - userAssembler.assembleRealServiceRate(Collections.singletonList(mch)); - SysDept platform = deptService.selectDeptById(Constants.ROOT_DEPT); - if (mch == null || platform == null) { - return Collections.emptyList(); - } - // 渠道类型 - String channelType = order.getChannelType(); + StoreVo store = storeService.selectSmStoreById(order.getLevelStoreId()); + List staffList = store.getStaffList(); - List result = new ArrayList<>(); - - // 是否平台收取 - boolean isPlatform = ChannelType.PLATFORM.getType().equals(channelType); - // 平台收取 - if (isPlatform) { - BigDecimal serviceRate = mch.getRealServiceRate() == null ? BigDecimal.ZERO : mch.getRealServiceRate(); - result.add(toPo(platform, serviceRate)); - } - - // 员工收取 - List staffList = storeStaffService.selectByStoreId(order.getLevelStoreId()); - if (CollectionUtils.isNotEmptyElement(staffList)) { - for (StoreStaffVO staff : staffList) { - this.addBonus(result, toPo(staff)); - } - } - - // 最后商户收取 - BigDecimal totalPoint = CollectionUtils.sumDecimal(result, Bonus::getPoint); - BigDecimal mchPoint = new BigDecimal("100").subtract(totalPoint); - Bonus mchBonus = toPo(mch.getUserId(), mch.getRealOrUserName(), mchPoint, "", BonusArrivalType.MCH); - this.addBonus(result, mchBonus); + // 构造基础的分成数据 + boolean isPlatform = ChannelType.PLATFORM.getType().equals(order.getChannelType()); + List result = this.toPoListByVip(store, staffList, isPlatform); // 带上业务数据 for (Bonus bonus : result) { @@ -190,6 +169,37 @@ public class BonusConverterImpl implements BonusConverter { return result; } + @Override + public List toPoListByVip(StoreVo store, List staffList, boolean isPlatform) { + SysDept platform = deptService.selectDeptById(Constants.ROOT_DEPT); + if (store == null || platform == null) { + return Collections.emptyList(); + } + + List result = new ArrayList<>(); + + // 平台收取 + if (isPlatform) { + BigDecimal serviceRate = store.getMchVipServiceRate() == null ? BigDecimal.ZERO : store.getMchVipServiceRate(); + result.add(toPo(platform, serviceRate)); + } + + // 员工收取 + if (CollectionUtils.isNotEmptyElement(staffList)) { + for (StoreStaffVO staff : staffList) { + this.addBonus(result, toPo(staff, staff.getVipPoint())); + } + } + + // 最后商户收取 + BigDecimal totalPoint = CollectionUtils.sumDecimal(result, Bonus::getPoint); + BigDecimal mchPoint = new BigDecimal("100").subtract(totalPoint); + Bonus mchBonus = toPo(store.getUserId(), store.getUserName(), mchPoint, "", BonusArrivalType.MCH); + this.addBonus(result, mchBonus); + + return result; + } + @Override public List toPoList(DeviceVO device, TransactionBillVO bill, String channelType) { // 只有通过平台渠道支付的才需要分成给余额 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/channel/domain/vo/ChannelNameVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/channel/domain/vo/ChannelNameVO.java new file mode 100644 index 00000000..4d61ac59 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/channel/domain/vo/ChannelNameVO.java @@ -0,0 +1,12 @@ +package com.ruoyi.ss.channel.domain.vo; + +import lombok.Data; + +@Data +public class ChannelNameVO { + + private Long channelId; + + private String name; +} + diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/channel/mapper/ChannelMapper.java b/smart-switch-service/src/main/java/com/ruoyi/ss/channel/mapper/ChannelMapper.java index 99190f02..4655ad30 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/channel/mapper/ChannelMapper.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/channel/mapper/ChannelMapper.java @@ -1,11 +1,13 @@ package com.ruoyi.ss.channel.mapper; +import java.util.List; + +import org.apache.ibatis.annotations.Param; + import com.ruoyi.ss.channel.domain.Channel; import com.ruoyi.ss.channel.domain.ChannelQuery; import com.ruoyi.ss.channel.domain.ChannelVO; -import org.apache.ibatis.annotations.Param; - -import java.util.List; +import com.ruoyi.ss.channel.domain.vo.ChannelNameVO; /** * 充值渠道Mapper接口 @@ -69,4 +71,9 @@ public interface ChannelMapper * @return */ int logicDel(@Param("ids") List ids); + + /** + * 查询全部充值渠道名称列表 + */ + List selectNameList(@Param("query") ChannelQuery query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/channel/mapper/ChannelMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/channel/mapper/ChannelMapper.xml index 81022fc2..aacfa609 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/channel/mapper/ChannelMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/channel/mapper/ChannelMapper.xml @@ -133,4 +133,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{channelId} + + + + + diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/channel/service/ChannelService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/channel/service/ChannelService.java index eaf91bca..409b513f 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/channel/service/ChannelService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/channel/service/ChannelService.java @@ -1,13 +1,14 @@ package com.ruoyi.ss.channel.service; -import com.ruoyi.ss.channel.domain.Channel; -import com.ruoyi.ss.channel.domain.ChannelQuery; -import com.ruoyi.ss.channel.domain.ChannelVO; - import java.util.List; import java.util.Map; import java.util.function.Function; +import com.ruoyi.ss.channel.domain.Channel; +import com.ruoyi.ss.channel.domain.ChannelQuery; +import com.ruoyi.ss.channel.domain.ChannelVO; +import com.ruoyi.ss.channel.domain.vo.ChannelNameVO; + /** * 充值渠道Service接口 * @@ -48,22 +49,6 @@ public interface ChannelService */ public int updateSmChannel(Channel channel); - /** - * 批量删除充值渠道 - * - * @param channelIds 需要删除的充值渠道主键集合 - * @return 结果 - */ - public int deleteSmChannelByChannelIds(Long[] channelIds); - - /** - * 删除充值渠道信息 - * - * @param channelId 充值渠道主键 - * @return 结果 - */ - public int deleteSmChannelByChannelId(Long channelId); - /** * 查询启用的充值渠道列表 * @@ -88,4 +73,9 @@ public interface ChannelService * 根据id查询 */ List selectByIds(List ids); + + /** + * 查询全部充值渠道名称列表 + */ + List selectAllChannelNameList(); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/channel/service/impl/ChannelServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/channel/service/impl/ChannelServiceImpl.java index 20fac009..d25fd77a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/channel/service/impl/ChannelServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/channel/service/impl/ChannelServiceImpl.java @@ -1,5 +1,17 @@ package com.ruoyi.ss.channel.service.impl; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.support.TransactionTemplate; + +import com.ruoyi.common.constant.CacheConstants; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.pay.xy.config.XyPayConfig; import com.ruoyi.common.pay.xy.service.XyWxPayService; import com.ruoyi.common.utils.DateUtils; @@ -9,18 +21,10 @@ import com.ruoyi.ss.channel.domain.Channel; import com.ruoyi.ss.channel.domain.ChannelQuery; import com.ruoyi.ss.channel.domain.ChannelVO; import com.ruoyi.ss.channel.domain.enums.ChannelApiType; +import com.ruoyi.ss.channel.domain.vo.ChannelNameVO; import com.ruoyi.ss.channel.mapper.ChannelMapper; import com.ruoyi.ss.channel.service.ChannelConverter; import com.ruoyi.ss.channel.service.ChannelService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.support.TransactionTemplate; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; /** * 充值渠道Service业务层处理 @@ -43,6 +47,9 @@ public class ChannelServiceImpl implements ChannelService @Autowired private TransactionTemplate transactionTemplate; + @Autowired + private RedisCache redisCache; + /** * 查询充值渠道 * @@ -86,6 +93,8 @@ public class ChannelServiceImpl implements ChannelService if (insert == 1) { ChannelVO vo = selectSmChannelByChannelId(channel.getChannelId()); this.connectCust(vo); + + clearCache(); } return insert; @@ -109,6 +118,8 @@ public class ChannelServiceImpl implements ChannelService if (update == 1) { ChannelVO vo = selectSmChannelByChannelId(channel.getChannelId()); this.connectCust(vo); + + clearCache(); } return update; @@ -128,30 +139,6 @@ public class ChannelServiceImpl implements ChannelService return true; } - /** - * 批量删除充值渠道 - * - * @param channelIds 需要删除的充值渠道主键 - * @return 结果 - */ - @Override - public int deleteSmChannelByChannelIds(Long[] channelIds) - { - return channelMapper.deleteSmChannelByChannelIds(channelIds); - } - - /** - * 删除充值渠道信息 - * - * @param channelId 充值渠道主键 - * @return 结果 - */ - @Override - public int deleteSmChannelByChannelId(Long channelId) - { - return channelMapper.deleteSmChannelByChannelId(channelId); - } - @Override public List selectEnabledRechargeList(ChannelQuery query) { query.setEnabled(true); @@ -189,7 +176,11 @@ public class ChannelServiceImpl implements ChannelService // ServiceUtil.assertion(ChannelType.SYSTEM.getType().equals(channel.getType()), "不允许删除系统预设渠道 \"%s\"}", channel.getName()); // } - return channelMapper.logicDel(ids); + int del = channelMapper.logicDel(ids); + if (del > 0) { + clearCache(); + } + return del; } @Override @@ -201,4 +192,23 @@ public class ChannelServiceImpl implements ChannelService query.setChannelIds(ids); return this.selectSmChannelList(query); } + + @Override + public List selectAllChannelNameList() { + List list = redisCache.getCacheList(CacheConstants.CHANNEL_NAME_LIST); + if (CollectionUtils.isEmpty(list)) { + list = channelMapper.selectNameList(new ChannelQuery()); + if (CollectionUtils.isNotEmpty(list)) { + redisCache.setCacheList(CacheConstants.CHANNEL_NAME_LIST, list); + } + } + return list; + } + + /** + * 清除缓存 + */ + private void clearCache() { + redisCache.deleteObject(CacheConstants.CHANNEL_NAME_LIST); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java index 870e2b03..05d280d6 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java @@ -1,5 +1,12 @@ package com.ruoyi.ss.device.service; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + import com.ruoyi.iot.domain.IotDeviceInfo; import com.ruoyi.iot.domain.response.CommandResponse; import com.ruoyi.ss.device.domain.Device; @@ -13,13 +20,6 @@ import com.ruoyi.ss.device.domain.enums.DevicePowerStatus; import com.ruoyi.ss.device.domain.vo.DeviceMacSnVO; import com.ruoyi.ss.device.domain.vo.DeviceVO; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; - /** * 设备Service接口 * @@ -431,4 +431,9 @@ public interface DeviceService * 蓝牙同步设备信息 */ int bltSyncIot(IotDeviceInfo info); + + /** + * 查询商户设备列表 + */ + List selectByMchId(Long userId); } 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 a3780689..27480b2a 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 @@ -1,5 +1,23 @@ package com.ruoyi.ss.device.service.impl; +import java.math.BigDecimal; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionTemplate; + import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.IotConstants; import com.ruoyi.common.core.redis.RedisLock; @@ -24,7 +42,11 @@ import com.ruoyi.ss.device.domain.DeviceQuery; import com.ruoyi.ss.device.domain.dto.DeviceBatchUpdateModelDTO; import com.ruoyi.ss.device.domain.dto.DeviceRegisterDTO; import com.ruoyi.ss.device.domain.dto.DeviceWifiDTO; -import com.ruoyi.ss.device.domain.enums.*; +import com.ruoyi.ss.device.domain.enums.DeviceOnlineStatus; +import com.ruoyi.ss.device.domain.enums.DevicePowerStatus; +import com.ruoyi.ss.device.domain.enums.DeviceServiceMode; +import com.ruoyi.ss.device.domain.enums.DeviceStatus; +import com.ruoyi.ss.device.domain.enums.DeviceUserOperaType; import com.ruoyi.ss.device.domain.vo.DeviceMacSnVO; import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.mapper.DeviceMapper; @@ -53,20 +75,8 @@ import com.ruoyi.ss.transactionBill.service.TransactionBillService; import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.UserService; import com.ruoyi.ss.user.service.UserValidator; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionTemplate; -import java.math.BigDecimal; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.*; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; -import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; /** * 设备Service业务层处理 @@ -1422,6 +1432,16 @@ public class DeviceServiceImpl implements DeviceService return this.updateIotInfo(device); } + @Override + public List selectByMchId(Long userId) { + if (userId == null) { + return Collections.emptyList(); + } + DeviceQuery query = new DeviceQuery(); + query.setUserId(userId); + return selectSmDeviceList(query); + } + private List selectIds(DeviceQuery query) { return deviceMapper.selectIds(query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/PayBillVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/PayBillVO.java index 3ecf154b..050007af 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/PayBillVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/PayBillVO.java @@ -13,4 +13,7 @@ public class PayBillVO extends PayBill{ @ApiModelProperty("渠道类型") private String channelType; + @ApiModelProperty("渠道名称") + private String channelName; + } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.xml index a02d4254..961f6905 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.xml @@ -27,7 +27,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" spb.refunding_amount, spb.ip, spb.app_id, - sc.type as channel_type + sc.type as channel_type, + sc.name as channel_name from ss_pay_bill spb left join sm_channel sc on sc.channel_id = spb.channel_id diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreVo.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreVo.java index 71e3a5a3..3a2e4ec0 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreVo.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreVo.java @@ -1,14 +1,18 @@ package com.ruoyi.ss.store.domain; +import java.math.BigDecimal; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonView; import com.ruoyi.common.core.domain.JsonViewProfile; +import com.ruoyi.ss.bonus.domain.Bonus; import com.ruoyi.ss.store.domain.vo.StoreOperatorVO; +import com.ruoyi.ss.storeStaff.domain.StoreStaffVO; + import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import java.math.BigDecimal; - /** * @author 辉 * 2024/3/5 @@ -48,4 +52,13 @@ public class StoreVo extends Store { @ApiModelProperty("操作") private StoreOperatorVO operator; + + @ApiModelProperty("商户VIP服务费") + private BigDecimal mchVipServiceRate; + + @ApiModelProperty("店铺分成") + private List bonusList; + + @ApiModelProperty("店铺员工") + private List staffList; } 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 12eebdb3..059144b8 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 @@ -34,7 +34,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ss.status, ss.enabled, ss.use_out_time, - if(su.is_real, su.real_name, su.user_name) as user_name + if(su.is_real, su.real_name, su.user_name) as user_name, + su.vip_service_rate as mch_vip_service_rate from sm_store ss left join sm_user su on su.user_id = ss.user_id diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreAssembler.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreAssembler.java index 676a6066..a13e5fb9 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreAssembler.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreAssembler.java @@ -1,9 +1,9 @@ package com.ruoyi.ss.store.service; -import com.ruoyi.ss.store.domain.StoreVo; - import java.util.List; +import com.ruoyi.ss.store.domain.StoreVo; + /** * @author wjh * 2024/4/29 @@ -61,4 +61,14 @@ public interface StoreAssembler { * 拼接操作 */ void assembleOperator(List list, Long userId); + + /** + * 拼接店铺分成 + */ + void assembleBonusList(List list); + + /** + * 拼接店铺员工列表 + */ + void assembleStaffList(List list); } 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 68907a93..f791a1d8 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,7 +1,18 @@ package com.ruoyi.ss.store.service.impl; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.dashboard.domain.vo.BillCountVo; +import com.ruoyi.ss.bonus.service.BonusConverter; import com.ruoyi.ss.device.domain.DeviceCountVO; import com.ruoyi.ss.device.domain.DeviceQuery; import com.ruoyi.ss.device.domain.enums.DeviceGroupBy; @@ -12,20 +23,13 @@ import com.ruoyi.ss.store.domain.StoreVo; import com.ruoyi.ss.store.domain.vo.StoreOperatorVO; import com.ruoyi.ss.store.service.StoreAssembler; import com.ruoyi.ss.store.service.StoreValidator; +import com.ruoyi.ss.storeStaff.domain.StoreStaffVO; +import com.ruoyi.ss.storeStaff.service.StoreStaffService; 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.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; /** * @author wjh @@ -43,6 +47,12 @@ public class StoreAssemblerImpl implements StoreAssembler { @Autowired private StoreValidator storeValidator; + @Autowired + private StoreStaffService storeStaffService; + + @Autowired + private BonusConverter bonusConverter; + /** * 拼接设备数量 * @@ -264,4 +274,34 @@ public class StoreAssemblerImpl implements StoreAssembler { store.setOperator(vo); } } + + @Override + public void assembleBonusList(List list) { + if (CollectionUtils.isEmptyElement(list)) { + return; + } + + // 查询店铺员工列表 + this.assembleStaffList(list); + + for (StoreVo store : list) { + bonusConverter.toPoListByVip(store, store.getStaffList(), true); + } + } + + @Override + public void assembleStaffList(List list) { + if (CollectionUtils.isEmptyElement(list)) { + return; + } + + List staffList = storeStaffService.selectListByStoreIds(CollectionUtils.map(list, StoreVo::getStoreId)); + + for (StoreVo store : list) { + List storeStaffList = staffList.stream() + .filter(staff -> Objects.equals(staff.getStoreId(), store.getStoreId())) + .collect(Collectors.toList()); + store.setStaffList(storeStaffList); + } + } } 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 40dcf004..e3e22524 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 @@ -1,5 +1,17 @@ package com.ruoyi.ss.store.service.impl; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionTemplate; + import com.github.pagehelper.PageHelper; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; @@ -7,7 +19,12 @@ import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.ss.device.domain.DeviceQuery; import com.ruoyi.ss.device.service.DeviceService; -import com.ruoyi.ss.store.domain.*; +import com.ruoyi.ss.store.domain.Store; +import com.ruoyi.ss.store.domain.StoreBO; +import com.ruoyi.ss.store.domain.StoreCountVO; +import com.ruoyi.ss.store.domain.StoreNameVO; +import com.ruoyi.ss.store.domain.StoreQuery; +import com.ruoyi.ss.store.domain.StoreVo; import com.ruoyi.ss.store.domain.enums.StoreGroupBy; import com.ruoyi.ss.store.domain.enums.StoreStatus; import com.ruoyi.ss.store.mapper.StoreMapper; @@ -17,18 +34,8 @@ import com.ruoyi.ss.store.service.StoreValidator; import com.ruoyi.ss.storeApply.domain.enums.StoreApplyType; import com.ruoyi.ss.storeApply.service.StoreApplyConverter; import com.ruoyi.ss.storeApply.service.StoreApplyService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionTemplate; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; /** * 店铺Service业务层处理 @@ -70,6 +77,9 @@ public class StoreServiceImpl implements StoreService @Override public StoreVo selectSmStoreById(Long storeId) { + if (storeId == null) { + return null; + } return storeMapper.selectSmStoreById(storeId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaff.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaff.java index 64ef9919..03fde6d2 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaff.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaff.java @@ -3,18 +3,17 @@ package com.ruoyi.ss.storeStaff.domain; import java.math.BigDecimal; import java.util.List; -import com.ruoyi.common.core.domain.ValidGroup; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; - import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.domain.ValidGroup; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + /** * 店铺员工对象 ss_store_staff * @@ -49,6 +48,12 @@ public class StoreStaff extends BaseEntity @Max(value = 100, message = "分成比例不允许大于100") private BigDecimal point; + @Excel(name = "VIP分成比例") + @ApiModelProperty("VIP分成比例") + @Min(value = 0, message = "VIP分成比例不允许小于0") + @Max(value = 100, message = "VIP分成比例不允许大于100") + private BigDecimal vipPoint; + @Excel(name = "是否启用") @ApiModelProperty("是否启用") @NotNull(message = "是否启用不能为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class}) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaffQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaffQuery.java index 310ee9f1..513675a5 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaffQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaffQuery.java @@ -1,10 +1,10 @@ package com.ruoyi.ss.storeStaff.domain; +import java.util.List; + import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.List; - /** * @author wjh * 2024/11/13 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.java index 9648eb6d..628e62f3 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.java @@ -3,11 +3,12 @@ package com.ruoyi.ss.storeStaff.mapper; import java.math.BigDecimal; import java.util.List; +import org.apache.ibatis.annotations.Param; + import com.ruoyi.common.core.domain.vo.LongCountVO; import com.ruoyi.ss.storeStaff.domain.StoreStaff; -import com.ruoyi.ss.storeStaff.domain.StoreStaffVO; import com.ruoyi.ss.storeStaff.domain.StoreStaffQuery; -import org.apache.ibatis.annotations.Param; +import com.ruoyi.ss.storeStaff.domain.StoreStaffVO; /** * 店铺员工Mapper接口 @@ -81,4 +82,9 @@ public interface StoreStaffMapper * 根据用户统计店员数量 */ List selectCountGroupByUserId(@Param("query") StoreStaffQuery query); + + /** + * 查询VIP分成比例总和 + */ + BigDecimal selectSumOfVipPoint(@Param("query") StoreStaffQuery query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.xml index a572a54d..00e8c640 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.xml @@ -21,6 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sss.create_time, sss.create_by, sss.create_id, + sss.vip_point, ss.name as store_name, ss.user_id as mch_id, if(su.is_real, su.real_name, su.user_name) as user_name @@ -105,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_time, create_by, create_id, + vip_point, #{storeId}, @@ -117,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{createTime}, #{createBy}, #{createId}, + #{vipPoint}, @@ -145,6 +148,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_time = #{data.createTime}, create_by = #{data.createBy}, create_id = #{data.createId}, + vip_point = #{data.vipPoint}, @@ -157,4 +161,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{employId} + + + + + diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffService.java index e22a198d..131f9439 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffService.java @@ -1,13 +1,13 @@ package com.ruoyi.ss.storeStaff.service; +import java.math.BigDecimal; +import java.util.List; + import com.ruoyi.common.core.domain.vo.LongCountVO; import com.ruoyi.ss.storeStaff.domain.StoreStaff; import com.ruoyi.ss.storeStaff.domain.StoreStaffQuery; import com.ruoyi.ss.storeStaff.domain.StoreStaffVO; -import java.math.BigDecimal; -import java.util.List; - /** * 店铺员工Service接口 * @@ -93,4 +93,19 @@ public interface StoreStaffService * 根据店铺查询店铺员工 */ List selectByStoreId(Long storeId); + + /** + * 查询VIP分成比例总和 + */ + BigDecimal selectSumOfVipPointByStoreId(Long storeId); + + /** + * 查询VIP分成比例总和 + */ + BigDecimal selectSumOfVipPoint(StoreStaffQuery query); + + /** + * 根据店铺id查询店铺员工列表 + */ + List selectListByStoreIds(List storeIds); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffServiceImpl.java index f2721c29..7b52f18a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffServiceImpl.java @@ -1,5 +1,13 @@ package com.ruoyi.ss.storeStaff.service.impl; +import java.math.BigDecimal; +import java.util.Collections; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.support.TransactionTemplate; + import com.ruoyi.common.core.domain.vo.LongCountVO; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ServiceUtil; @@ -12,13 +20,6 @@ import com.ruoyi.ss.storeStaff.service.StoreStaffService; import com.ruoyi.ss.storeStaff.service.StoreStaffValidator; import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.UserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.support.TransactionTemplate; - -import java.math.BigDecimal; -import java.util.Collections; -import java.util.List; /** * 店铺员工Service业务层处理 @@ -193,4 +194,31 @@ public class StoreStaffServiceImpl implements StoreStaffService query.setStoreId(storeId); return storeStaffMapper.selectStoreStaffList(query); } + + @Override + public BigDecimal selectSumOfVipPointByStoreId(Long storeId) { + if (storeId == null) { + return BigDecimal.ZERO; + } + StoreStaffQuery query = new StoreStaffQuery(); + query.setStoreId(storeId); + return this.selectSumOfVipPoint(query); + } + + @Override + public BigDecimal selectSumOfVipPoint(StoreStaffQuery query) { + BigDecimal result = storeStaffMapper.selectSumOfVipPoint(query); + return result == null ? BigDecimal.ZERO : result; + } + + @Override + public List selectListByStoreIds(List storeIds) { + if (CollectionUtils.isEmptyElement(storeIds)) { + return Collections.emptyList(); + } + StoreStaffQuery query = new StoreStaffQuery(); + query.setStoreIds(storeIds); + return storeStaffMapper.selectStoreStaffList(query); + } } + diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffValidatorImpl.java index e2938efd..1f52a70f 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffValidatorImpl.java @@ -1,5 +1,12 @@ package com.ruoyi.ss.storeStaff.service.impl; +import java.math.BigDecimal; +import java.util.List; +import java.util.Objects; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.collection.CollectionUtils; @@ -16,12 +23,6 @@ import com.ruoyi.ss.storeStaff.service.StoreStaffValidator; import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.UserAssembler; import com.ruoyi.ss.user.service.UserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Objects; /** * @author wjh @@ -81,6 +82,27 @@ public class StoreStaffValidatorImpl implements StoreStaffValidator { this.checkStorePoint(vo); // 校验设备分成 this.checkDevicePoint(vo); + // 校验VIP分成 + this.checkVipPoint(vo); + } + + // 校验VIP分成 + private void checkVipPoint(StoreStaffVO vo) { + // 查询店铺员工总比例 + BigDecimal totalPoint = storeStaffService.selectSumOfVipPointByStoreId(vo.getStoreId()); + + // 查询店铺商户比例 + SmUserVO mch = userService.selectSimpleById(vo.getMchId()); + BigDecimal mchPoint = mch == null || mch.getVipServiceRate() == null ? BigDecimal.ZERO : mch.getVipServiceRate(); + + // 计算总比例 + totalPoint = totalPoint.add(mchPoint); + if (totalPoint.compareTo(BigDecimal.valueOf(100)) > 0) { + throw new ServiceException(String.format("店铺成员的总分成比例不能超过100%%,当前:%s%%", totalPoint)); + } + if (totalPoint.compareTo(BigDecimal.ZERO) < 0) { + throw new ServiceException("店铺成员的总分成比例不能为负数"); + } } private void checkStorePoint(StoreStaffVO vo) { diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml index bd1342ae..f2ca3ffa 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml @@ -64,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" su.ali_open_id, su.channel_ids, su.app_id, + su.vip_service_rate, if(su.is_real, su.real_name, su.user_name) as real_or_user_name, sa.name as app_name from sm_user su @@ -100,7 +101,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and su.agent_allow_mch_switch != #{agentAllowMchSwitch} and if(su.is_real, su.real_name, su.user_name) like concat('%', #{realOrUserName}, '%') and su.real_id_card = #{eqRealIdCard} - and app_id = #{appId} + and su.app_id = #{appId} + and su.is_real = #{isReal} and su.user_id in ( select sdt.tenant_id @@ -218,6 +220,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ali_open_id, channel_ids, app_id, + vip_service_rate, #{userName}, @@ -269,6 +272,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{aliOpenId}, #{channelIds,typeHandler=com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler}, #{appId}, + #{vipServiceRate}, @@ -336,6 +340,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ali_open_id = #{aliOpenId}, channel_ids = #{channelIds,typeHandler=com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler}, app_id = #{appId}, + vip_service_rate = #{vipServiceRate}, where user_id = #{userId} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserConverterImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserConverterImpl.java index e380fe79..493ad72a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserConverterImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserConverterImpl.java @@ -1,8 +1,9 @@ package com.ruoyi.ss.user.service.impl; +import org.springframework.stereotype.Service; + import com.ruoyi.common.core.domain.entity.SmUser; import com.ruoyi.ss.user.service.UserConverter; -import org.springframework.stereotype.Service; /** * @author wjh @@ -55,6 +56,7 @@ public class UserConverterImpl implements UserConverter { po.setAgentAllowMchSwitch(data.getAgentAllowMchSwitch()); po.setChannelIds(data.getChannelIds()); po.setRemark(data.getRemark()); + po.setVipServiceRate(data.getVipServiceRate()); return po; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserServiceImpl.java index db48a45b..3288d12b 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserServiceImpl.java @@ -1,5 +1,18 @@ package com.ruoyi.ss.user.service.impl; +import java.math.BigDecimal; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionTemplate; + import com.github.pagehelper.PageHelper; import com.ruoyi.common.auth.ali.AliAuthService; import com.ruoyi.common.auth.ali.AliConfig; @@ -60,19 +73,8 @@ import com.ruoyi.system.domain.enums.config.ConfigKey; import com.ruoyi.system.domain.enums.verificationCode.CodeBusinessType; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.IVerificationCodeService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionTemplate; -import java.math.BigDecimal; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; /** * 普通用户信息Service业务层处理 @@ -850,6 +852,11 @@ public class UserServiceImpl implements UserService BigDecimal serviceRate = sysConfigService.getBigDecimal(ConfigKey.SERVICE_FEE_RATE); smUser.setServiceRate(serviceRate); } + // 若用户没有单独设置VIP服务费,则使用系统默认VIP服务费 + if (smUser.getVipServiceRate() == null) { + BigDecimal vipServiceRate = sysConfigService.getBigDecimal(ConfigKey.VIP_SERVICE_FEE_RATE); + smUser.setVipServiceRate(vipServiceRate); + } // 若有wxOpenId,则加锁 if (StringUtils.hasText(smUser.getWxOpenId())) { diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserValidatorImpl.java index aedf87e7..d76dcdb1 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserValidatorImpl.java @@ -1,5 +1,12 @@ package com.ruoyi.ss.user.service.impl; +import java.math.BigDecimal; +import java.util.HashSet; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + import com.ruoyi.common.core.domain.BaseValidator; import com.ruoyi.common.core.domain.ValidateResult; import com.ruoyi.common.core.domain.entity.SmUser; @@ -7,19 +14,20 @@ import com.ruoyi.common.enums.UserStatus; import com.ruoyi.common.enums.UserType; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.collection.CollectionUtils; +import com.ruoyi.ss.bonus.domain.Bonus; +import com.ruoyi.ss.bonus.service.BonusConverter; import com.ruoyi.ss.device.domain.DeviceQuery; +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.store.domain.StoreVo; +import com.ruoyi.ss.store.service.StoreAssembler; +import com.ruoyi.ss.store.service.StoreService; import com.ruoyi.ss.user.domain.SmUserQuery; import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.UserService; import com.ruoyi.ss.user.service.UserValidator; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.math.BigDecimal; -import java.util.HashSet; -import java.util.List; /** * @author wjh @@ -34,6 +42,18 @@ public class UserValidatorImpl extends BaseValidator implements UserValidator { @Autowired private DeviceService deviceService; + @Autowired + private BonusConverter bonusConverter; + + @Autowired + private DeviceAssembler deviceAssembler; + + @Autowired + private StoreService storeService; + + @Autowired + private StoreAssembler storeAssembler; + /** * 判断用户是否存在 * @@ -125,6 +145,50 @@ public class UserValidatorImpl extends BaseValidator implements UserValidator { // 校验代理商服务费 this.checkAgentServiceRate(vo); + // 校验服务费 + this.checkServiceRate(vo); + + // 校验VIP服务费 + this.checkVipServiceRate(vo); + } + + // 校验VIP服务费 + private void checkVipServiceRate(SmUserVO vo) { + if (vo == null) { + return; + } + // 查询店铺列表 + List storeList = storeService.selectByUserId(vo.getUserId()); + if (CollectionUtils.isEmpty(storeList)) { + return; + } + // 拼接店铺分成 + storeAssembler.assembleBonusList(storeList); + // 拼接商户VIP服务费 + for (StoreVo store : storeList) { + BigDecimal totalPoint = CollectionUtils.sumDecimal(store.getBonusList(), Bonus::getPoint); + ServiceUtil.assertion(totalPoint.compareTo(BigDecimal.valueOf(100)) > 0, "校验商户VIP服务费失败,店铺【%s】的分成总和大于100%,当前值:%s%%", store.getName(), totalPoint); + } + } + + // 校验服务费 + private void checkServiceRate(SmUserVO vo) { + if (vo == null) { + return; + } + // 查询设备列表 + List deviceList = deviceService.selectByMchId(vo.getUserId()); + if (CollectionUtils.isEmpty(deviceList)) { + return; + } + // 拼接设备分成 + deviceAssembler.assembleBonusList(deviceList); + // 校验设备分成 + for (DeviceVO device : deviceList) { + BigDecimal totalPoint = CollectionUtils.sumDecimal(device.getBonusList(), Bonus::getPoint); + ServiceUtil.assertion(totalPoint.compareTo(BigDecimal.valueOf(100)) > 0, "校验商户服务费失败,设备【%s】的分成总和大于100%,当前值:%s%%", device.getDeviceNo(), totalPoint); + } + } @Override diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/vipOrder/service/VipOrderService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/vipOrder/service/VipOrderService.java index 8da41248..b6fa849b 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/vipOrder/service/VipOrderService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/vipOrder/service/VipOrderService.java @@ -1,13 +1,13 @@ package com.ruoyi.ss.vipOrder.service; +import java.util.List; + import com.ruoyi.ss.vipOrder.domain.VipOrder; import com.ruoyi.ss.vipOrder.domain.VipOrderQuery; import com.ruoyi.ss.vipOrder.domain.VipOrderVO; import com.ruoyi.ss.vipOrder.domain.bo.AddPayVipOrderBO; import com.ruoyi.ss.vipOrder.domain.vo.AddAndPayVO; -import java.util.List; - /** * 会员订单Service接口 * diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmChannelController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmChannelController.java index a0877c4f..6aa9b080 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmChannelController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmChannelController.java @@ -1,5 +1,21 @@ package com.ruoyi.web.controller.ss; +import java.util.List; + +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -10,14 +26,8 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.ss.channel.domain.Channel; import com.ruoyi.ss.channel.domain.ChannelQuery; import com.ruoyi.ss.channel.domain.ChannelVO; +import com.ruoyi.ss.channel.domain.vo.ChannelNameVO; import com.ruoyi.ss.channel.service.ChannelService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.util.List; /** * 充值渠道Controller @@ -44,6 +54,17 @@ public class SmChannelController extends BaseController return getDataTable(list); } + /** + * 查询全部充值渠道列表 + */ + @PreAuthorize("@ss.hasPermi('system:channel:list')") + @GetMapping("/listAll") + public AjaxResult listAll() + { + List list = smChannelService.selectAllChannelNameList(); + return success(list); + } + /** * 查询充值渠道列表 */ @@ -124,7 +145,7 @@ public class SmChannelController extends BaseController } /** - * 新增充值渠道 + * 删除充值渠道 */ @PreAuthorize("@ss.hasPermi('system:channel:delete')") @Log(title = "充值渠道", businessType = BusinessType.DELETE) diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmUserController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmUserController.java index 82a42794..7c973be6 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmUserController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmUserController.java @@ -1,5 +1,23 @@ package com.ruoyi.web.controller.ss; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -13,16 +31,8 @@ import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.UserAssembler; import com.ruoyi.ss.user.service.UserConverter; import com.ruoyi.ss.user.service.UserService; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import io.swagger.annotations.ApiOperation; /** * 普通用户信息Controller @@ -149,7 +159,7 @@ public class SmUserController extends BaseController } /** - * 删除普通用户信息 + * 解除实名认证 */ @PreAuthorize("@ss.hasPermi('system:smUser:unbindRealName')") @Log(title = "解除实名认证", businessType = BusinessType.OTHER)