|
|
@@ -162,6 +162,22 @@ class StoreService extends BaseService
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ $params = request()->all();
|
|
|
+ $system = isset($params['system']) ? $params['system'] : [];
|
|
|
+ $system = $system && !is_array($system) ? json_decode($system, true) : $system;
|
|
|
+ $uuid = isset($system['uuid']) ? $system['uuid'] : '';
|
|
|
+ $uuKey = "caches:storeId:uuid_{$uuid}";
|
|
|
+ $ipKey = "caches:storeId:ip_".get_client_ip();
|
|
|
+ if($userId<=0){
|
|
|
+ if($storeId = RedisService::get($ipKey)){
|
|
|
+ $this->error = "未登录缓存的店铺";
|
|
|
+ return $storeId;
|
|
|
+ }else if($uuid && $storeId = RedisService::get($uuKey)){
|
|
|
+ $this->error = "未登录缓存的店铺";
|
|
|
+ return $storeId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 用户信息
|
|
|
$userInfo = MemberModel::with(['store'])
|
|
|
->where(['id'=>$userId,'mark'=>1])
|
|
|
@@ -188,31 +204,24 @@ class StoreService extends BaseService
|
|
|
}
|
|
|
|
|
|
// 用户上级有商家
|
|
|
- $parentStoreInfo = $this->model->whereIn('user_id',$ids)
|
|
|
- ->where(['status'=>1,'mark'=>1])
|
|
|
- ->select(['id','user_id','name'])
|
|
|
- ->orderByRaw("FIELD(user_id,".(implode(',',$ids)).") asc")
|
|
|
- ->first();
|
|
|
+ $parentStoreInfo = [];
|
|
|
+ if($ids){
|
|
|
+ $parentStoreInfo = $this->model->whereIn('user_id',$ids)
|
|
|
+ ->where(['status'=>1,'mark'=>1])
|
|
|
+ ->select(['id','user_id','name'])
|
|
|
+ ->orderByRaw("FIELD(user_id,".(implode(',',$ids)).") asc")
|
|
|
+ ->first();
|
|
|
+ }
|
|
|
+
|
|
|
$storeId = isset($parentStoreInfo['id'])?$parentStoreInfo['id'] : 0;
|
|
|
$parentUserId = isset($parentStoreInfo['user_id'])?$parentStoreInfo['user_id'] : 0;
|
|
|
- $params = request()->all();
|
|
|
- $system = isset($params['system']) ? $params['system'] : [];
|
|
|
- $system = $system && !is_array($system) ? json_decode($system, true) : $system;
|
|
|
- $uuid = isset($system['uuid']) ? $system['uuid'] : '';
|
|
|
- $uuKey = "caches:storeId:uuid_{$uuid}";
|
|
|
- $ipKey = "caches:storeId:ip_".get_client_ip();
|
|
|
+
|
|
|
if($parentStoreInfo && $storeId>0){
|
|
|
RedisService::set($cacheKey, $storeId, 7 * 86400);
|
|
|
RedisService::set($ipKey, $storeId, 7 * 86400);
|
|
|
RedisService::set($uuKey, $storeId, 7 * 86400);
|
|
|
$this->error = "上级[{$parentUserId}]的店铺";
|
|
|
return $storeId;
|
|
|
- }else if($storeId = RedisService::get($ipKey)){
|
|
|
- $this->error = "未登录缓存的店铺";
|
|
|
- return $storeId;
|
|
|
- }else if($uuid && $storeId = RedisService::get($uuKey)){
|
|
|
- $this->error = "未登录缓存的店铺";
|
|
|
- return $storeId;
|
|
|
}
|
|
|
|
|
|
$this->error = "";
|