| 1234567891011121314151617181920212223242526272829 | <?phpnamespace app\admin\service\statistics;use app\model\Goods;use app\model\GoodsRunning;use app\model\SysCategory;class GoodsService{    public static function getGoods()    {        $categoryPath = SysCategory::where('category_id', 5)->value('category_super_path');        $categoryPath .= '#5#';        $categoryIds = SysCategory::where('category_super_path', 'like', $categoryPath . '%')->pluck('category_id')->toArray();        $categoryIds[] = 5;        if (!empty($categoryIds)) {            $categoryId = $categoryIds;        } else {            $categoryId = [5];        }        $data['storageWarning'] = GoodsRunning::leftJoin('goods','goods.goods_id','=','goods_running.join_running_goods_id')            ->where("goods_running_storage",'<=',2)            ->whereIn('goods.join_goods_category_id',$categoryId)            ->count();        return $data;    }}
 |