店铺员工、提现debug
This commit is contained in:
parent
dab9f0c143
commit
8760f7a39e
smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/utils/collection
smart-switch-service/src/main/java/com/ruoyi/ss
bonus
device
domain/vo
service
store/service
storeStaff
domain
mapper
service
transactionBill
domain/bo
service/impl
transfer/service/impl
smart-switch-web/src/main/java/com/ruoyi/web/controller
|
@ -1,6 +1,7 @@
|
|||
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;
|
||||
|
@ -169,4 +170,11 @@ public class CollectionUtils extends org.springframework.util.CollectionUtils {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算集合中BigDecimal的和
|
||||
*/
|
||||
public static <T> BigDecimal sumDecimal(Collection<T> collection, Function<T, BigDecimal> decimalMapper) {
|
||||
return collection.stream().map(decimalMapper).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,8 @@ public enum BonusArrivalType {
|
|||
|
||||
PLATFORM("1", "平台"),
|
||||
AGENT("2", "代理商"),
|
||||
MCH("3", "商户");
|
||||
MCH("3", "商户"),
|
||||
STAFF("4", "员工");
|
||||
|
||||
private final String type;
|
||||
private final String msg;
|
||||
|
@ -50,7 +51,7 @@ public enum BonusArrivalType {
|
|||
* 用户表
|
||||
*/
|
||||
public static List<String> userList() {
|
||||
return asList(AGENT, MCH);
|
||||
return asList(AGENT, MCH, STAFF);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,10 +3,8 @@ package com.ruoyi.ss.bonus.service;
|
|||
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.transactionBill.domain.bo.RechargeBO;
|
||||
import com.ruoyi.ss.transactionBill.domain.dto.RechargePayBO;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffVO;
|
||||
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
|
||||
import com.ruoyi.ss.user.domain.SmUserVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -15,27 +13,10 @@ import java.util.List;
|
|||
* 2024/8/20
|
||||
*/
|
||||
public interface BonusConverter {
|
||||
|
||||
/**
|
||||
* 支付转为分成明细
|
||||
* 生产分成列表
|
||||
*/
|
||||
List<Bonus> toPo(RechargePayBO bo);
|
||||
|
||||
/**
|
||||
* 订单转为分成明细
|
||||
*/
|
||||
List<Bonus> toPo(RechargeBO bo);
|
||||
|
||||
/**
|
||||
* 生成分成列表
|
||||
*
|
||||
* @param mch
|
||||
* @param agent
|
||||
* @param platform
|
||||
* @param device
|
||||
* @return
|
||||
*/
|
||||
List<Bonus> genBonusList(SmUserVO mch, SmUserVO agent, SysDept platform, DeviceVO device);
|
||||
List<Bonus> toPoList(SysDept platform, DeviceVO device, List<StoreStaffVO> staffList);
|
||||
|
||||
/**
|
||||
* 旧订单转为分成明细
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.ruoyi.ss.bonus.service.impl;
|
|||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.bonus.domain.Bonus;
|
||||
import com.ruoyi.ss.bonus.domain.enums.BonusArrivalType;
|
||||
import com.ruoyi.ss.bonus.domain.enums.BonusStatus;
|
||||
|
@ -11,16 +11,8 @@ import com.ruoyi.ss.bonus.service.BonusConverter;
|
|||
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.service.StoreService;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
|
||||
import com.ruoyi.ss.transactionBill.domain.bo.RechargeBO;
|
||||
import com.ruoyi.ss.transactionBill.domain.dto.RechargePayBO;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffVO;
|
||||
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
|
||||
import com.ruoyi.ss.user.domain.SmUserVO;
|
||||
import com.ruoyi.ss.user.service.ISmUserService;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -41,68 +33,15 @@ import java.util.stream.Stream;
|
|||
@Service
|
||||
public class BonusConverterImpl implements BonusConverter {
|
||||
|
||||
@Autowired
|
||||
private ISmUserService userService;
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@Autowired
|
||||
private TransactionBillService transactionBillService;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService sysConfigService;
|
||||
|
||||
@Autowired
|
||||
private DeviceAssembler deviceAssembler;
|
||||
|
||||
/**
|
||||
* 订单转为分成明细
|
||||
*
|
||||
* @param bo
|
||||
*/
|
||||
@Override
|
||||
public List<Bonus> toPo(RechargePayBO bo) {
|
||||
if (bo == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
TransactionBill bill = bo.getOrder();
|
||||
if (bill == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Bonus> result = genBonusList(bo.getMch(), null, bo.getPlatform(), bo.getDevice());
|
||||
|
||||
for (Bonus bonus : result) {
|
||||
bonus.setBillId(bill.getBillId());
|
||||
bonus.setBillNo(bill.getBillNo());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Bonus> toPo(RechargeBO bo) {
|
||||
if (bo == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
TransactionBill bill = bo.getOrder();
|
||||
if (bill == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return genBonusList(bo.getMch(), bo.getAgent(), bo.getPlatform(), bo.getDevice());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Bonus> genBonusList(SmUserVO mch, SmUserVO agent, SysDept platform, DeviceVO device) {
|
||||
public List<Bonus> toPoList(SysDept platform, DeviceVO device, List<StoreStaffVO> staffList) {
|
||||
List<Bonus> result = new ArrayList<>();
|
||||
if (mch == null || platform == null || device == null) {
|
||||
if (platform == null || device == null) {
|
||||
return result;
|
||||
}
|
||||
// 剩余可分配的分成比例
|
||||
|
@ -115,35 +54,61 @@ public class BonusConverterImpl implements BonusConverter {
|
|||
|
||||
// 按照百分比收取服务费
|
||||
BigDecimal serviceRate = device.getRealServiceRate(); // 服务费比例
|
||||
result.add(this.toPo(platform, serviceRate));
|
||||
|
||||
Bonus platformBonus = this.toPo(platform, serviceRate);
|
||||
result.add(platformBonus);
|
||||
point = point.subtract(serviceRate);
|
||||
}
|
||||
// 代理模式
|
||||
else if (DeviceServiceMode.AGENT.getMode().equals(device.getServiceMode())) {
|
||||
// 平台收取服务费
|
||||
ServiceUtil.assertion(agent == null, "代理商不存在,请联系管理员处理");
|
||||
ServiceUtil.assertion(agent.getAgentServiceRate() == null, "代理商服务费未配置");
|
||||
ServiceUtil.assertion(device.getAgentServiceRate() == null, "代理商设备服务费未配置");
|
||||
// 平台收取代理商的服务费
|
||||
BigDecimal platformAgentServiceRate = device.getAgentUserServiceRate() == null ? BigDecimal.ZERO : device.getAgentUserServiceRate();
|
||||
// 代理商给商户设备设置的服务费
|
||||
BigDecimal agentMchServiceRate = device.getAgentServiceRate() == null ? BigDecimal.ZERO : device.getAgentServiceRate();
|
||||
|
||||
result.add(this.toPo(platform, agent.getAgentServiceRate()));
|
||||
point = point.subtract(agent.getAgentServiceRate());
|
||||
// 添加平台服务费
|
||||
Bonus platformBonus = this.toPo(platform, platformAgentServiceRate);
|
||||
result.add(platformBonus);
|
||||
point = point.subtract(platformAgentServiceRate);
|
||||
|
||||
// 代理商收取服务费
|
||||
BigDecimal agentArrivalPoint = device.getAgentServiceRate().subtract(agent.getAgentServiceRate());
|
||||
result.add(this.toPo(agent, agentArrivalPoint, agent.getUserId().toString(), BonusArrivalType.AGENT));
|
||||
point = point.subtract(agentArrivalPoint);
|
||||
// 添加代理服务费
|
||||
// 代理商收取服务费 = 代理商给商户的服务费 - 平台收取代理商的服务费
|
||||
if (device.getAgentId() != null) {
|
||||
BigDecimal agentArrivalPoint = agentMchServiceRate.subtract(platformAgentServiceRate);
|
||||
Bonus agentBonus = this.toPo(device.getAgentId(), device.getAgentName(), agentArrivalPoint, device.getAgentId().toString(), BonusArrivalType.AGENT);
|
||||
if (agentBonus != null) {
|
||||
result.add(agentBonus);
|
||||
point = point.subtract(agentArrivalPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ServiceUtil.assertion(point.compareTo(BigDecimal.ZERO) < 0, "商户剩余分成不允许小于0");
|
||||
ServiceUtil.assertion(point.compareTo(BigDecimal.valueOf(100)) > 0, "商户剩余分成不允许大于100");
|
||||
// 若有员工,则判断是否有分成
|
||||
if (CollectionUtils.isNotEmptyElement(staffList)) {
|
||||
for (StoreStaffVO staff : staffList) {
|
||||
if (staff == null || staff.getPoint().compareTo(BigDecimal.ZERO) == 0 || staff.getEnabled() == null || !staff.getEnabled()) {
|
||||
continue;
|
||||
}
|
||||
String staffAncestors = Stream.of(device.getUserId(), staff.getUserId())
|
||||
.filter(Objects::nonNull)
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.joining(","));
|
||||
Bonus staffBonus = this.toPo(staff.getUserId(), staff.getUserName(), staff.getPoint(), staffAncestors, BonusArrivalType.STAFF);
|
||||
if (staffBonus != null) {
|
||||
result.add(staffBonus);
|
||||
point = point.subtract(staffBonus.getPoint());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 剩余的给商户
|
||||
String ancestors = Stream.of(device.getAgentId(), device.getUserId())
|
||||
.filter(Objects::nonNull)
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.joining(","));
|
||||
result.add(this.toPo(mch, point, ancestors, BonusArrivalType.MCH));
|
||||
Bonus mchBonus = this.toPo(device.getUserId(), device.getUserName(), point, ancestors, BonusArrivalType.MCH);
|
||||
if (mchBonus != null) {
|
||||
result.add(mchBonus);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -223,15 +188,15 @@ public class BonusConverterImpl implements BonusConverter {
|
|||
return po;
|
||||
}
|
||||
|
||||
private Bonus toPo(SmUserVO user, BigDecimal point, String ancestors, BonusArrivalType arrivalType) {
|
||||
if (user == null || point == null) {
|
||||
private Bonus toPo(Long userId, String userName, BigDecimal point, String ancestors, BonusArrivalType arrivalType) {
|
||||
if (userId == null || point == null || point.compareTo(BigDecimal.ZERO) < 0 || point.compareTo(new BigDecimal(100)) > 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Bonus po = new Bonus();
|
||||
po.setStatus(BonusStatus.UN_DIVIDEND.getStatus());
|
||||
po.setArrivalId(user.getUserId());
|
||||
po.setArrivalName(user.getRealOrUserName());
|
||||
po.setArrivalId(userId);
|
||||
po.setArrivalName(userName);
|
||||
po.setArrivalType(arrivalType.getType());
|
||||
po.setPoint(point);
|
||||
po.setAncestors(ancestors);
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.ruoyi.common.core.domain.JsonViewProfile;
|
||||
import com.ruoyi.iot.interfaces.IotDevice;
|
||||
import com.ruoyi.ss.bonus.domain.Bonus;
|
||||
import com.ruoyi.ss.device.domain.Device;
|
||||
import com.ruoyi.ss.device.domain.DeviceView;
|
||||
import com.ruoyi.ss.suit.domain.SuitVO;
|
||||
|
@ -104,6 +105,9 @@ public class DeviceVO extends Device implements IotDevice {
|
|||
@JsonView(JsonViewProfile.App.class)
|
||||
private Boolean allowSwitch;
|
||||
|
||||
@ApiModelProperty("分成比例列表")
|
||||
private List<Bonus> bonusList;
|
||||
|
||||
@Override
|
||||
public String iotMac1() {
|
||||
return getMac();
|
||||
|
|
|
@ -51,4 +51,13 @@ public interface DeviceAssembler {
|
|||
default void assembleAllowSwitch(DeviceVO device, Long userId) {
|
||||
assembleAllowSwitch(Collections.singletonList(device), userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接分成比例列表
|
||||
*/
|
||||
void assembleBonusList(List<DeviceVO> list);
|
||||
|
||||
default void assembleBonusList(DeviceVO device) {
|
||||
this.assembleBonusList(Collections.singletonList(device));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,4 +98,9 @@ public interface DeviceValidator {
|
|||
* 判断代理商是否允许商户开关
|
||||
*/
|
||||
boolean isAgentAllowMchSwitch(DeviceVO device);
|
||||
|
||||
/**
|
||||
* 校验分成
|
||||
*/
|
||||
void checkBonus(DeviceVO device);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package com.ruoyi.ss.device.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.ss.bonus.domain.Bonus;
|
||||
import com.ruoyi.ss.bonus.service.BonusConverter;
|
||||
import com.ruoyi.ss.device.domain.enums.DeviceServiceMode;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.device.service.DeviceAssembler;
|
||||
|
@ -14,6 +18,9 @@ import com.ruoyi.ss.deviceSuit.service.DeviceSuitService;
|
|||
import com.ruoyi.ss.store.domain.StoreQuery;
|
||||
import com.ruoyi.ss.store.domain.StoreVo;
|
||||
import com.ruoyi.ss.store.service.StoreService;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffQuery;
|
||||
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;
|
||||
|
@ -21,6 +28,7 @@ import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillType;
|
|||
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
|
||||
import com.ruoyi.system.domain.enums.config.ConfigKey;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -50,6 +58,15 @@ public class DeviceAssemblerImpl implements DeviceAssembler {
|
|||
@Autowired
|
||||
private DeviceValidator deviceValidator;
|
||||
|
||||
@Autowired
|
||||
private BonusConverter bonusConverter;
|
||||
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@Autowired
|
||||
private StoreStaffService storeStaffService;
|
||||
|
||||
/**
|
||||
* 拼接套餐列表
|
||||
*
|
||||
|
@ -218,4 +235,31 @@ public class DeviceAssemblerImpl implements DeviceAssembler {
|
|||
device.setAllowSwitch(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assembleBonusList(List<DeviceVO> list) {
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SysDept platform = deptService.selectDeptById(Constants.ROOT_DEPT);
|
||||
|
||||
// 查询店铺员工
|
||||
List<Long> storeIds = CollectionUtils.map(list, DeviceVO::getStoreId);
|
||||
Map<Long, List<StoreStaffVO>> staffGroup = null;
|
||||
if (CollectionUtils.isNotEmptyElement(storeIds)) {
|
||||
StoreStaffQuery query = new StoreStaffQuery();
|
||||
query.setStoreIds(storeIds);
|
||||
staffGroup = storeStaffService.selectStoreStaffList(query).stream().collect(Collectors.groupingBy(StoreStaffVO::getStoreId));
|
||||
}
|
||||
|
||||
for (DeviceVO device : list) {
|
||||
List<StoreStaffVO> staffList = null;
|
||||
if (staffGroup != null && device.getStoreId() != null) {
|
||||
staffList = staffGroup.get(device.getStoreId());
|
||||
}
|
||||
List<Bonus> bonusList = bonusConverter.toPoList(platform, device, staffList);
|
||||
device.setBonusList(bonusList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,6 +192,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
|
||||
// 后校验
|
||||
DeviceVO vo = this.selectById(data.getDeviceId());
|
||||
deviceAssembler.assembleBonusList(vo);
|
||||
deviceValidator.afterCheck(vo);
|
||||
|
||||
// 创建OneNet设备1
|
||||
|
@ -314,9 +315,11 @@ public class DeviceServiceImpl implements DeviceService
|
|||
|
||||
@Override
|
||||
public List<DeviceVO> selectSmDeviceByStoreId(Long storeId) {
|
||||
if (storeId == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
DeviceQuery dto = new DeviceQuery();
|
||||
dto.setStoreId(storeId);
|
||||
dto.setDeleted(false);
|
||||
return deviceMapper.selectSmDeviceList(dto);
|
||||
}
|
||||
|
||||
|
@ -756,6 +759,8 @@ public class DeviceServiceImpl implements DeviceService
|
|||
// 后校验
|
||||
DeviceVO vo = this.selectById(deviceId);
|
||||
deviceValidator.checkAgent(vo);
|
||||
deviceAssembler.assembleBonusList(vo);
|
||||
deviceValidator.checkBonus(vo);
|
||||
|
||||
// 添加绑定记录
|
||||
int record = smDeviceBindRecordService.record(agentId, deviceId, BindRecordType.BIND, BindRecordUserType.AGENT);
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.ruoyi.common.utils.SecurityUtils;
|
|||
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.device.domain.DeviceBO;
|
||||
import com.ruoyi.ss.device.domain.DeviceQuery;
|
||||
import com.ruoyi.ss.device.domain.enums.DeviceServiceMode;
|
||||
|
@ -24,6 +25,7 @@ import com.ruoyi.ss.user.service.impl.SmUserServiceImpl;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -191,11 +193,14 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato
|
|||
if (vo == null) {
|
||||
return;
|
||||
}
|
||||
// 校验MAC
|
||||
this.checkMac(vo.getDeviceId(), vo.getMac(), vo.getMac2());
|
||||
// 校验SN
|
||||
this.checkSn(vo.getDeviceId(), vo.getDeviceNo());
|
||||
|
||||
// 校验代理商
|
||||
this.checkAgent(vo);
|
||||
// 校验分成
|
||||
this.checkBonus(vo);
|
||||
|
||||
}
|
||||
|
||||
|
@ -210,6 +215,7 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato
|
|||
ServiceUtil.assertion(vo.getAgentServiceRate() == null || vo.getAgentUserServiceRate() == null, "设备代理商服务费或平台代理商服务费不允许为空");
|
||||
ServiceUtil.assertion(vo.getAgentServiceRate().compareTo(vo.getAgentUserServiceRate()) < 0,
|
||||
"设备服务费不允许小于平台收取代理商的服务费:" + vo.getAgentUserServiceRate() + "%");
|
||||
ServiceUtil.assertion(vo.getAgentServiceRate().compareTo(new BigDecimal(100)) > 0, "代理服务费不允许超过100%");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,4 +262,21 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkBonus(DeviceVO device) {
|
||||
if (device == null || CollectionUtils.isEmpty(device.getBonusList())) {
|
||||
return;
|
||||
}
|
||||
BigDecimal decimal100 = new BigDecimal(100);
|
||||
|
||||
BigDecimal sumPoint = CollectionUtils.sumDecimal(device.getBonusList(), Bonus::getPoint);
|
||||
ServiceUtil.assertion(sumPoint.compareTo(decimal100) > 0, "设备%s的总分成比例不允许超过100", device.getDeviceNo());
|
||||
|
||||
// 不允许分成小于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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.ruoyi.ss.store.domain.StoreBO;
|
|||
import com.ruoyi.ss.store.domain.StoreVo;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -69,6 +70,10 @@ public interface StoreValidator {
|
|||
*/
|
||||
boolean isStoreBelongUser(List<Long> storeId, Long userId);
|
||||
|
||||
default boolean isStoreBelongUser(Long storeId, Long userId) {
|
||||
return isStoreBelongUser(Collections.singletonList(storeId), userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断店铺是否属于用户
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* 店铺员工对象 ss_store_staff
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-13
|
||||
*/
|
||||
@Data
|
||||
public class StoreStaff extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long employId;
|
||||
|
||||
@Excel(name = "店铺ID")
|
||||
@ApiModelProperty("店铺ID")
|
||||
@NotNull(message = "店铺不能为空", groups = {ValidGroup.Create.class})
|
||||
private Long storeId;
|
||||
|
||||
@Excel(name = "用户ID")
|
||||
@ApiModelProperty("用户ID")
|
||||
@NotNull(message = "用户不能为空", groups = {ValidGroup.Create.class})
|
||||
private Long userId;
|
||||
|
||||
@Excel(name = "角色", readConverterExp = "1=店铺所有人,2=员工")
|
||||
@ApiModelProperty("角色")
|
||||
@NotNull(message = "角色不能为空", groups = {ValidGroup.Create.class})
|
||||
private String role;
|
||||
|
||||
@Excel(name = "分成比例")
|
||||
@ApiModelProperty("分成比例")
|
||||
@NotNull(message = "分成比例不能为空", groups = {ValidGroup.Create.class})
|
||||
@Min(value = 0, message = "分成比例不允许小于0")
|
||||
@Max(value = 100, message = "分成比例不允许大于100")
|
||||
private BigDecimal point;
|
||||
|
||||
@Excel(name = "是否启用")
|
||||
@ApiModelProperty("是否启用")
|
||||
@NotNull(message = "是否启用不能为空", groups = {ValidGroup.Create.class})
|
||||
private Boolean enabled;
|
||||
|
||||
@Excel(name = "权限列表", readConverterExp = "1=查看店铺,2=操作店铺,3=查看设备,4=操作设备,5=查看订单,6=操作订单")
|
||||
@ApiModelProperty("权限列表")
|
||||
private List<String> permissions;
|
||||
|
||||
@Excel(name = "创建人ID")
|
||||
@ApiModelProperty("创建人ID")
|
||||
private Long createId;
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.ruoyi.ss.storeStaff.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/11/13
|
||||
*/
|
||||
@Data
|
||||
public class StoreStaffQuery extends StoreStaffVO {
|
||||
|
||||
@ApiModelProperty("ID列表")
|
||||
private List<Long> employIds;
|
||||
|
||||
@ApiModelProperty("排除的店铺员工ID")
|
||||
private Long excludeEmployId;
|
||||
|
||||
@ApiModelProperty("店铺ID列表")
|
||||
private List<Long> storeIds;
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.ruoyi.ss.storeStaff.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/11/13
|
||||
*/
|
||||
@Data
|
||||
public class StoreStaffVO extends StoreStaff{
|
||||
|
||||
@ApiModelProperty("店铺名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty("用户名称")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("商户ID")
|
||||
private Long mchId;
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.ruoyi.ss.storeStaff.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 店铺员工Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-13
|
||||
*/
|
||||
public interface StoreStaffMapper
|
||||
{
|
||||
/**
|
||||
* 查询店铺员工
|
||||
*
|
||||
* @param employId 店铺员工主键
|
||||
* @return 店铺员工
|
||||
*/
|
||||
public StoreStaffVO selectStoreStaffByEmployId(Long employId);
|
||||
|
||||
/**
|
||||
* 查询店铺员工列表
|
||||
*
|
||||
* @param query 店铺员工
|
||||
* @return 店铺员工集合
|
||||
*/
|
||||
public List<StoreStaffVO> selectStoreStaffList(@Param("query")StoreStaffQuery query);
|
||||
|
||||
/**
|
||||
* 新增店铺员工
|
||||
*
|
||||
* @param storeStaff 店铺员工
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertStoreStaff(StoreStaff storeStaff);
|
||||
|
||||
/**
|
||||
* 修改店铺员工
|
||||
*
|
||||
* @param storeStaff 店铺员工
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateStoreStaff(@Param("data") StoreStaff storeStaff);
|
||||
|
||||
/**
|
||||
* 删除店铺员工
|
||||
*
|
||||
* @param employId 店铺员工主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStoreStaffByEmployId(Long employId);
|
||||
|
||||
/**
|
||||
* 批量删除店铺员工
|
||||
*
|
||||
* @param employIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStoreStaffByEmployIds(@Param("employIds") List<Long> employIds);
|
||||
|
||||
/**
|
||||
* 查询分成比例总和
|
||||
*/
|
||||
BigDecimal selectSumOfPoint(@Param("query") StoreStaffQuery query);
|
||||
|
||||
/**
|
||||
* 查询数量
|
||||
*/
|
||||
int selectCount(@Param("query") StoreStaffQuery query);
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ss.storeStaff.mapper.StoreStaffMapper">
|
||||
|
||||
<resultMap type="StoreStaffVO" id="StoreStaffResult" autoMapping="true">
|
||||
<result property="permissions" column="permissions" typeHandler="com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectStoreStaffVo">
|
||||
select
|
||||
sss.employ_id,
|
||||
sss.store_id,
|
||||
sss.user_id,
|
||||
sss.remark,
|
||||
sss.role,
|
||||
sss.point,
|
||||
sss.enabled,
|
||||
sss.permissions,
|
||||
sss.create_time,
|
||||
sss.create_by,
|
||||
sss.create_id,
|
||||
ss.name as store_name,
|
||||
ss.user_id as mch_id,
|
||||
su.user_name as user_name
|
||||
from ss_store_staff sss
|
||||
left join sm_store ss on ss.store_id = sss.store_id
|
||||
left join sm_user su on su.user_id = sss.user_id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.employId != null "> and sss.employ_id = #{query.employId}</if>
|
||||
<if test="query.storeId != null "> and sss.store_id = #{query.storeId}</if>
|
||||
<if test="query.userId != null "> and sss.user_id = #{query.userId}</if>
|
||||
<if test="query.remark != null and query.remark != ''"> and sss.remark like concat('%', #{query.remark}, '%')</if>
|
||||
<if test="query.role != null and query.role != ''"> and sss.role = #{query.role}</if>
|
||||
<if test="query.point != null "> and sss.point = #{query.point}</if>
|
||||
<if test="query.enabled != null "> and sss.enabled = #{query.enabled}</if>
|
||||
<if test="query.createId != null "> and sss.create_id = #{query.createId}</if>
|
||||
<if test="query.storeName != null and query.storeName != ''">and ss.name like concat('%', #{query.storeName}, '%')</if>
|
||||
<if test="query.userName != null and query.userName != ''">and su.user_name like concat('%', #{query.userName}, '%')</if>
|
||||
<if test="query.mchId != null">and ss.user_id = #{query.mchId}</if>
|
||||
<if test="query.excludeEmployId != null">
|
||||
and sss.employ_id != #{query.excludeEmployId}
|
||||
</if>
|
||||
<if test="query.storeIds != null and query.storeIds.size() > 0">
|
||||
and sss.store_id in
|
||||
<foreach collection="query.storeIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectStoreStaffList" parameterType="StoreStaffQuery" resultMap="StoreStaffResult">
|
||||
<include refid="selectStoreStaffVo"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectStoreStaffByEmployId" parameterType="Long" resultMap="StoreStaffResult">
|
||||
<include refid="selectStoreStaffVo"/>
|
||||
where sss.employ_id = #{employId}
|
||||
</select>
|
||||
|
||||
<select id="selectSumOfPoint" resultType="java.math.BigDecimal">
|
||||
select sum(sss.point)
|
||||
from ss_store_staff sss
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectCount" resultType="java.lang.Integer">
|
||||
select count(sss.employ_id)
|
||||
from ss_store_staff sss
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertStoreStaff" parameterType="StoreStaff" useGeneratedKeys="true" keyProperty="employId">
|
||||
insert into ss_store_staff
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="storeId != null">store_id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="role != null and role != ''">`role`,</if>
|
||||
<if test="point != null">`point`,</if>
|
||||
<if test="enabled != null">enabled,</if>
|
||||
<if test="permissions != null and permissions != ''">permissions,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createId != null">create_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="storeId != null">#{storeId},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="role != null and role != ''">#{role},</if>
|
||||
<if test="point != null">#{point},</if>
|
||||
<if test="enabled != null">#{enabled},</if>
|
||||
<if test="permissions != null and permissions != ''">#{permissions,typeHandler=com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createId != null">#{createId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateStoreStaff" parameterType="StoreStaff">
|
||||
update ss_store_staff
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<include refid="updateColumns"/>
|
||||
</trim>
|
||||
where employ_id = #{data.employId}
|
||||
</update>
|
||||
|
||||
<sql id="updateColumns">
|
||||
<if test="data.storeId != null">store_id = #{data.storeId},</if>
|
||||
<if test="data.userId != null">user_id = #{data.userId},</if>
|
||||
<if test="data.remark != null">remark = #{data.remark},</if>
|
||||
<if test="data.role != null and data.role != ''">`role` = #{data.role},</if>
|
||||
<if test="data.point != null">`point` = #{data.point},</if>
|
||||
<if test="data.enabled != null">enabled = #{data.enabled},</if>
|
||||
<if test="data.permissions != null and data.permissions != ''">permissions = #{data.permissions,typeHandler=com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
<if test="data.createBy != null">create_by = #{data.createBy},</if>
|
||||
<if test="data.createId != null">create_id = #{data.createId},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteStoreStaffByEmployId" parameterType="Long">
|
||||
delete from ss_store_staff where employ_id = #{employId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteStoreStaffByEmployIds" parameterType="String">
|
||||
delete from ss_store_staff where employ_id in
|
||||
<foreach item="employId" collection="employIds" open="(" separator="," close=")">
|
||||
#{employId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,80 @@
|
|||
package com.ruoyi.ss.storeStaff.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaff;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffVO;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffQuery;
|
||||
|
||||
/**
|
||||
* 店铺员工Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-13
|
||||
*/
|
||||
public interface StoreStaffService
|
||||
{
|
||||
/**
|
||||
* 查询店铺员工
|
||||
*
|
||||
* @param employId 店铺员工主键
|
||||
* @return 店铺员工
|
||||
*/
|
||||
public StoreStaffVO selectStoreStaffByEmployId(Long employId);
|
||||
|
||||
/**
|
||||
* 查询店铺员工列表
|
||||
*
|
||||
* @param storeStaff 店铺员工
|
||||
* @return 店铺员工集合
|
||||
*/
|
||||
public List<StoreStaffVO> selectStoreStaffList(StoreStaffQuery storeStaff);
|
||||
|
||||
/**
|
||||
* 新增店铺员工
|
||||
*
|
||||
* @param storeStaff 店铺员工
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertStoreStaff(StoreStaff storeStaff);
|
||||
|
||||
/**
|
||||
* 修改店铺员工
|
||||
*
|
||||
* @param storeStaff 店铺员工
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateStoreStaff(StoreStaff storeStaff);
|
||||
|
||||
/**
|
||||
* 批量删除店铺员工
|
||||
*
|
||||
* @param employIds 需要删除的店铺员工主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStoreStaffByEmployIds(List<Long> employIds);
|
||||
|
||||
/**
|
||||
* 删除店铺员工信息
|
||||
*
|
||||
* @param employId 店铺员工主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStoreStaffByEmployId(Long employId);
|
||||
|
||||
/**
|
||||
* 查询分成比例总和
|
||||
*/
|
||||
BigDecimal selectSumOfPoint(StoreStaffQuery query);
|
||||
|
||||
/**
|
||||
* 查询数量
|
||||
*/
|
||||
int selectCount(StoreStaffQuery query);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
StoreStaffVO selectOne(StoreStaffQuery query);
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.ruoyi.ss.storeStaff.service;
|
||||
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaff;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/11/13
|
||||
*/
|
||||
public interface StoreStaffValidator {
|
||||
|
||||
/**
|
||||
* 校验分成比例
|
||||
*/
|
||||
void checkPoint(StoreStaff data);
|
||||
|
||||
/**
|
||||
* 新增、修改后校验
|
||||
*/
|
||||
void afterCheck(StoreStaffVO vo);
|
||||
|
||||
/**
|
||||
* 是否是商户
|
||||
*/
|
||||
boolean isMch(List<Long> employIds, Long userId);
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package com.ruoyi.ss.storeStaff.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.storeStaff.service.StoreStaffValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.ss.storeStaff.mapper.StoreStaffMapper;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaff;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffVO;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffQuery;
|
||||
import com.ruoyi.ss.storeStaff.service.StoreStaffService;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
/**
|
||||
* 店铺员工Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-13
|
||||
*/
|
||||
@Service
|
||||
public class StoreStaffServiceImpl implements StoreStaffService
|
||||
{
|
||||
@Autowired
|
||||
private StoreStaffMapper storeStaffMapper;
|
||||
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
private StoreStaffValidator storeStaffValidator;
|
||||
|
||||
/**
|
||||
* 查询店铺员工
|
||||
*
|
||||
* @param employId 店铺员工主键
|
||||
* @return 店铺员工
|
||||
*/
|
||||
@Override
|
||||
public StoreStaffVO selectStoreStaffByEmployId(Long employId)
|
||||
{
|
||||
return storeStaffMapper.selectStoreStaffByEmployId(employId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询店铺员工列表
|
||||
*
|
||||
* @param storeStaff 店铺员工
|
||||
* @return 店铺员工
|
||||
*/
|
||||
@Override
|
||||
public List<StoreStaffVO> selectStoreStaffList(StoreStaffQuery storeStaff)
|
||||
{
|
||||
return storeStaffMapper.selectStoreStaffList(storeStaff);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增店铺员工
|
||||
*
|
||||
* @param storeStaff 店铺员工
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertStoreStaff(StoreStaff storeStaff) {
|
||||
storeStaff.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
int insert = storeStaffMapper.insertStoreStaff(storeStaff);
|
||||
ServiceUtil.assertion(insert != 1, "新增店铺员工失败");
|
||||
|
||||
StoreStaffVO vo = this.selectStoreStaffByEmployId(storeStaff.getEmployId());
|
||||
storeStaffValidator.afterCheck(vo);
|
||||
|
||||
return insert;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改店铺员工
|
||||
*
|
||||
* @param storeStaff 店铺员工
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateStoreStaff(StoreStaff storeStaff) {
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
int update = storeStaffMapper.updateStoreStaff(storeStaff);
|
||||
ServiceUtil.assertion(update != 1, "修改店铺员工失败");
|
||||
|
||||
StoreStaffVO vo = this.selectStoreStaffByEmployId(storeStaff.getEmployId());
|
||||
storeStaffValidator.afterCheck(vo);
|
||||
|
||||
return update;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除店铺员工
|
||||
*
|
||||
* @param employIds 需要删除的店铺员工主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteStoreStaffByEmployIds(List<Long> employIds)
|
||||
{
|
||||
return storeStaffMapper.deleteStoreStaffByEmployIds(employIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除店铺员工信息
|
||||
*
|
||||
* @param employId 店铺员工主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteStoreStaffByEmployId(Long employId)
|
||||
{
|
||||
return storeStaffMapper.deleteStoreStaffByEmployId(employId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal selectSumOfPoint(StoreStaffQuery query) {
|
||||
return storeStaffMapper.selectSumOfPoint(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectCount(StoreStaffQuery query) {
|
||||
return storeStaffMapper.selectCount(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoreStaffVO selectOne(StoreStaffQuery query) {
|
||||
List<StoreStaffVO> list = selectStoreStaffList(query);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return null;
|
||||
}
|
||||
return list.get(0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package com.ruoyi.ss.storeStaff.service.impl;
|
||||
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.bonus.domain.Bonus;
|
||||
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.storeStaff.domain.StoreStaff;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffQuery;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffVO;
|
||||
import com.ruoyi.ss.storeStaff.service.StoreStaffService;
|
||||
import com.ruoyi.ss.storeStaff.service.StoreStaffValidator;
|
||||
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
|
||||
* 2024/11/13
|
||||
*/
|
||||
@Service
|
||||
public class StoreStaffValidatorImpl implements StoreStaffValidator {
|
||||
|
||||
@Autowired
|
||||
private DeviceAssembler deviceAssembler;
|
||||
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
private DeviceValidator deviceValidator;
|
||||
|
||||
@Autowired
|
||||
private StoreStaffService storeStaffService;
|
||||
|
||||
@Override
|
||||
public void checkPoint(StoreStaff data) {
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<DeviceVO> deviceList = deviceService.selectSmDeviceByStoreId(data.getStoreId());
|
||||
if (CollectionUtils.isEmptyElement(deviceList)) {
|
||||
return;
|
||||
}
|
||||
deviceAssembler.assembleBonusList(deviceList);
|
||||
|
||||
// 校验设备分成
|
||||
for (DeviceVO device : deviceList) {
|
||||
deviceValidator.checkBonus(device);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCheck(StoreStaffVO vo) {
|
||||
if (vo == null) {
|
||||
return;
|
||||
}
|
||||
// 校验用户是否重复成为店铺员工
|
||||
this.checkRepeatUser(vo.getStoreId(), vo.getUserId(), vo.getEmployId());
|
||||
// 校验分成
|
||||
this.checkPoint(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMch(List<Long> employIds, Long mchId) {
|
||||
if (mchId == null) {
|
||||
return false;
|
||||
}
|
||||
if (CollectionUtils.isEmptyElement(employIds)) {
|
||||
return true;
|
||||
}
|
||||
StoreStaffQuery query = new StoreStaffQuery();
|
||||
query.setEmployIds(employIds);
|
||||
query.setMchId(mchId);
|
||||
List<StoreStaffVO> list = storeStaffService.selectStoreStaffList(query);
|
||||
|
||||
for (Long employId : employIds) {
|
||||
if (employId == null) {
|
||||
continue;
|
||||
}
|
||||
StoreStaffVO staff = list.stream().filter(item -> Objects.equals(employId, item.getEmployId()) && Objects.equals(item.getMchId(), mchId))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (staff == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkRepeatUser(Long storeId, Long userId, Long employId) {
|
||||
if (storeId == null || userId == null) {
|
||||
return;
|
||||
}
|
||||
StoreStaffQuery query = new StoreStaffQuery();
|
||||
query.setStoreId(storeId);
|
||||
query.setUserId(userId);
|
||||
query.setExcludeEmployId(employId);
|
||||
ServiceUtil.assertion(storeStaffService.selectCount(query) > 0, "当前用户已成为店铺员工,请勿重复操作"); ;
|
||||
}
|
||||
}
|
|
@ -41,9 +41,6 @@ public class RechargeBO {
|
|||
// 店铺
|
||||
private StoreVo store;
|
||||
|
||||
// 分成详情
|
||||
private List<Bonus> bonusList;
|
||||
|
||||
// 平台
|
||||
private SysDept platform;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.ruoyi.ss.channel.service.ChannelService;
|
|||
import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawVO;
|
||||
import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService;
|
||||
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.StoreService;
|
||||
|
@ -70,6 +71,9 @@ public class TransactionBillConverterImpl implements TransactionBillConverter {
|
|||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@Autowired
|
||||
private DeviceAssembler deviceAssembler;
|
||||
|
||||
/**
|
||||
* 将参数转为充值BO
|
||||
*
|
||||
|
@ -83,6 +87,7 @@ public class TransactionBillConverterImpl implements TransactionBillConverter {
|
|||
|
||||
DeviceVO device = deviceService.selectByDeviceNo(dto.getDeviceNo());
|
||||
ServiceUtil.assertion(device == null, "设备不存在");
|
||||
deviceAssembler.assembleBonusList(Collections.singletonList(device)); // 拼接分成列表
|
||||
|
||||
StoreVo store = storeService.selectSmStoreById(device.getStoreId());
|
||||
|
||||
|
|
|
@ -265,10 +265,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
|
||||
// 生成订单
|
||||
TransactionBill order = parseToOrder(bo);
|
||||
|
||||
// 生成分成列表
|
||||
List<Bonus> bonusList = bonusConverter.toPo(bo);
|
||||
bo.setBonusList(bonusList);
|
||||
List<Bonus> bonusList = bo.getDevice().getBonusList();
|
||||
|
||||
transactionTemplate.execute(status -> {
|
||||
// 收取月费
|
||||
|
@ -279,13 +276,13 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
int insert = this.insertSmTransactionBill(order);
|
||||
ServiceUtil.assertion(insert != 1, "下单失败");
|
||||
|
||||
// 代理商模式,插入分成列表
|
||||
for (Bonus bonus : bo.getBonusList()) {
|
||||
// 插入分成列表
|
||||
for (Bonus bonus : bonusList) {
|
||||
bonus.setBillId(order.getBillId());
|
||||
bonus.setBillNo(order.getBillNo());
|
||||
}
|
||||
int bonusInsert = bonusService.batchInsert(bo.getBonusList());
|
||||
ServiceUtil.assertion(bonusInsert != bo.getBonusList().size(), "创建分成失败");
|
||||
int bonusInsert = bonusService.batchInsert(bonusList);
|
||||
ServiceUtil.assertion(bonusInsert != bonusList.size(), "创建分成失败");
|
||||
|
||||
return insert;
|
||||
});
|
||||
|
@ -302,9 +299,9 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
// 处理充值服务费
|
||||
private void handleRechargeService(RechargePayBO bo) {
|
||||
|
||||
TransactionBillVO order = bo.getOrder();
|
||||
|
||||
List<Bonus> bonusList = bonusConverter.toPo(bo);
|
||||
// TransactionBillVO order = bo.getOrder();
|
||||
//
|
||||
// List<Bonus> bonusList = bonusConverter.toPo(bo);
|
||||
|
||||
// 获取商户的服务费配置
|
||||
// UserRechargeServiceVO userRechargeService = this.getMchRechargeService(bo.getChannel(), bo.getMch(), bo.getDevice());
|
||||
|
|
|
@ -10,6 +10,8 @@ import com.ruoyi.ss.transfer.domain.enums.TransferStatus;
|
|||
import com.ruoyi.ss.transfer.service.TransferConverter;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailVO;
|
||||
import com.ruoyi.ss.transferDetail.domain.enums.TransferDetailStatus;
|
||||
import com.ruoyi.ss.user.domain.SmUserVO;
|
||||
import com.ruoyi.ss.user.service.ISmUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -26,6 +28,9 @@ public class TransferConverterImpl implements TransferConverter {
|
|||
@Autowired
|
||||
private ChannelWithdrawService channelWithdrawService;
|
||||
|
||||
@Autowired
|
||||
private ISmUserService userService;
|
||||
|
||||
|
||||
/**
|
||||
* 提现转为转账单VO
|
||||
|
@ -39,6 +44,10 @@ public class TransferConverterImpl implements TransferConverter {
|
|||
// 渠道
|
||||
ChannelWithdrawVO channel = channelWithdrawService.selectChannelWithdrawByChannelId(bill.getChannelId());
|
||||
|
||||
// 用户
|
||||
SmUserVO user = userService.selectSimpleById(bill.getUserId());
|
||||
|
||||
|
||||
// 拼接数据
|
||||
TransferVO vo = new TransferVO();
|
||||
// 渠道转为账户类型
|
||||
|
@ -62,6 +71,9 @@ public class TransferConverterImpl implements TransferConverter {
|
|||
detail.setAmount(bill.getArrivalAmount());
|
||||
detail.setAccountNo(bill.getAccountNo());
|
||||
detail.setRemark(String.format("提现申请%s转账", bill.getBillNo()));
|
||||
if (user != null) {
|
||||
detail.setUserName(user.getRealName());
|
||||
}
|
||||
detailList.add(detail);
|
||||
vo.setDetailList(detailList);
|
||||
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
package com.ruoyi.web.controller.mch;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.ss.store.service.StoreValidator;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaff;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffQuery;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffVO;
|
||||
import com.ruoyi.ss.storeStaff.service.StoreStaffService;
|
||||
import com.ruoyi.ss.storeStaff.service.StoreStaffValidator;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/11/13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mch/storeStaff")
|
||||
public class MchStoreStaffController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private StoreStaffService storeStaffService;
|
||||
|
||||
@Autowired
|
||||
private StoreValidator storeValidator;
|
||||
|
||||
@Autowired
|
||||
private StoreStaffValidator storeStaffValidator;
|
||||
|
||||
@ApiOperation("商户查询店铺员工列表")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(StoreStaffQuery query) {
|
||||
startPage();
|
||||
startOrderBy();
|
||||
query.setMchId(getUserId());
|
||||
List<StoreStaffVO> list = storeStaffService.selectStoreStaffList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ApiOperation("商户获取店铺员工详细信息")
|
||||
@GetMapping(value = "/{employId}")
|
||||
public AjaxResult getInfo(@PathVariable("employId") Long employId)
|
||||
{
|
||||
StoreStaffQuery query = new StoreStaffQuery();
|
||||
query.setMchId(getUserId());
|
||||
query.setEmployId(employId);
|
||||
return success(storeStaffService.selectOne(query));
|
||||
}
|
||||
|
||||
@ApiOperation("商户新增店铺员工")
|
||||
@Log(title = "店铺员工", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) StoreStaff storeStaff) {
|
||||
// 校验店铺是否为本人的
|
||||
if (!storeValidator.isStoreBelongUser(storeStaff.getStoreId(), getUserId())) {
|
||||
return error("您只能操作自己的店铺");
|
||||
}
|
||||
|
||||
storeStaff.setCreateBy(getUsername());
|
||||
storeStaff.setCreateId(getUserId());
|
||||
return toAjax(storeStaffService.insertStoreStaff(storeStaff));
|
||||
}
|
||||
|
||||
@ApiOperation("商户修改店铺员工")
|
||||
@Log(title = "店铺员工", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) StoreStaff storeStaff) {
|
||||
if (storeStaff.getStoreId() != null) {
|
||||
// 校验店铺是否为本人的
|
||||
if (!storeValidator.isStoreBelongUser(storeStaff.getStoreId(), getUserId())) {
|
||||
return error("您只能操作自己的店铺");
|
||||
}
|
||||
}
|
||||
return toAjax(storeStaffService.updateStoreStaff(storeStaff));
|
||||
}
|
||||
|
||||
@ApiOperation("商户删除店铺员工")
|
||||
@Log(title = "店铺员工", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{employIds}")
|
||||
public AjaxResult remove(@PathVariable List<Long> employIds) {
|
||||
if (!storeStaffValidator.isMch(employIds, getUserId())) {
|
||||
return error("您只能操作自己的店铺");
|
||||
}
|
||||
|
||||
return toAjax(storeStaffService.deleteStoreStaffByEmployIds(employIds));
|
||||
}
|
||||
|
||||
}
|
|
@ -87,6 +87,7 @@ public class SmDeviceController extends BaseController
|
|||
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
|
||||
DeviceVO device = deviceService.selectById(deviceId);
|
||||
deviceAssembler.assembleRealServiceRate(device);
|
||||
deviceAssembler.assembleBonusList(device);
|
||||
return success(device);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package com.ruoyi.web.controller.ss;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
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;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaff;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffVO;
|
||||
import com.ruoyi.ss.storeStaff.domain.StoreStaffQuery;
|
||||
import com.ruoyi.ss.storeStaff.service.StoreStaffService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 店铺员工Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ss/storeStaff")
|
||||
public class StoreStaffController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private StoreStaffService storeStaffService;
|
||||
|
||||
/**
|
||||
* 查询店铺员工列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:storeStaff:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(StoreStaffQuery query)
|
||||
{
|
||||
startPage();
|
||||
startOrderBy();
|
||||
List<StoreStaffVO> list = storeStaffService.selectStoreStaffList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出店铺员工列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:storeStaff:export')")
|
||||
@Log(title = "店铺员工", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, StoreStaffQuery query)
|
||||
{
|
||||
List<StoreStaffVO> list = storeStaffService.selectStoreStaffList(query);
|
||||
ExcelUtil<StoreStaffVO> util = new ExcelUtil<StoreStaffVO>(StoreStaffVO.class);
|
||||
util.exportExcel(response, list, "店铺员工数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺员工详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:storeStaff:query')")
|
||||
@GetMapping(value = "/{employId}")
|
||||
public AjaxResult getInfo(@PathVariable("employId") Long employId)
|
||||
{
|
||||
return success(storeStaffService.selectStoreStaffByEmployId(employId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增店铺员工
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:storeStaff:add')")
|
||||
@Log(title = "店铺员工", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) StoreStaff storeStaff)
|
||||
{
|
||||
storeStaff.setCreateBy(getUsername());
|
||||
return toAjax(storeStaffService.insertStoreStaff(storeStaff));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改店铺员工
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:storeStaff:edit')")
|
||||
@Log(title = "店铺员工", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) StoreStaff storeStaff)
|
||||
{
|
||||
return toAjax(storeStaffService.updateStoreStaff(storeStaff));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除店铺员工
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:storeStaff:remove')")
|
||||
@Log(title = "店铺员工", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{employIds}")
|
||||
public AjaxResult remove(@PathVariable List<Long> employIds)
|
||||
{
|
||||
return toAjax(storeStaffService.deleteStoreStaffByEmployIds(employIds));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user