jun 2 долоо хоног өмнө
parent
commit
d9f3a8f5d6

BIN
app.zip


+ 4 - 5
app/Http/Controllers/Api/Product.php

@@ -187,6 +187,7 @@ class Product extends Api{
 		$uid						= $this->getUid();
         // 获取客户信息
         $custom						= $uid ? $Custom->getOne($uid) : [];
+        $cityId                     = empty($custom['city_id']) ? 0 : $custom['city_id'];
 		// 接收参数
 		$id						    = request('id',0);
 		// 显示
@@ -198,14 +199,14 @@ class Product extends Api{
         // 允许城市
         $allowCity                  = $ProductCity->where([['product_id','=',$id]])->pluck('city_id')->toArray();
         // 如果不是全国城市 也不是服务城市范围
-        if ( !in_array(1,$allowCity) &&  ( isset($custom['city_id']) && !in_array($custom['city_id'],$allowCity)) ) return json_send(['code'=>'error','msg'=>'您的城市不在该产品服务范围','data'=>['error'=>'您的城市不在该产品服务范围']]);
+        if ( !in_array(1,$allowCity) &&  ( isset($cityId) && !in_array($cityId,$allowCity)) ) return json_send(['code'=>'error','msg'=>'您的城市不在该产品服务范围','data'=>['error'=>'您的城市不在该产品服务范围']]);
         //判断产品城市是否设置了支付
         $payCity                        = $PayCity->where([['status','=',0]])->first();
         $isPay                          = 0;
-        if ($payCity && $payCity['city_ids']) {
+        if ($payCity && $payCity['city_ids'] && isset($cityId)) {
             $cityIds = explode(',',$payCity['city_ids']);
             foreach ($allowCity as $item) {
-                if (($item == 1 || in_array($item,$cityIds)) && in_array($custom['city_id'],$cityIds))     $isPay                  = 1;
+                if (($item == 1 || in_array($item,$cityIds)) && in_array($cityId,$cityIds))     $isPay                  = 1;
             }
         }
         // 转数组
@@ -305,11 +306,9 @@ class Product extends Api{
         }
         // 查询用户标签
         $tags                       =   [];
-        $cityId                     =   '';
         if ($custom){
             $tags					= $WeiBanTags->getListByWeibanExtid($custom['weiban_extid']);
             $tagsList               = array_column($tags,'name');
-            $cityId					= $custom['city_id'];
             // 判断是不是可以参与
 			if( $data['tag_scope'] ) {
 				// 解析数组