更新统计数据
This commit is contained in:
parent
79337dbfb3
commit
8f05d5882f
|
@ -14,5 +14,7 @@ public class RoleConstants {
|
||||||
public static final String MCH = "mch";
|
public static final String MCH = "mch";
|
||||||
// 加盟商
|
// 加盟商
|
||||||
public static final String JOIN = "join";
|
public static final String JOIN = "join";
|
||||||
|
// 系统管理员
|
||||||
|
public static final String SYS_ADMIN = "sys_admin";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<select id="selectSimpleList">
|
<select id="selectSimpleList">
|
||||||
select
|
select
|
||||||
ba.id,
|
ba.id,
|
||||||
ba.name
|
ba.name,
|
||||||
|
su.nick_name as user_name
|
||||||
from <include refid="searchTables"/>
|
from <include refid="searchTables"/>
|
||||||
<where>
|
<where>
|
||||||
<include refid="searchCondition"/>
|
<include refid="searchCondition"/>
|
||||||
|
|
|
@ -144,4 +144,12 @@ public interface BonusService {
|
||||||
*/
|
*/
|
||||||
public List<Bonus> preview(Long deviceId);
|
public List<Bonus> preview(Long deviceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预分成
|
||||||
|
*
|
||||||
|
* @param id 分成明细ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int prepayBonus(Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ public class BonusServiceImpl implements BonusService {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bonus.setPrePayTime(now.plusHours(user.getBonusDelay()));
|
bonus.setPrePayTime(now.plusHours(user.getBonusDelay()).plusMinutes(1));
|
||||||
} else {
|
} else {
|
||||||
bonus.setPrePayTime(now);
|
bonus.setPrePayTime(now);
|
||||||
}
|
}
|
||||||
|
@ -409,4 +409,13 @@ public class BonusServiceImpl implements BonusService {
|
||||||
|
|
||||||
return bonusConverter.toBaseBonusListPlatform(device, partners, join);
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,7 +458,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select
|
select
|
||||||
bo.area_id,
|
bo.area_id,
|
||||||
ba.name as area_name,
|
ba.name as area_name,
|
||||||
sum(<include refid="actualAmount"/>) as actual_amount,
|
sum(if(bo.status = 'PROCESSING', 0, <include refid="actualAmount"/>)) as actual_amount,
|
||||||
count(bo.id) as `count`,
|
count(bo.id) as `count`,
|
||||||
sum(if(bo.status = 'PROCESSING', 1, 0)) as processing_count
|
sum(if(bo.status = 'PROCESSING', 1, 0)) as processing_count
|
||||||
from <include refid="searchTables"/>
|
from <include refid="searchTables"/>
|
||||||
|
|
|
@ -21,11 +21,13 @@ import com.ruoyi.bst.bonus.domain.Bonus;
|
||||||
import com.ruoyi.bst.bonus.domain.enums.BonusBstType;
|
import com.ruoyi.bst.bonus.domain.enums.BonusBstType;
|
||||||
import com.ruoyi.bst.bonus.service.BonusConverter;
|
import com.ruoyi.bst.bonus.service.BonusConverter;
|
||||||
import com.ruoyi.bst.bonus.service.BonusService;
|
import com.ruoyi.bst.bonus.service.BonusService;
|
||||||
|
import com.ruoyi.bst.device.domain.Device;
|
||||||
import com.ruoyi.bst.device.domain.DeviceVO;
|
import com.ruoyi.bst.device.domain.DeviceVO;
|
||||||
import com.ruoyi.bst.device.domain.enums.DeviceUnLockType;
|
import com.ruoyi.bst.device.domain.enums.DeviceUnLockType;
|
||||||
import com.ruoyi.bst.device.domain.vo.DeviceIotVO;
|
import com.ruoyi.bst.device.domain.vo.DeviceIotVO;
|
||||||
import com.ruoyi.bst.device.service.DeviceIotService;
|
import com.ruoyi.bst.device.service.DeviceIotService;
|
||||||
import com.ruoyi.bst.device.service.DeviceService;
|
import com.ruoyi.bst.device.service.DeviceService;
|
||||||
|
import com.ruoyi.bst.device.service.impl.DeviceValidatorImpl;
|
||||||
import com.ruoyi.bst.fault.domain.Fault;
|
import com.ruoyi.bst.fault.domain.Fault;
|
||||||
import com.ruoyi.bst.fault.service.FaultConverter;
|
import com.ruoyi.bst.fault.service.FaultConverter;
|
||||||
import com.ruoyi.bst.fault.service.FaultService;
|
import com.ruoyi.bst.fault.service.FaultService;
|
||||||
|
@ -77,6 +79,8 @@ import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||||
import com.ruoyi.system.user.service.UserService;
|
import com.ruoyi.system.user.service.UserService;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单Service业务层处理
|
* 订单Service业务层处理
|
||||||
*
|
*
|
||||||
|
@ -84,7 +88,10 @@ import com.ruoyi.system.user.service.UserService;
|
||||||
* @date 2025-03-24
|
* @date 2025-03-24
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class OrderServiceImpl implements OrderService {
|
public class OrderServiceImpl implements OrderService {
|
||||||
|
|
||||||
|
private final DeviceValidatorImpl deviceValidatorImpl;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderMapper orderMapper;
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
|
@ -145,6 +152,10 @@ public class OrderServiceImpl implements OrderService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SmsService smsService;
|
private SmsService smsService;
|
||||||
|
|
||||||
|
OrderServiceImpl(DeviceValidatorImpl deviceValidatorImpl) {
|
||||||
|
this.deviceValidatorImpl = deviceValidatorImpl;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单
|
* 查询订单
|
||||||
*
|
*
|
||||||
|
@ -400,6 +411,12 @@ public class OrderServiceImpl implements OrderService {
|
||||||
OrderInParkingVO inParkingVO = bo.getInParkingVO();
|
OrderInParkingVO inParkingVO = bo.getInParkingVO();
|
||||||
AreaVO area = bo.getArea();
|
AreaVO area = bo.getArea();
|
||||||
OrderDeviceVO orderDevice = bo.getOrderDevice();
|
OrderDeviceVO orderDevice = bo.getOrderDevice();
|
||||||
|
DeviceVO device = bo.getDevice();
|
||||||
|
|
||||||
|
// 处理其他线程操作
|
||||||
|
scheduledExecutorService.execute(() -> {
|
||||||
|
this.handleDeviceLocation(device, dto);
|
||||||
|
});
|
||||||
|
|
||||||
// 设置订单数据
|
// 设置订单数据
|
||||||
order.setEndTime(LocalDateTime.now()); // 结束时间
|
order.setEndTime(LocalDateTime.now()); // 结束时间
|
||||||
|
@ -448,15 +465,36 @@ public class OrderServiceImpl implements OrderService {
|
||||||
|
|
||||||
boolean isSuccess = result != null && result == 1;
|
boolean isSuccess = result != null && result == 1;
|
||||||
if (isSuccess && OrderStatus.FINISHED.getCode().equals(order.getStatus())) {
|
if (isSuccess && OrderStatus.FINISHED.getCode().equals(order.getStatus())) {
|
||||||
|
this.handleFinished(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用手机定位设置设备定位
|
||||||
|
private void handleDeviceLocation(DeviceVO device, OrderEndDTO dto) {
|
||||||
|
if (dto.getLon() != null && dto.getLat() != null
|
||||||
|
&& dto.getLon().compareTo(BigDecimal.ZERO) != 0
|
||||||
|
&& dto.getLat().compareTo(BigDecimal.ZERO) != 0) {
|
||||||
|
Device data = new Device();
|
||||||
|
data.setId(device.getId());
|
||||||
|
data.setLongitude(dto.getLon());
|
||||||
|
data.setLatitude(dto.getLat());
|
||||||
|
int rows = deviceService.updateDevice(data);
|
||||||
|
if (rows != 1) {
|
||||||
|
log.error("通过手机定位修改设备定位失败deviceId={}", device.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理订单完成
|
||||||
|
private void handleFinished(OrderVO order) {
|
||||||
scheduledExecutorService.schedule(() -> {
|
scheduledExecutorService.schedule(() -> {
|
||||||
int refund = this.refundRemainAmount(order);
|
int refund = this.refundRemainAmount(order);
|
||||||
ServiceUtil.assertion(refund != 1, "ID为%s的订单退还剩余金额失败", order.getId());
|
ServiceUtil.assertion(refund != 1, "ID为%s的订单退还剩余金额失败", order.getId());
|
||||||
}, 10, TimeUnit.SECONDS);
|
}, 10, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置订单状态
|
// 设置订单状态
|
||||||
private void setOrderStatus(OrderVO order, String returnType) {
|
private void setOrderStatus(OrderVO order, String returnType) {
|
||||||
// 根据是否需要审核,设置订单状态
|
// 根据是否需要审核,设置订单状态
|
||||||
|
@ -750,10 +788,7 @@ public class OrderServiceImpl implements OrderService {
|
||||||
|
|
||||||
// 若审核通过,则退还剩余金额
|
// 若审核通过,则退还剩余金额
|
||||||
if (pass && result != null && result > 0) {
|
if (pass && result != null && result > 0) {
|
||||||
scheduledExecutorService.schedule(() -> {
|
this.handleFinished(order);
|
||||||
int refund = this.refundRemainAmount(order);
|
|
||||||
ServiceUtil.assertion(refund != 1, "ID为%s的订单退还剩余金额失败", order.getId());
|
|
||||||
}, 10, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result == null ? 0 : result;
|
return result == null ? 0 : result;
|
||||||
|
|
|
@ -107,4 +107,13 @@ public class BonusController extends BaseController
|
||||||
return success(bonusService.payBonus(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