package com.luozhihui.project.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import com.luozhihui.project.entity.Order;
import org.springframework.transaction.annotation.Transactional;

public interface CarRentMapper {
//    更新车辆状态
//    1为未出租，0为出租中，3为维修中
        @Insert("insert into `order`(`UserId`,`CarId`,`OrderMoney`,`OutPicture`,`OutTime`,`Mode`,`OrderStatus`) VALUES (#{UserId},#{CarId},#{OrderMoney},#{OutPicture},NOW(),#{Mode},#{OrderStatus})")
        @Transactional
        void addorder(Order order);
        @Update("update `car` set `CarStatus` = 0 where `CarId` = #{CarId}")
        void updateCarStatus(Integer carId);
        @Update("update `order` SET `OrderMoney`=#{OrderMoney},`InPicture`=#{InPicture},`InTime`=NOW()  WHERE `OrderId` = #{OrderId} ")
        void carRented(Order order);

        @Update("update `order` set `OrderStatus` = 1 where `OrderId` = #{OrderId}")
        void finishOrder(String orderId);
        //还车改变车辆状态为可用
        @Update("update `car` set `CarStatus` = 1, `parking_id` = #{parking_id} where `CarId` = #{carId}")
        void endCarStatus(@Param("carId") String carId, @Param("parking_id") String parkingId);

}
