diff --git a/app/controller/api/dataview/Logistics.php b/app/controller/api/dataview/Logistics.php new file mode 100644 index 00000000..44ef1327 --- /dev/null +++ b/app/controller/api/dataview/Logistics.php @@ -0,0 +1,36 @@ +repository = $repository; + $this->areaCode = $this->request->param('areaCode', ''); + $this->streetCode = $this->request->param('streetCode', ''); + + if ($this->areaCode == '' && $this->streetCode == '') { + throw new ValidateException('请选择地区'); + } + } + + // 三轮车列表 从供销系统获取 + public function vehicleList() + { + // 请求供销,供销查区域下的公司,在通过公司查三轮车列表 + $client = new \GuzzleHttp\Client(); + $getUrl = env('TASK_WORKER_HOST_URL') . '/api/index/vehicleCarList?areaCode='.$this->areaCode.'&streetCode='.$this->streetCode; + $response = $client->request('GET', $getUrl); + $result = json_decode($response->getBody(), true); + $list = $result['data']; + $count = count($list); + return app('json')->success(compact('count', 'list')); + } +} \ No newline at end of file diff --git a/app/controller/api/dataview/Order.php b/app/controller/api/dataview/Order.php index ce1f6d15..6cf6dbfd 100644 --- a/app/controller/api/dataview/Order.php +++ b/app/controller/api/dataview/Order.php @@ -2,9 +2,8 @@ namespace app\controller\api\dataview; -use app\common\repositories\article\ArticleRepository as repository; +use app\common\repositories\BaseRepository; use crmeb\basic\BaseController; -use GuzzleHttp\Exception\ClientException; use think\App; use think\exception\ValidateException; use think\facade\Db; @@ -25,7 +24,7 @@ class Order extends BaseController * @param App $app * @param repository $repository */ - public function __construct(App $app, repository $repository) + public function __construct(App $app, BaseRepository $repository) { parent::__construct($app); $this->repository = $repository; @@ -81,9 +80,7 @@ class Order extends BaseController $pendingPickupOrderCountQuery->where('og.district_code', $this->areaCode); $undeliveredOrderCountQuery->where('og.district_code', $this->areaCode); $doneOrderCountQuery->where('og.district_code', $this->areaCode); - } - - if ($this->streetCode != '') { + } else if ($this->streetCode != '') { $currOrderCountQuery->where('og.street_code', $this->streetCode); $pendingPickupOrderCountQuery->where('og.street_code', $this->streetCode); $undeliveredOrderCountQuery->where('og.street_code', $this->streetCode); @@ -124,7 +121,6 @@ class Order extends BaseController // 镇级订单数排行榜 public function orderRanking() { - $type = $this->request->get('type',2); // 1今日 2总计 $townList = Db::name('geo_street')->field('street_code,street_name')->where('area_code', $this->areaCode)->select()->toArray(); // 镇/街道列表 $orderCount = 0; @@ -174,4 +170,34 @@ class Order extends BaseController } return $desc[$status]; } + + public function deliveredProductRanking() + { + // 查到镇级 + if ($this->areaCode != '' && $this->streetCode != '') { + $list = Db::query("SELECT p.store_name, SUM(o.`total_num`) AS total_quantity + FROM `eb_store_product` p + JOIN `eb_store_order_product` op ON p.product_id = op.product_id + JOIN `eb_store_order` o ON o.`order_id` = op.`order_id` + JOIN `eb_product_order_log` opg ON o.`order_id`= opg.`order_id` + WHERE opg.`street_code`= '{$this->streetCode}' + GROUP BY p.store_name + ORDER BY total_quantity DESC + LIMIT 50"); + } else { + // 查到区县级 + $list = Db::query("SELECT p.store_name, SUM(o.`total_num`) AS total_quantity + FROM `eb_store_product` p + JOIN `eb_store_order_product` op ON p.product_id = op.product_id + JOIN `eb_store_order` o ON o.`order_id` = op.`order_id` + JOIN `eb_product_order_log` opg ON o.`order_id`= opg.`order_id` + WHERE opg.`district_code`= '{$this->areaCode}' + GROUP BY p.store_name + ORDER BY total_quantity DESC + LIMIT 50"); + } + + + return app('json')->success($list); + } } \ No newline at end of file diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index a4ff6061..f0ceb9cf 100644 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -62,16 +62,17 @@ class Merchant extends BaseController if (empty($where['type_id'])) { $where['type_id'] =[10,17]; } - if($where['store_category_id']>0){ - $arr= Db::name('store_category')->where(['pid'=>$where['store_category_id'],'mer_id'=>0,'level'=>1,'is_show'=>1])->column('cate_name'); - if($arr){ - $category_id=Db::name('merchant_category')->whereIn('category_name',$arr)->column('merchant_category_id'); - if($category_id){ - $where['category_id']=implode(',',$category_id); - } - } - unset($where['store_category_id']); - } + // if($where['store_category_id']>0){ + // $arr= Db::name('store_category')->where(['pid'=>$where['store_category_id'],'mer_id'=>0,'level'=>1,'is_show'=>1])->column('cate_name'); + // if($arr){ + // $category_id=Db::name('merchant_category')->whereIn('category_name',$arr)->column('merchant_category_id'); + // if($category_id){ + // $where['category_id']=implode(',',$category_id); + // } + // } + // unset($where['store_category_id']); + // } + $where['category_id']=$where['store_category_id']??''; return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo)); } diff --git a/config/database.php b/config/database.php index 2634d53e..6b4e9823 100644 --- a/config/database.php +++ b/config/database.php @@ -68,6 +68,46 @@ return [ 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR, ], - // 更多的数据库配置信息 + // 物流系统 + 'logistics' => [ + // 数据库类型 + 'type' => env('database2.type', 'mysql'), + // 服务器地址 + 'hostname' => env('database2.hostname', '127.0.0.1'), + // 数据库名 + 'database' => env('database2.database', ''), + // 用户名 + 'username' => env('database2.username', 'root'), + // 密码 + 'password' => env('database2.password', ''), + // 端口 + 'hostport' => env('database2.hostport', '3306'), + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 +// 'charset' => env('database.charset', 'utf8'), + 'charset' => 'utf8mb4', + // 数据库表前缀 + 'prefix' => env('database2.prefix', ''), + + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 是否需要断线重连 + 'break_reconnect' => true, + // 监听SQL + 'trigger_sql' => env('app_debug', true), + // 开启字段缓存 + 'fields_cache' => false, + // 字段缓存路径 + 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR, + ], ], ]; diff --git a/route/api.php b/route/api.php index 211c3871..d13e31da 100644 --- a/route/api.php +++ b/route/api.php @@ -719,6 +719,8 @@ Route::group('api/', function () { // Route::post('cancel/:id', '/cancelGroupOrder'); Route::get('curr_order_info', 'Order/currOrderInfo'); Route::get('order_ranking', 'Order/orderRanking'); + Route::get('delivered_product_ranking', 'Order/deliveredProductRanking'); + Route::get('vehicle_list', 'Logistics/vehicleList'); })->prefix('api.dataview.'); })->middleware(AllowOriginMiddleware::class)