分享链接页面信息
Showing
2 changed files
with
23 additions
and
12 deletions
| ... | @@ -3,6 +3,7 @@ | ... | @@ -3,6 +3,7 @@ | 
| 3 | namespace App\Models\Legal; | 3 | namespace App\Models\Legal; | 
| 4 | 4 | ||
| 5 | use App\Models\BaseModel; | 5 | use App\Models\BaseModel; | 
| 6 | use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 6 | 7 | ||
| 7 | /** | 8 | /** | 
| 8 | * Class PropertyShare | 9 | * Class PropertyShare | 
| ... | @@ -10,6 +11,9 @@ use App\Models\BaseModel; | ... | @@ -10,6 +11,9 @@ use App\Models\BaseModel; | 
| 10 | */ | 11 | */ | 
| 11 | class PropertyShare extends BaseModel | 12 | class PropertyShare extends BaseModel | 
| 12 | { | 13 | { | 
| 14 | |||
| 15 | use SoftDeletes; | ||
| 16 | |||
| 13 | protected $updated_at = false; | 17 | protected $updated_at = false; | 
| 14 | protected $guarded = []; | 18 | protected $guarded = []; | 
| 15 | } | 19 | } | ... | ... | 
| ... | @@ -129,18 +129,25 @@ class PropertyTrackService extends Service | ... | @@ -129,18 +129,25 @@ class PropertyTrackService extends Service | 
| 129 | $share_url_hash = crc64($share); | 129 | $share_url_hash = crc64($share); | 
| 130 | $expire_time = time() + $propertyConfig['token_valid']; | 130 | $expire_time = time() + $propertyConfig['token_valid']; | 
| 131 | 131 | ||
| 132 | if (PropertyShare::query()->insertGetId([ | 132 | //生成新链接-上一个失效 | 
| 133 | 'pf_id' => $this->request->input('track_id'), | 133 | try { | 
| 134 | 'phone' => $this->request->input('phone'), | 134 | |
| 135 | 'share_url' => $share, | 135 | //将上一条链接删除 | 
| 136 | 'share_url_hash'=> $share_url_hash, | 136 | PropertyShare::query()->where(['pf_id'=>$this->request->input('track_id')])->orderByDesc('id')->limit(1)->delete(); | 
| 137 | 'expire_time' => date('Y-m-d H:i:s', $expire_time), | 137 | |
| 138 | 'from' => $this->request->input('from'), | 138 | //生成新链接 | 
| 139 | 'user_id' => $this->request->input('from') ? $this->request->get('identifier')->company_id : $this->request->input('user_id'), //用户 | 139 | PropertyShare::query()->create([ | 
| 140 | 'created_at' => $this->now, | 140 | 'pf_id' => $this->request->input('track_id'), | 
| 141 | ])) { | 141 | 'phone' => $this->request->input('phone'), | 
| 142 | 'share_url' => $share, | ||
| 143 | 'share_url_hash'=> $share_url_hash, | ||
| 144 | 'expire_time' => date('Y-m-d H:i:s', $expire_time), | ||
| 145 | 'from' => $this->request->input('from'), | ||
| 146 | 'user_id' => $this->request->input('from') ? $this->request->get('identifier')->company_id : $this->request->input('user_id'), //用户 | ||
| 147 | ]); | ||
| 148 | |||
| 142 | return Response::success(['url'=>$share]); | 149 | return Response::success(['url'=>$share]); | 
| 143 | } else { | 150 | } catch (\Throwable $throwable) { | 
| 144 | return Response::error(); | 151 | return Response::error(); | 
| 145 | } | 152 | } | 
| 146 | } | 153 | } | 
| ... | @@ -150,7 +157,7 @@ class PropertyTrackService extends Service | ... | @@ -150,7 +157,7 @@ class PropertyTrackService extends Service | 
| 150 | */ | 157 | */ | 
| 151 | public function shareUser() | 158 | public function shareUser() | 
| 152 | { | 159 | { | 
| 153 | $share = PropertyShare::query()->where(['share_url_hash'=>crc64($this->request->input('share_url'))])->first(); | 160 | $share = PropertyShare::withTrashed()->where(['share_url_hash'=>crc64($this->request->input('share_url'))])->first(); | 
| 154 | if (empty($share)) {return Response::error(ErrorCode::URL_FAIL);} //找不到此链接 | 161 | if (empty($share)) {return Response::error(ErrorCode::URL_FAIL);} //找不到此链接 | 
| 155 | 162 | ||
| 156 | $data = ['from'=>$share->from, 'name'=>'']; | 163 | $data = ['from'=>$share->from, 'name'=>'']; | ... | ... | 
- 
Please register or sign in to post a comment