更新统计数据
This commit is contained in:
parent
1de65139c1
commit
dd9ecb1c48
|
@ -104,6 +104,8 @@ public class Bonus extends BaseEntity
|
|||
@ApiModelProperty("其他可见用户ID列表")
|
||||
private List<Long> viewUserIds;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDateTime waitTime;
|
||||
|
||||
public void addViewUserId(Long userId) {
|
||||
if (userId == null) {
|
||||
|
|
|
@ -25,6 +25,10 @@ public class BonusQuery extends BonusVO {
|
|||
@ApiModelProperty("创建日期范围")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private List<LocalDate> createDateRange;
|
||||
|
||||
@ApiModelProperty("结算日期范围")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private List<LocalDate> waitDateRange;
|
||||
|
||||
@ApiModelProperty("分成状态列表")
|
||||
private List<String> statusList;
|
||||
|
|
|
@ -34,7 +34,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bb.create_time,
|
||||
bb.area_id,
|
||||
bb.view_user_ids,
|
||||
bb.channel_id
|
||||
bb.channel_id,
|
||||
bb.wait_time
|
||||
from <include refid="searchTables"/>
|
||||
</sql>
|
||||
|
||||
|
@ -68,6 +69,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
and date(bb.create_time) >= #{query.createDateRange[0]}
|
||||
and date(bb.create_time) <= #{query.createDateRange[1]}
|
||||
</if>
|
||||
<if test="query.waitDateRange != null and query.waitDateRange.size() > 1">
|
||||
and date(bb.wait_time) >= #{query.waitDateRange[0]}
|
||||
and date(bb.wait_time) <= #{query.waitDateRange[1]}
|
||||
</if>
|
||||
<if test="query.statusList != null and query.statusList.size() > 0">
|
||||
and bb.status in
|
||||
<foreach collection="query.statusList" item="item" separator="," open="(" close=")">
|
||||
|
@ -117,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="areaId != null">area_id,</if>
|
||||
<if test="viewUserIds != null">view_user_ids,</if>
|
||||
<if test="channelId != null">channel_id,</if>
|
||||
<if test="waitTime != null">wait_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="bstId != null">#{bstId},</if>
|
||||
|
@ -139,6 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="areaId != null">#{areaId},</if>
|
||||
<if test="viewUserIds != null">#{viewUserIds,typeHandler=com.ruoyi.common.mybatis.typehandler.LongSplitListTypeHandler},</if>
|
||||
<if test="channelId != null">#{channelId},</if>
|
||||
<if test="waitTime != null">#{waitTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -164,7 +171,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
create_time,
|
||||
area_id,
|
||||
view_user_ids,
|
||||
channel_id
|
||||
channel_id,
|
||||
wait_time,
|
||||
</trim>
|
||||
values
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
|
@ -209,6 +217,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="i.viewUserIds == null ">default,</if>
|
||||
<if test="i.channelId != null ">#{i.channelId},</if>
|
||||
<if test="i.channelId == null ">default,</if>
|
||||
<if test="i.waitTime != null ">#{i.waitTime},</if>
|
||||
<if test="i.waitTime == null ">default,</if>
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
@ -242,6 +252,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<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>
|
||||
<if test="data.channelId != null">channel_id = #{data.channelId},</if>
|
||||
<if test="data.waitTime != null">wait_time = #{data.waitTime},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteBonusById" parameterType="Long">
|
||||
|
@ -282,6 +293,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="bb.wait_time = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.waitTime != null">
|
||||
WHEN #{item.id} THEN #{item.waitTime}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN bb.wait_time
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
bb.status = 'WAIT_DIVIDE',
|
||||
bb.wait_amount = bb.wait_amount + bb.invalid_amount,
|
||||
bb.invalid_amount = 0
|
||||
|
|
|
@ -97,7 +97,7 @@ public interface BonusService {
|
|||
* @param bstId 业务ID
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean prepayByBst(BonusBstType bstType, Long bstId);
|
||||
public boolean prepayByBst(BonusBstType bstType, Long bstId, LocalDateTime waitTime);
|
||||
|
||||
/**
|
||||
* 分成打款
|
||||
|
@ -144,12 +144,4 @@ public interface BonusService {
|
|||
*/
|
||||
public List<Bonus> preview(Long deviceId);
|
||||
|
||||
/**
|
||||
* 预分成
|
||||
*
|
||||
* @param id 分成明细ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int prepayBonus(Long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ public class BonusServiceImpl implements BonusService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean prepayByBst(BonusBstType bstType, Long bstId) {
|
||||
public boolean prepayByBst(BonusBstType bstType, Long bstId, LocalDateTime waitTime) {
|
||||
if (bstType == null || bstId == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -192,12 +192,12 @@ public class BonusServiceImpl implements BonusService {
|
|||
query.setBstType(bstType.getType());
|
||||
query.setBstId(bstId);
|
||||
List<BonusVO> list = this.selectBonusList(query);
|
||||
int rows = prepay(list);
|
||||
int rows = prepay(list, waitTime);
|
||||
return rows == list.size();
|
||||
}
|
||||
|
||||
// 预分成
|
||||
private int prepay(List<BonusVO> list) {
|
||||
private int prepay(List<BonusVO> list, LocalDateTime waitTime) {
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -210,6 +210,7 @@ public class BonusServiceImpl implements BonusService {
|
|||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
for (BonusVO bonus : list) {
|
||||
bonus.setWaitTime(waitTime);
|
||||
// 设置预计分成时间
|
||||
if (BonusArrivalType.userList().contains(bonus.getArrivalType())) {
|
||||
UserVO user = userList.stream().filter(item -> item.getUserId().equals(bonus.getArrivalId()))
|
||||
|
@ -409,13 +410,4 @@ public class BonusServiceImpl implements BonusService {
|
|||
|
||||
return bonusConverter.toBaseBonusListPlatform(device, partners, join);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int prepayBonus(Long id) {
|
||||
BonusVO bonus = this.selectBonusById(id);
|
||||
if (bonus == null) {
|
||||
return 0;
|
||||
}
|
||||
return prepay(Collections.singletonList(bonus));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -359,12 +359,10 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
// 监控设备
|
||||
for (Long deviceId : idList) {
|
||||
try {
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
// 获取设备最新信息
|
||||
DeviceVO device = deviceMapper.selectDeviceById(deviceId);
|
||||
this.refresh(device, null);
|
||||
this.monitor(device);
|
||||
},0, TimeUnit.SECONDS);
|
||||
// 获取设备最新信息
|
||||
DeviceVO device = deviceMapper.selectDeviceById(deviceId);
|
||||
this.refresh(device, null);
|
||||
this.monitor(device);
|
||||
} catch (Exception e) {
|
||||
log.error("监控设备id={}出错:{}", deviceId, e.getMessage());
|
||||
}
|
||||
|
@ -397,7 +395,7 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
this.monitor(Collections.singletonList(deviceId));
|
||||
this.asyncMonitorCount(deviceId, count - 1);
|
||||
}
|
||||
}, count, TimeUnit.SECONDS);
|
||||
}, 20 - count * 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,7 +30,7 @@ public class DeviceUtil {
|
|||
if (coordinates != null && coordinates.size() >= 2) {
|
||||
device.setLongitude(coordinates.get(1));
|
||||
device.setLatitude(coordinates.get(0));
|
||||
|
||||
|
||||
// 只有定位是正常的才认为是有获取到定位
|
||||
if (!MathUtils.equals(device.getLongitude(), BigDecimal.ZERO) && !MathUtils.equals(device.getLatitude(), BigDecimal.ZERO)) {
|
||||
device.setLastLocationTime(at);
|
||||
|
|
|
@ -799,7 +799,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
if (order == null) {
|
||||
return false;
|
||||
}
|
||||
return bonusService.prepayByBst(BonusBstType.ORDER, orderId);
|
||||
return bonusService.prepayByBst(BonusBstType.ORDER, orderId, order.getEndTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,8 @@ public class StatKeys {
|
|||
public static final String ORDER_COUNT = "order_count";
|
||||
// 订单支付金额
|
||||
public static final String ORDER_PAY_AMOUNT = "order_pay_amount";
|
||||
// 订单结算支付金额
|
||||
public static final Object ORDER_FINISHED_PAY_AMOUNT = "order_finished_pay_amount";
|
||||
// 订单退款金额
|
||||
public static final String ORDER_REFUND_AMOUNT = "order_refund_amount";
|
||||
// 待审核的订单
|
||||
|
|
|
@ -91,7 +91,7 @@ public class RevenueStatQuery {
|
|||
query.setArrivalId(userId);
|
||||
query.setAreaId(areaId);
|
||||
query.setArrivalTypes(BonusArrivalType.userList());
|
||||
query.setCreateDateRange(dateRange);
|
||||
query.setWaitDateRange(dateRange);
|
||||
return query;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,6 @@ public class RevenueStatQuery {
|
|||
query.setStatusList(OrderStatus.valid());
|
||||
query.setRefundStatusList(RefundStatus.valid());
|
||||
query.setRefundCreateDateRange(dateRange);
|
||||
query.setBonusUserId(userId);
|
||||
query.setAreaId(areaId);
|
||||
query.setScope(scope);
|
||||
query.addAreaPermission(AreaJoinPermission.ORDER_VIEW.getCode());
|
||||
|
|
|
@ -16,8 +16,14 @@ public class RevenueStatVO {
|
|||
private Integer orderUserCount;
|
||||
@ApiModelProperty("订单总金额")
|
||||
private BigDecimal orderActualTotalAmount;
|
||||
@ApiModelProperty("订单支付金额")
|
||||
private BigDecimal orderPayAmount;
|
||||
@ApiModelProperty("订单结算支付金额")
|
||||
private BigDecimal orderFinishedPayAmount;
|
||||
@ApiModelProperty("订单实收金额")
|
||||
private BigDecimal orderActualAmount;
|
||||
public BigDecimal getOrderActualAmount() {
|
||||
return MathUtils.subtractDecimal(orderFinishedPayAmount, orderRefundAmount);
|
||||
}
|
||||
@ApiModelProperty("订单骑行费")
|
||||
private BigDecimal orderRiddingFee;
|
||||
@ApiModelProperty("订单车损费")
|
||||
|
|
|
@ -148,8 +148,14 @@ public class DashboardService {
|
|||
// 订单总金额
|
||||
if (keys.contains(StatKeys.ORDER_ACTUAL_AMOUNT)) {
|
||||
vo.setOrderActualTotalAmount(orderDashboard.selectSumOfActualTotalAmount(query.toOrderQueryForEnd()));
|
||||
|
||||
vo.setOrderActualAmount(orderDashboard.selectSumOfActualAmount(query.toOrderQueryForEnd()));
|
||||
}
|
||||
// 订单结算支付金额
|
||||
if (keys.contains(StatKeys.ORDER_FINISHED_PAY_AMOUNT) || keys.contains(StatKeys.ORDER_ACTUAL_AMOUNT)) {
|
||||
vo.setOrderFinishedPayAmount(orderDashboard.selectPayAmount(query.toOrderQueryForEnd()));
|
||||
}
|
||||
// 订单支付金额
|
||||
if (keys.contains(StatKeys.ORDER_PAY_AMOUNT)) {
|
||||
vo.setOrderPayAmount(orderDashboard.selectPayAmount(query.toOrderQuery()));
|
||||
}
|
||||
// 订单骑行费
|
||||
if (keys.contains(StatKeys.ORDER_RIDDING_FEE)) {
|
||||
|
@ -172,7 +178,7 @@ public class DashboardService {
|
|||
vo.setOrderCount(orderDashboard.selectCount(query.toOrderQuery()));
|
||||
}
|
||||
// 订单退款金额
|
||||
if (keys.contains(StatKeys.ORDER_REFUND_AMOUNT)) {
|
||||
if (keys.contains(StatKeys.ORDER_REFUND_AMOUNT) || keys.contains(StatKeys.ORDER_ACTUAL_AMOUNT)) {
|
||||
OrderRefundQuery refundQuery = query.toOrderRefundQuery();
|
||||
refundQuery.setRefundType(RefundType.AUTO.getCode());
|
||||
vo.setOrderAutoRefundAmount(orderDashboard.selectRefundAmount(refundQuery));
|
||||
|
|
|
@ -106,14 +106,4 @@ public class BonusController extends BaseController
|
|||
public AjaxResult pay(Long id) {
|
||||
return success(bonusService.payBonus(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 预分成
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:bonus:prepay')")
|
||||
@PutMapping("/prepay")
|
||||
@Log(title = "预支付分成", businessType = BusinessType.OTHER, bizIdName = "arg0", bizType = LogBizType.BONUS )
|
||||
public AjaxResult prepay(Long id) {
|
||||
return success(bonusService.prepayBonus(id));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user