Pu Zhibing
2024-12-13 73b750200f25df08aa64124da49e7461f9de6653
UserNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/CharteredCar/server/impl/OrderCharteredCarServiceImpl.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.CharteredCar.dao.OrderCharteredCarMapper;
import com.stylefeng.guns.modular.CharteredCar.dto.CharteredCarDto;
import com.stylefeng.guns.modular.CharteredCar.model.OrderCharteredCar;
import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService;
import com.stylefeng.guns.modular.system.dao.SensitiveWordsMapper;
@@ -15,10 +16,12 @@
import com.stylefeng.guns.modular.system.service.ISystemNoticeService;
import com.stylefeng.guns.modular.system.util.DateUtil;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -140,7 +143,37 @@
        return ResultUtil.success(map);
    }
    @Override
    public ResultUtil createOrder(CharteredCarDto charteredCarDto) {
        OrderCharteredCar orderCharteredCar = new OrderCharteredCar();
        BeanUtils.copyProperties(charteredCarDto,orderCharteredCar);
        try {
            orderCharteredCar.setOrderNumber(this.getOrderNum());
            orderCharteredCar.setCompanyId(1);
            orderCharteredCar.setIsDelete(1);
            orderCharteredCar.setState(1);
            orderCharteredCar.setInsertTime(new Date());
            orderCharteredCar.setCarTime(charteredCarDto.getCarTime());
            String strDateTime = charteredCarDto.getTraveltime();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d H:m");
            try {
                Date date = sdf.parse(strDateTime);
                System.out.println("Converted Date and Time: " + date);
                orderCharteredCar.setTraveltime(date);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        this.insert(orderCharteredCar);
        return ResultUtil.success();
    }
    public synchronized String getOrderNum() throws Exception{