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.IAppDistributorOrderService;
import com.ruoyi.web.modules.trading.support.AppDistributorPageSupport;

/**
 * 承销商小程序订单。
 */
@RestController
@RequestMapping("/app/distributor/order")
public class BizAppDistributorOrderController extends BaseController
{
    @Autowired
    private IAppDistributorOrderService appDistributorOrderService;

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

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