diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index caa8d8e..d7712d6 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -116,7 +116,7 @@ class Index extends BaseController $sum_216 = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) - ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=216')->sum('p.land_area'); + ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id')->sum('p.breed_area'); $sum_215 = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) @@ -133,20 +133,7 @@ class Index extends BaseController ->alias('u') ->where($where) ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=69')->sum('p.land_area'); - // 荒地面积 - $sum_waste_land_area = Db::table('fa_szxc_information_useraddress') - ->alias('u') - ->where($where) - ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=69')->sum('p.waste_land_area'); -// 养殖面积 - $breed_area = Db::table('fa_szxc_information_useraddress') - ->alias('u') - ->where($where) - ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=69')->sum('p.breed_area'); - - $hd_num = $sum_waste_land_area - $breed_area; - $waste_land_area = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) @@ -173,8 +160,6 @@ class Index extends BaseController 'sum_214' => $sum_214, 'sum_70' => $sum_70, 'sum_69' => $sum_69, - 'sum_waste_land_area' => $hd_num<0 ?$hd_num:0, - 'breed_area' => $breed_area, ] ); return View(); diff --git a/app/admin/controller/nk/Analysis.php b/app/admin/controller/nk/Analysis.php index 2839513..29ed00b 100644 --- a/app/admin/controller/nk/Analysis.php +++ b/app/admin/controller/nk/Analysis.php @@ -66,7 +66,7 @@ class Analysis extends BaseController $map[] = ['a.status','=',1]; $map[] = ['a.is_del','=',0]; //企业农产品销量 - $list['num_2'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->join('eb_store_order c','a.mer_id = c.mer_id')->where($mmm)->where($map)->where('c.is_del',0)->where('c.paid',1)->count(); + $list['num_2'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->join('nk_lihaink_cn.eb_product_order_log c','a.mer_id = c.mer_id')->where($mmm)->where($map)->where('c.status',1)->count(); //本镇已录入的商户 $list['num_4'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->where($mmm)->where($map)->count(); @@ -76,7 +76,7 @@ class Analysis extends BaseController $list['num_1'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->where($mmm)->where($map)->count(); //企业通过我们平台采购的农产品 - $list['num_3'] = Db::connect('shop')->table('eb_user')->alias('a')->join('eb_nk_user b','a.uid = b.user_id')->join('eb_store_order c','a.uid = c.uid')->join('nk_lihaink_cn.fa_szxc_information_useraddress d','b.n_user_id = d.user_id')->where($www)->where('a.status',1)->where('c.is_del',0)->where('c.paid',1)->count(); + $list['num_3'] = Db::connect('shop')->table('eb_user')->alias('a')->join('eb_nk_user b','a.uid = b.user_id')->join('nk_lihaink_cn.eb_product_order_log c','a.uid = c.uid')->join('nk_lihaink_cn.fa_szxc_information_useraddress d','b.n_user_id = d.user_id')->where($www)->where('a.status',1)->where('c.status',1)->count(); //镇农产品需求量分析(事业单位、企业、居民) //农产品市场行情分析、显示 @@ -129,7 +129,7 @@ class Analysis extends BaseController $map[] = ['a.status','=',1]; $map[] = ['a.is_del','=',0]; //企业农产品销量 - $list['num_2'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->join('eb_store_order c','a.mer_id = c.mer_id')->where($mmm)->where($map)->where('c.is_del',0)->where('c.paid',1)->count(); + $list['num_2'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->join('nk_lihaink_cn.eb_product_order_log c','a.mer_id = c.mer_id')->where($mmm)->where($map)->where('c.status',1)->count(); //本镇已录入的商户 $list['num_4'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->where($mmm)->where($map)->count(); @@ -139,7 +139,7 @@ class Analysis extends BaseController $list['num_1'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->where($mmm)->where($map)->count(); //企业通过我们平台采购的农产品 - $list['num_3'] = Db::connect('shop')->table('eb_user')->alias('a')->join('eb_nk_user b','a.uid = b.user_id')->join('eb_store_order c','a.uid = c.uid')->join('nk_lihaink_cn.fa_szxc_information_useraddress d','b.n_user_id = d.user_id')->where($www)->where('a.status',1)->where('c.is_del',0)->where('c.paid',1)->count(); + $list['num_3'] = Db::connect('shop')->table('eb_user')->alias('a')->join('eb_nk_user b','a.uid = b.user_id')->join('nk_lihaink_cn.eb_product_order_log c','a.uid = c.uid')->join('nk_lihaink_cn.fa_szxc_information_useraddress d','b.n_user_id = d.user_id')->where($www)->where('a.status',1)->where('c.status',1)->count(); //镇农产品需求量分析(事业单位、企业、居民) //农产品市场行情分析、显示 diff --git a/app/admin/controller/nk/Village.php b/app/admin/controller/nk/Village.php index d7310d1..f10e989 100644 --- a/app/admin/controller/nk/Village.php +++ b/app/admin/controller/nk/Village.php @@ -35,7 +35,7 @@ class Village extends BaseController if (request()->isAjax()) { $params= get_params(); $where[]=['status','=',1]; - $where[]=['village_id','<>',0]; + $where[]=['village_id','>',0]; if (isset($params['keywords'])){ $where[]=['title','like','%'.$params['keywords'].'%']; } diff --git a/app/api/controller/Village.php b/app/api/controller/Village.php index e2278c7..e0ba933 100644 --- a/app/api/controller/Village.php +++ b/app/api/controller/Village.php @@ -17,7 +17,7 @@ class Village extends BaseController * @var array */ protected $middleware = [ - Auth::class => ['except' => ['get_list','get_ranking_list','get_detail','get_json','get_village','thumbs_up'] ] + Auth::class => ['except' => ['get_list','get_ranking_list','get_detail','get_json','get_village','thumbs_up','get_ranking_town'] ] ]; /** @@ -43,7 +43,7 @@ class Village extends BaseController $where['status'] = 1; $list = Db::table('fa_szxc_village') ->where($where) - ->where('village_id','<>',0) + ->where('village_id','>',0) ->page($page,10) ->field('id,title,address,people_num,images,views,likes,createtime,area_id,street_id,village_id') ->order('likes desc') @@ -88,7 +88,7 @@ class Village extends BaseController $list = Db::table('fa_szxc_village') ->where($where) - ->where('village_id','<>',0) + ->where('village_id','>',0) ->page($page,$limit) ->field('id,title,address,people_num,images,views,likes,createtime,area_id,street_id,village_id') ->order('likes desc') @@ -242,7 +242,7 @@ class Village extends BaseController $where[] = ['address', 'like', '%'.$keyword.'%']; $list = Db::table('fa_szxc_village') ->where($where) - ->where('village_id','<>',0) + ->where('village_id','>',0) ->field('id,title,address,people_num,images,views,likes,createtime') ->order('likes desc') ->withAttr('images', function ($value, $data) { @@ -594,6 +594,64 @@ class Village extends BaseController $this->apiSuccess('获取成功', $news); } + /** + * 获取镇排名 + * + */ + public function get_ranking_town($page = 1,$limit=10) + { + + $www[] = ['status','=',1]; + $www[] = ['village_id','=',0]; + $arr = Db::table('fa_szxc_village')->where($www)->select()->toArray(); + foreach ($arr as $k=>$v){ + $www2['status'] = 1; + $www2['street_id'] = $v['street_id']; + $www2['area_id'] = $v['area_id']; + $sum = Db::table('fa_szxc_village')->where($www2)->where('village_id','>',0)->sum('likes'); + if($v['likes'] < $sum){ + $ddd['likes'] = $sum; + $mmm['id'] = $v['id']; + Db::table('fa_szxc_village')->where($mmm)->update($ddd); + } + } + + $where['status'] = 1; + $list = Db::table('fa_szxc_village') + ->where($where) + ->where('village_id','=',0) + ->page($page,$limit) + ->field('id,title,address,people_num,images,views,likes,createtime,area_id,street_id,village_id') + ->order('likes desc') + ->withAttr('images', function ($value, $data) { + if ($data['images'] != '') { + return explode(',',$data['images']); + }else{ + return ''; + } + }) + ->withAttr('is_dz', function ($value, $data) { + // 判断redis + $user_id = JWT_UID; + if($user_id){ + $name = $user_id . $data['id']; + $is_zan = Cache::store('redis')->get($name); + if($is_zan){ + return 1; + }else{ + return 0; + } + }else{ + return 0; + } + }) + ->select(); + if($list){ + $this->apiSuccess('获取成功',$list); + }else{ + $this->apiError('暂无数据',[]); + } + } }