Compare commits

...

3 Commits

Author SHA1 Message Date
ccb1ee5fc4 1. 调整 2024-08-08 10:05:51 +08:00
aeba491f42 1. 调整 2024-08-07 20:13:16 +08:00
803d2211aa 1. 调整 2024-08-07 10:25:15 +08:00
12 changed files with 242 additions and 65 deletions

View File

@ -345,6 +345,20 @@ public class AppController extends BaseController
return success(orders);
}
/**
* 查询当前用户是否有正在审核中的订单
*/
@PostMapping("/user/isInAuditOrder")
public AjaxResult isInAuditOrder(Long userId)
{
if(StrUtil.isBlank(userId.toString())){
logger.info("没有userId参数【userId={}】",userId);
return error("请传userId参数"+"【userId="+userId+"");
}
List<EtOrder> orders = etOrderService.isInAuditOrder(userId,null);
return success(orders);
}
/**
* 根据定位获取地址 逆地理编码
@ -587,4 +601,14 @@ public class AppController extends BaseController
return success(token);
}
/**
* 修复押金抵扣资金流水
*/
@GetMapping(value = "/repair/deduction")
public AjaxResult repairDeduction(Long areaId)
{
logger.info("【修复押金抵扣请求】区域id={}",areaId);
return toAjax(etOrderService.repairDeduction(areaId));
}
}

View File

@ -270,6 +270,9 @@ public class AppVerifyController extends BaseController
if(!ServiceConstants.ORDER_PAY_STATUS_NON_PAYMENT.equals(etOrder1.getPaid())){
throw new ServiceException("订单已支付,不能改价");
}
if("1".equals(etOrder1.getLocking())){
throw new ServiceException("用户正在支付中,请勿操作");
}
if(!ServiceConstants.ORDER_STATUS_RIDING_END.equals(etOrder1.getStatus()) && !ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT.equals(etOrder1.getStatus())){
throw new ServiceException("改价失败,订单未结束,订单状态:"+etOrder1.getStatus());
}
@ -937,6 +940,20 @@ public class AppVerifyController extends BaseController
return toAjax(etOrderService.updateEtOrderByOrderNo(etOrder));
}
/**
* 取消锁单
*/
@Log(title = "取消锁单", businessType = BusinessType.UNLOCKORDER)
@PostMapping("/order/unlockOrder")
public AjaxResult unlockOrder(String orderNo)
{
logger.info("【取消锁单】:{}", orderNo);
EtOrder etOrder = new EtOrder();
etOrder.setLocking("0");
etOrder.setOrderNo(orderNo);
return toAjax(etOrderService.updateEtOrderByOrderNo(etOrder));
}
/**
* 还车审核通过
* 改状态退押金
@ -1059,6 +1076,25 @@ public class AppVerifyController extends BaseController
logger.info("没有orderNo参数【orderNo={}】",orderNo);
return error("请传orderNo号参数"+"【orderNo="+orderNo+"");
}
//运营时间判断
if(!asDeviceService.isOperatingTime(newSn)){
return error("不在营业时间内,不得骑行");
}
//非正常状态不得骑行
AsDevice newDevice = asDeviceMapper.selectAsDeviceBySn(newSn);
String status = newDevice.getStatus();
if(!ServiceConstants.VEHICLE_STATUS_NORMAL.equals(status)){
return error(CommonUtil.format(status));
}
// 当前有骑行中的订单
EtOrder currentOrder = etOrderService.getCurrentOrder(newDevice.getSn());
if(ObjectUtil.isNotNull(currentOrder)){
return error("当前车辆有骑行中的订单,请换车");
}
//低电量不得骑行判断
if(asDeviceService.isLowBattery(newDevice.getSn())){
return error("低电量不得骑行");
}
logger.info("【换车开锁请求】orderNo={},newSn ={}",orderNo,newSn);
Boolean aBoolean =etOrderService.changeVehicleLockUnlocking(orderNo,newSn,isBluetooth,lon,lat,voltage);
return success(aBoolean);

View File

@ -159,6 +159,10 @@ public enum BusinessType
* 保存视频
*/
VIDEO,
/**
* 取消锁单
*/
UNLOCKORDER,
/**
* 重启设备
*/

View File

@ -263,4 +263,8 @@ public class EtOrder extends BaseEntity
/** 换车原因1-电量过低2-车辆故障 */
@Excel(name = "换车原因1-电量过低2-车辆故障")
private String changeReason;
/** 锁单中: 0-否1-是 */
@Excel(name = "锁单中: 0-否1-是")
private String locking;
}

View File

@ -94,6 +94,15 @@ public interface EtOrderMapper
*/
public List<EtOrder> isInOrder(@Param("userId") Long userId,@Param("orderNo") String orderNo);
/**
* 查询当前用户是否有正在进行中的审核订单
*
* @param userId 用户id
* @param orderNo 排除当前订单号
* @return 结果
*/
public List<EtOrder> isInAuditOrder(@Param("userId") Long userId,@Param("orderNo") String orderNo);
/**
* 查询当前车辆是否有正在进行中的订单
*
@ -280,5 +289,7 @@ public interface EtOrderMapper
// BigDecimal getPlatformServiceFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("areaId") Long areaId);
Integer getAppCount();
// Integer getAppCount();
List<EtOrder> selectDeductionList(Long areaId);
}

View File

@ -115,6 +115,11 @@ public interface IEtOrderService
*/
List<EtOrder> isInOrder(Long userId,String orderNo);
/**
* 查询当前用户是否有正在审核中的订单
*/
List<EtOrder> isInAuditOrder(Long userId,String orderNo);
/**
* 查询当前车辆是否有正在进行中的订单
*/
@ -194,6 +199,11 @@ public interface IEtOrderService
*/
int deduction(EtOrder etOrder);
/**
* 修复押金抵扣
*/
int repairDeduction(Long areaId);
/**
* 还车审核通过
*/

View File

@ -1318,8 +1318,14 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
/** 2.发送命令*/
sendCommand(asDevice.getMac(), Token.getToken(),IotConstants.COMMAND_CLOSE+IotConstants.COMMAND_FREQUENCY_3600,"管理员锁车",null,userName);
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
if(!asDevice.getStatus().equals(ServiceConstants.VEHICLE_STATUS_NOT_LISTING)){
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
// 判断该sn是否有正在骑行中的订单如果有骑行中的订单则修改为临时锁车
EtOrder etOrder = etOrderService.getCurrentOrder(asDevice.getSn());
if(ObjectUtil.isNotNull(etOrder)){
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK);
}else{
if(!asDevice.getStatus().equals(ServiceConstants.VEHICLE_STATUS_NOT_LISTING)){
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
}
}
asDevice.setIsAdminUnlocking("0");
int device = asDeviceMapper.updateAsDevice(asDevice);
@ -1557,6 +1563,19 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
// order.setReturnTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, "2024-07-23 17:09:32"));//2024-06-28 18:15:56
String token = Token.getToken();
AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn());
if(ObjectUtil.isNull(device)){
String usedSn = order.getUsedSn();
// 判断字符串中是否包含逗号
if (usedSn.contains(",")) {
// 使用逗号分割字符串
String[] parts = usedSn.split(",");
// 获取最后一个对象
String lastPart = parts[parts.length - 1];
order.setSn(lastPart);
} else {
order.setSn(usedSn);
}
}
if(ServiceConstants.RETURN_TYPE_NORMAL.equals(returnType)){
if(!"true".equals(isBluetooth)){
/** 2. 车辆远程关锁*/
@ -1591,13 +1610,15 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
}
}
}
/** 4. 更新车辆状态*/
device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
int deviceUpdate = asDeviceMapper.updateAsDevice(device);
if(deviceUpdate==0){
log.info("【还车关锁】更新车辆状态失败");
throw new ServiceException("【还车关锁】更新车辆状态失败");
if(ObjectUtil.isNotNull(device)){
/** 4. 更新车辆状态*/
device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
int deviceUpdate = asDeviceMapper.updateAsDevice(device);
if(deviceUpdate==0){
log.info("【还车关锁】更新车辆状态失败");
throw new ServiceException("【还车关锁】更新车辆状态失败");
}
}
/** 3. 计算订单费用,保存订单总金额*/
order = calculateOrderFee(order,isInParkingArea);
@ -1633,10 +1654,12 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
throw new ServiceException("更新订单状态失败");
}
/** 5.记录行程*/
int tripLog = tripLogService.tripLog(order.getOrderNo(),device.getSn(),ServiceConstants.TRIP_LOG_TYPE_RETRUN_LOCK);
if(tripLog==0){
log.info("【还车关锁】记录行程失败");
throw new ServiceException("【还车关锁】记录行程失败");
if(ObjectUtil.isNotNull(device)){
int tripLog = tripLogService.tripLog(order.getOrderNo(),device.getSn(),ServiceConstants.TRIP_LOG_TYPE_RETRUN_LOCK);
if(tripLog==0){
log.info("【还车关锁】记录行程失败");
throw new ServiceException("【还车关锁】记录行程失败");
}
}
log.info("还车成功");
return Boolean.TRUE;
@ -1813,7 +1836,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
}
/** 调度费*/
//判断是否在运营区内
if(!isAreaZone(order.getSn(), area)){
if(StrUtil.isNotBlank(order.getSn()) && !isAreaZone(order.getSn(), area)){
BigDecimal dispatchFee = area.getDispatchFee();//调度费
order.setDispatchFee(dispatchFee);
}

View File

@ -194,6 +194,7 @@ public class CallbackServiceImpl implements CallbackService {
order.setPaid("1");
order.setPayTime(DateUtils.getNowDate());
order.setPayType(ServiceConstants.PAY_TYPE_WX);
order.setLocking("0");
if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_RIDING)){
logger.info("【微信支付回调】骑行支付");
// 1-骑行支付 关锁

View File

@ -38,6 +38,8 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 订单Service业务层处理
@ -464,6 +466,41 @@ public class EtOrderServiceImpl implements IEtOrderService
throw new ServiceException("【押金抵扣】,更新用户信息失败");
}
}
/** 押金抵扣后生成资金流水记录 */
callbackService.capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ);
}
return 1;
}
/**
* 修复押金抵扣
* 1. 查询所有押金抵扣的订单
* 2. 如果是骑行费大于押金则按押金计算
* 如果骑行费小于押金则按骑行费计算
* 3. 增加一条资金流水记录
*/
@Override
@Transactional
public int repairDeduction(Long areaId) {
List<EtOrder> orders = etOrderMapper.selectDeductionList(areaId);
for (EtOrder order : orders) {
// 找出所有骑行费大于押金的订单把骑行费改成押金
if(order.getMark().contains("大于")){
String input = order.getMark();
// 正则表达式匹配押金后的金额
String regex = "押金【(\\d+\\.\\d+)】";
// 编译正则表达式
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
// 查找匹配项
if (matcher.find()) {
// 提取金额
String depositAmount = matcher.group(1);
order.setPayFee(new BigDecimal(depositAmount));
}
}
/** 押金抵扣后生成资金流水记录 */
callbackService.capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ);
}
return 1;
}
@ -1546,6 +1583,15 @@ public class EtOrderServiceImpl implements IEtOrderService
}
return inOrder;
}
/**
* 查询当前用户是否有正在进行中的订单
*/
@Override
public List<EtOrder> isInAuditOrder(Long userId,String orderNo) {
List<EtOrder> inOrder = etOrderMapper.isInAuditOrder(userId, orderNo);
return inOrder;
}
/**
* 查询当前车辆是否有正在进行中的订单
*/
@ -1570,53 +1616,54 @@ public class EtOrderServiceImpl implements IEtOrderService
throw new ServiceException("该订单状态非骑行中");
}
String sn = order.getSn();
if(StrUtil.isBlank(sn))throw new ServiceException("sn不能为空");
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn);
/** 2.发送命令*/
if(!"true".equals(isBluetooth)){
ResponseVo responseVo = asDeviceService.sendCommandWithResp(asDevice.getMac(), Token.getToken(), IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "换车关锁",orderNo);
if(responseVo.getCode()!=0){
log.info("【还车关锁】远程关锁失败");
throw new ServiceException("远程关锁失败");
}
}else{
asDevice.setLongitude(lon);
asDevice.setLatitude(lat);
if(StrUtil.isNotBlank(voltage)){
BigDecimal divide = new BigDecimal(voltage).divide(new BigDecimal(10));
asDevice.setVoltage(divide.toString());
EtModel model = etModelService.selectEtModelByModelId(asDevice.getModelId());
Integer remainingMileage = 0;
if(StrUtil.isNotBlank(asDevice.getVoltage())){
remainingMileage = CommonUtil.getRemainingMileage(asDevice.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance());
if(StrUtil.isNotBlank(sn)){
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn);
/** 2.发送命令*/
if(!"true".equals(isBluetooth)){
ResponseVo responseVo = asDeviceService.sendCommandWithResp(asDevice.getMac(), Token.getToken(), IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "换车关锁",orderNo);
if(responseVo.getCode()!=0){
log.info("【还车关锁】远程关锁失败");
throw new ServiceException("远程关锁失败");
}
Integer electricQuantity = CommonUtil.getElectricQuantity(asDevice.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百
asDevice.setRemainingMileage(remainingMileage);
asDevice.setRemainingPower(electricQuantity.toString());
}else{
asDevice.setLongitude(lon);
asDevice.setLatitude(lat);
if(StrUtil.isNotBlank(voltage)){
BigDecimal divide = new BigDecimal(voltage).divide(new BigDecimal(10));
asDevice.setVoltage(divide.toString());
EtModel model = etModelService.selectEtModelByModelId(asDevice.getModelId());
Integer remainingMileage = 0;
if(StrUtil.isNotBlank(asDevice.getVoltage())){
remainingMileage = CommonUtil.getRemainingMileage(asDevice.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance());
}
Integer electricQuantity = CommonUtil.getElectricQuantity(asDevice.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百
asDevice.setRemainingMileage(remainingMileage);
asDevice.setRemainingPower(electricQuantity.toString());
}
asDevice.setLastTime(DateUtils.getNowDate());
}
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
asDevice.setIsAdminUnlocking("0");
int device = asDeviceMapper.updateAsDevice(asDevice);
if(device==0){
log.info("【临时解锁】改变车辆状态失败");
throw new ServiceException("【临时锁车】改变车辆状态失败");
}
String usedSn = order.getUsedSn();
if(StrUtil.isNotBlank(usedSn)){
usedSn = usedSn+","+sn;
}else{
usedSn = sn;
}
order.setUsedSn(usedSn);
order.setSn("");
order.setChangeReason(changeReason);
int i = etOrderMapper.updateEtOrderByOrderNo(order);
if(i==0){
log.info("【换车关锁】改变订单使用过的sn失败");
throw new ServiceException("【换车关锁】改变订单使用过的sn失败");
}
asDevice.setLastTime(DateUtils.getNowDate());
}
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
asDevice.setIsAdminUnlocking("0");
int device = asDeviceMapper.updateAsDevice(asDevice);
if(device==0){
log.info("【临时解锁】改变车辆状态失败");
throw new ServiceException("【临时锁车】改变车辆状态失败");
}
String usedSn = order.getUsedSn();
if(StrUtil.isNotBlank(usedSn)){
usedSn = usedSn+","+sn;
}else{
usedSn = sn;
}
order.setUsedSn(usedSn);
order.setSn("");
order.setChangeReason(changeReason);
int i = etOrderMapper.updateEtOrderByOrderNo(order);
if(i==0){
log.info("【换车关锁】改变订单使用过的sn失败");
throw new ServiceException("【换车关锁】改变订单使用过的sn失败");
}
return Boolean.TRUE;
}
@ -1665,8 +1712,7 @@ public class EtOrderServiceImpl implements IEtOrderService
}
newDevice.setLastTime(DateUtils.getNowDate());
}
newDevice.setIsAdminUnlocking("1");
newDevice.setStatus(ServiceConstants.VEHICLE_STATUS_SCHEDULING);
newDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
newDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
int i = asDeviceMapper.updateAsDevice(newDevice);
if(i>0){

View File

@ -108,6 +108,7 @@ public class WxPayService implements IWxPayService {
request.setAmount(getAmount(order.getPayFee()));
String outTradeNo = IdUtils.getOrderNo("wx");
order.setOutTradeNo(outTradeNo);
order.setLocking("1");
int updateEtOrder = etOrderService.updateEtOrder(order);
if(updateEtOrder == 0){
throw new ServiceException("更新订单outTradeNo失败");

View File

@ -109,7 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
COALESCE(SUM(CASE WHEN f.type = '2' THEN handling_charge ELSE 0 END), 0) AS net_fee
from et_capital_flow f
LEFT JOIN et_order o on o.order_no = f.order_no
where f.area_id != 14 and f.bus_type != '5' and f.bus_type != '6'
where f.bus_type != '5' and f.bus_type != '6'
<if test="sn != null and sn != ''"> and o.sn = #{sn}</if>
<if test="timeStart != null and timeStart != ''">
AND date_format(f.create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')

View File

@ -46,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="audioFiles" column="audio_files" />
<result property="usedSn" column="used_sn" />
<result property="changeReason" column="change_reason" />
<result property="locking" column="locking" />
</resultMap>
<sql id="selectEtOrderVo">
@ -53,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
device_mac, sn, pay_time, paid, pay_type, type, total_fee, pay_fee, dispatch_fee,
manage_fee, riding_fee, appointment_fee, mark, duration, distance, status,
create_time, appointment_start_time, appointment_end_time,appointment_timeout, unlock_time,return_time,
rule_end_time, return_type, AsText(trip_route) trip_route,trip_route_str,cycle,deposit_deduction,video_url,upload_time,deduction_amount,audio_files,used_sn,change_reason from et_order
rule_end_time, return_type, AsText(trip_route) trip_route,trip_route_str,cycle,deposit_deduction,video_url,upload_time,deduction_amount,audio_files,used_sn,change_reason,locking from et_order
</sql>
<select id="selectEtOrderList" parameterType="EtOrder" resultMap="EtOrderResult">
@ -101,7 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
o.deduction_amount,
o.audio_files,
o.used_sn,
o.change_reason
o.change_reason,
o.locking
FROM
et_order o
LEFT JOIN
@ -125,6 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
@ -209,6 +212,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="isInAuditOrder" resultMap="EtOrderResult" parameterType="Long">
<include refid="selectEtOrderVo"/>
<where>
<if test="orderNo != null and orderNo != ''"> and order_no != #{orderNo}</if>
and user_id = #{userId} and status in(5,6,7) and type = 1
</where>
</select>
<select id="isInOrderBySn" resultMap="EtOrderResult" parameterType="String">
<include refid="selectEtOrderVo"/>
where sn = #{sn} and status =2 and type = 1
@ -587,6 +598,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND o.is_test = '0'
</select>
<select id="selectDeductionList" resultType="com.ruoyi.system.domain.EtOrder" parameterType="long">
select * from et_order o where o.pay_type = 'yj' and o.area_id = #{areaId}
</select>
<insert id="insertEtOrder" parameterType="EtOrder" useGeneratedKeys="true" keyProperty="orderId">
insert into et_order
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -699,6 +714,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="audioFiles != null">audio_files = #{audioFiles},</if>
<if test="usedSn != null">used_sn = #{usedSn},</if>
<if test="changeReason != null">change_reason = #{changeReason},</if>
<if test="locking != null">locking = #{locking},</if>
</trim>
where order_id = #{orderId}
</update>
@ -743,6 +759,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="audioFiles != null">audio_files = #{audioFiles},</if>
<if test="usedSn != null">used_sn = #{usedSn},</if>
<if test="changeReason != null">change_reason = #{changeReason},</if>
<if test="locking != null">locking = #{locking},</if>
</trim>
where order_no = #{orderNo}
</update>