分享链接页面信息
Showing
2 changed files
with
16 additions
and
5 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,7 +129,14 @@ class PropertyTrackService extends Service | ... | @@ -129,7 +129,14 @@ 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 | try { | ||
134 | |||
135 | //将上一条链接删除 | ||
136 | PropertyShare::query()->where(['pf_id'=>$this->request->input('track_id')])->orderByDesc('id')->limit(1)->delete(); | ||
137 | |||
138 | //生成新链接 | ||
139 | PropertyShare::query()->create([ | ||
133 | 'pf_id' => $this->request->input('track_id'), | 140 | 'pf_id' => $this->request->input('track_id'), |
134 | 'phone' => $this->request->input('phone'), | 141 | 'phone' => $this->request->input('phone'), |
135 | 'share_url' => $share, | 142 | 'share_url' => $share, |
... | @@ -137,10 +144,10 @@ class PropertyTrackService extends Service | ... | @@ -137,10 +144,10 @@ class PropertyTrackService extends Service |
137 | 'expire_time' => date('Y-m-d H:i:s', $expire_time), | 144 | 'expire_time' => date('Y-m-d H:i:s', $expire_time), |
138 | 'from' => $this->request->input('from'), | 145 | 'from' => $this->request->input('from'), |
139 | 'user_id' => $this->request->input('from') ? $this->request->get('identifier')->company_id : $this->request->input('user_id'), //用户 | 146 | 'user_id' => $this->request->input('from') ? $this->request->get('identifier')->company_id : $this->request->input('user_id'), //用户 |
140 | 'created_at' => $this->now, | 147 | ]); |
141 | ])) { | 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