123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- <?php
- namespace app\api\controller;
- use app\admin\controller\InsurancePersonal;
- use app\admin\model\Category;
- use app\admin\model\Company;
- use app\admin\model\InsuranceEnterprise;
- use app\admin\model\InsuranceInfo;
- use app\admin\model\InsuranceMedical;
- use app\admin\model\InsuranceMedicalList;
- use app\admin\model\InsuranceProperty;
- use app\admin\model\Product;
- use app\admin\model\ProductRanking;
- use app\common\controller\Api;
- use think\Config;
- class Insurance extends Api{
- protected $noNeedLogin = '*';
- protected $noNeedRight = '*';
-
- public function getRanking(){
- $type = $this->request->post("type");
-
- if($type == 1){
- $list = Product::field('id,name,sort')->order('sort asc')->select();
- $this->success(__('成功'),$list);
- }
-
- if($type == 2){
-
- $list = Category::where(array('pid'=>1))->select();
- $new_list = [];
- if($list){
- foreach ($list as $key=>$value){
- $new_list[$key]['id'] = $value['id'];
- $new_list[$key]['name'] = $value['name'];
- $new_list[$key]['label'] = $value['nickname'];
- $new_list[$key]['sort'] = 0;
- }
- }
- $this->success(__('成功'),$new_list);
- }
-
- if($type == 3){
-
- $list = Category::where(array('pid'=>3))->select();
- $new_list = [];
- if($list){
- foreach ($list as $key=>$value){
- $new_list[$key]['id'] = $value['id'];
- $new_list[$key]['name'] = $value['name'];
- $new_list[$key]['label'] = $value['nickname'];
- $new_list[$key]['sort'] = 0;
- }
- }
- $this->success(__('成功'),$new_list);
- }
-
- if($type == 4){
-
- $list = Category::where(array('pid'=>2))->select();
- $new_list = [];
- if($list){
- foreach ($list as $key=>$value){
- $new_list[$key]['id'] = $value['id'];
- $new_list[$key]['name'] = $value['name'];
- $new_list[$key]['label'] = $value['nickname'];
- $new_list[$key]['sort'] = 0;
- }
- }
- $this->success(__('成功'),$new_list);
- }
- $this->error(__('参数错误'));
- }
-
- public function getIndexSecondaryClassification(){
- $first_ids = Category::where(array('pid'=>0))->order('sort desc')->field('id')->select();
- $ids = array_column($first_ids, 'id');
- $secondaryList = Category::where('pid','in',$ids)->field('id,name,sort')->order('sort asc')->select();
- if($secondaryList){
- foreach ($secondaryList as $key=>$value){
- $subordinate = Category::where(array('pid'=>$value['id']))->field('id,name,sort')->page(1,4)->select();
- if($subordinate){
- $last_names = array_column($subordinate,'sort');
- array_multisort($last_names,SORT_ASC,$subordinate);
- }
- $secondaryList[$key]['subordinate'] = $subordinate;
- }
- }
- $this->success(__('成功'),$secondaryList);
- }
-
- public function lookSecondaryList(){
- $id = $this->request->post("id",0);
- $p = input("p",0);
- $list = Category::where(array('pid'=>$id))->field('id,name')->order('sort asc')->page($p,20)->select();
- $this->success(__('成功'),$list);
- }
-
- public function lookthird(){
- $p = input("p",0);
- $first_ids = Category::where(array('pid'=>0))->order('sort desc')->field('id')->select();
- $ids = array_column($first_ids, 'id');
- $secondaryList = Category::where('pid','in',$ids)->field('id')->order('sort asc')->select();
- $sids = array_column($secondaryList, 'id');
-
- $thirdlist = Category::where('pid','in',$sids)->field('id,name,sort')->order('sort asc')->select();
-
-
- $this->success(__('成功'),$thirdlist);
- }
-
- public function getProductList(){
- $id = $this->request->post("id",0);
- $p = $this->request->post("p",0);
- $list = Product::where(array('category_id'=>$id,'status'=>0))->order('sort desc')->page($p,20)->select();
- if($list){
- foreach ($list as $key=>$value){
- $list[$key]['p_image'] = 'http://'.$_SERVER['HTTP_HOST'].'/'.$value['p_image'];
- $list[$key]['content'] = json_decode($value['content'],true);
- }
- }
- $this->success(__('成功'),$list);
- }
-
- public function getIndexUpperList(){
- $type = $this->request->post("type",0);
-
- $id = $this->request->post("id",0);
- $p = $this->request->post("p",0);
-
- $list = Product::where(array('category_id'=>$id))
- ->order('sort asc')->page($p,20)->select();
- $this->success(__('成功'),$list);
- }
-
- public function getMedicalList(){
- $type = $this->request->post("type",0);
- $p = $this->request->post("p",1);
- $more = $this->request->post("more",0);
- if($more == 1){
-
- $rows = 20;
- }else{
- $rows = 3;
- }
- if($type == 1){
- $where['id'] = 9;
- }else{
- $where['id'] = 22;
- }
- $list = Category::where($where)->page($p,$rows)->select();
- $this->success(__('成功'),$list);
- }
-
- public function getIndexBelowList(){
- $p = $this->request->post("p",1);
- $id = $this->request->post("id",1);
- $list = Product::where(array('category_id'=>$id))->order('sort asc')
- ->page($p,20)->select();
- $this->success(__('成功'),$list);
- }
-
- public function getEcommendList(){
- $p = $this->request->post("p",0);
- $where['pid'] = 0;
- $list = Category::where($where)->field('id,name')->order('sort asc')->page($p,20)->select();
- $this->success(__('成功'),$list);
- }
-
- public function getEcommendList2(){
- $id = $this->request->post("id",0);
- if(empty($id)){
- $this->error('缺少id');
- }
- $p = $this->request->post("p",0);
- $where['pid'] = $id;
- $list = Category::where($where)->field('id,name')->order('sort asc')->page($p,20)->select();
- $this->success(__('成功'),$list);
- }
-
- public function getEcommendList3(){
- $id = $this->request->post("id",0);
- if(empty($id)){
- $this->error('缺少id');
- }
- $p = $this->request->post("p",0);
- $where['pid'] = $id;
- $list = Category::where($where)->field('id,name')->order('sort asc')->page($p,20)->select();
- $this->success(__('成功'),$list);
- }
-
- public function getInsuranceClassification(){
- $id = $this->request->post("id",0);
- $p = $this->request->post("p",0);
- $list = Category::where(array('pid'=>$id))->field('id,name')->order('sort desc')->page($p,50)->select();
- $this->success(__('成功'),$list);
- }
-
- public function getInsuranceClassList(){
- $category_id = $this->request->post("id",0);
- $p = $this->request->post("p",0);
- $where['category_id'] =$category_id;
- $where['status'] =0;
- $list = Product::where($where)->order('sort asc')->page($p,50)->select();
- $companyModel = new Company();
- if($list){
- foreach ($list as $key=>$value){
- $list[$key]['p_image'] = 'http://'.$_SERVER['HTTP_HOST'].'/'.$value['p_image'];
- $list[$key]['content'] = json_decode($value['content'],true);
- $list[$key]['company_name'] = $companyModel->where(array('id'=>$value['company_id']))->value('name');
- if($value['attribute'] == '新上架产品'){
- $list[$key]['attribute_status'] = 1;
- }
- if($value['attribute'] == '在售产品'){
- $list[$key]['attribute_status'] = 2;
- }
- if($value['attribute'] == '停售产品'){
- $list[$key]['attribute_status'] = 3;
- }
- }
- }
- $this->success(__('成功'),$list);
- }
-
- public function getAboutInfo(){
- $info['mobile'] = Config::get('about_mobile');
- $info['email'] = Config::get('about_email');
- $this->success(__('成功'),$info);
- }
- }
|