56 lines
2.2 KiB
PHP

<?php
namespace app\controller\api\dataview;
use app\common\repositories\BaseRepository;
use crmeb\basic\BaseController;
use think\App;
use think\exception\ValidateException;
use think\facade\Db;
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('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'));
}
// 镇级最新物流配送详情
public function latestLogistics()
{
if ($this->streetCode == '') {
return app('json')->fail('未获取到位置信息');
}
$detail = 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')
->where('og.street_code', $this->streetCode)
->order('o.order_id', 'desc')
->find();
$detail['status'] = app()->make(Order::class)->getStatusDesc($detail['status']);
return app('json')->success($detail);
}
}