<?php namespace Channel\Api;
use Dever;
use Manage\Lib\Auth;
class Manage extends Auth
{
    # 获取渠道下的商品
    public function getGoods($value = false)
    {
        $result['goods_id']['value'] = '';
        $result['goods_id']['option'] = array();
        if (!$value) {
            return $result;
        }
        $goods = Dever::db('goods', 'channel')->select(array('channel_id' => $value), array('group' => 'goods_id'));
        if ($goods) {
            $option = array();
            foreach ($goods as $k => $v) {
                $option[] = Dever::db('info', 'goods')->find($v['goods_id']);
            }
            $result['goods_id']['option'] = $option;
        }
        return $result;
    }

    # 获取商品下规格
    public function getSku($value = false)
    {
        if (!$value) {
            $result['goods_id']['option'] = array();
            return $result;
        }
        $result = array();
        $goods = Dever::db('goods', 'channel')->select(array('channel_id' => $value));
        if ($goods) {
            $option = array();
            foreach ($goods as $k => $v) {
                $option[] = Dever::db('info', 'goods')->find($v['goods_id']);
            }
            $result['goods_id']['option'] = $option;
        }
        return $result;
    }
}