<?php

use App\Base\Base;
use App\Services\goods\GoodsService;
use App\Services\goods\CategoryService;
use App\Services\goods\StoresService;
use App\Services\goods\SetmealService;
use \Validate\EditStoresValidate;
use \Validate\StoresListValidate;
use \Validate\EditSetmealValidate;
use \Validate\SetmealListValidate;
use \Validate\GoodsAuditValidate;


class GoodsController extends Base
{
    /**
     * 获取商品分类列表
     */
    public function get_goods_category_listAction()
    {
        $categoryList = CategoryService::getCategoryList();
        $this->success(["data" => $categoryList]);
    }

    /**
     * 增加商品
     */
    public function addAction()
    {
        $lifeAccountId = 111;
        $params = [
            "name" => "商品name",
            "url" => "url1, url2, url3",
            "desc" => "描述描述",
            "category_1_id" => 1,
            "category_2_id" => 13,
            "expiration_time" => "2021-06-10 12:20:30",
            "rule_limit" => 3,
            "rule_date_type" => 1,
            "rule_start_time" => "2021-06-11 12:20:30",
            "rule_end_time" => "2021-06-12 12:20:30",
            "rule_desc" => "规则描述",
            "inventory_total" => 10,
            "original_price" => 1500,
            "price" => 500,
        ];
        GoodsService::addGoods($lifeAccountId, $params);
        $this->success();
    }

    /**
     * 编辑商品
     */
    public function editAction()
    {

    }

    /**
     * 商品详情
     */
    public function infoAction()
    {

    }

    /**
     * 上下架
     * @throws \App\Exception\custom\GoodsException
     * @throws \App\Exception\custom\ParamException
     */
    public function online_offlineAction()
    {
        (new GoodsAuditValidate())->validate();

        $params = $this->params;
        GoodsService::onlineOrOffline($params);
        $this->success();
    }

    /**
     * 审核通过/驳回
     */
    public function auditAction()
    {
        (new GoodsAuditValidate())->validate();

        $params = $this->params;
        GoodsService::audit($params);
        $this->success();
    }

    /**
     * 判断商品名称是否可用
     */
    public function check_goods_nameAction()
    {

    }

    /**
     * op后台：商品列表 (spu list)
     */
    public function goods_list_opAction()
    {

    }

    /**
     * b端：商品列表（spu list）
     */
    public function goods_list_bAction()
    {

    }

    /**
     * c端 es：商品列表 (sku list)
     */
    public function goods_list_cAction()
    {

    }
}