add 三轮车列表接口
This commit is contained in:
parent
1ecdff83fc
commit
1462eb8e71
35
app/controller/api/dataview/Logistics.php
Normal file
35
app/controller/api/dataview/Logistics.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\api\dataview;
|
||||
|
||||
use app\common\repositories\BaseRepository;
|
||||
use crmeb\basic\BaseController;
|
||||
use think\App;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
class Logistics extends BaseController
|
||||
{
|
||||
public function __construct(App $app, BaseRepository $repository)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->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('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'];
|
||||
return app('json')->success($list);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user