dataview-今日订单接口
This commit is contained in:
parent
52273c1299
commit
865b2acc8f
79
app/controller/api/dataview/Order.php
Normal file
79
app/controller/api/dataview/Order.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\api\dataview;
|
||||
|
||||
use app\common\repositories\article\ArticleRepository as repository;
|
||||
use crmeb\basic\BaseController;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use think\App;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
|
||||
class Order extends BaseController
|
||||
{
|
||||
/**
|
||||
* @var repository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
public $areaCode; // 区县地区码
|
||||
|
||||
public $streetCode; // 镇街道地区码
|
||||
|
||||
/**
|
||||
* StoreBrand constructor.
|
||||
* @param App $app
|
||||
* @param repository $repository
|
||||
*/
|
||||
public function __construct(App $app, repository $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 currOrderInfo()
|
||||
{
|
||||
try {
|
||||
// 今日订单数
|
||||
$currOrderCountQuery = Db::name('store_order')->alias('o')
|
||||
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
|
||||
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
|
||||
->leftJoin('merchant m', 'o.mer_id = m.mer_id')
|
||||
->leftJoin('store_order_product op', 'o.order_id = op.order_id')
|
||||
->leftJoin('product_library p', 'op.product_id = p.id')
|
||||
->whereDay('og.create_time', '2023-11-29')
|
||||
->where('o.paid', 1)
|
||||
->whereNotNull('o.pay_time');
|
||||
if ($this->areaCode != '') {
|
||||
$currOrderCountQuery->where('og.district_code', $this->areaCode);
|
||||
}
|
||||
if ($this->streetCode != '') {
|
||||
$currOrderCountQuery->where('og.street_code', $this->streetCode);
|
||||
}
|
||||
$currOrderCount = $currOrderCountQuery->count();
|
||||
|
||||
[$page, $limit] = $this->getPage();
|
||||
$client = new \GuzzleHttp\Client();
|
||||
// 今日订单列表
|
||||
$currOrderList = $currOrderCountQuery->page($page, $limit)->select()->toArray();
|
||||
|
||||
foreach ($currOrderList as $k => $order) {
|
||||
$getUrl = env('LOGISTICS_HOST_URL') . '/api/courierData?order_sn=' . $order['order_sn'];
|
||||
$response = $client->request('GET', $getUrl);
|
||||
$courierData = json_decode($response->getBody(), true);
|
||||
$currOrderList[$k]['courier'] = $courierData['data']['courier_name'];
|
||||
}
|
||||
|
||||
return app('json')->success(compact('currOrderCount', 'currOrderList'));
|
||||
|
||||
} catch (ValidateException $e) {
|
||||
throw new ValidateException($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -713,6 +713,13 @@ Route::group('api/', function () {
|
||||
//滑块验证码
|
||||
Route::get('ajcaptcha', 'api.Auth/ajcaptcha');
|
||||
Route::post('ajcheck', 'api.Auth/ajcheck');
|
||||
|
||||
// dataview接口
|
||||
Route::group('dataview', function () {
|
||||
// Route::post('cancel/:id', '/cancelGroupOrder');
|
||||
Route::get('curr_order_info', 'Order/currOrderInfo');
|
||||
|
||||
})->prefix('api.dataview.');
|
||||
})->middleware(AllowOriginMiddleware::class)
|
||||
->middleware(InstallMiddleware::class)
|
||||
->middleware(CheckSiteOpenMiddleware::class)
|
||||
@ -730,3 +737,4 @@ Route::group('/open-location', function () {
|
||||
Route::miss('View/h5');
|
||||
})->middleware(InstallMiddleware::class)
|
||||
->middleware(CheckSiteOpenMiddleware::class);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user