1. 预约超时处理
This commit is contained in:
		
							parent
							
								
									2dcd705ae4
								
							
						
					
					
						commit
						45eed997ed
					
				| 
						 | 
				
			
			@ -206,4 +206,7 @@ public class EtOrder extends BaseEntity
 | 
			
		|||
    @TableField(exist = false)
 | 
			
		||||
    private String latitude;
 | 
			
		||||
 | 
			
		||||
    /** 1-预约超时,系统自动取消 */
 | 
			
		||||
    private String appointmentTimeout;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,6 +42,7 @@ import java.math.RoundingMode;
 | 
			
		|||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.concurrent.ScheduledExecutorService;
 | 
			
		||||
import java.util.concurrent.TimeUnit;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -66,12 +67,6 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
			
		|||
    @Autowired
 | 
			
		||||
    private IEtOrderService etOrderService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ISysConfigService sysConfigService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private IEtAdminOrderService etAdminOrderService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private IEtFeeRuleService etFeeRuleService;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -87,7 +82,8 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
			
		|||
    @Resource
 | 
			
		||||
    private IEtModelService etModelService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ScheduledExecutorService scheduledExecutorService;
 | 
			
		||||
 | 
			
		||||
    @Value(value = "${iot.iotUrl}")
 | 
			
		||||
    private String iotUrl;
 | 
			
		||||
| 
						 | 
				
			
			@ -752,12 +748,13 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
			
		|||
    /**
 | 
			
		||||
     * 车辆预约
 | 
			
		||||
     */
 | 
			
		||||
    @Transactional
 | 
			
		||||
    @Override
 | 
			
		||||
    public OrderResponse deviceAppointment(EtOrderVo appointmentVo) {
 | 
			
		||||
        OrderResponse orderResponse = new OrderResponse();
 | 
			
		||||
        String orderNo = IdUtils.randomUUID2();
 | 
			
		||||
        AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(appointmentVo.getSn());
 | 
			
		||||
        //如果是正常计费模式,则按正常的订单走
 | 
			
		||||
        //创建订单
 | 
			
		||||
        EtOrder order = etOrderService.createOrder(appointmentVo, orderNo);
 | 
			
		||||
        int i = etOrderService.insertEtOrder(order);
 | 
			
		||||
        if(i==0){
 | 
			
		||||
| 
						 | 
				
			
			@ -765,11 +762,26 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
			
		|||
        }
 | 
			
		||||
        orderResponse.setOrderNo(orderNo);
 | 
			
		||||
        orderResponse.setSessionId(IdUtils.randomUUIDByDigit(8));
 | 
			
		||||
        //改变车辆状态
 | 
			
		||||
        asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_APPOINTMENT);
 | 
			
		||||
        int u = asDeviceMapper.updateAsDevice(asDevice);
 | 
			
		||||
        if(u==0){
 | 
			
		||||
            throw new ServiceException("【车辆预约】:更新车辆状态失败");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId());
 | 
			
		||||
        int delay = 60 * area.getTimeoutMinutes();
 | 
			
		||||
        //定时取消预约
 | 
			
		||||
        scheduledExecutorService.schedule(() -> {
 | 
			
		||||
            //订单更新最后预约时间,并结束订单,做超出预约时间标记
 | 
			
		||||
            order.setStatus(ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT);
 | 
			
		||||
            order.setAppointmentEndTime(new Date());
 | 
			
		||||
            order.setAppointmentTimeout("1");
 | 
			
		||||
            int update = etOrderService.updateEtOrder(order);
 | 
			
		||||
            if(update==0){
 | 
			
		||||
                throw new ServiceException("【车辆预约】:更新订单状态失败");
 | 
			
		||||
            }
 | 
			
		||||
        }, delay, TimeUnit.SECONDS);
 | 
			
		||||
        return orderResponse;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
        <result property="createTime"    column="create_time"    />
 | 
			
		||||
        <result property="appointmentStartTime"    column="appointment_start_time"    />
 | 
			
		||||
        <result property="appointmentEndTime"    column="appointment_end_time"    />
 | 
			
		||||
        <result property="appointmentTimeout"    column="appointment_timeout"    />
 | 
			
		||||
        <result property="unlockTime"    column="unlock_time"    />
 | 
			
		||||
        <result property="returnTime"    column="return_time"    />
 | 
			
		||||
        <result property="ruleEndTime"    column="rule_end_time"    />
 | 
			
		||||
| 
						 | 
				
			
			@ -41,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
        select order_id, area_id, order_no, out_trade_no, user_id, rule_id,
 | 
			
		||||
               device_mac, sn, pay_time, paid, pay_type, type, total_fee, dispatch_fee,
 | 
			
		||||
               manage_fee, riding_fee, appointment_fee, mark, duration, distance, status,
 | 
			
		||||
               create_time, appointment_start_time, appointment_end_time, unlock_time,return_time, rule_end_time, return_type, AsText(trip_route) trip_route,trip_route_str from et_order
 | 
			
		||||
               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 from et_order
 | 
			
		||||
    </sql>
 | 
			
		||||
 | 
			
		||||
    <select id="selectEtOrderList" parameterType="EtOrder" resultMap="EtOrderResult">
 | 
			
		||||
| 
						 | 
				
			
			@ -73,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            o.create_time,
 | 
			
		||||
            o.appointment_start_time,
 | 
			
		||||
            o.appointment_end_time,
 | 
			
		||||
            o.appointment_timeout,
 | 
			
		||||
            o.unlock_time,
 | 
			
		||||
            o.return_time,
 | 
			
		||||
            o.rule_end_time,
 | 
			
		||||
| 
						 | 
				
			
			@ -317,6 +319,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="createTime != null">create_time,</if>
 | 
			
		||||
            <if test="appointmentStartTime != null">appointment_start_time,</if>
 | 
			
		||||
            <if test="appointmentEndTime != null">appointment_end_time,</if>
 | 
			
		||||
            <if test="appointmentTimeout != null">appointment_timeout,</if>
 | 
			
		||||
            <if test="unlockTime != null">unlock_time,</if>
 | 
			
		||||
            <if test="returnTime != null">return_time,</if>
 | 
			
		||||
            <if test="ruleEndTime != null">rule_end_time,</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -348,6 +351,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="createTime != null">#{createTime},</if>
 | 
			
		||||
            <if test="appointmentStartTime != null">#{appointmentStartTime},</if>
 | 
			
		||||
            <if test="appointmentEndTime != null">#{appointmentEndTime},</if>
 | 
			
		||||
            <if test="appointmentTimeout != null">#{appointmentTimeout},</if>
 | 
			
		||||
            <if test="unlockTime != null">#{unlockTime},</if>
 | 
			
		||||
            <if test="returnTime != null">#{returnTime},</if>
 | 
			
		||||
            <if test="ruleEndTime != null">#{ruleEndTime},</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -382,6 +386,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="createTime != null">create_time = #{createTime},</if>
 | 
			
		||||
            <if test="appointmentStartTime != null">appointment_start_time = #{appointmentStartTime},</if>
 | 
			
		||||
            <if test="appointmentEndTime != null">appointment_end_time = #{appointmentEndTime},</if>
 | 
			
		||||
            <if test="appointmentTimeout != null">appointment_timeout = #{appointmentTimeout},</if>
 | 
			
		||||
            <if test="unlockTime != null">unlock_time = #{unlockTime},</if>
 | 
			
		||||
            <if test="returnTime != null">return_time = #{returnTime},</if>
 | 
			
		||||
            <if test="returnType != null">return_type = #{returnType},</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -416,6 +421,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="createTime != null">create_time = #{createTime},</if>
 | 
			
		||||
            <if test="appointmentStartTime != null">appointment_start_time = #{appointmentStartTime},</if>
 | 
			
		||||
            <if test="appointmentEndTime != null">appointment_end_time = #{appointmentEndTime},</if>
 | 
			
		||||
            <if test="appointment_timeout != null">appointment_timeout = #{appointment_timeout},</if>
 | 
			
		||||
            <if test="unlockTime != null">unlock_time = #{unlockTime},</if>
 | 
			
		||||
            <if test="returnTime != null">return_time = #{returnTime},</if>
 | 
			
		||||
            <if test="returnType != null">return_type = #{returnType},</if>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user