package com.wteam.controller.order;

import com.wteam.framework.common.enums.ResultUtil;
import com.wteam.framework.common.vo.ResultMessage;
import com.wteam.framework.modules.book.entity.dto.OrderReq;
import com.wteam.framework.modules.book.service.OrderInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.WxJsapiSignature;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.print.DocFlavor;
import java.sql.Timestamp;
import java.util.Date;

/**
 * @author doncic
 * @date 2023/9/19 22:25
 */
@Slf4j
@Tag(name = "订单相关接口管理")
@RestController
@RequestMapping("/v1/order")
public class OrderController {

    @Autowired
    private OrderInfoService orderInfoService;


    /**
     * 用户提交订场订单信息
     *
     * @param orderReq
     * @return
     */
    @Operation(summary = "提交订单")
    @PostMapping("/generateOrder/{accessToken}")
    public ResultMessage<Long> generateOrder(
            @PathVariable("accessToken") String accessToken,
            @ApiParam(value = "订单参数", required = true) @RequestBody OrderReq orderReq) {
        return orderInfoService.generateOrder(accessToken, orderReq);
    }

    /**
     * 根据获取当前时间的订单信息，从而得到场地订场情况
     * @return
     */
    @Operation(summary = "订场情况查询")
    @GetMapping("/bookStatus/{id}")
    public ResultMessage<String> bookStatus(
            @ApiParam(value = "门店ID", required = true) @PathVariable("id") Long id,
            @RequestParam("dateTime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") Date dateTime) {
        return orderInfoService.bookStatus(id, dateTime);
    }
}
