where($where)->whereAge('>', 80)->count(); //61-80岁 $num2 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<=', 80)->whereAge('>', 60)->count(); //36-60岁 $num3 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<=', 60)->whereAge('>=', 36)->count(); //18-35岁 $num4 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 36)->whereAge('>', 17)->count(); //0-17岁 $num5 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 18)->count(); $return = [ ['value'=>$num1,'name'=>'80岁以上'], ['value'=>$num2,'name'=>'61-80岁'], ['value'=>$num3,'name'=>'36-60岁'], ['value'=>$num4,'name'=>'18-35岁'], ['value'=>$num5,'name'=>'0-17岁'] ]; $this->apiSuccess('获取成功',$return); } //人群关爱(特困人员、高龄老人、低保人员、空巢老人、残疾人员、留守儿童) public function get_people2($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 特困人员 $num1 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>', 80)->count(); //高龄老人 $num2 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>', 80)->count(); //空巢老人 $num4 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<=', 80)->whereAge('>', 60)->count(); //留守儿童 $num6 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 18)->count(); foreach ($where as $key =>$value){ $where[$key][0] = 'm.'.$value[0]; } //低保人员 $num3 = Db::table('fa_szxc_information_usermsg') ->alias('m') ->where($where) ->join(['fa_szxc_information_insurance'=> 'i'],'m.user_id=i.user_id and i.insurance_type!=219')->count(); //残疾人员 $num5 = Db::table('fa_szxc_information_usermsg') ->alias('m') ->where($where) ->join(['fa_szxc_information_insurance' => 'i'],'m.user_id=i.user_id and i.whether_disabled!=112')->count(); $return = [ ['value'=>$num1,'name'=>'特困人员'], ['value'=>$num2,'name'=>'高龄老人'], ['value'=>$num3,'name'=>'空巢老人'], ['value'=>$num4,'name'=>'留守儿童'], ['value'=>$num5,'name'=>'低保人员'], ['value'=>$num6,'name'=>'残疾人员'] ]; $this->apiSuccess('获取成功',$return); } //事项办理(待办事项、延期待办、总计办理、办理结率) public function get_num($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['county', '=', $area_id]; } if ($street_id){ $where[] = ['township', '=', $street_id]; } if ($village_id){ $where[] = ['village', '=', $village_id]; } // 待办事项 $shuqiu = Db::table('fa_article')->where('is_solve', 0)->where($where)->where('category_id', 'in',[165,150,149,148,147])->whereTime('end_time','>', date('Y-m-d h:i:s'))->count(); // 延期待办 $time = Db::table('fa_article')->where('is_solve', 0)->where($where)->where('category_id', 'in',[165,150,149,148,147])->whereTime('end_time','<=', date('Y-m-d h:i:s'))->count(); // 总计办理 $is_solve = Db::table('fa_article')->where('is_solve', 1)->where($where)->count(); if($is_solve){ // 办理结率 $num4 = ($is_solve-$shuqiu-$time)/$is_solve; }else{ $num4 = 0; } $num4 = round($num4*100,2).'%'; $return = [ ['value'=>$shuqiu,'name'=>'待办事项'], ['value'=>$time,'name'=>'延期待办'], ['value'=>$is_solve,'name'=>'总计办理'], ['value'=>$num4,'name'=>'办理结率'] ]; $this->apiSuccess('获取成功',$return); } //资产情况(总耕地面积、人均耕地面积、退林还耕面积、种植物种类、养殖物种类) public function get_num2($area_id=0,$street_id=0,$village_id=0){ $where = $map = []; if ($area_id){ $where[] = ['b.area_id', '=', $area_id]; $map[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['b.street_id', '=', $street_id]; $map[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['b.village_id', '=', $village_id]; $map[] = ['village_id', '=', $village_id]; } // 总耕地面积 $num1 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where($where)->sum('land_area'); //人均耕地面积 $all = Db::table('fa_szxc_information_usermsg')->where($map)->whereStatus('=', 1)->count(); if($all){ $num2 = $num1/$all; }else{ $num2 = 0; } //退林还耕面积 $num3 = $num1*0.3; //种植物种类 $num4 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where($where)->column('crops_msg'); $a = 0; foreach ($num4 as $k=>$v){ $v = json_decode($v,true); $v = array_filter(array_column($v,'name')); $v = array_filter($v); $a = $a + count($v); } $num4 = $a; //养殖物种类 $num5 = 12; $return = [ ['value'=>$num1,'name'=>'总耕地面积'], ['value'=>$num2,'name'=>'人均耕地面积'], ['value'=>$num3,'name'=>'退林还耕面积'], ['value'=>$num4,'name'=>'种植物种类'], ['value'=>$num5,'name'=>'养殖物种类'] ]; $this->apiSuccess('获取成功',$return); } //消费数据(农资消费总计、食品消费总计、衣着消费总计、居住消费总计、生活用品及服务总计、交通通信总计、教育文化娱乐总计、医疗服务总计) public function get_num3($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 农资消费总计 $num1 = 3687; // 食品消费总计 $num2 = 42222; // 衣着消费总计 $num3 = 25841; // 居住消费总计 $num4 = 84511; // 生活用品及服务总计 $num5 = 4254; // 交通通信总计 $num6 = 12631; // 教育文化娱乐总计 $num7 = 8571; //医疗服务总计 $num8 = 63541; $return = [ ['value'=>$num1,'name'=>'农资消费总计'], ['value'=>$num2,'name'=>'食品消费总计'], ['value'=>$num3,'name'=>'衣着消费总计'], ['value'=>$num4,'name'=>'居住消费总计'], ['value'=>$num5,'name'=>'生活用品及服务总计'], ['value'=>$num6,'name'=>'交通通信总计'], ['value'=>$num7,'name'=>'教育文化娱乐总计'], ['value'=>$num8,'name'=>'医疗服务总计'] ]; $this->apiSuccess('获取成功',$return); } //收入构成(工资性收入、生产经营性收入、财产性收入、保险性收入) public function get_num4($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 工资性收入 $num1 = 12; // 生产经营性收入 $num2 = 123; // 财产性收入 $num3 = 124; // 保险性收入 $num4 = 125; $return = [ ['value'=>$num1,'name'=>'工资性收入'], ['value'=>$num2,'name'=>'生产经营性收入'], ['value'=>$num3,'name'=>'财产性收入'], ['value'=>$num4,'name'=>'保险性收入'] ]; $this->apiSuccess('获取成功',$return); } //土地性质(园地 //耕地 //林地 //牧草地 //养殖 //坑塘 //农田水利设施用地) public function get_num5($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['b.area_id', '=', $area_id]; } if ($street_id){ $where[] = ['b.street_id', '=', $street_id]; } if ($village_id){ $where[] = ['b.village_id', '=', $village_id]; } // 总耕地面积 $num1 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',70)->where($where)->sum('land_area'); //园地 $num2 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',69)->where($where)->sum('land_area'); //林地 $num3 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',214)->where($where)->sum('land_area'); //牧草地 $num4 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',215)->where($where)->sum('land_area'); //养殖 $num5 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',216)->where($where)->sum('land_area'); //坑塘 $num6 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',217)->where($where)->sum('land_area'); //农田水利设施用地 $num7 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',218)->where($where)->sum('land_area'); $return = [ ['value'=>$num1,'name'=>'耕地面积'], ['value'=>$num2,'name'=>'园地'], ['value'=>$num3,'name'=>'林地'], ['value'=>$num4,'name'=>'牧草地'], ['value'=>$num5,'name'=>'养殖'], ['value'=>$num6,'name'=>'坑塘'], ['value'=>$num7,'name'=>'农田水利设施用地'] ]; $this->apiSuccess('获取成功',$return); } //文化程度( //文盲及半文盲 //小学 //初中 //高中/技校/中专 //大学专科及以上 //不详) public function get_num6($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 文盲及半文盲 $num1 = Db::table('fa_szxc_information_usermsg')->where('education',71)->where($where)->count(); //小学 $num2 = Db::table('fa_szxc_information_usermsg')->where('education',72)->where($where)->count(); //初中 $num3 = Db::table('fa_szxc_information_usermsg')->where('education',73)->where($where)->count(); //高中/技校/中专 $num4 = Db::table('fa_szxc_information_usermsg')->where('education',74)->where($where)->count(); //大学专科及以上 $num5 = Db::table('fa_szxc_information_usermsg')->where('education',75)->where($where)->count(); //不详 $num6 = Db::table('fa_szxc_information_usermsg')->where('education',76)->where($where)->count(); $total = $num2 + $num3 + $num4 + $num5; $bcdiv1 = bcmul(bcdiv($num2,$total,3),100,1); $bcdiv2 = bcmul(bcdiv($num3,$total,3),100,1); $bcdiv3 = bcmul(bcdiv($num4,$total,3),100,1); $bcdiv4 = bcmul(bcdiv($num5,$total,3),100,1); $return = [ // ['value'=>$num1,'name'=>'文盲及半文盲'], ['value'=>$num2,'name'=>'小学','bfb'=>$bcdiv1], ['value'=>$num3,'name'=>'初中','bfb'=>$bcdiv2], ['value'=>$num4,'name'=>'高中/技校/中专','bfb'=>$bcdiv3], ['value'=>$num5,'name'=>'大学专科及以上','bfb'=>$bcdiv4], // ['value'=>$num6,'name'=>'不详'], ]; $this->apiSuccess('获取成功',$return); } //政治面貌( //群众 //团员 //党员 //预备役) public function get_num7($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 群众 $num1 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',2)->where($where)->count(); //团员 $num2 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',3)->where($where)->count(); //党员 $num3 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',4)->where($where)->count(); //预备役 $num4 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',177)->where($where)->count(); $return = [ ['value'=>$num1,'name'=>'群众'], ['value'=>$num2,'name'=>'团员'], ['value'=>$num3,'name'=>'党员'], ['value'=>$num4,'name'=>'预备役'], ]; $this->apiSuccess('获取成功',$return); } //优秀村民 public function get_num8($area_id=0,$street_id=0,$village_id=0,$page=1,$limit=10){ // $where[] = ['user_id','in','1,3,5']; $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 群众 $return = Db::table('fa_szxc_information_usermsg') ->field('name,age,address_name as address,gender') ->where($where) ->page($page,$limit) ->withAttr('gender', function ($value, $data) { if($value == 1){ return '男'; }elseif($value == 2){ return '女'; }else{ return '暂无'; } }) ->select(); $this->apiSuccess('获取成功',$return); } //是否参保 public function get_num9($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['yi'=>346], ['wei'=>30], ['type' => [['value'=>30,'name'=>'未参保'], ['value'=>60,'name'=>'低保'], ['value'=>45,'name'=>'城乡居民基本医保'], ['value'=>77,'name'=>'新农合'], ['value'=>82,'name'=>'城镇居民医保'], ['value'=>62,'name'=>'职工医保'], ['value'=>20,'name'=>'其他']] ] ]; $this->apiSuccess('获取成功',$return); } //农业结构 public function get_num10($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['value'=>135,'name'=>'萝卜'], ['value'=>24,'name'=>'白菜'], ['value'=>87,'name'=>'芋头'], ['value'=>51,'name'=>'地瓜'], ['value'=>102,'name'=>'土豆'], ['value'=>24,'name'=>'山药'], ]; $this->apiSuccess('获取成功',$return); } //村名数量 男 女 已婚 未婚 技能培训次数 农业指导次数 政策指导次数 求职人数 土地总面积 荒地总面积 养殖面积 种植面积 public function get_num11() { // $return = "{villagernum:1000,mannum:600,wumannum:400,married:600,unmarried:400,skillnum:20,policynum:20,agriculture:20,Jobnum:105,landsum:800,wasteland:100,breeding:200,planting500}"; $return = [ 'villagernum' => 1000, 'mannum' => 600, 'wumannum' => 400, 'married' => 600, 'unmarried' => 400, 'skillnum' => 20, 'policynum' => 20, 'agriculture' => 20, 'Jobnum' => 105, 'landsum' => 800, 'wasteland' => 100, 'breeding' => 200, 'planting' => 500 ]; $this->apiSuccess('获取成功', $return); } //优秀工作人员 public function get_num12($area_id=0,$street_id=0,$village_id=0,$page=1,$limit=10){ $where[] = ['user_id','in','77,78,79']; // $where = []; // if ($area_id){ // $where[] = ['area_id', '=', $area_id]; // } // if ($street_id){ // $where[] = ['street_id', '=', $street_id]; // } // if ($village_id){ // $where[] = ['village_id', '=', $village_id]; // } // 群众 $return = Db::table('fa_szxc_information_usermsg') ->field('name,phone as telephone') ->where($where) ->page($page,$limit) ->select()->toArray(); foreach ($return as $k=>$v){ $return[$k]['pic'] = "https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230118/a32db5b98f8cf2aa8d1fa07dce0ca9a3.png"; } $this->apiSuccess('获取成功',$return); } //职业 // 国家机关、党群组织、企业、事业单位负责人 // 专业技术人员 // 办事人员和有关人员 // 社会生产服务和生活服务人员 // 农、林、牧、渔业生产及辅助人员 // 生产、运输设备操作人员及有关人员 // 军人 // 不便分类的其他从业人员 public function get_num13($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 国家机关、党群组织、企业、事业单位负责人 $num1 = 1358; // 专业技术人员 $num2 = 2578; // 办事人员和有关人员 $num3 = 3684; // 社会生产服务和生活服务人员 $num4 = 8524; // 农、林、牧、渔业生产及辅助人员 $num5 = 9687; // 生产、运输设备操作人员及有关人员 $num6 = 1458; // 军人 $num7 = 998; // 不便分类的其他从业人员 $num8 = 8745; $return = [ ['value'=>$num1,'name'=>'国家机关、党群组织、企业、事业单位负责人'], ['value'=>$num2,'name'=>'专业技术人员'], ['value'=>$num3,'name'=>'办事人员和有关人员'], ['value'=>$num4,'name'=>'社会生产服务和生活服务人员'], ['value'=>$num5,'name'=>'农、林、牧、渔业生产及辅助人员'], ['value'=>$num6,'name'=>'生产、运输设备操作人员及有关人员'], ['value'=>$num7,'name'=>'军人'], ['value'=>$num8,'name'=>'不便分类的其他从业人员'] ]; $this->apiSuccess('获取成功',$return); } //农业产量 public function get_num14($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['value'=>1351,'name'=>'萝卜'], ['value'=>245,'name'=>'白菜'], ['value'=>874,'name'=>'芋头'], ['value'=>511,'name'=>'地瓜'], ['value'=>1024,'name'=>'土豆'], ['value'=>249,'name'=>'山药'], ]; $this->apiSuccess('获取成功',$return); } //农产品品牌 public function get_num15($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return['msg'] = [['value'=>'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230112/e0ce290ac9ff41da33f00f6ae72d02f1.png','name'=>'百合山药企业'], ['value'=>'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230112/e0ce290ac9ff41da33f00f6ae72d02f1.png','name'=>'通滩山药企业'], ['value'=>'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230112/e0ce290ac9ff41da33f00f6ae72d02f1.png','name'=>'百合土豆企业'], ['value'=>'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230112/e0ce290ac9ff41da33f00f6ae72d02f1.png','name'=>'云龙土豆企业'], ['value'=>'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230112/e0ce290ac9ff41da33f00f6ae72d02f1.png','name'=>'奇峰山药企业']]; $return['total'] = '62'; $return['xl'] = ['43','1.68']; $return['cgl'] = ['24','1.21']; $this->apiSuccess('获取成功',$return); } //农产品市场行情 public function get_num16($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['month'=>'1月','minnum'=>'661','maxnum'=>'879'], ['month'=>'2月','minnum'=>'356','maxnum'=>'521'], ['month'=>'3月','minnum'=>'415','maxnum'=>'754'], ['month'=>'4月','minnum'=>'258','maxnum'=>'369'], ['month'=>'5月','minnum'=>'779','maxnum'=>'916'], ['month'=>'6月','minnum'=>'1465','maxnum'=>'1874'], ['month'=>'7月','minnum'=>'668','maxnum'=>'837'], ['month'=>'8月','minnum'=>'571','maxnum'=>'710'], ['month'=>'9月','minnum'=>'498','maxnum'=>'638'], ['month'=>'10月','minnum'=>'587','maxnum'=>'800'], ['month'=>'11月','minnum'=>'881','maxnum'=>'983'], ['month'=>'12月','minnum'=>'1008','maxnum'=>'1250'], ]; $this->apiSuccess('获取成功',$return); } //农产品需求量 public function get_num17($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['value'=>835,'name'=>'萝卜'], ['value'=>124,'name'=>'白菜'], ['value'=>187,'name'=>'芋头'], ['value'=>251,'name'=>'地瓜'], ['value'=>902,'name'=>'土豆'], ['value'=>214,'name'=>'山药'], ]; $this->apiSuccess('获取成功',$return); } //企业直播 public function get_num18($area_id=0,$street_id=0,$village_id=0){ $where = []; // if ($area_id){ // $where[] = ['area_id', '=', $area_id]; // } // if ($street_id){ // $where[] = ['street_id', '=', $street_id]; // } // if ($village_id){ // $where[] = ['village_id', '=', $village_id]; // } $list = Db::connect('shop')->table('eb_broadcast_room')->field('name,cover_img,share_img,start_time,end_time,anchor_name,anchor_wechat,phone,live_status')->where($where)->select(); $this->apiSuccess('获取成功',$list); } //商户列表 public function get_num19($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['b.area_id', '=', $area_id]; } if ($street_id){ $where[] = ['b.street_id', '=', $street_id]; } if ($village_id){ $where[] = ['b.village_id', '=', $village_id]; } $list = Db::connect('shop')->table('eb_merchant') ->alias('a') ->join('eb_merchant_address b','a.mer_id = b.mer_id') ->field('mer_name,real_name,mer_phone,mer_address,mer_keyword,mer_avatar,sales,category_id') ->withAttr('category',function ($value,$data){ return Db::connect('shop')->table('eb_merchant_category')->where('merchant_category_id',$data['category_id'])->value('category_name'); }) ->where($where) ->select(); $this->apiSuccess('获取成功',$list); } //农产品销量前十 public function get_num20($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $map[] = ['a.status','=',1]; $map[] = ['a.is_del','=',0]; // 录入商户 $return['shanghu'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->where($where)->where($map)->count(); // 总订单 $return['total_order'] = Db::connect('shop')->table('eb_product_order_log')->where('status',1)->count(); // 镇订单 // 先默认方山镇 $z_order = Db::connect('shop')->table('eb_product_order_log')->where($where)->where('status',1)->count(); // 镇分佣 $return['fenyong'] = 0; //总市场流量 // $return['liuliang'] = bcmul(bcdiv($z_order,$return['total_order'],2),100); $return['liuliang'] = 15; // 商品销量前十 $return['data'] = Db::connect('shop')->table('eb_store_product') ->alias('a') ->join('eb_product_order_log b','a.product_id = b.product_id') ->join('eb_store_order c','b.order_id = c.order_id') ->field('a.store_name as name,sum(c.total_num) as value') ->where($where) ->limit(10) ->group('a.product_id') ->order('value desc') ->select(); $this->apiSuccess('获取成功',$return); } //新农产品市场行情 public function get_num21($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ [ 'name'=>'萝卜', 'demand'=>7852, 'minnum'=> [['month'=>'1月','value'=>'661'], ['month'=>'2月','value'=>'356'], ['month'=>'3月','value'=>'415'], ['month'=>'4月','value'=>'258'], ['month'=>'5月','value'=>'779'], ['month'=>'6月','value'=>'1465'], ['month'=>'7月','value'=>'668'], ['month'=>'8月','value'=>'571'], ['month'=>'9月','value'=>'498'], ['month'=>'10月','value'=>'587'], ['month'=>'11月','value'=>'881'], ['month'=>'12月','value'=>'1008']], 'maxnum'=> [['month'=>'1月','value'=>'879'], ['month'=>'2月','value'=>'521'], ['month'=>'3月','value'=>'754'], ['month'=>'4月','value'=>'369'], ['month'=>'5月','value'=>'916'], ['month'=>'6月','value'=>'1874'], ['month'=>'7月','value'=>'837'], ['month'=>'8月','value'=>'667'], ['month'=>'9月','value'=>'547'], ['month'=>'10月','value'=>'741'], ['month'=>'11月','value'=>'983'], ['month'=>'12月','value'=>'1150']], ], [ 'name'=>'白菜', 'demand'=>8869, 'minnum'=> [['month'=>'1月','value'=>'123'], ['month'=>'2月','value'=>'456'], ['month'=>'3月','value'=>'789'], ['month'=>'4月','value'=>'147'], ['month'=>'5月','value'=>'258'], ['month'=>'6月','value'=>'369'], ['month'=>'7月','value'=>'159'], ['month'=>'8月','value'=>'267'], ['month'=>'9月','value'=>'367'], ['month'=>'10月','value'=>'541'], ['month'=>'11月','value'=>'354'], ['month'=>'12月','value'=>'897']], 'maxnum'=> [['month'=>'1月','value'=>'879'], ['month'=>'2月','value'=>'897'], ['month'=>'3月','value'=>'1053'], ['month'=>'4月','value'=>'354'], ['month'=>'5月','value'=>'535'], ['month'=>'6月','value'=>'774'], ['month'=>'7月','value'=>'337'], ['month'=>'8月','value'=>'410'], ['month'=>'9月','value'=>'468'], ['month'=>'10月','value'=>'600'], ['month'=>'11月','value'=>'883'], ['month'=>'12月','value'=>'1100']], ], [ 'name'=>'芋头', 'demand'=>2356, 'minnum'=> [['month'=>'1月','value'=>'245'], ['month'=>'2月','value'=>'245'], ['month'=>'3月','value'=>'411'], ['month'=>'4月','value'=>'246'], ['month'=>'5月','value'=>'631'], ['month'=>'6月','value'=>'1234'], ['month'=>'7月','value'=>'546'], ['month'=>'8月','value'=>'246'], ['month'=>'9月','value'=>'356'], ['month'=>'10月','value'=>'466'], ['month'=>'11月','value'=>'744'], ['month'=>'12月','value'=>'998']], 'maxnum'=> [['month'=>'1月','value'=>'879'], ['month'=>'2月','value'=>'511'], ['month'=>'3月','value'=>'754'], ['month'=>'4月','value'=>'469'], ['month'=>'5月','value'=>'916'], ['month'=>'6月','value'=>'1474'], ['month'=>'7月','value'=>'887'], ['month'=>'8月','value'=>'710'], ['month'=>'9月','value'=>'678'], ['month'=>'10月','value'=>'854'], ['month'=>'11月','value'=>'983'], ['month'=>'12月','value'=>'1005']], ], [ 'name'=>'地瓜', 'demand'=>3641, 'minnum'=> [['month'=>'1月','value'=>'255'], ['month'=>'2月','value'=>'324'], ['month'=>'3月','value'=>'124'], ['month'=>'4月','value'=>'235'], ['month'=>'5月','value'=>'364'], ['month'=>'6月','value'=>'688'], ['month'=>'7月','value'=>'678'], ['month'=>'8月','value'=>'471'], ['month'=>'9月','value'=>'468'], ['month'=>'10月','value'=>'510'], ['month'=>'11月','value'=>'789'], ['month'=>'12月','value'=>'986']], 'maxnum'=> [['month'=>'1月','value'=>'899'], ['month'=>'2月','value'=>'531'], ['month'=>'3月','value'=>'759'], ['month'=>'4月','value'=>'569'], ['month'=>'5月','value'=>'946'], ['month'=>'6月','value'=>'1474'], ['month'=>'7月','value'=>'737'], ['month'=>'8月','value'=>'610'], ['month'=>'9月','value'=>'538'], ['month'=>'10月','value'=>'700'], ['month'=>'11月','value'=>'911'], ['month'=>'12月','value'=>'1050']], ], [ 'name'=>'土豆', 'demand'=>5345, 'minnum'=> [['month'=>'1月','value'=>'468'], ['month'=>'2月','value'=>'315'], ['month'=>'3月','value'=>'409'], ['month'=>'4月','value'=>'268'], ['month'=>'5月','value'=>'756'], ['month'=>'6月','value'=>'1126'], ['month'=>'7月','value'=>'641'], ['month'=>'8月','value'=>'552'], ['month'=>'9月','value'=>'483'], ['month'=>'10月','value'=>'568'], ['month'=>'11月','value'=>'821'], ['month'=>'12月','value'=>'896']], 'maxnum'=> [['month'=>'1月','value'=>'879'], ['month'=>'2月','value'=>'551'], ['month'=>'3月','value'=>'756'], ['month'=>'4月','value'=>'389'], ['month'=>'5月','value'=>'946'], ['month'=>'6月','value'=>'1474'], ['month'=>'7月','value'=>'847'], ['month'=>'8月','value'=>'720'], ['month'=>'9月','value'=>'668'], ['month'=>'10月','value'=>'830'], ['month'=>'11月','value'=>'993'], ['month'=>'12月','value'=>'1260']], ], [ 'name'=>'山药', 'demand'=>6548, 'minnum'=> [['month'=>'1月','value'=>'578'], ['month'=>'2月','value'=>'316'], ['month'=>'3月','value'=>'409'], ['month'=>'4月','value'=>'249'], ['month'=>'5月','value'=>'789'], ['month'=>'6月','value'=>'1420'], ['month'=>'7月','value'=>'647'], ['month'=>'8月','value'=>'561'], ['month'=>'9月','value'=>'478'], ['month'=>'10月','value'=>'513'], ['month'=>'11月','value'=>'841'], ['month'=>'12月','value'=>'889']], 'maxnum'=> [['month'=>'1月','value'=>'889'], ['month'=>'2月','value'=>'531'], ['month'=>'3月','value'=>'774'], ['month'=>'4月','value'=>'569'], ['month'=>'5月','value'=>'910'], ['month'=>'6月','value'=>'1574'], ['month'=>'7月','value'=>'857'], ['month'=>'8月','value'=>'740'], ['month'=>'9月','value'=>'648'], ['month'=>'10月','value'=>'810'], ['month'=>'11月','value'=>'983'], ['month'=>'12月','value'=>'1241']], ], ]; $this->apiSuccess('获取成功',$return); } //养殖户数 public function get_num22($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['value'=>50,'name'=>'养鸡'], ['value'=>48,'name'=>'养鸭'], ['value'=>28,'name'=>'养鹅'], ['value'=>10,'name'=>'养羊'], ['value'=>8,'name'=>'养虾'], ['value'=>30,'name'=>'养鱼'], ]; $this->apiSuccess('获取成功',$return); } //养殖户销量分析 public function get_num23($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ [ 'name'=>'鸡', 'data'=> [['month'=>'1月','value'=>'661'], ['month'=>'2月','value'=>'356'], ['month'=>'3月','value'=>'415'], ['month'=>'4月','value'=>'258'], ['month'=>'5月','value'=>'779'], ['month'=>'6月','value'=>'1465'], ['month'=>'7月','value'=>'668'], ['month'=>'8月','value'=>'571'], ['month'=>'9月','value'=>'498'], ['month'=>'10月','value'=>'587'], ['month'=>'11月','value'=>'881'], ['month'=>'12月','value'=>'1008']], ], [ 'name'=>'鸭', 'data'=> [['month'=>'1月','value'=>'123'], ['month'=>'2月','value'=>'456'], ['month'=>'3月','value'=>'789'], ['month'=>'4月','value'=>'147'], ['month'=>'5月','value'=>'258'], ['month'=>'6月','value'=>'369'], ['month'=>'7月','value'=>'159'], ['month'=>'8月','value'=>'267'], ['month'=>'9月','value'=>'367'], ['month'=>'10月','value'=>'541'], ['month'=>'11月','value'=>'354'], ['month'=>'12月','value'=>'897']], ], [ 'name'=>'鹅', 'data'=> [['month'=>'1月','value'=>'245'], ['month'=>'2月','value'=>'245'], ['month'=>'3月','value'=>'411'], ['month'=>'4月','value'=>'246'], ['month'=>'5月','value'=>'631'], ['month'=>'6月','value'=>'1234'], ['month'=>'7月','value'=>'546'], ['month'=>'8月','value'=>'246'], ['month'=>'9月','value'=>'356'], ['month'=>'10月','value'=>'466'], ['month'=>'11月','value'=>'744'], ['month'=>'12月','value'=>'998']], ] ]; $this->apiSuccess('获取成功',$return); } //养殖户产量分析 public function get_num24($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['name' => '鸡','value'=>40], ['name' => '鸭','value'=>50], ['name' => '鹅','value'=>10], ]; $this->apiSuccess('获取成功',$return); } }