用户信息、个人名片、加密、水印
This commit is contained in:
@@ -4,6 +4,7 @@ namespace app\common\controller;
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\UsedCar;
|
||||
use app\common\model\UsedCarPdfLog;
|
||||
use app\common\model\User;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\UsedCarService;
|
||||
@@ -138,8 +139,14 @@ class UsedCarController extends BaseController
|
||||
}
|
||||
$data['attachment'] = $attachments;
|
||||
$data['price'] = $price;
|
||||
|
||||
$pdf = (new MpdfDriver())->exportUsedCarPdf($data);
|
||||
$user = User::where('id',$request->user['id'])->first();
|
||||
$contact = $user['email'] ?? $user['phone'] ?? $user['whatsapp'] ?? null;
|
||||
if(!empty($user['social_code'])){
|
||||
$ossService = new OssService();
|
||||
$user['social_code'] = $ossService->generatePrivateUrl($user['social_code']);
|
||||
$user['social_code'] = $this->service->downloadImage($user['social_code']);
|
||||
}
|
||||
$pdf = (new MpdfDriver())->exportUsedCarPdf($data,$user,$contact);
|
||||
UsedCar::where('id', $data['id'])->update(['pdf_src' => $pdf]);
|
||||
|
||||
array_map('unlink', glob(runtime_path('pdf/images/*.jpg')));
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace app\common\controller;
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\UserService;
|
||||
use support\Request;
|
||||
|
||||
class UserController extends BaseController
|
||||
{
|
||||
@@ -30,4 +31,60 @@ class UserController extends BaseController
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return mixed 返回更新成功的数据或信息
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$request->setPost('id',$request->user['id']);
|
||||
$res = $this->service->serviceUpdate($request, $data);
|
||||
return $this->success([], '更新成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详情
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @param int|string $id 资源 ID
|
||||
* @return mixed 返回资源详情数据
|
||||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
try {
|
||||
$request->setGet('id',$request->user['id']);
|
||||
$raw = $this->service->serviceShow($request);
|
||||
$data = $this->transformData($raw, method_exists($this, 'showFormat')
|
||||
? [$this, 'showFormat']
|
||||
: null);
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
unset($data['union_id']);
|
||||
unset($data['app_id']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user