<?php
|
|
namespace app\admin\controller;
|
|
use think\Exception;
|
use think\facade\View;
|
use think\facade\Request;
|
use think\facade\Config;
|
use think\facade\Db;
|
|
class PublicApi extends Common {
|
|
private $categoryService;
|
private $deliverRegionService;
|
private $logisticsProductService;
|
private $platformLogisticsProductService;
|
|
public function __construct() {
|
// parent::__construct();
|
$this->categoryService = new \services\CategoryService();
|
$this->deliverRegionService = new \services\DeliverRegionService();
|
$this->logisticsProductService = new \services\LogisticsProductService();
|
$this->platformLogisticsProductService = new \services\PlatformLogisticsProductService();
|
}
|
|
public function categoryList(){
|
header('Content-Type:text/html;charset=utf-8');
|
if (!Request::isPost()) {
|
return $this->errorResponse(lang('request_method_incorrect'));
|
}
|
try {
|
$where = [];
|
if (Request::has('pid','post')) {
|
$pid = trim(input('pid'));
|
// if (!is_numeric($pid)) {
|
// throw new Exception('参数错误!', 400);
|
// }
|
$where[] = ['father_code', '=', $pid];
|
}
|
if (Request::has('keyWord','post')) {
|
$where[] = ['cate_name', 'like', '%'.trim(input('keyWord')).'%'];
|
}
|
$categorys = [];
|
$categorys['list'] = $this->categoryService->getList($where);
|
return $this->successResponse($categorys);
|
} catch (Exception $e) {
|
return $this->errorResponse($e->getMessage());
|
}
|
}
|
|
public function deliverRegionList(){
|
header('Content-Type:text/html;charset=utf-8');
|
if (!Request::isPost()) {
|
return $this->errorResponse(lang('request_method_incorrect'));
|
}
|
try {
|
$where = [];
|
$data = [];
|
$data['list'] = $this->deliverRegionService->getList($where);
|
$data['list'] = datalist($data['list'], 'deliver_region_id', '', FALSE);
|
return $this->successResponse($data);
|
} catch (Exception $e) {
|
return $this->errorResponse($e->getMessage());
|
}
|
}
|
|
public function logisticsProductList(){
|
header('Content-Type:text/html;charset=utf-8');
|
if (!Request::isPost()) {
|
return $this->errorResponse(lang('request_method_incorrect'));
|
}
|
try {
|
$where = [];
|
$data = [];
|
$data['list'] = $this->logisticsProductService->getList($where);
|
$data['list'] = datalist($data['list'], 'id', '', FALSE);
|
return $this->successResponse($data);
|
} catch (Exception $e) {
|
return $this->errorResponse($e->getMessage());
|
}
|
}
|
|
public function platformLogisticsProductList(){
|
header('Content-Type:text/html;charset=utf-8');
|
if (!Request::isPost()) {
|
return $this->errorResponse(lang('request_method_incorrect'));
|
}
|
try {
|
$where = [];
|
$data = [];
|
$data['list'] = $this->platformLogisticsProductService->getList($where);
|
$data['list'] = datalist($data['list'], 'id', '', FALSE);
|
return $this->successResponse($data);
|
} catch (Exception $e) {
|
return $this->errorResponse($e->getMessage());
|
}
|
}
|
|
}
|