<?php

namespace Api\Controller;

class NormalController extends PublicController
{
    /**
     * @description: 子类的初始化
     */
    public function _initialize()
    {
    }
    public function index()
    {
        echo "hello world";
    }
    /**
     * @description: 分类列表
     */
    public function getCategoryList()
    {
        $where['shop_id'] = $_REQUEST["shop_id"];
        $order['sort'] = 'desc';
        $field = array('id', 'pid', 'path', 'name', 'shop_id', 'sort', 'show', 'describe', 'photo');
        $categoryDb = D('category');
        if ($categoryList = $categoryDb->where($where)->order($order)->field($field)->select()) {
            echo json_encode(array('status' => 1, 'msg' => '访问成功', "categoryList" => $categoryList));
        } else {
            echo json_encode(array('status' => 0, 'msg' => '暂无分类数据'));
        }
    }
    /**
     * @description: 获取spu列表
     */
    public function getSpuList()
    {
        $where['shop_id'] = $_REQUEST["shop_id"];
        $where['del'] = '0';
        $order['sort'] = 'desc';
        $order['id'] = 'desc';
        $spuDb = D('spu');
        if ($spuList = $spuDb->where($where)->order($order)->select()) {
            echo json_encode(array('status' => 1, 'msg' => '访问成功', "spuList" => $spuList));
        } else {
            echo json_encode(array('status' => 0, 'msg' => '暂无商品数据'));
        }
    }
    /**
     * @description: 获取sku列表
     */
    public function getSkuList()
    {
        $where['shop_id'] = $_REQUEST["shop_id"];
        $where['del'] = '0';
        $order['id'] = 'desc';
        $skuDb = D('sku');
        if ($skuList = $skuDb->where($where)->order($order)->select()) {
            echo json_encode(array('status' => 1, 'msg' => '访问成功', "skuList" => $skuList));
        } else {
            echo json_encode(array('status' => 0, 'msg' => '暂无商品数据'));
        }
    }
    /**
     * @description: 获取站点列表
     */
    public function getSiteList()
    {
        $where['shop_id'] = $_REQUEST["shop_id"];
        $field = array('id', 'sitename', 'photo', 'describe');
        $siteDb = D('receive_site');
        if ($siteList = $siteDb->where($where)->field($field)->select()) {
            echo json_encode(array('status' => 1, 'msg' => '访问成功', "siteList" => $siteList));
        } else {
            echo json_encode(array('status' => 0, 'msg' => '暂无商品数据'));
        }
    }
    /**
     * @description: 获取商铺信息
     */
    public function getShopCon()
    {
        $where['shop_id'] = $_REQUEST["shop_id"];
        $shopDb = D('shop');
        if ($shopCon = $shopDb->where($where)->find()) {
            echo json_encode(array('status' => 1, 'msg' => '访问成功', "shopCon" => $shopCon));
        } else {
            echo json_encode(array('status' => 0, 'msg' => '暂无商铺信息'));
        }
    }
}
