161 lines
7.0 KiB
PHP
161 lines
7.0 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\nk;
|
|
|
|
use app\admin\BaseController;
|
|
use think\facade\Db;
|
|
use think\facade\View;
|
|
|
|
|
|
/**
|
|
* 产品情况
|
|
*
|
|
* @icon fa fa-circle-o
|
|
*/
|
|
class Analysis extends BaseController
|
|
{
|
|
|
|
/**
|
|
* 构造函数
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->adminInfo = get_login_admin();
|
|
$this->url=[
|
|
'/admin/nk.analysis/index',
|
|
];
|
|
}
|
|
/**
|
|
* 数据列表
|
|
*/
|
|
public function index()
|
|
{
|
|
if (request()->isAjax()) {
|
|
$mmm = $www = [];
|
|
$post = get_params();
|
|
|
|
//权限组信息
|
|
if ($this->adminInfo['group_access'] != 1) {
|
|
$find = Db::table('fa_szxc_information_useraddress')->where('admin_id', $this->adminInfo['id'])->find();
|
|
if ($find) {
|
|
if ($find['auth_range'] == 1) {
|
|
$mmm['b.village_id'] = $www['d.village_id'] = $find['village_id'];
|
|
} elseif ($find['auth_range'] == 2) {
|
|
$mmm['b.street_id'] = $www['d.street_id'] = $find['street_id'];
|
|
} elseif ($find['auth_range'] == 3) {
|
|
$mmm['b.area_id'] = $www['d.area_id'] = $find['area_id'];
|
|
}
|
|
}
|
|
}
|
|
if ($post) {
|
|
if (isset($post['area_id']) && !empty($post['area_id'])) {
|
|
$mmm['b.area_id'] = $www['d.area_id'] = $post['area_id'];
|
|
}
|
|
if (isset($post['street_id']) && !empty($post['street_id'])) {
|
|
$mmm['b.street_id'] = $www['d.street_id'] = $post['street_id'];
|
|
}
|
|
if (isset($post['village_id']) && !empty($post['village_id'])) {
|
|
$mmm['b.village_id'] = $www['d.village_id'] = $post['village_id'];
|
|
}
|
|
// if (isset($post['brigade_id']) && !empty($post['brigade_id'])) {
|
|
// $mmm['b.brigade_id'] = $www['d.brigade_id'] = $post['brigade_id'];
|
|
// }
|
|
}
|
|
|
|
|
|
$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('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();
|
|
|
|
//加工企业和品牌企业数量
|
|
$map[] = ['a.type_id','in','2,3'];
|
|
$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('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();
|
|
|
|
//镇农产品需求量分析(事业单位、企业、居民)
|
|
//农产品市场行情分析、显示
|
|
//农产品市内需求量
|
|
|
|
$result = ['data' => $list];
|
|
return table_assign(0, '', $result);
|
|
}
|
|
//权限组信息
|
|
$mmm = $www = [];
|
|
if ($this->adminInfo['group_access'] != 1) { //不是超级管理员
|
|
$www['admin_id'] = $this->adminInfo['id'];
|
|
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
|
|
if ($user_address) {
|
|
|
|
if ($user_address['auth_range'] == 1) {
|
|
$mmm['b.village_id'] = $www['d.village_id'] = $user_address['village_id'];
|
|
} elseif ($user_address['auth_range'] == 2) {
|
|
$mmm['b.street_id'] = $www['d.street_id'] = $user_address['street_id'];
|
|
} elseif ($user_address['auth_range'] == 3) {
|
|
$mmm['b.area_id'] = $www['d.area_id'] = $user_address['area_id'];
|
|
}
|
|
|
|
if ($user_address['auth_range'] <=3 &&$user_address['auth_range'] >=1 ) {
|
|
$select = Db::table('fa_geo_area')->where('city_code', '510500')->where('area_code', $user_address['area_id'])->select();
|
|
} else {
|
|
$select = Db::table('fa_geo_area')->where('city_code', '510500')->select();
|
|
}
|
|
View::assign('row', $user_address);
|
|
} else {
|
|
$user_address['area_id'] = '';
|
|
$user_address['street_id'] = '';
|
|
$user_address['village_id'] = '';
|
|
$user_address['auth_range'] = '1';
|
|
$select = Db::table('fa_geo_area')->where('city_code', '510500')->select();
|
|
View::assign('row', $user_address);
|
|
}
|
|
|
|
$is_admin = 0;
|
|
} else {
|
|
$user_address['area_id'] = '';
|
|
$user_address['street_id'] = '';
|
|
$user_address['village_id'] = '';
|
|
$user_address['auth_range'] = '';
|
|
$select = Db::table('fa_geo_area')->where('city_code', '510500')->select();
|
|
View::assign('row', $user_address);
|
|
$is_admin = 1;
|
|
}
|
|
|
|
$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('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();
|
|
|
|
//加工企业和品牌企业数量
|
|
$map[] = ['a.type_id','in','2,3'];
|
|
$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('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();
|
|
|
|
//镇农产品需求量分析(事业单位、企业、居民)
|
|
//农产品市场行情分析、显示
|
|
//农产品市内需求量
|
|
View::assign('data', $list);
|
|
|
|
View::assign('arealist', $select);
|
|
View::assign('is_admin', $is_admin);
|
|
View::assign('url', $this->url);
|
|
return view();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|