| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 | <?php// +----------------------------------------------------------------------// | A3Mall// +----------------------------------------------------------------------// | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.// +----------------------------------------------------------------------// | Author: xzncit <158373108@qq.com>// +----------------------------------------------------------------------namespace app\admin\controller\common;use app\admin\controller\Auth;use mall\response\Response;use think\facade\Request;use think\facade\View;use app\admin\service\users\Users as UsersService;use app\admin\service\products\Goods as GoodsService;use app\admin\service\products\Area as AreaService;use app\admin\service\products\Attribute as AttributeService;use app\admin\service\products\Model as ModelService;class Ajax extends Auth {    /**     * 获取未成为分销会员列表     * @return string|\think\response\Json     * @throws \think\db\exception\DataNotFoundException     * @throws \think\db\exception\DbException     * @throws \think\db\exception\ModelNotFoundException     */    public function get_users(){        if(Request::isAjax()){            $list = UsersService::getList(Request::param(),["users.is_spread"=>0]);            return Response::returnArray("ok",0,$list['data'],$list['count']);        }        return View::fetch("common/get_users",UsersService::getSearchData());    }    /**     * 获取商品列表     * @return string|\think\response\Json     * @throws \think\db\exception\DataNotFoundException     * @throws \think\db\exception\DbException     * @throws \think\db\exception\ModelNotFoundException     */    public function get_goods(){        if(Request::isAjax()){            $list = GoodsService::getList(Request::param(),"");            return Response::returnArray("ok",0,$list["data"],$list["count"]);        }        return View::fetch("common/get_goods",GoodsService::getSearchData());    }    /**     * 获取商品规格     * @return \think\response\Json     */    public function get_goods_data(){        try{            return Response::returnArray("ok",1,GoodsService::getGoodsItemData(Request::param("id",0,"intval")));        }catch (\Exception $ex){            return Response::returnArray($ex->getMessage(),0);        }    }    /**     * 获取商品列表     * @return string|\think\response\Json     * @throws \think\db\exception\DataNotFoundException     * @throws \think\db\exception\DbException     * @throws \think\db\exception\ModelNotFoundException     */    public function get_goods_list(){        if(Request::isAjax()){            $list = GoodsService::getList(Request::param(),"");            return Response::returnArray("ok",0,$list["data"],$list["count"]);        }        return View::fetch("common/get_goods_list",GoodsService::getSearchData());    }    /**     * 获取商品列表     * @return \think\response\Json     */    public function get_goods_list_data(){        try{            $result = GoodsService::getGoodsListData(Request::param("id", "0","trim,strip_tags"));            $html = View::fetch("common/get_goods_list_data",[ "data"=>$result["data"] ]);            return Response::returnArray("ok",1,[ "content"=>$html, "goods_id"=>implode(",",$result["goods_id"]) ]);        }catch (\Exception $ex){            return Response::returnArray($ex->getMessage(),0);        }    }    /**     * 获取省级地区列表     * @return \think\response\Json     * @throws \think\db\exception\DataNotFoundException     * @throws \think\db\exception\DbException     * @throws \think\db\exception\ModelNotFoundException     */    public function get_area(){        return Response::returnArray('ok',1,AreaService::getArea(Request::get("id","0","intval")));    }    /**     * 获取所有地址信息     * @return string     * @throws \think\db\exception\DataNotFoundException     * @throws \think\db\exception\DbException     * @throws \think\db\exception\ModelNotFoundException     */    public function get_distribution(){        return View::fetch('common/get_distribution',AreaService::getDistribution());    }    /**     * 获取规格     * @return \think\response\Json     */    public function get_attr(){        $attribute = AttributeService::getAttr(Request::param());        $html = View::fetch("common/get_attr",[ "spec_checked"=>$attribute["spec_checked"],"result"=>$attribute["result"] ]);        return Response::returnArray("ok",1,$html);    }    /**     * 生成规格数据     * @return \think\response\Json     */    public function get_attr_data(){        try{            $html = View::fetch("common/get_attr_data",AttributeService::getAttrData(Request::param()));            return Response::returnArray("ok", 1, $html);        }catch (\Exception $ex){            return Response::returnArray("ok", 1,"");        }    }    /**     * 获取商品参数     * @return \think\response\Json     */    public function get_model(){        try{            $html = View::fetch("common/get_model",ModelService::getModel(Request::param()));            return Response::returnArray("ok",1,$html);        }catch (\Exception $ex){            return Response::returnArray($ex->getMessage(),0);        }    }    /**     * 获取门店核销会员     * @return string|\think\response\Json     * @throws \think\db\exception\DataNotFoundException     * @throws \think\db\exception\DbException     * @throws \think\db\exception\ModelNotFoundException     */    public function get_shop_users(){        if(Request::isAjax()){            $list = UsersService::getList(Request::param());            return Response::returnArray("ok",0,$list['data'],$list['count']);        }        return View::fetch("common/get_shop_users",UsersService::getSearchData());    }}
 |