package org.jeecg.modules.api.studytourController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.api.bean.PageBean;
import org.jeecg.modules.api.service.OrderService;
import org.jeecg.modules.studytourOrder.entity.StudytourOrder;
import org.jeecg.modules.studytourPerson.entity.StudytourPerson;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags="研学订单-相关接口")
@RestController
@RequestMapping("/studytour/order")
@Slf4j
public class OrderController {

    /******************************************************************************************************************/
    //订单
    @Resource
    private OrderService orderService;
    /******************************************************************************************************************/

    @ApiOperation(value="我的订单-查询订单列表", notes="我的订单-查询订单列表")
    @RequestMapping(value = "/queryOrderList", method = {RequestMethod.GET})
    public Result<?> queryOrderList(@RequestHeader("X-Access-Token") String token, StudytourOrder studytourOrder, PageBean pageBean){
        return orderService.queryOrderList(token, studytourOrder, pageBean);
    }

    @ApiOperation(value="我的订单-查询订单详情", notes="我的订单-查询订单详情")
    @RequestMapping(value = "/queryOrderById", method = {RequestMethod.GET})
    public Result<?> queryOrderById(@RequestHeader("X-Access-Token") String token, String orderId){
        return orderService.queryOrderById(token, orderId);
    }

    @ApiOperation(value="我的订单-创建订单", notes="我的订单-创建订单")
    @RequestMapping(value = "/createOrder", method = {RequestMethod.POST})
    public Result<?> createOrder(@RequestHeader("X-Access-Token") String token, StudytourOrder studytourOrder){
        return orderService.createOrder(token, studytourOrder);
    }

    @ApiOperation(value="我的订单-支付订单", notes="我的订单-支付订单")
    @RequestMapping(value = "/payOrder", method = {RequestMethod.POST})
    public Result<?> payOrder(@RequestHeader("X-Access-Token") String token, String orderId){
        return orderService.payOrder(token, orderId);
    }

    @ApiOperation(value="我的订单-查询出行人列表", notes="我的订单-查询出行人列表")
    @RequestMapping(value = "/queryTouristList", method = {RequestMethod.GET})
    public Result<?> queryTouristList(@RequestHeader("X-Access-Token") String token, StudytourPerson studytourPerson, PageBean pageBean){
        return orderService.queryTouristList(token, studytourPerson, pageBean);
    }

    @ApiOperation(value="我的订单-查询出行人详情", notes="我的订单-查询出行人详情")
    @RequestMapping(value = "/queryTouristById", method = {RequestMethod.GET})
    public Result<?> queryTouristById(@RequestHeader("X-Access-Token") String token, String personId){
        return orderService.queryTouristById(token, personId);
    }

    @ApiOperation(value="我的订单-添加出行人", notes="我的订单-添加出行人")
    @RequestMapping(value = "/addTourist", method = {RequestMethod.POST})
    public Result<?> addTourist(@RequestHeader("X-Access-Token") String token, StudytourPerson studytourPerson){
        return orderService.addTourist(token, studytourPerson);
    }

    @ApiOperation(value="我的订单-修改出行人信息", notes="我的订单-修改出行人信息")
    @RequestMapping(value = "/updateTourist", method = {RequestMethod.POST})
    public Result<?> updateTourist(@RequestHeader("X-Access-Token") String token, StudytourPerson studytourPerson){
        return orderService.updateTourist(token, studytourPerson);
    }

    //支付回调
    @PostMapping("/payOrderNotify")
    public Object payOrderNotify(@RequestBody String requestBody){
        return orderService.payOrderNotify(requestBody);
    }

}
