diff --git a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/vo/UserVO.java b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/vo/UserVO.java
index c251904..69128c5 100644
--- a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/vo/UserVO.java
+++ b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/vo/UserVO.java
@@ -44,4 +44,13 @@ public class UserVO extends User {
@ApiModelProperty("爆灯次数")
private Integer lightingNum;
+ @ApiModelProperty("所属商户账号")
+ private String mchName;
+
+ @ApiModelProperty("所属商户昵称")
+ private String mchNickName;
+
+ @ApiModelProperty("所属商户ID")
+ private String mchId;
+
}
diff --git a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLock.java b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLock.java
index 5405fd3..b0be4ab 100644
--- a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLock.java
+++ b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLock.java
@@ -41,6 +41,10 @@ public class RedisLock {
return lock(redisLockKey.getKey() + ":" + key);
}
+ public boolean lock(RedisLockKey redisLockKey, Object key, long seconds) {
+ return lock(redisLockKey.getKey() + ":" + key, String.valueOf(SnowFlakeUtil.newId()), seconds, TimeUnit.SECONDS, retry);
+ }
+
/**
* 获取锁
*/
diff --git a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/enums/RedisLockKey.java b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/enums/RedisLockKey.java
index 42f06fc..3fbf682 100644
--- a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/enums/RedisLockKey.java
+++ b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/enums/RedisLockKey.java
@@ -15,6 +15,7 @@ public enum RedisLockKey {
ORDER_CREATE("order_create", "订单创建"),
PAY_CREATE("create_pay", "创建支付"),
ADD_DEVICE("add_device", "创建设备"),
+ BOOTH_LIGHTING("booth_lighting", "卡座爆灯"),
BOOTH_CHANGE_USER("booth_change_user", "用户换绑卡座"),
BOOTH_BIND_USER("booth_bind_user", "用户绑定卡座");
diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/app/mapper/AppMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/app/mapper/AppMapper.xml
index 34a1d05..94db4be 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/bst/app/mapper/AppMapper.xml
+++ b/ruoyi-service/src/main/java/com/ruoyi/bst/app/mapper/AppMapper.xml
@@ -9,7 +9,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-
select
ba.id,
@@ -21,6 +20,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from bst_app ba
+
+ bst_app ba
+ left join bst_user_app bua on ba.id = bua.app_id
+ left join sys_user su on bua.user_id = su.user_id
+
+
and ba.id = #{query.id}
and ba.name like concat('%', #{query.name}, '%')
@@ -31,6 +36,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
+
+ and su.user_id in
+
+ #{item}
+
+
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
.appAlias("ba.id")
.build()
diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/bindRecord/domain/BindRecordVO.java b/ruoyi-service/src/main/java/com/ruoyi/bst/bindRecord/domain/BindRecordVO.java
index 37fd3d0..a56f6ff 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/bst/bindRecord/domain/BindRecordVO.java
+++ b/ruoyi-service/src/main/java/com/ruoyi/bst/bindRecord/domain/BindRecordVO.java
@@ -8,10 +8,14 @@ import lombok.Data;
public class BindRecordVO extends BindRecord{
- @Excel(name = "用户名称")
- @ApiModelProperty("用户名称")
+ @Excel(name = "用户账号")
+ @ApiModelProperty("用户账号")
private String userName;
+ @Excel(name = "用户昵称")
+ @ApiModelProperty("用户昵称")
+ private String nickName;
+
@Excel(name = "设备名称")
@ApiModelProperty("设备名称")
private String deviceName;
diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/bindRecord/mapper/BindRecordMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/bindRecord/mapper/BindRecordMapper.xml
index 4965163..61f9247 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/bst/bindRecord/mapper/BindRecordMapper.xml
+++ b/ruoyi-service/src/main/java/com/ruoyi/bst/bindRecord/mapper/BindRecordMapper.xml
@@ -20,7 +20,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bbr.create_time,
bbr.type,
bd.device_name,
- su.user_name
+ su.user_name,
+ su.nick_name
from bst_bind_record bbr
left join bst_device bd on bbr.device_id = bd.device_id
left join sys_user su on bbr.user_id = su.user_id
diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/booth/service/impl/BoothServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/bst/booth/service/impl/BoothServiceImpl.java
index bfdba31..cabd5e1 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/bst/booth/service/impl/BoothServiceImpl.java
+++ b/ruoyi-service/src/main/java/com/ruoyi/bst/booth/service/impl/BoothServiceImpl.java
@@ -35,6 +35,7 @@ import com.ruoyi.iot.constants.IotConstants;
import com.ruoyi.iot.domain.response.CommandResponse;
import com.ruoyi.iot.service.IotService;
import com.ruoyi.iot.util.IotUtil;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bst.booth.mapper.BoothMapper;
@@ -50,9 +51,9 @@ import org.springframework.transaction.support.TransactionTemplate;
* @author ruoyi
* @date 2025-04-18
*/
+@Slf4j
@Service
-public class BoothServiceImpl implements BoothService
-{
+public class BoothServiceImpl implements BoothService {
@Autowired
private BoothMapper boothMapper;
@Autowired
@@ -87,8 +88,7 @@ public class BoothServiceImpl implements BoothService
* @return 卡座
*/
@Override
- public BoothVO selectBoothByBoothId(Long id, boolean scope)
- {
+ public BoothVO selectBoothByBoothId(Long id, boolean scope) {
if (id == null) {
return null;
}
@@ -100,8 +100,7 @@ public class BoothServiceImpl implements BoothService
}
@Override
- public BoothVO selectBoothByBoothNo(String boothNo, boolean scope)
- {
+ public BoothVO selectBoothByBoothNo(String boothNo, boolean scope) {
if (boothNo == null) {
return null;
}
@@ -119,6 +118,7 @@ public class BoothServiceImpl implements BoothService
List list = this.selectBoothList(query);
return CollectionUtils.firstElement(list);
}
+
/**
* 查询卡座列表
*
@@ -126,8 +126,7 @@ public class BoothServiceImpl implements BoothService
* @return 卡座
*/
@Override
- public List selectBoothList(BoothQuery booth)
- {
+ public List selectBoothList(BoothQuery booth) {
return boothMapper.selectBoothList(booth);
}
@@ -138,14 +137,13 @@ public class BoothServiceImpl implements BoothService
* @return 结果
*/
@Override
- public int insertBooth(Booth booth)
- {
+ public int insertBooth(Booth booth) {
booth.setCreateTime(DateUtils.getNowDate());
Integer result = transactionTemplate.execute(status -> {
int rows = boothMapper.insertBooth(booth);
if (rows > 0) {
// 后校验
- boothValidator.validate(booth.getBoothId(),booth.getBoothNo());
+ boothValidator.validate(booth.getBoothId(), booth.getBoothNo());
}
return rows;
});
@@ -159,10 +157,9 @@ public class BoothServiceImpl implements BoothService
* @return 结果
*/
@Override
- public int updateBooth(Booth booth)
- {
- if (booth.getBoothNo()!=null) {
- boothValidator.validate(booth.getBoothId(),booth.getBoothNo());
+ public int updateBooth(Booth booth) {
+ if (booth.getBoothNo() != null) {
+ boothValidator.validate(booth.getBoothId(), booth.getBoothNo());
}
return boothMapper.updateBooth(booth);
}
@@ -174,8 +171,7 @@ public class BoothServiceImpl implements BoothService
* @return 结果
*/
@Override
- public int deleteBoothByBoothIds(List boothIds)
- {
+ public int deleteBoothByBoothIds(List boothIds) {
return boothMapper.deleteBoothByBoothIds(boothIds);
}
@@ -186,8 +182,7 @@ public class BoothServiceImpl implements BoothService
* @return 结果
*/
@Override
- public int deleteBoothByBoothId(Long boothId)
- {
+ public int deleteBoothByBoothId(Long boothId) {
return boothMapper.deleteBoothByBoothId(boothId);
}
@@ -200,20 +195,22 @@ public class BoothServiceImpl implements BoothService
query.setUserId(userId);
query.setTime(LocalDateTime.now());
List list = boothMapper.selectBoothList(query);
- ServiceUtil.assertion(list != null && !list.isEmpty(),"请勿绑定多个卡座");
+ if (list != null && !list.isEmpty()){
+ return CollectionUtils.firstElement(list);
+ };
BoothVO booth = boothMapper.selectBoothByBoothNo(boothNo);
- ServiceUtil.assertion(booth==null,"当前卡座不存在");
- if (booth.getUserId()!=null&&booth.getExpiredTime() != null && booth.getExpiredTime().isAfter(LocalDateTime.now())) {
+ ServiceUtil.assertion(booth == null, "当前卡座不存在");
+ if (booth.getUserId() != null && booth.getExpiredTime() != null && booth.getExpiredTime().isAfter(LocalDateTime.now())) {
// 卡座未过期,被其他用户绑定
- ServiceUtil.assertion(!booth.getUserId().equals(userId),"卡座已被绑定");
+ ServiceUtil.assertion(!booth.getUserId().equals(userId), "卡座已被绑定");
// 卡座未过期,被当前用户绑定
- ServiceUtil.assertion(booth.getUserId().equals(userId),"请勿重复绑定该设备");
- }else {
+ ServiceUtil.assertion(booth.getUserId().equals(userId), "请勿重复绑定该设备");
+ } else {
booth.setExpiredTime(LocalDateTime.now().plusMinutes(30));
booth.setUserId(userId);
}
int i = boothMapper.updateBooth(booth);
- ServiceUtil.assertion(i==0,"操作失败");
+ ServiceUtil.assertion(i == 0, "操作失败");
return booth;
} finally {
redisLock.unlock(RedisLockKey.BOOTH_BIND_USER, userId);
@@ -222,7 +219,7 @@ public class BoothServiceImpl implements BoothService
@Override
- public void getDevices(BoothVO booth){
+ public void getDevices(BoothVO booth) {
DeviceQuery query = new DeviceQuery();
query.setBoothId(booth.getBoothId());
List devices = deviceMapper.selectDeviceList(query);
@@ -236,31 +233,31 @@ public class BoothServiceImpl implements BoothService
}
@Override
- public int userChangeBind(String usingBoothNo, String changeBoothNo ,Long userId) {
+ public int userChangeBind(String usingBoothNo, String changeBoothNo, Long userId) {
BoothVO usingBooth = boothMapper.selectBoothByBoothNo(usingBoothNo);
- ServiceUtil.assertion(usingBooth == null,"编号为%s的卡座信息不存在",usingBoothNo);
- ServiceUtil.assertion(usingBooth.getUserId() == null,"请先绑定编号为%s的卡座后再进行操作",usingBoothNo);
- ServiceUtil.assertion(!usingBooth.getUserId().equals(userId),"您无权限更改当前卡座信息",usingBoothNo);
+ ServiceUtil.assertion(usingBooth == null, "编号为%s的卡座信息不存在", usingBoothNo);
+ ServiceUtil.assertion(usingBooth.getUserId() == null, "请先绑定编号为%s的卡座后再进行操作", usingBoothNo);
+ ServiceUtil.assertion(!usingBooth.getUserId().equals(userId), "您无权限更改当前卡座信息", usingBoothNo);
BoothVO changeBooth = boothMapper.selectBoothByBoothNo(changeBoothNo);
- ServiceUtil.assertion(changeBooth == null,"编号为%s的卡座信息不存在",changeBoothNo);
+ ServiceUtil.assertion(changeBooth == null, "编号为%s的卡座信息不存在", changeBoothNo);
boolean lock = redisLock.lock(RedisLockKey.BOOTH_CHANGE_USER, changeBoothNo);
ServiceUtil.assertion(!lock, "您当前操作过于频繁,请稍后重试");
try {
Integer result = transactionTemplate.execute(status -> {
usingBooth.setUserId(null);
int unbind = boothMapper.updateBooth(usingBooth);
- ServiceUtil.assertion(unbind != 1,"解绑当前设备失败");
- if (changeBooth.getUserId()!=null && changeBooth.getExpiredTime() != null && changeBooth.getExpiredTime().isAfter(LocalDateTime.now())) {
+ ServiceUtil.assertion(unbind != 1, "解绑当前设备失败");
+ if (changeBooth.getUserId() != null && changeBooth.getExpiredTime() != null && changeBooth.getExpiredTime().isAfter(LocalDateTime.now())) {
// 卡座未过期,被其他用户绑定
- ServiceUtil.assertion(!changeBooth.getUserId().equals(userId),"卡座已被绑定");
+ ServiceUtil.assertion(!changeBooth.getUserId().equals(userId), "卡座已被绑定");
// 卡座未过期,被当前用户绑定
- ServiceUtil.assertion(changeBooth.getUserId().equals(userId),"请勿重复绑定该设备");
+ ServiceUtil.assertion(changeBooth.getUserId().equals(userId), "请勿重复绑定该设备");
}
changeBooth.setUserId(userId);
changeBooth.setExpiredTime(LocalDateTime.now().plusMinutes(30));
int changeBind = boothMapper.updateBooth(changeBooth);
- ServiceUtil.assertion(changeBind != 1,"用户换绑失败");
+ ServiceUtil.assertion(changeBind != 1, "用户换绑失败");
return changeBind;
});
return result;
@@ -270,20 +267,18 @@ public class BoothServiceImpl implements BoothService
}
-
@Override
- public DeviceIotVO lighting(BoothVO booth,Long userId,boolean requiredIot) {
+ public DeviceIotVO lighting(BoothVO booth, Long userId, boolean requiredIot) {
// 操作校验
- ServiceUtil.assertion(booth.getStoreId()==null,"当前卡座未绑定店铺");
+ ServiceUtil.assertion(booth.getStoreId() == null, "当前卡座未绑定店铺");
ServiceUtil.assertion(booth.getExpiredTime().isBefore(LocalDateTime.now()), "请重新绑定卡座");
// 判断当前用户是否在该店铺下有余额
- LightingNumVO vo = lightingNumMapper.selectLightingNumByUserId(userId,booth.getStoreId());
- ServiceUtil.assertion(vo == null,"请先购买余额");
- ServiceUtil.assertion(vo.getNumber()<=0,"余额不足,请充值");
+ LightingNumVO vo = lightingNumMapper.selectLightingNumByUserId(userId, booth.getStoreId());
+ ServiceUtil.assertion(vo == null, "请先购买余额");
+ ServiceUtil.assertion(vo.getNumber() <= 0, "余额不足,请充值");
- // 设备相关校验
// 根据id查询出卡座对应的所有设备
DeviceQuery deviceQuery = new DeviceQuery();
deviceQuery.setBoothId(booth.getBoothId());
@@ -291,32 +286,29 @@ public class BoothServiceImpl implements BoothService
deviceQuery.setBoothNo(booth.getBoothNo());
List deviceVOList = deviceMapper.selectDeviceList(deviceQuery);
- //
+ // 设备相关校验
if (deviceVOList != null && !deviceVOList.isEmpty()) {
deviceVOList.forEach(deviceVO -> {
ServiceUtil.assertion(deviceVO == null || deviceVO.getDeviceId() == null, "设备不存在");
ServiceUtil.assertion(StringUtils.isAllBlank(deviceVO.getMac(), deviceVO.getMac2()), "设备MAC号为空");
- ServiceUtil.assertion(deviceVO.getDuration() == null,"设备编号为%s的设备暂未设置开启时长",deviceVO.getDeviceNo());
- if (deviceVO.getExpireTime()!=null) {
- ServiceUtil.assertion( deviceVO.getExpireTime().isAfter(LocalDateTime.now()),"请勿在爆灯时间内重复爆灯");
- }
+ ServiceUtil.assertion(deviceVO.getDuration() == null, "设备编号为%s的设备暂未设置开启时长", deviceVO.getDeviceNo());
});
}
+ // 新建IotVO 返回数据库操作与物联网操作结果
DeviceIotVO iotVO = new DeviceIotVO();
// 爆灯
Integer result = transactionTemplate.execute(status -> {
-
// 先扣减次数
LightingNum data = new LightingNum();
data.setNumber(1);
OrderQuery query = new OrderQuery();
query.setUserId(userId);
query.setStoreId(booth.getStoreId());
- int i = lightingNumService.reduceLightingNumByQuery(data,query);
+ int i = lightingNumService.reduceLightingNumByQuery(data, query);
iotVO.setDb(i);
- ServiceUtil.assertion(i!=1,"操作失败");
+ ServiceUtil.assertion(i != 1, "操作失败");
// 新建变化记录表
ChangeRecord changeRecord = new ChangeRecord();
changeRecord.setBstType(ChangeRecordBstType.LIGHTING.getCode());
@@ -327,14 +319,14 @@ public class BoothServiceImpl implements BoothService
changeRecord.setBstId(booth.getBoothId());
changeRecord.setNumber(1);
changeRecord.setBeforeNum(vo.getNumber());
- changeRecord.setAfterNum(vo.getNumber()-1);
+ changeRecord.setAfterNum(vo.getNumber() - 1);
changeRecord.setCreateTime(DateUtils.getNowDate());
changeRecord.setReason("用户爆灯");
i = changeRecordMapper.insertChangeRecord(changeRecord);
- ServiceUtil.assertion(i!=1,"操作失败");
+ ServiceUtil.assertion(i != 1, "操作失败");
deviceVOList.forEach(deviceVO -> {
boolean iotOp = this.lighting(deviceVO);
- ServiceUtil.assertion(requiredIot && !iotOp, "");
+ ServiceUtil.assertion(requiredIot && !iotOp, "设备开启失败");
iotVO.setIot(iotOp);
});
return i;
@@ -345,15 +337,16 @@ public class BoothServiceImpl implements BoothService
@Override
public boolean lighting(DeviceVO device) {
- Integer result = transactionTemplate.execute(status -> {
- device.setExpireTime(LocalDateTime.now().plusSeconds(device.getDuration()));
- int i = deviceService.updateDevice(device);
- ServiceUtil.assertion(i != 1,"更新设备防重复爆灯时间失败");
+ // 增加缓存 防止重复爆灯
+ boolean lock = redisLock.lock(RedisLockKey.BOOTH_LIGHTING, device.getDeviceNo(), device.getDuration() + 3);
+ if (lock) {
CommandResponse res = iotService.setTime(device, device.getDuration(), "爆灯");
+ // TODO: 要不要下面这个语句
ServiceUtil.assertion(res == null, "设备爆灯失败:未知错误");
- boolean iot = IotUtil.isSuccess(res);
- return iot? 1:0;
- });
- return MathUtils.equals(result,1);
+ return IotUtil.isSuccess(res);
+ } else {
+ ServiceUtil.assertion(true, "爆灯频繁,请稍等后再进行爆灯");
+ }
+ return false;
}
}
diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/device/service/impl/DeviceServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/bst/device/service/impl/DeviceServiceImpl.java
index 3e6319f..630dfcb 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/bst/device/service/impl/DeviceServiceImpl.java
+++ b/ruoyi-service/src/main/java/com/ruoyi/bst/device/service/impl/DeviceServiceImpl.java
@@ -100,9 +100,9 @@ public class DeviceServiceImpl implements DeviceService
return null;
}
DeviceQuery query = new DeviceQuery();
- query.setBoothId(id);
+ query.setDeviceId(id);
query.setScope(scope);
- query.addStorePermission(StoreStaffPermission.BOOTH_VIEW.getCode());
+ query.addStorePermission(StoreStaffPermission.DEVICE_VIEW.getCode());
return this.selectOne(query);
}
diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/domain/LightingNumVO.java b/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/domain/LightingNumVO.java
index 7afadfa..3826c74 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/domain/LightingNumVO.java
+++ b/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/domain/LightingNumVO.java
@@ -11,8 +11,20 @@ public class LightingNumVO extends LightingNum{
@ApiModelProperty("店铺名")
private String storeName;
- @Excel(name = "用户名")
- @ApiModelProperty("用户名")
+ @Excel(name = "用户账号")
+ @ApiModelProperty("用户账号")
private String userName;
+ @Excel(name = "用户昵称")
+ @ApiModelProperty("用户昵称")
+ private String nickName;
+
+ @Excel(name = "用户账号")
+ @ApiModelProperty("用户账号")
+ private String mchName;
+
+ @Excel(name = "用户昵称")
+ @ApiModelProperty("用户昵称")
+ private String mchNickName;
+
}
diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/mapper/LightingNumMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/mapper/LightingNumMapper.xml
index 799de37..a370642 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/mapper/LightingNumMapper.xml
+++ b/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/mapper/LightingNumMapper.xml
@@ -21,7 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bln.create_time,
bs.store_name,
bs.user_id as mch_id,
- su.user_name
+ su.user_name,
+ su.nick_name
from
diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/part/mapper/PartMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/part/mapper/PartMapper.xml
index 209afd1..04e5e60 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/bst/part/mapper/PartMapper.xml
+++ b/ruoyi-service/src/main/java/com/ruoyi/bst/part/mapper/PartMapper.xml
@@ -86,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
part_name,
picture,
create_time,
+ order_num,
#{storeId},
@@ -93,6 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{partName},
#{picture},
#{createTime},
+ #{orderNum},
diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/refund/service/impl/RefundServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/bst/refund/service/impl/RefundServiceImpl.java
index 901a442..a5f2447 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/bst/refund/service/impl/RefundServiceImpl.java
+++ b/ruoyi-service/src/main/java/com/ruoyi/bst/refund/service/impl/RefundServiceImpl.java
@@ -16,14 +16,12 @@ import com.ruoyi.bst.refund.service.RefundService;
import com.ruoyi.common.domain.vo.LocalDateDecimalVO;
import com.ruoyi.common.domain.vo.LongDecimalVO;
import com.ruoyi.common.pay.PayApi;
-import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.ServiceUtil;
-import com.ruoyi.common.utils.SnowFlakeUtil;
-import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.*;
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;
import java.util.concurrent.ScheduledExecutorService;
@@ -137,6 +135,8 @@ public class RefundServiceImpl implements RefundService
@Override
public int createRefund(Refund refund) {
Integer result = transactionTemplate.execute(status -> {
+ ServiceUtil.assertion(refund.getNumber()==0&&MathUtils.equals(refund.getAmount(),BigDecimal.ZERO),"退款金额和次数不能同时为0");
+
refund.setStatus(RefundStatus.REFUNDING.getStatus());
int insertRefund = this.insertRefund(refund);
ServiceUtil.assertion(insertRefund != 1, "创建退款订单失败");
@@ -157,14 +157,13 @@ public class RefundServiceImpl implements RefundService
AppVO app = appService.selectAppById(vo.getAppId());
ServiceUtil.assertion(app == null, "ID为%s的APP不存在", vo.getAppId());
- // TODO 正式环境取消注释 调用API退款
- payApi.refund(vo, channelConverter.toConfig(channel, app));
- //TODO 5秒后支付成功,测试,正式环境需删除
-// scheduledExecutorService.schedule(() -> {
-// this.handleRefundSuccess(refund.getNo());
-// }, 5, TimeUnit.SECONDS);
+
+ if (!MathUtils.equals(refund.getAmount(), BigDecimal.ZERO)){
+ // TODO 正式环境取消注释 调用API退款
+ payApi.refund(vo, channelConverter.toConfig(channel, app));
+ }
// TODO 正式环境取消注释 判断是否同步通知,若是则直接处理支付成功
if (channelApiType.getIsRefundSync() != null && channelApiType.getIsRefundSync()) {
scheduledExecutorService.schedule(() -> {
@@ -172,6 +171,11 @@ public class RefundServiceImpl implements RefundService
}, 10, TimeUnit.SECONDS);
}
+ //TODO 5秒后支付成功,测试,正式环境需删除
+// scheduledExecutorService.schedule(() -> {
+// this.handleRefundSuccess(refund.getNo());
+// }, 5, TimeUnit.SECONDS);
+
return insertRefund;
});
diff --git a/ruoyi-service/src/main/java/com/ruoyi/dashboard/constants/StatKeys.java b/ruoyi-service/src/main/java/com/ruoyi/dashboard/constants/StatKeys.java
index fe4650e..4173bc6 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/dashboard/constants/StatKeys.java
+++ b/ruoyi-service/src/main/java/com/ruoyi/dashboard/constants/StatKeys.java
@@ -28,8 +28,11 @@ public class StatKeys {
// 店铺数量
public static final String STORE_COUNT = "store_count";
- // 用户爆灯次数
- public static final String LIGHTING_NUM_COUNT = "lighting_num_count";
+ // 用户剩余爆灯次数
+ public static final String CURRENT_LIGHTING_NUM_COUNT = "current_lighting_num_count";
+ // 用户爆灯过的次数
+ public static final String USED_LIGHTING_NUM_COUNT = "user_lighting_num_count";
+
// 用户充值金额
public static final String USER_RECHARGE_AMOUNT = "user_recharge_amount";
// 用户退款金额
diff --git a/ruoyi-service/src/main/java/com/ruoyi/dashboard/service/DashboardService.java b/ruoyi-service/src/main/java/com/ruoyi/dashboard/service/DashboardService.java
index 5887000..9ba5947 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/dashboard/service/DashboardService.java
+++ b/ruoyi-service/src/main/java/com/ruoyi/dashboard/service/DashboardService.java
@@ -73,8 +73,12 @@ public class DashboardService {
if (keys.contains(StatKeys.DEVICE_ONLINE_STATUS_COUNT)) {
vo.setDeviceOnlineStatusMap(deviceDashboard.selectOnlineStatusCount(query.toDeviceQuery()));
}
- // 爆灯次数
- if (keys.contains(StatKeys.LIGHTING_NUM_COUNT)) {
+ // 当前爆灯次数
+ if (keys.contains(StatKeys.CURRENT_LIGHTING_NUM_COUNT)) {
+ vo.setUserLightingNum(lightingNumDashboard.selectCount(query.toLightingNumQuery()));
+ }
+ // 爆灯过的次数
+ if (keys.contains(StatKeys.CURRENT_LIGHTING_NUM_COUNT)) {
vo.setUserLightingNum(lightingNumDashboard.selectCount(query.toLightingNumQuery()));
}
// 用户充值金额
diff --git a/ruoyi-service/src/main/java/com/ruoyi/system/user/domain/UserQuery.java b/ruoyi-service/src/main/java/com/ruoyi/system/user/domain/UserQuery.java
index b1e04af..0570e37 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/system/user/domain/UserQuery.java
+++ b/ruoyi-service/src/main/java/com/ruoyi/system/user/domain/UserQuery.java
@@ -56,4 +56,7 @@ public class UserQuery extends UserVO {
@ApiModelProperty("创建日期范围")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private List createDateRange;
+
+ @ApiModelProperty("所属店铺ID")
+ private Long storeId;
}
diff --git a/ruoyi-service/src/main/java/com/ruoyi/system/user/mapper/UserMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/system/user/mapper/UserMapper.xml
index d7a744f..6b49f12 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/system/user/mapper/UserMapper.xml
+++ b/ruoyi-service/src/main/java/com/ruoyi/system/user/mapper/UserMapper.xml
@@ -71,13 +71,19 @@
d.dept_name,
d.order_num,
d.leader,
- d.status as dept_status
+ d.status as dept_status,
+ mch.user_name as mch_name,
+ mch.nick_name as mch_nick_name,
+ mch.user_id as mch_id
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
+ left join bst_order bo on u.user_id = bo.user_id
+ left join bst_store bs on bo.store_id = bs.store_id
+ left join sys_user mch on bs.user_id = mch.user_id
@@ -337,6 +343,7 @@
nick_name = #{nickName},
user_type = #{userType},
email = #{email},
+ declaration = #{declaration},
phonenumber = #{phonenumber},
sex = #{sex},
avatar = #{avatar},
diff --git a/ruoyi-service/src/main/java/com/ruoyi/system/user/service/UserAssembler.java b/ruoyi-service/src/main/java/com/ruoyi/system/user/service/UserAssembler.java
index 862ad6d..d83d9e7 100644
--- a/ruoyi-service/src/main/java/com/ruoyi/system/user/service/UserAssembler.java
+++ b/ruoyi-service/src/main/java/com/ruoyi/system/user/service/UserAssembler.java
@@ -27,7 +27,7 @@ public interface UserAssembler {
void assembleLastConsumeTime(List list);
/**
- * 拼接用户爆灯次数
+ * 拼接用户剩余爆灯次数
* @param list
*/
void assembleLightingNum(List list);
diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/app/AppBoothController.java b/ruoyi-web/src/main/java/com/ruoyi/web/app/AppBoothController.java
index 9bba68f..ca15ee8 100644
--- a/ruoyi-web/src/main/java/com/ruoyi/web/app/AppBoothController.java
+++ b/ruoyi-web/src/main/java/com/ruoyi/web/app/AppBoothController.java
@@ -38,9 +38,15 @@ public class AppBoothController extends BaseController {
return error("卡座编号不能为空");
}
BoothVO booth = boothService.selectBoothByBoothNo(boothNo);
- ServiceUtil.assertion(booth==null,"当前卡座信息不存在");
- ServiceUtil.assertion(booth.getUserId()==null,"请先绑定该卡座后再进行操作");
- ServiceUtil.assertion(!booth.getUserId().equals(getUserId()),"您无权操作当前卡座设备");
+ if (booth == null) {
+ return error("当前卡座信息不存在");
+ }
+ if (booth.getUserId()==null) {
+ return error("您无权操作当前卡座设备");
+ }
+ if (!booth.getUserId().equals(getUserId())){
+ return error("您无权操作当前卡座设备");
+ }
return success(boothService.lighting(booth,getUserId(),requiredIot));
}
diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/system/SysProfileController.java b/ruoyi-web/src/main/java/com/ruoyi/web/system/SysProfileController.java
index 55c3469..a4c478f 100644
--- a/ruoyi-web/src/main/java/com/ruoyi/web/system/SysProfileController.java
+++ b/ruoyi-web/src/main/java/com/ruoyi/web/system/SysProfileController.java
@@ -67,6 +67,7 @@ public class SysProfileController extends BaseController
User currentUser = loginUser.getUser();
currentUser.setEmail(user.getEmail());
currentUser.setPhonenumber(user.getPhonenumber());
+ currentUser.setDeclaration(user.getDeclaration());
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser))
{
return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在");