更新
This commit is contained in:
parent
cc628ffc94
commit
79dc7fde0f
|
@ -2,6 +2,7 @@ package com.ruoyi.bst.bonus.domain;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
|
@ -94,4 +95,7 @@ public class Bonus extends BaseEntity
|
|||
@ApiModelProperty("运营区ID")
|
||||
private Long areaId;
|
||||
|
||||
@Excel(name = "其他可见用户ID列表")
|
||||
@ApiModelProperty("其他可见用户ID列表")
|
||||
private List<Long> viewUserIds;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.bst.bonus.mapper.BonusMapper">
|
||||
|
||||
<resultMap type="BonusVO" id="BonusResult" autoMapping="true"/>
|
||||
<resultMap type="BonusVO" id="BonusResult" autoMapping="true">
|
||||
<result property="viewUserIds" column="view_user_ids" typeHandler="com.ruoyi.common.mybatis.typehandler.LongSplitListTypeHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="checkAmount">
|
||||
bb.invalid_amount + bb.wait_amount + bb.payed_amount + bb.refund_amount = bb.amount
|
||||
|
@ -30,7 +32,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bb.to_balance,
|
||||
bb.reason,
|
||||
bb.create_time,
|
||||
bb.area_id
|
||||
bb.area_id,
|
||||
bb.view_user_ids
|
||||
from <include refid="searchTables"/>
|
||||
</sql>
|
||||
|
||||
|
@ -68,13 +71,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
${@com.ruoyi.framework.util.DataScopeUtil@dataScope(
|
||||
null,
|
||||
"su.user_id",
|
||||
null,
|
||||
null,
|
||||
query.scope
|
||||
)}
|
||||
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
|
||||
.userAlias("su.user_id")
|
||||
.userSetAlias("bb.view_user_ids")
|
||||
.build()
|
||||
}
|
||||
${query.params.dataScope}
|
||||
</sql>
|
||||
|
||||
|
@ -111,6 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="reason != null">reason,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="areaId != null">area_id,</if>
|
||||
<if test="viewUserIds != null">view_user_ids,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="bstId != null">#{bstId},</if>
|
||||
|
@ -131,6 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="reason != null">#{reason},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="areaId != null">#{areaId},</if>
|
||||
<if test="viewUserIds != null">#{viewUserIds,typeHandler=com.ruoyi.common.mybatis.typehandler.LongSplitListTypeHandler},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -155,6 +158,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
reason,
|
||||
create_time,
|
||||
area_id,
|
||||
view_user_ids
|
||||
</trim>
|
||||
values
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
|
@ -195,6 +199,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="i.createTime == null ">default,</if>
|
||||
<if test="i.areaId != null ">#{i.areaId},</if>
|
||||
<if test="i.areaId == null ">default,</if>
|
||||
<if test="i.viewUserIds != null ">#{i.viewUserIds,typeHandler=com.ruoyi.common.mybatis.typehandler.LongSplitListTypeHandler},</if>
|
||||
<if test="i.viewUserIds == null ">default,</if>
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
@ -226,6 +232,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.reason != null">reason = #{data.reason},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
<if test="data.areaId != null">area_id = #{data.areaId},</if>
|
||||
<if test="data.viewUserIds != null">view_user_ids = #{data.viewUserIds,typeHandler=com.ruoyi.common.mybatis.typehandler.LongSplitListTypeHandler},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteBonusById" parameterType="Long">
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.bst.bonus.service.impl;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -98,7 +99,7 @@ public class BonusConverterImpl implements BonusConverter {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Long areaUserId = device.getAreaUserId(); // 运营区归属用户
|
||||
Long areaUserId = device.getAreaUserId(); // 运营区归属用户(运营商)
|
||||
Long areaAgentId = device.getAreaAgentId(); // 运营区代理商
|
||||
BigDecimal totalPoint = BigDecimal.ZERO; // 已分成百分比
|
||||
BigDecimal decimal100 = new BigDecimal(100);
|
||||
|
@ -111,6 +112,7 @@ public class BonusConverterImpl implements BonusConverter {
|
|||
Bonus bonus = BonusUtil.getInitBonus(BonusArrivalType.JOIN, joinUserId, join.getUserName(), join.getPoint());
|
||||
if (bonus != null) {
|
||||
result.add(bonus);
|
||||
bonus.setViewUserIds(Arrays.asList(areaUserId, areaAgentId)); // 代理商、运营商可见
|
||||
totalPoint = totalPoint.add(bonus.getPoint());
|
||||
}
|
||||
}
|
||||
|
@ -121,6 +123,7 @@ public class BonusConverterImpl implements BonusConverter {
|
|||
Bonus bonus = BonusUtil.getInitBonus(BonusArrivalType.PARTNER, partner.getUserId(), partner.getUserName(), partner.getPoint());
|
||||
if (bonus != null) {
|
||||
result.add(bonus);
|
||||
bonus.setViewUserIds(Arrays.asList(areaUserId, areaAgentId)); // 代理商、运营商可见
|
||||
totalPoint = totalPoint.add(bonus.getPoint());
|
||||
}
|
||||
}
|
||||
|
@ -131,6 +134,7 @@ public class BonusConverterImpl implements BonusConverter {
|
|||
Bonus bonus = BonusUtil.getInitBonus(BonusArrivalType.MCH, areaUserId, device.getAreaUserName(), device.getAreaUserPoint().subtract(totalPoint));
|
||||
if (bonus != null) {
|
||||
result.add(bonus);
|
||||
bonus.setViewUserIds(Arrays.asList(areaAgentId)); // 代理商可见
|
||||
totalPoint = totalPoint.add(bonus.getPoint());
|
||||
}
|
||||
}
|
||||
|
@ -163,6 +167,7 @@ public class BonusConverterImpl implements BonusConverter {
|
|||
ServiceUtil.assertion(bonus.getPoint().compareTo(BigDecimal.ZERO) < 0, "分成计算错误,分成方【%s】分成百分比为负数", bonus.getArrivalName());
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -331,6 +331,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bd.lock_status,
|
||||
bd.area_id,
|
||||
bd.order_device_id,
|
||||
bd.last_location_time,
|
||||
bd.longitude,
|
||||
bd.latitude,
|
||||
bod.status as order_device_status,
|
||||
bod.order_id
|
||||
from bst_device bd
|
||||
|
|
|
@ -45,7 +45,7 @@ public enum OrderStatus {
|
|||
|
||||
// 可以退款的订单状态
|
||||
public static List<String> canRefund() {
|
||||
return CollectionUtils.map(OrderStatus::getCode, FINISHED, REFUNDED);
|
||||
return CollectionUtils.map(OrderStatus::getCode, FINISHED, REFUNDED, REJECTED, WAIT_VERIFY);
|
||||
}
|
||||
|
||||
// 未支付的订单状态
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.ruoyi.bst.orderDevice.domain.enums.OrderDeviceStatus;
|
|||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.MathUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.iot.constants.IotConstants;
|
||||
import com.ruoyi.iot.domain.IotDeviceSysInfo;
|
||||
|
@ -80,11 +81,19 @@ public class IotReceiveServiceImpl implements IotReceiveService {
|
|||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 转为设备信息
|
||||
IotDeviceSysInfo sys = IotUtil.toSysInfo(msg.getValue());
|
||||
LocalDateTime at = DateUtils.toLocalDateTime(msg.getAt());
|
||||
|
||||
// 处理设备定位BUG,若出现BUG则重启设备
|
||||
int handle = this.handleDeviceReboot(device, sys, at);
|
||||
if (handle == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置设备信息
|
||||
DeviceUtil.setIotSysInfo(device, sys);
|
||||
LocalDateTime at = DateUtils.toLocalDateTime(msg.getAt());
|
||||
device.setLastTime(at);
|
||||
device.setLastLocationTime(at);
|
||||
|
||||
|
@ -104,6 +113,27 @@ public class IotReceiveServiceImpl implements IotReceiveService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理设备重启
|
||||
* @param device
|
||||
*/
|
||||
private int handleDeviceReboot(DeviceVO device, IotDeviceSysInfo sys, LocalDateTime at) {
|
||||
if (device == null || StringUtils.isBlank(device.getMac()) || device.getLastLocationTime() == null || at == null) {
|
||||
return 0;
|
||||
}
|
||||
boolean isOpen = DeviceLockStatus.OPEN.getCode().equals(device.getLockStatus()); // 是否开锁
|
||||
// 需要在设备未启动的时候做,否则可能有安全问题
|
||||
if (!isOpen) {
|
||||
// 若当前数据点的上报时间和设备内上次上报的时间不一样,但是定位一样,则重启设备
|
||||
if (at.isAfter(device.getLastLocationTime()) && MathUtils.equals(device.getLongitude(), sys.getLon()) && MathUtils.equals(device.getLatitude(), sys.getLat())) {
|
||||
deviceIotService.reboot(device, "设备不同时间的两次定位一样,重启设备", true);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理车辆运营区
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.web.bst;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
@ -13,8 +14,10 @@ import org.springframework.web.bind.annotation.PutMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ruoyi.bst.bonus.domain.Bonus;
|
||||
import com.ruoyi.bst.bonus.domain.BonusQuery;
|
||||
import com.ruoyi.bst.bonus.domain.BonusVO;
|
||||
import com.ruoyi.bst.bonus.domain.enums.BonusArrivalType;
|
||||
import com.ruoyi.bst.bonus.service.BonusService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
|
@ -80,7 +83,17 @@ public class BonusController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('bst:bonus:preview')")
|
||||
@GetMapping(value = "/preview")
|
||||
public AjaxResult preview(Long deviceId) {
|
||||
return success(bonusService.preview(deviceId));
|
||||
List<Bonus> list = bonusService.preview(deviceId);
|
||||
// 若不是系统管理员,则只返回当前用户可见信息
|
||||
if (!isSysAdmin()) {
|
||||
Long userId = getUserId();
|
||||
list = list.stream().filter(bonus ->
|
||||
BonusArrivalType.userList().contains(bonus.getArrivalType())
|
||||
&& bonus.getViewUserIds() != null
|
||||
&& bonus.getViewUserIds().contains(userId)
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user