From cb946c57808012f80c9002cf09db425dc1fcc2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=A1=83?= <1098598843@qq.com> Date: Fri, 10 Feb 2023 17:12:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Census.php | 80 +++++++++++++++++-------------- app/api/controller/Statistics.php | 33 +++++++++++++ 2 files changed, 76 insertions(+), 37 deletions(-) diff --git a/app/api/controller/Census.php b/app/api/controller/Census.php index 159cc09..a9ca965 100644 --- a/app/api/controller/Census.php +++ b/app/api/controller/Census.php @@ -14,7 +14,7 @@ class Census extends BaseController // 获取一些统计数据 public function get_list(){ - $where = $mmm = $www = []; + $where = $mmm = $www = $where2 = []; $post = get_params(); // //根据个人村id进行查询 @@ -33,12 +33,15 @@ class Census extends BaseController if ($post) { if (isset($post['area_id']) && !empty($post['area_id'])) { $mmm['b.area_id'] = $www['d.area_id'] = $where['area_id'] = $post['area_id']; + $where2['a.area_id'] = $post['area_id']; } if (isset($post['street_id']) && !empty($post['street_id'])) { $mmm['b.street_id'] = $www['d.street_id'] = $where['street_id'] = $post['street_id']; + $where2['a.street_id'] = $post['street_id']; } if (isset($post['village_id']) && !empty($post['village_id'])) { $mmm['b.village_id'] = $www['d.village_id'] = $where['village_id'] = $post['village_id']; + $where2['a.village_id'] = $post['village_id']; } } @@ -66,28 +69,28 @@ class Census extends BaseController //种植面积 养殖面积 荒地面积 //镇农产品结构展示 //运输距离显示 - // 大于60岁人数 - $old_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>=', 60)->count(); -// 儿童人数 - $children_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 15)->count(); -// 未婚男 - $unmarried_man_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 1], ['marital_status', '=', 169]])->count(); -// 未婚女 - $unmarried_woman_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 2], ['marital_status', '=', 169]])->count(); -// 少数民族 - $nation_s_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereBetween('nation', [13, 68])->count(); -// 汉族 - $nation_h_num = Db::table('fa_szxc_information_usermsg')->where($where)->where('nation', 12)->count(); - //残疾人数 - $whether_disabled_num = 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(); -// 参保人数 - $insurance_type_num = 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(); +// // 大于60岁人数 +// $old_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>=', 60)->count(); +//// 儿童人数 +// $children_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 15)->count(); +//// 未婚男 +// $unmarried_man_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 1], ['marital_status', '=', 169]])->count(); +//// 未婚女 +// $unmarried_woman_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 2], ['marital_status', '=', 169]])->count(); +//// 少数民族 +// $nation_s_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereBetween('nation', [13, 68])->count(); +//// 汉族 +// $nation_h_num = Db::table('fa_szxc_information_usermsg')->where($where)->where('nation', 12)->count(); +// //残疾人数 +// $whether_disabled_num = 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(); +//// 参保人数 +// $insurance_type_num = 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(); //土地总面积 $land_area_num = Db::table('fa_szxc_information_useraddress') @@ -142,10 +145,10 @@ class Census extends BaseController ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id')->sum('p.waste_land_area'); //农产品种类 $cms_agriculture_products = Db::table('cms_agriculture_products')->where('status',1)->count(); - //蔬菜基地数量 - $cms_manufacturer = Db::table('cms_manufacturer')->where('status',1)->count(); - //农贸市场数量 - $cms_farm_product_market = Db::table('cms_farm_product_market')->where('status',1)->count(); +// //蔬菜基地数量 +// $cms_manufacturer = Db::table('cms_manufacturer')->where('status',1)->count(); +// //农贸市场数量 +// $cms_farm_product_market = Db::table('cms_farm_product_market')->where('status',1)->count(); //种植面积 $zz_mianji = $land_area_num - $sum_216 - $waste_land_area; //总人口 @@ -166,6 +169,8 @@ class Census extends BaseController }) ->where('status',1)->field('content')->select(); +// 订单商品总数 + $need_num = Db::connect('shop')->table('eb_product_order_log')->alias('a')->join('eb_store_order b','a.order_id = b.order_id')->where($where2)->where('a.status',1)->sum('b.total_num'); $return['index'] = [ ['name' => '总人口','value'=>$num.'人'], ['name' => '农产品种类','value'=>$cms_agriculture_products.'种'], @@ -188,16 +193,17 @@ class Census extends BaseController ['name' => '农产品销量','value'=>$num_2.'单'], ['name' => '农产采购量','value'=>$num_3.'单'], ['name' => '已录入商户','value'=>$num_4], - ['name' => '大于60岁人数','value'=>$old_num], - ['name' => '儿童人数','value'=>$children_num], - ['name' => '未婚男','value'=>$unmarried_man_num], - ['name' => '未婚女','value'=>$unmarried_woman_num], - ['name' => '少数民族','value'=>$nation_s_num], - ['name' => '汉族','value'=>$nation_h_num], - ['name' => '残疾人数','value'=>$whether_disabled_num], - ['name' => '参保人数','value'=>$insurance_type_num], - ['name' => '蔬菜基地数量','value'=>$cms_manufacturer.'个'], - ['name' => '农贸市场数量','value'=>$cms_farm_product_market.'个'], + ['name' => '市需求量','value'=>$need_num.'个'], +// ['name' => '大于60岁人数','value'=>$old_num], +// ['name' => '儿童人数','value'=>$children_num], +// ['name' => '未婚男','value'=>$unmarried_man_num], +// ['name' => '未婚女','value'=>$unmarried_woman_num], +// ['name' => '少数民族','value'=>$nation_s_num], +// ['name' => '汉族','value'=>$nation_h_num], +// ['name' => '残疾人数','value'=>$whether_disabled_num], +// ['name' => '参保人数','value'=>$insurance_type_num], +// ['name' => '蔬菜基地数量','value'=>$cms_manufacturer.'个'], +// ['name' => '农贸市场数量','value'=>$cms_farm_product_market.'个'], ]; $return['zhouqi'] = [ ['name' => '农产品周期','value'=>$zhouqi], diff --git a/app/api/controller/Statistics.php b/app/api/controller/Statistics.php index e652ca7..fec4baa 100644 --- a/app/api/controller/Statistics.php +++ b/app/api/controller/Statistics.php @@ -696,5 +696,38 @@ class Statistics extends BaseController $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($where)->where('status',1)->count(); +// 商品销量前十 + $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); + } + + }