89 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			89 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			PHP
		
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								namespace app\controller\api;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use app\exception\RepositoryException;
							 | 
						||
| 
								 | 
							
								use app\repository\BusinessRepository;
							 | 
						||
| 
								 | 
							
								use think\response\Json;
							 | 
						||
| 
								 | 
							
								use app\model\{
							 | 
						||
| 
								 | 
							
								    Business as BusinessModel
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * APP 数据字典
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * Class Dictionary
							 | 
						||
| 
								 | 
							
								 * @package app\controller\api
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								class Dictionary extends Base
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    protected $noNeedLogin = [
							 | 
						||
| 
								 | 
							
								        'getDistanceList',
							 | 
						||
| 
								 | 
							
								        'getAgencyList',
							 | 
						||
| 
								 | 
							
								    ];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 获取距离(distance)列表
							 | 
						||
| 
								 | 
							
								     * @return Json
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function getDisList(): Json
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $list = [
							 | 
						||
| 
								 | 
							
								            ['id' => 1, 'name'=> "1km", 'value' => 1],
							 | 
						||
| 
								 | 
							
								            ['id' => 3, 'name'=> "3km", 'value' => 3],
							 | 
						||
| 
								 | 
							
								            ['id' => 5, 'name'=> "5km", 'value' => 5],
							 | 
						||
| 
								 | 
							
								            ['id' => 10, 'name'=> "10km", 'value' => 10],
							 | 
						||
| 
								 | 
							
								        ];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        return $this->json(0, 'success', $list);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 获取商圈列表
							 | 
						||
| 
								 | 
							
								     * TODO 待确认是否需要这个接口
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function getBusinessCircle()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 获取代理机构(渠道代理商)列表
							 | 
						||
| 
								 | 
							
								     * (来源商家表中的渠道代理商)
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     * $size 0 表示不分页,获取所有数据
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function getAgencyList(): Json
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        try {
							 | 
						||
| 
								 | 
							
								            $page = $this->request->param('page/d', 1);
							 | 
						||
| 
								 | 
							
								            $size = $this->request->param('size/d', 10);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            $whereMap   = [];
							 | 
						||
| 
								 | 
							
								            $whereMap[] = ['is_agency', '=', self::BOOL_TRUE];
							 | 
						||
| 
								 | 
							
								            $whereMap[] = ['is_delete', '=', self::BOOL_FALSE];
							 | 
						||
| 
								 | 
							
								            $whereMap[] = ['state', '=', BusinessModel::state_on];
							 | 
						||
| 
								 | 
							
								            $whereMap[] = ['enable', '=', self::BOOL_FALSE];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            $sortOrder  = ['id'=>"asc"];
							 | 
						||
| 
								 | 
							
								            $fields = ['id', 'code', 'business_name', 'business_subtitle', 'business_license',
							 | 
						||
| 
								 | 
							
								                'lat', 'lng', 'business_address', 'contact_name', 'contact_phone',
							 | 
						||
| 
								 | 
							
								                'create_time', 'type', 'type_name', 'characteristic', 'intro',
							 | 
						||
| 
								 | 
							
								                'business_circle', 'business_circle_id', 'background', 'score'
							 | 
						||
| 
								 | 
							
								            ];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            $repo   = BusinessRepository::getInstance();
							 | 
						||
| 
								 | 
							
								            $res    = $repo->findList($whereMap, $fields, $page, $size, null, $sortOrder);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            return $this->json(0 , 'success', $res);
							 | 
						||
| 
								 | 
							
								        } catch (RepositoryException | \Exception $e) {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            return $this->json(0 , 'success', []);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 |