chengkun
2025-08-29 73cdff843994b42beef7a22844326f83fee104de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?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());
        }
    }
    
}