Commit f90266f3 f90266f3b3cf5ec8820276a624a33750822e2ba0 by lemon

分享链接页面信息

1 parent 23203efb
......@@ -3,6 +3,7 @@
namespace App\Models\Legal;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class PropertyShare
......@@ -10,6 +11,9 @@ use App\Models\BaseModel;
*/
class PropertyShare extends BaseModel
{
use SoftDeletes;
protected $updated_at = false;
protected $guarded = [];
}
......
......@@ -129,18 +129,25 @@ class PropertyTrackService extends Service
$share_url_hash = crc64($share);
$expire_time = time() + $propertyConfig['token_valid'];
if (PropertyShare::query()->insertGetId([
'pf_id' => $this->request->input('track_id'),
'phone' => $this->request->input('phone'),
'share_url' => $share,
'share_url_hash'=> $share_url_hash,
'expire_time' => date('Y-m-d H:i:s', $expire_time),
'from' => $this->request->input('from'),
'user_id' => $this->request->input('from') ? $this->request->get('identifier')->company_id : $this->request->input('user_id'), //用户
'created_at' => $this->now,
])) {
//生成新链接-上一个失效
try {
//将上一条链接删除
PropertyShare::query()->where(['pf_id'=>$this->request->input('track_id')])->orderByDesc('id')->limit(1)->delete();
//生成新链接
PropertyShare::query()->create([
'pf_id' => $this->request->input('track_id'),
'phone' => $this->request->input('phone'),
'share_url' => $share,
'share_url_hash'=> $share_url_hash,
'expire_time' => date('Y-m-d H:i:s', $expire_time),
'from' => $this->request->input('from'),
'user_id' => $this->request->input('from') ? $this->request->get('identifier')->company_id : $this->request->input('user_id'), //用户
]);
return Response::success(['url'=>$share]);
} else {
} catch (\Throwable $throwable) {
return Response::error();
}
}
......@@ -150,7 +157,7 @@ class PropertyTrackService extends Service
*/
public function shareUser()
{
$share = PropertyShare::query()->where(['share_url_hash'=>crc64($this->request->input('share_url'))])->first();
$share = PropertyShare::withTrashed()->where(['share_url_hash'=>crc64($this->request->input('share_url'))])->first();
if (empty($share)) {return Response::error(ErrorCode::URL_FAIL);} //找不到此链接
$data = ['from'=>$share->from, 'name'=>''];
......