package com.yc.ship.module.trade.controller.app.otc;

import com.yc.ship.framework.common.pojo.CommonResult;
import com.yc.ship.framework.operatelog.core.annotations.OperateLog;
import com.yc.ship.framework.security.core.annotations.PreAuthenticated;
import com.yc.ship.module.trade.controller.app.otc.vo.AppTradeOrderReqVO;
import com.yc.ship.module.trade.controller.app.otc.vo.AppTradeOrderRespVO;
import com.yc.ship.module.trade.service.otc.AppOtaTradeOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static com.yc.ship.framework.operatelog.core.enums.OperateTypeEnum.API;


/**
 * &#064;Description ：旅行社APP交易服务controller, 自助机、小程序
 * &#064;Author ：qsl
 * &#064;Date ：2025/6/17 20:52
 */
@Tag(name = "旅行社APP(OTA)交易服务")
@RestController
@RequestMapping("/app/ota/trade")
@Validated
@Slf4j
public class AppOtaTradeOrderController {

    @Resource
    private AppOtaTradeOrderService appOtaTradeOrderService;

    @PostMapping("/miniApp/orderList")
    @Operation(summary = "小程序-查询OTA订单列表")
    @PreAuthenticated
    @OperateLog(type = API)
    public CommonResult<List<AppTradeOrderRespVO>> getOtaOrderList(@Valid @RequestBody AppTradeOrderReqVO.TradeOrderQueryReqVO reqVO) {
        return appOtaTradeOrderService.getOtaOrderList(reqVO);
    }

    @GetMapping("/miniApp/getOrderInfo")
    @Operation(summary = "小程序-OTA订单详情", description = "根据订单id查询OTA订单详情")
    @PreAuthenticated
    @OperateLog(type = API)
    public CommonResult<AppTradeOrderRespVO> miniOrderInfoById(@Valid Long id) {
        return appOtaTradeOrderService.miniOrderInfoById(id);
    }

    @PostMapping("/miniApp/orderSendAndMeet")
    @Operation(summary = "小程序-设置订单接送点")
    @PreAuthenticated
    @OperateLog(type = API)
    public CommonResult<Long> orderSendAndMeet(@Valid @RequestBody AppTradeOrderReqVO.OtaTradeOrderReqVO reqVO) {
        return appOtaTradeOrderService.orderSendAndMeet(reqVO);
    }

}
