package com.prolog.rdc.tms.app.controller.business;

import java.util.List;

import javax.validation.Valid;

import com.prolog.rdc.tms.app.model.dto.AppointmentBillQueryForCarrierDTO;
import com.prolog.rdc.tms.app.model.vo.AppointmentBillQueryForCarrierVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.app.model.dto.business.BookingGetShipbillDTO;
import com.prolog.rdc.tms.app.model.dto.business.BookingItemDetailDTO;
import com.prolog.rdc.tms.app.model.dto.business.BookingPackageDetailDTO;
import com.prolog.rdc.tms.app.model.dto.business.BookingQueryDTO;
import com.prolog.rdc.tms.app.model.vo.business.BookingGetShipbillVO;
import com.prolog.rdc.tms.app.model.vo.business.BookingItemDetailVO;
import com.prolog.rdc.tms.app.model.vo.business.BookingPackageDetailVO;
import com.prolog.rdc.tms.app.model.vo.business.BookingQueryVO;
import com.prolog.rdc.tms.app.service.business.BookingService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 园区管理-预约管理控制层
 * <p>
 * Company: 湖北普罗格科技股份有限公司
 *
 * @author xiaoyf
 * @since 2022/7/5 10:28
 */
@RestController
@Api(tags = "业务APP——预约审核控制层")
@RequestMapping("/booking")
public class BookingController {

	@Autowired
	private BookingService bookingService;

	@UserLog("主界面分页查询")
	@ApiOperation(value = "主界面分页查询", notes = "主界面分页查询")
	@PostMapping("/page")
	public RestMessage<Page<BookingQueryDTO>> queryPage(@RequestBody @Valid BookingQueryVO bookingQueryVO) {
		Page<BookingQueryDTO> page = bookingService.queryPage(bookingQueryVO);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("承运商预约列表分页查询")
	@ApiOperation(value = "承运商预约列表分页查询", notes = "承运商预约列表分页查询")
	@PostMapping("/pageForCarrier")
	public RestMessage<Page<AppointmentBillQueryForCarrierDTO>> pageForCarrier(@RequestBody @Valid AppointmentBillQueryForCarrierVO carrierVO) {
		Page<AppointmentBillQueryForCarrierDTO> page = bookingService.pageForCarrier(carrierVO);
		return RestMessage.newInstance(true, "查询成功！", page);
	}


	@UserLog("配载运单查询")
	@ApiOperation(value = "配载运单查询", notes = "配载运单查询")
	@PostMapping("/get_shipbill")
	public RestMessage<Page<BookingGetShipbillDTO>> getShipbillExecute(@RequestBody @Valid BookingGetShipbillVO bookingGetShipbillVO) {
		Page<BookingGetShipbillDTO> page = bookingService.getShipbillData(bookingGetShipbillVO);
		return RestMessage.newInstance(true, "查询成功！", page);

	}

	@UserLog("配载商品查询")
	@ApiOperation(value = "配载商品查询", notes = "配载商品查询")
	@PostMapping("/item_detail")
	public RestMessage<Page<BookingItemDetailDTO>> itemDetailExecute(@RequestBody @Valid BookingItemDetailVO bookingItemDetailVO) {
		Page<BookingItemDetailDTO> page = bookingService.itemDetailData(bookingItemDetailVO);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("配载包裹查询")
	@ApiOperation(value = "配载包裹查询", notes = "配载包裹查询")
	@PostMapping("/package_detail")
	public RestMessage<Page<BookingPackageDetailDTO>> packageDetailExecute(@RequestBody @Valid BookingPackageDetailVO bookingPackageDetailVO) {
		Page<BookingPackageDetailDTO> page = bookingService.packageDetailData(bookingPackageDetailVO);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("预约单审核")
	@ApiOperation(value = "预约单审核", notes = "预约单审核")
	@PostMapping("/review")
	public RestMessage<Object> reviewExecute(@RequestBody List<String> appointmentIds) {
		bookingService.reviewData(appointmentIds);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

	@UserLog("预约单取消")
	@ApiOperation(value = "预约单取消", notes = "预约单取消")
	@PostMapping("/cancel")
	public RestMessage<Object> cancelExecute(@RequestBody List<String> appointmentIds) {
		bookingService.cancelData(appointmentIds);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

}
