package com.ruoyi.web.modules.trading.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.modules.trading.domain.BizTradeOrder;
import com.ruoyi.web.modules.trading.service.IAppSupplierOrderService;
import com.ruoyi.web.modules.trading.support.AppSupplierPageSupport;

/**
 * 供应商小程序交易订单。
 */
@RestController
@RequestMapping("/app/supplier/order")
public class BizAppSupplierOrderController extends BaseController
{
    @Autowired
    private IAppSupplierOrderService appSupplierOrderService;

    /**
     * 交易订单分页列表（主表 + lineList 明细）。
     *
     * @param statusTab ALL | PENDING | COMPLETED，默认 ALL
     */
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(value = "statusTab", defaultValue = "ALL") String statusTab)
    {
        AppSupplierPageSupport.startPage();
        List<BizTradeOrder> list = appSupplierOrderService.selectOrderList(statusTab);
        return getDataTable(list);
    }

    /**
     * 交易订单详情（主表 + lineList 明细）。
     */
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appSupplierOrderService.selectOrderById(id));
    }
}
