settter
							parent
							
								
									164d0abd68
								
							
						
					
					
						commit
						64d880e05c
					
				|  | @ -580,18 +580,18 @@ if (!function_exists('arrayNullToString')) { | ||||||
|      * 数组|或数据集中null值转为空字符串,并以数组格式返回 |      * 数组|或数据集中null值转为空字符串,并以数组格式返回 | ||||||
|      * 通常用于api json 返回内容null转换 |      * 通常用于api json 返回内容null转换 | ||||||
|      * |      * | ||||||
|      * @param array $data 【array|collection】 |      * @param $data | ||||||
|      * @return array |      * @return array | ||||||
|      */ |      */ | ||||||
|     function arrayNullToString($data) |     function arrayNullToString($data) | ||||||
|     { |     { | ||||||
|         if ($data instanceof Collection) { |         if ($data instanceof Collection || $data instanceof Model) { | ||||||
|             $data = $data->toArray(); |             $data = $data->toArray(); | ||||||
|         } |         } | ||||||
|         // 判断是否可以遍历
 |         // 判断是否可以遍历
 | ||||||
|         if (is_iterable($data)) { |         if (is_iterable($data)) { | ||||||
|             foreach ($data as $key => $val) { |             foreach ($data as $key => $val) { | ||||||
|                 if ($val instanceof Collection) { |                 if ($val instanceof Collection || $data instanceof Model) { | ||||||
|                     $val = $val->toArray(); |                     $val = $val->toArray(); | ||||||
|                 } |                 } | ||||||
|                 if (is_iterable($val)) { |                 if (is_iterable($val)) { | ||||||
|  | @ -606,7 +606,6 @@ if (!function_exists('arrayNullToString')) { | ||||||
|         return $data; |         return $data; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| if (!function_exists('arrayKeysExcludeFilter')) { | if (!function_exists('arrayKeysExcludeFilter')) { | ||||||
|     /** |     /** | ||||||
|      * 一维数组键名排除过滤 |      * 一维数组键名排除过滤 | ||||||
|  |  | ||||||
|  | @ -109,8 +109,12 @@ class Business extends Base | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (!empty($params['agency_code'])) { |             if (!empty($params['agency_code'])) { | ||||||
|                 $agencyBusiness = $busRepo->findOneByWhere(['code'=> $params['agency_code'], 'is_agency'=> self::BOOL_TRUE, 'state' => BusinessModel::state_on]); |                 $agencyBusiness = $busRepo->findOneByWhere([ | ||||||
|                 if (empty($agencyBusiness) || $agencyBusiness['is_delete'] == self::BOOL_TRUE) { |                     ['code',"=", $params['agency_code']], | ||||||
|  |                     ['is_agency',"=", BusinessModel::COMMON_ON], | ||||||
|  |                     [ 'state' ,"=", BusinessModel::state_on] | ||||||
|  |                 ]); | ||||||
|  |                 if (empty($agencyBusiness)) { | ||||||
|                     throw new ValidateException('没有相关的代理商记录!'); |                     throw new ValidateException('没有相关的代理商记录!'); | ||||||
|                 } elseif ($agencyBusiness['enable'] == self::BOOL_TRUE) { |                 } elseif ($agencyBusiness['enable'] == self::BOOL_TRUE) { | ||||||
|                     throw new ValidateException('该代理商已被封禁!'); |                     throw new ValidateException('该代理商已被封禁!'); | ||||||
|  |  | ||||||
|  | @ -6,9 +6,7 @@ use app\repository\BusinessRepository; | ||||||
| use app\repository\CouponRepository; | use app\repository\CouponRepository; | ||||||
| use app\repository\DictionaryRepository; | use app\repository\DictionaryRepository; | ||||||
| use think\response\Json; | use think\response\Json; | ||||||
| use app\model\{ | use app\model\{Business as BusinessModel, Member}; | ||||||
|     Business as BusinessModel |  | ||||||
| }; |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * APP 数据字典 |  * APP 数据字典 | ||||||
|  | @ -81,28 +79,9 @@ class Dictionary extends Base | ||||||
|     public function getAgencyList(): Json |     public function getAgencyList(): Json | ||||||
|     { |     { | ||||||
|         try { |         try { | ||||||
|             $page = $this->request->param('page/d', 1); |             $data =  Member::getAgentAll(); | ||||||
|             $size = $this->request->param('size/d', 10); |             return $this->json(0 , 'success', $data); | ||||||
| 
 |  | ||||||
|             $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) { |         } catch (RepositoryException | \Exception $e) { | ||||||
| 
 |  | ||||||
|             return $this->json(0 , 'success', []); |             return $this->json(0 , 'success', []); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -234,6 +234,10 @@ class Agency extends Base | ||||||
|                             Db::rollback(); |                             Db::rollback(); | ||||||
|                             return $this->json(4001, "指定商家不存在"); |                             return $this->json(4001, "指定商家不存在"); | ||||||
|                         } |                         } | ||||||
|  |                         if($business->is_agency ==  BusinessModel::COMMON_ON){ | ||||||
|  |                             Db::rollback(); | ||||||
|  |                             return $this->json(4001, "该商家已经是代理商,不能重复绑定"); | ||||||
|  |                         } | ||||||
|                         $business->save(["is_agency" => BusinessModel::COMMON_ON]); |                         $business->save(["is_agency" => BusinessModel::COMMON_ON]); | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue