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.admin.order.vo.order.TradeDetailRespVO;
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.AppTradeOrderService;
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(平台订单)交易服务")
@RestController
@RequestMapping("/app/trade")
@Validated
@Slf4j
public class AppTradeOrderController {

    @Resource
    private AppTradeOrderService appTradeOrderService;

    @PostMapping("/miniApp/orderList")
    @Operation(summary = "小程序-订单列表[分页]", description = "根据条件查询订单列表")
    @PreAuthenticated
    @OperateLog(type = API)
    public CommonResult<List<AppTradeOrderRespVO>> getTradeOrderPage(@Valid @RequestBody AppTradeOrderReqVO.TradeOrderQueryReqVO reqVO) {
        return appTradeOrderService.miniTradeOrderPage(reqVO);
    }

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

    @GetMapping("/miniApp/getDetailList")
    @Operation(summary = "小程序-查询订单明细", description = "根据订单id查询订单明细")
    @PreAuthenticated
    @OperateLog(type = API)
    public CommonResult<List<TradeDetailRespVO>> getDetailList(@Valid Long id) {
        return appTradeOrderService.miniTradeOrderDetailList(id);
    }
}
