1. 优化押金列表
2. 车辆与订单状态同步 3. 硬件版本优化 4. 计算距离 5. 有车损收入的押金 退款按钮隐藏
This commit is contained in:
parent
428cc5ea64
commit
f7aeb814d0
electripper-admin/src/main/java/com/ruoyi/web/controller
app
system
electripper-system/src/main
java/com/ruoyi/system
resources/mapper/system
|
@ -922,11 +922,13 @@ public class AppVerifyController extends BaseController
|
|||
logger.info("【获取运营商信息】获取到areaId:【{}】", areaId);
|
||||
SysDept sysDept = wxPayService.getDeptObjByAreaId(areaId);
|
||||
|
||||
BigDecimal todayOrderAmount = getTodayOrderAmount(sysDept);
|
||||
// 更新 sysDept 的余额字段
|
||||
if (sysDept.getBalance() != null) {
|
||||
sysDept.setSettlementAmount(todayOrderAmount);
|
||||
sysDept.setWithdrawableAmount(sysDept.getBalance().subtract(todayOrderAmount));
|
||||
if(ObjectUtil.isNotNull(sysDept)){
|
||||
BigDecimal todayOrderAmount = getTodayOrderAmount(sysDept);
|
||||
// 更新 sysDept 的余额字段
|
||||
if (sysDept.getBalance() != null) {
|
||||
sysDept.setSettlementAmount(todayOrderAmount);
|
||||
sysDept.setWithdrawableAmount(sysDept.getBalance().subtract(todayOrderAmount));
|
||||
}
|
||||
}
|
||||
return success(sysDept);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,17 @@ public class EtHardwareVersionController extends BaseController
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询硬件版本列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:hardwareVersion:list')")
|
||||
@GetMapping("/list/exclude")
|
||||
public AjaxResult listExclude(EtHardwareVersion etHardwareVersion)
|
||||
{
|
||||
List<EtHardwareVersion> list = etHardwareVersionService.selectEtHardwareVersionListExclude(etHardwareVersion);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出硬件版本列表
|
||||
*/
|
||||
|
|
|
@ -1,41 +1,29 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.common.constant.ServiceConstants;
|
||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.domain.EtOperatingArea;
|
||||
import com.ruoyi.system.domain.vo.RechargeVo;
|
||||
import com.ruoyi.system.service.IAsUserService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
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.constant.ServiceConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.system.domain.EtOrder;
|
||||
import com.ruoyi.system.service.IEtOrderService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.domain.EtOrder;
|
||||
import com.ruoyi.system.domain.vo.RechargeVo;
|
||||
import com.ruoyi.system.service.IAsUserService;
|
||||
import com.ruoyi.system.service.IEtOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单Controller
|
||||
|
|
|
@ -105,15 +105,17 @@ public class SysDeptController extends BaseController
|
|||
AjaxResult ajax = AjaxResult.success();
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
SysDept sysDept = deptService.selectDeptById(deptId);
|
||||
BigDecimal todayOrderAmount = getTodayOrderAmount(deptId);
|
||||
if(ObjectUtil.isNotNull(sysDept)){
|
||||
BigDecimal todayOrderAmount = getTodayOrderAmount(deptId);
|
||||
|
||||
if(todayOrderAmount.compareTo(sysDept.getBalance()) > 0){
|
||||
todayOrderAmount = sysDept.getBalance();
|
||||
}
|
||||
// 更新 sysDept 的余额字段
|
||||
if (sysDept.getBalance() != null) {
|
||||
sysDept.setSettlementAmount(todayOrderAmount);
|
||||
sysDept.setWithdrawableAmount(sysDept.getBalance().subtract(todayOrderAmount));
|
||||
if(todayOrderAmount.compareTo(sysDept.getBalance()) > 0){
|
||||
todayOrderAmount = sysDept.getBalance();
|
||||
}
|
||||
// 更新 sysDept 的余额字段
|
||||
if (sysDept.getBalance() != null) {
|
||||
sysDept.setSettlementAmount(todayOrderAmount);
|
||||
sysDept.setWithdrawableAmount(sysDept.getBalance().subtract(todayOrderAmount));
|
||||
}
|
||||
}
|
||||
|
||||
ajax.put(AjaxResult.DATA_TAG,sysDept);
|
||||
|
@ -260,10 +262,12 @@ public class SysDeptController extends BaseController
|
|||
}
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
SysDept sysDept = deptService.selectDeptById(deptId);
|
||||
BigDecimal todayOrderAmount = getTodayOrderAmount(deptId);//获取今日金额
|
||||
// 更新 sysDept 的余额字段
|
||||
if (sysDept.getBalance() != null) {
|
||||
sysDept.setBalance(sysDept.getBalance().subtract(todayOrderAmount));
|
||||
if(ObjectUtil.isNotNull(sysDept)){
|
||||
BigDecimal todayOrderAmount = getTodayOrderAmount(deptId);//获取今日金额
|
||||
// 更新 sysDept 的余额字段
|
||||
if (sysDept.getBalance() != null) {
|
||||
sysDept.setBalance(sysDept.getBalance().subtract(todayOrderAmount));
|
||||
}
|
||||
}
|
||||
ajax.put(AjaxResult.DATA_TAG, sysDept);
|
||||
return ajax;
|
||||
|
|
|
@ -57,4 +57,8 @@ public class RechargeVo {
|
|||
@Excel(name = "是否已退款")
|
||||
private Boolean isRefunded;
|
||||
|
||||
/** 是否押金抵扣:0-否;1-是 */
|
||||
@Excel(name = "是否押金抵扣")
|
||||
private String depositDeduction;
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,14 @@ public interface EtHardwareVersionMapper
|
|||
*/
|
||||
public List<EtHardwareVersion> selectEtHardwareVersionList(EtHardwareVersion etHardwareVersion);
|
||||
|
||||
/**
|
||||
* 查询硬件版本列表(排除父节点)
|
||||
*
|
||||
* @param etHardwareVersion 硬件版本
|
||||
* @return 硬件版本集合
|
||||
*/
|
||||
public List<EtHardwareVersion> selectEtHardwareVersionListExclude(EtHardwareVersion etHardwareVersion);
|
||||
|
||||
/**
|
||||
* 新增硬件版本
|
||||
*
|
||||
|
|
|
@ -45,6 +45,14 @@ public interface EtOrderMapper
|
|||
*/
|
||||
public List<EtOrder> selectEtOrderList(EtOrder etOrder);
|
||||
|
||||
/**
|
||||
* 查询订单列表(不带路由)
|
||||
*
|
||||
* @param etOrder 订单
|
||||
* @return 订单集合
|
||||
*/
|
||||
public List<EtOrder> selectEtOrderListNoRoute(EtOrder etOrder);
|
||||
|
||||
/**
|
||||
* 新增订单
|
||||
*
|
||||
|
@ -312,4 +320,9 @@ public interface EtOrderMapper
|
|||
* 7天前未支付的订单
|
||||
*/
|
||||
List<EtOrder> selectToBePaidEtOrderList();
|
||||
|
||||
/**
|
||||
* 查询所有正在骑行中的订单
|
||||
*/
|
||||
List<EtOrder> getCurrentOrderList();
|
||||
}
|
||||
|
|
|
@ -5,15 +5,15 @@ import com.ruoyi.system.domain.EtHardwareVersion;
|
|||
|
||||
/**
|
||||
* 硬件版本Service接口
|
||||
*
|
||||
*
|
||||
* @author qiuzhenzhao
|
||||
* @date 2024-07-22
|
||||
*/
|
||||
public interface IEtHardwareVersionService
|
||||
public interface IEtHardwareVersionService
|
||||
{
|
||||
/**
|
||||
* 查询硬件版本
|
||||
*
|
||||
*
|
||||
* @param id 硬件版本主键
|
||||
* @return 硬件版本
|
||||
*/
|
||||
|
@ -21,15 +21,24 @@ public interface IEtHardwareVersionService
|
|||
|
||||
/**
|
||||
* 查询硬件版本列表
|
||||
*
|
||||
*
|
||||
* @param etHardwareVersion 硬件版本
|
||||
* @return 硬件版本集合
|
||||
*/
|
||||
public List<EtHardwareVersion> selectEtHardwareVersionList(EtHardwareVersion etHardwareVersion);
|
||||
|
||||
/**
|
||||
* 查询硬件版本列表(排除父节点)
|
||||
*
|
||||
* @param etHardwareVersion 硬件版本
|
||||
* @return 硬件版本集合
|
||||
*/
|
||||
public List<EtHardwareVersion> selectEtHardwareVersionListExclude(EtHardwareVersion etHardwareVersion);
|
||||
|
||||
|
||||
/**
|
||||
* 新增硬件版本
|
||||
*
|
||||
*
|
||||
* @param etHardwareVersion 硬件版本
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -37,7 +46,7 @@ public interface IEtHardwareVersionService
|
|||
|
||||
/**
|
||||
* 修改硬件版本
|
||||
*
|
||||
*
|
||||
* @param etHardwareVersion 硬件版本
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -45,7 +54,7 @@ public interface IEtHardwareVersionService
|
|||
|
||||
/**
|
||||
* 批量删除硬件版本
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的硬件版本主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -53,7 +62,7 @@ public interface IEtHardwareVersionService
|
|||
|
||||
/**
|
||||
* 删除硬件版本信息
|
||||
*
|
||||
*
|
||||
* @param id 硬件版本主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
|
@ -185,6 +185,11 @@ public interface IEtOrderService
|
|||
*/
|
||||
EtOrder getCurrentOrder(String sn);
|
||||
|
||||
/**
|
||||
* 查询所有正在骑行中的订单
|
||||
*/
|
||||
List<EtOrder> getCurrentOrderList();
|
||||
|
||||
// /**
|
||||
// * 判断当前是否有正在骑行中的订单
|
||||
// */
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.system.mapper.AsDeviceMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.EtHardwareVersionMapper;
|
||||
import com.ruoyi.system.domain.EtHardwareVersion;
|
||||
import com.ruoyi.system.mapper.AsDeviceMapper;
|
||||
import com.ruoyi.system.mapper.EtHardwareVersionMapper;
|
||||
import com.ruoyi.system.service.IEtHardwareVersionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 硬件版本Service业务层处理
|
||||
|
@ -86,6 +86,18 @@ public class EtHardwareVersionServiceImpl implements IEtHardwareVersionService
|
|||
return etHardwareVersions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询硬件版本列表(排除父节点)
|
||||
*
|
||||
* @param etHardwareVersion 硬件版本
|
||||
* @return 硬件版本
|
||||
*/
|
||||
@Override
|
||||
public List<EtHardwareVersion> selectEtHardwareVersionListExclude(EtHardwareVersion etHardwareVersion) {
|
||||
List<EtHardwareVersion> etHardwareVersions = etHardwareVersionMapper.selectEtHardwareVersionListExclude(etHardwareVersion);
|
||||
return etHardwareVersions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增硬件版本
|
||||
*
|
||||
|
@ -95,6 +107,12 @@ public class EtHardwareVersionServiceImpl implements IEtHardwareVersionService
|
|||
@Override
|
||||
public int insertEtHardwareVersion(EtHardwareVersion etHardwareVersion)
|
||||
{
|
||||
if(ObjectUtil.isNull(etHardwareVersion.getParentId()) || etHardwareVersion.getParentId() == 0){
|
||||
etHardwareVersion.setAncestors("0");
|
||||
}else{
|
||||
EtHardwareVersion info = etHardwareVersionMapper.selectEtHardwareVersionById(etHardwareVersion.getParentId());
|
||||
etHardwareVersion.setAncestors(info.getAncestors() + "," + etHardwareVersion.getParentId());
|
||||
}
|
||||
etHardwareVersion.setCreateTime(DateUtils.getNowDate());
|
||||
return etHardwareVersionMapper.insertEtHardwareVersion(etHardwareVersion);
|
||||
}
|
||||
|
|
|
@ -307,13 +307,14 @@ public class EtOrderServiceImpl implements IEtOrderService
|
|||
if(StrUtil.isBlank(status) || "1".equals(status)){
|
||||
etOrder.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
|
||||
etOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
||||
List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(etOrder);
|
||||
List<EtOrder> etOrders = etOrderMapper.selectEtOrderListNoRoute(etOrder);
|
||||
etOrders.forEach(etOrder1 -> {
|
||||
RechargeVo rechargeVo = new RechargeVo();
|
||||
BeanUtils.copyProperties(etOrder1,rechargeVo);
|
||||
rechargeVo.setRechargeStatus(ServiceConstants.RECHARGE_STATUS_SUCCESS);
|
||||
rechargeVo.setRechargeType(ServiceConstants.ORDER_TYPE_DEPOSIT);
|
||||
rechargeVo.setTotalFee(etOrder1.getPayFee());
|
||||
rechargeVo.setDepositDeduction(etOrder1.getDepositDeduction());
|
||||
List<EtRefund> etRefunds = etRefundMapper.selectEtRefundByOrderNo(etOrder1.getOrderNo());
|
||||
if(ObjectUtil.isNull(etRefunds) || etRefunds.size() == 0){
|
||||
rechargeVo.setIsRefunded(false);
|
||||
|
@ -332,7 +333,7 @@ public class EtOrderServiceImpl implements IEtOrderService
|
|||
PageUtils.startPage();
|
||||
List<EtRefund> etRefunds = etRefundMapper.selectEtRefundList(refund);
|
||||
etRefunds.forEach(etRefund -> {
|
||||
AsUser asUser = asUserService.selectUserById(etRefund.getUserId());
|
||||
AsUser asUser = asUserMapper.selectUserById(etRefund.getUserId());
|
||||
RechargeVo rechargeVo = new RechargeVo();
|
||||
BeanUtils.copyProperties(etRefund,rechargeVo);
|
||||
rechargeVo.setOutTradeNo(etRefund.getRefundNo());
|
||||
|
@ -370,6 +371,17 @@ public class EtOrderServiceImpl implements IEtOrderService
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有正在骑行中的订单
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<EtOrder> getCurrentOrderList() {
|
||||
List<EtOrder> etOrders = etOrderMapper.getCurrentOrderList();
|
||||
return etOrders;
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 获取当前正在骑行中的订单数量
|
||||
// * @param sn
|
||||
|
@ -670,11 +682,13 @@ public class EtOrderServiceImpl implements IEtOrderService
|
|||
Refund refund = wxPayService.refund(depositOrder, "还车审核通过后退押金",residualDeposit,IdUtils.getOrderNo("ref"));
|
||||
/** 3.记录退款表 创建退款对象*/
|
||||
depositOrder.setReason("还车审核通过后退押金");
|
||||
EtRefund refund1= createRefund(depositOrder, residualDeposit, null, null, null, null, refund.getOutRefundNo(),ServiceConstants.REFUND_TYPE_DEPOSIT);
|
||||
int i = etRefundService.insertEtRefund(refund1);
|
||||
if(i == 0){
|
||||
log.info("【还车审核通过】保存退款对象失败");
|
||||
throw new ServiceException("【还车审核通过】,保存退款对象失败");
|
||||
if(deductionAmount.compareTo(BigDecimal.ZERO) > 0){
|
||||
EtRefund refund1= createRefund(depositOrder, residualDeposit, null, null, null, null, refund.getOutRefundNo(),ServiceConstants.REFUND_TYPE_DEPOSIT);
|
||||
int i = etRefundService.insertEtRefund(refund1);
|
||||
if(i == 0){
|
||||
log.info("【还车审核通过】保存退款对象失败");
|
||||
throw new ServiceException("【还车审核通过】,保存退款对象失败");
|
||||
}
|
||||
}
|
||||
/** 4.更新用户余额*/
|
||||
AsUser asUser = asUserService.selectUserById(depositOrder.getUserId());
|
||||
|
@ -688,7 +702,7 @@ public class EtOrderServiceImpl implements IEtOrderService
|
|||
throw new ServiceException("【还车审核通过】,更新用户信息失败");
|
||||
}
|
||||
}
|
||||
if(deductionAmount.compareTo(BigDecimal.ZERO) > 0){//抵扣金额大于0时,增加车损收入
|
||||
if(deductionAmount.compareTo(BigDecimal.ZERO) >= 0){//抵扣金额大于0时,增加车损收入
|
||||
/** 押金抵扣后生成资金流水记录 */
|
||||
etOrder.setPayFee(deductionAmount);
|
||||
callbackService.capitalFlowRecords(etOrder,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_VEHICLE_DAMAGE,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ);
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.system.task;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.ServiceConstants;
|
||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
||||
|
@ -15,7 +16,6 @@ import com.ruoyi.common.utils.uuid.IdUtils;
|
|||
import com.ruoyi.system.domain.*;
|
||||
import com.ruoyi.system.mapper.*;
|
||||
import com.ruoyi.system.service.*;
|
||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
import com.wechat.pay.java.service.refund.model.Refund;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -86,6 +86,9 @@ public class EtTask {
|
|||
@Resource
|
||||
private EtLocationLogMapper etLocationLogMapper;
|
||||
|
||||
@Autowired
|
||||
private IAsDeviceService deviceService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -373,7 +376,7 @@ public class EtTask {
|
|||
}
|
||||
|
||||
/**
|
||||
* 开始骑行未结束的订单,10秒算一次距离
|
||||
* 开始骑行未结束的订单,1分钟算一次距离
|
||||
* cron: 0 5 0 * * ?
|
||||
*/
|
||||
public void computeDistance(){
|
||||
|
@ -383,7 +386,9 @@ public class EtTask {
|
|||
order.setStatus(ServiceConstants.ORDER_STATUS_RIDING);
|
||||
List<EtOrder> orders = etOrderService.selectEtOrderList(order);
|
||||
for(EtOrder etOrder:orders){
|
||||
String tripRouteStr = etOrder.getTripRouteStr();
|
||||
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getNowDate());
|
||||
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, etOrder.getUnlockTime());
|
||||
String tripRouteStr = deviceService.trajectory(etOrder.getSn(), startTime, endTime);
|
||||
if(StrUtil.isNotBlank(tripRouteStr)){
|
||||
double[][] doubles = GeoUtils.parseJsonTrack(tripRouteStr);
|
||||
double v = GeoUtils.calculateTotalDistance(doubles);
|
||||
|
@ -408,6 +413,52 @@ public class EtTask {
|
|||
etLocationLogMapper.deleteLocationLogByCreateTime();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 车辆与订单状态同步
|
||||
* 1. 如果有正在骑行中的订单,车辆的状态是待骑行的,改成临时锁车,不发命令
|
||||
* 2. 如果车辆状态是骑行中或临时锁车,查询订单没有订单,则修改车辆状态为待骑行
|
||||
*
|
||||
*/
|
||||
public void stausSynchronization(){
|
||||
log.info("-------------------【定时任务】车辆与订单状态同步-------------------");
|
||||
// 当前有骑行中的订单
|
||||
List<EtOrder> orders = etOrderService.getCurrentOrderList();
|
||||
for (EtOrder order:orders) {
|
||||
AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn());
|
||||
if(ObjectUtil.isNotNull(device) && device.getStatus().equals(ServiceConstants.VEHICLE_STATUS_NORMAL)){
|
||||
AsDevice device1 = new AsDevice();
|
||||
device1.setSn(device.getSn());
|
||||
device1.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK);
|
||||
device1.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||
int i = asDeviceMapper.updateAsDeviceBySn(device1);
|
||||
if(i>0){
|
||||
log.info("【定时任务】车辆状态修改为临时锁车:【sn="+device.getSn()+"】");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 如果车辆状态是骑行中或临时锁车,查询当前没有订单,则修改车辆状态为待骑行
|
||||
QueryWrapper<AsDevice> wrapper = new QueryWrapper<>();
|
||||
wrapper.in("status", "3","4"); // 设备状态正常
|
||||
// 查询所有设备
|
||||
List<AsDevice> allDevices = asDeviceMapper.selectList(wrapper);
|
||||
for(AsDevice device:allDevices){
|
||||
if(ObjectUtil.isNotNull(etOrderService.getCurrentOrder(device.getSn()))){
|
||||
continue;
|
||||
}else{
|
||||
AsDevice device1 = new AsDevice();
|
||||
device1.setSn(device.getSn());
|
||||
device1.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
|
||||
device1.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||
int i = asDeviceMapper.updateAsDeviceBySn(device1);
|
||||
if(i>0){
|
||||
log.info("【定时任务】车辆状态修改为待骑行:【sn="+device.getSn()+"】");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 写一个定时,如果车辆是骑行中,没有现在骑行中的订单,则关闭车辆
|
||||
/**
|
||||
* 自动押金抵扣
|
||||
|
@ -427,37 +478,6 @@ public class EtTask {
|
|||
updateOrderPaid(order);
|
||||
}else{
|
||||
etOrderService.deduction(order);
|
||||
// if(StrUtil.isNotBlank(order.getOutTradeNo())){
|
||||
// String outTradeNo = order.getOutTradeNo();
|
||||
// log.info("【自动押金抵扣】订单【{}】,有outTradeNo = 【{}】", order.getOrderNo(),outTradeNo);
|
||||
// // 如果原来有outtradeno,去查询一次,查询是否支付过
|
||||
// Transaction transaction = wxPayService.queryOrderByOutTradeNo(outTradeNo);
|
||||
// if(Transaction.TradeStateEnum.SUCCESS.equals(transaction.getTradeState())) {
|
||||
// // 订单已支付
|
||||
// order.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
|
||||
// order.setPayTime(DateUtils.getNowDate());
|
||||
// order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
||||
// order.setPayType(ServiceConstants.PAY_TYPE_WX);
|
||||
// order.setMark("主动查询-骑行支付");
|
||||
// int updateEtOrder = etOrderMapper.updateEtOrder(order);
|
||||
// if (updateEtOrder == 0) {
|
||||
// throw new ServiceException("押金抵扣失败,更新骑行订单失败");
|
||||
// }
|
||||
// }else{
|
||||
// updateOrderPaid(order);
|
||||
// }
|
||||
// }else{
|
||||
// // 3. 查询用户是否还有未退款的押金,如果有,则进行押金抵扣,如果没有,则结束订单
|
||||
// List<EtOrder> yjOrders = etRefundService.checkUserDeposit(order.getUserId());
|
||||
// if(ObjectUtil.isNotNull(yjOrders) && yjOrders.size()>0){
|
||||
// // 取出最后一个订单对象
|
||||
// yjOrders.sort(Comparator.comparing(EtOrder::getCreateTime)); // 按create_time升序排序
|
||||
// EtOrder lastOrder = yjOrders.get(yjOrders.size() - 1); // 获取最后一个订单对象
|
||||
// etOrderService.deduction();
|
||||
// }else{
|
||||
// updateOrderPaid(order);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,10 +24,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="partnerDividend" column="partner_dividend" />
|
||||
<result property="payType" column="pay_type" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="modelId" column="model_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEtCapitalFlowVo">
|
||||
select flow_id, area_id, owner, owner_id, owner_type, order_no, out_trade_no, type, bus_type, status, amount, handling_charge, platform_service_fee, operator_dividend, operator_balance, partner_dividend, pay_type, create_time from et_capital_flow
|
||||
select flow_id, area_id, owner, owner_id, owner_type, order_no, out_trade_no, type, bus_type, status, amount, handling_charge, platform_service_fee, operator_dividend, operator_balance, partner_dividend, pay_type, create_time, model_id from et_capital_flow
|
||||
</sql>
|
||||
|
||||
<select id="selectEtCapitalFlowList" parameterType="EtCapitalFlow" resultMap="EtCapitalFlowResult">
|
||||
|
@ -189,6 +190,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="partnerDividend != null">partner_dividend,</if>
|
||||
<if test="payType != null">pay_type,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="modelId != null">model_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="flowId != null">#{flowId},</if>
|
||||
|
@ -209,6 +211,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="partnerDividend != null">#{partnerDividend},</if>
|
||||
<if test="payType != null">#{payType},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="modelId != null">#{modelId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -232,6 +235,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="partnerDividend != null">partner_dividend = #{partnerDividend},</if>
|
||||
<if test="payType != null">pay_type = #{payType},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="modelId != null">model_id = #{modelId},</if>
|
||||
</trim>
|
||||
where flow_id = #{flowId}
|
||||
</update>
|
||||
|
|
|
@ -31,6 +31,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
order by version
|
||||
</select>
|
||||
|
||||
<select id="selectEtHardwareVersionListExclude" parameterType="EtHardwareVersion" resultMap="EtHardwareVersionResult">
|
||||
<include refid="selectEtHardwareVersionVo"/>
|
||||
where parent_id !=0
|
||||
<if test="version != null and version != ''"> and version = #{version}</if>
|
||||
<if test="productionTime != null "> and production_time = #{productionTime}</if>
|
||||
<if test="instructions != null and instructions != ''"> and instructions = #{instructions}</if>
|
||||
order by version
|
||||
</select>
|
||||
|
||||
<select id="selectEtHardwareVersionById" parameterType="Long" resultMap="EtHardwareVersionResult">
|
||||
<include refid="selectEtHardwareVersionVo"/>
|
||||
where id = #{id}
|
||||
|
|
|
@ -159,6 +159,99 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
order by o.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectEtOrderListNoRoute" parameterType="EtOrder" resultMap="EtOrderResult">
|
||||
SELECT
|
||||
o.order_id,
|
||||
o.area_id,
|
||||
oa.area_name AS area,
|
||||
oa.is_deposit_deduction isDepositDeduction,
|
||||
u.user_name AS userName,
|
||||
u.phonenumber AS phonenumber,
|
||||
u.real_name AS realName,
|
||||
o.order_no,
|
||||
o.out_trade_no,
|
||||
o.user_id,
|
||||
o.rule_id,
|
||||
o.device_mac,
|
||||
o.sn,
|
||||
de.vehicle_num,
|
||||
o.pay_time,
|
||||
o.paid,
|
||||
o.pay_type,
|
||||
o.type,
|
||||
COALESCE(o.total_fee, 0) AS total_fee,
|
||||
COALESCE(o.pay_fee, 0) AS pay_fee,
|
||||
COALESCE(o.dispatch_fee, 0) AS dispatch_fee,
|
||||
COALESCE(o.manage_fee, 0) AS manage_fee,
|
||||
COALESCE(o.riding_fee, 0) AS riding_fee,
|
||||
COALESCE(o.appointment_fee, 0) AS appointment_fee,
|
||||
o.mark,
|
||||
o.duration,
|
||||
o.distance,
|
||||
o.status,
|
||||
o.create_time,
|
||||
o.appointment_start_time,
|
||||
o.appointment_end_time,
|
||||
o.appointment_timeout,
|
||||
o.unlock_time,
|
||||
o.return_time,
|
||||
o.rule_end_time,
|
||||
o.return_type,
|
||||
o.video_url,
|
||||
o.upload_time,
|
||||
o.deduction_amount,
|
||||
o.deposit_deduction,
|
||||
o.audio_files,
|
||||
o.used_sn,
|
||||
o.change_reason,
|
||||
o.locking
|
||||
FROM
|
||||
et_order o
|
||||
LEFT JOIN
|
||||
et_operating_area oa ON o.area_id = oa.area_id
|
||||
LEFT JOIN
|
||||
et_device de ON de.sn = o.sn
|
||||
LEFT JOIN
|
||||
et_user u ON u.user_id = o.user_id
|
||||
LEFT join et_area_dept ad on ad.area_id = oa.area_id
|
||||
LEFT join sys_dept d on d.dept_id = ad.dept_id
|
||||
where 1 = 1
|
||||
<if test="orderNo != null and orderNo != ''"> and o.order_no like concat('%', #{orderNo}, '%')</if>
|
||||
<if test="area != null and area != ''"> and oa.area_name like concat('%', #{area}, '%')</if>
|
||||
<if test="areaId != null"> and o.area_id = #{areaId}</if>
|
||||
<if test="userName != null and userName != ''"> and u.user_name like concat('%', #{userName}, '%')</if>
|
||||
<if test="phonenumber != null and phonenumber != ''"> and u.phonenumber like concat('%', #{phonenumber}, '%')</if>
|
||||
<if test="userId != null and userId != ''"> and o.user_id = #{userId}</if>
|
||||
<if test="deviceMac != null and deviceMac != ''"> and o.device_mac like concat('%', #{deviceMac}, '%')</if>
|
||||
<if test="vehicleNum != null and vehicleNum != ''"> and de.vehicle_num like concat('%', #{vehicleNum }, '%')</if>
|
||||
<if test="sn != null and sn != ''"> and o.sn like concat('%', #{sn}, '%')</if>
|
||||
<if test="type != null and type != ''"> and o.type = #{type}</if>
|
||||
<if test="status != null and status != ''"> and o.status = #{status}</if>
|
||||
<if test="paid != null and paid != ''"> and o.paid = #{paid}</if>
|
||||
<if test="payType != null and payType != ''"> and o.pay_type = #{payType}</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(o.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(o.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(o.create_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(o.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="statusList != null">
|
||||
AND o.status IN
|
||||
<foreach item="item" index="index" collection="statusList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
order by o.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectEtOrderByOrderId" parameterType="Long" resultMap="EtOrderResult">
|
||||
select o.order_id,
|
||||
o.area_id,
|
||||
|
@ -874,5 +967,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where status = 3 and return_time <= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
||||
</select>
|
||||
|
||||
<select id="getCurrentOrderList" resultType="com.ruoyi.system.domain.EtOrder">
|
||||
select order_id, area_id, order_no, sn from et_order
|
||||
where status = 2
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue
Block a user