feat : check
This commit is contained in:
@@ -10,10 +10,36 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Api\Salesman;
|
||||
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\SalesmanTakePhoto;
|
||||
use App\Service\ServiceTrait\Common\OssTrait;
|
||||
use Hyperf\DbConnection\Db;
|
||||
|
||||
class ForceTakePhotoService extends BaseSalesmanService
|
||||
{
|
||||
public function handle()
|
||||
use OssTrait;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws ErrException
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
//todo Write logic
|
||||
$imageId = (int)$this->request->input('image_id');
|
||||
|
||||
Db::transaction(function () use ($imageId) {
|
||||
$insertModel = new SalesmanTakePhoto();
|
||||
|
||||
$insertModel->user_id = $this->userId;
|
||||
$insertModel->cycle_id = $this->cycleId;
|
||||
$insertModel->date = date('Y-m-d');
|
||||
$insertModel->image_id = $imageId;
|
||||
|
||||
$this->updateOssObjects([$imageId]);
|
||||
|
||||
if (!$insertModel->save()) throw new ErrException('拍照失败');
|
||||
});
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user