From addac7854d418c186804e08efbf84ba6b98b11f4 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Fri, 23 Oct 2020 16:25:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=AE=8C=E6=88=90=E6=8D=A2?= =?UTF-8?q?=E7=9C=9F=E5=AE=9E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/HorsemanController.php | 26 ++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/app/Controller/v3/HorsemanController.php b/app/Controller/v3/HorsemanController.php index 50a885f..2676eb5 100644 --- a/app/Controller/v3/HorsemanController.php +++ b/app/Controller/v3/HorsemanController.php @@ -3,8 +3,14 @@ namespace App\Controller\v3; +use App\Constants\v3\ErrorCode; +use App\Constants\v3\LogLabel; use App\Controller\BaseController; +use App\Exception\ErrorCodeException; +use App\Model\v3\OrderMain; use App\Service\v3\Interfaces\HorsemanServiceInterface; +use App\Service\v3\Interfaces\SeparateAccountsServiceInterface; +use Hyperf\DbConnection\Db; use Hyperf\Di\Annotation\Inject; use App\Service\v3\Interfaces\OrderOnlineServiceInterface; use App\Request\v3\EmployeesRequest; @@ -23,6 +29,12 @@ class HorsemanController extends BaseController */ protected $orderOnlineService; + /** + * @Inject + * @var SeparateAccountsServiceInterface + */ + protected $separateAccountsService; + public function getOrderList(EmployeesRequest $request) { $employeesId = $this->request->input('employees_id', -1); @@ -62,7 +74,17 @@ class HorsemanController extends BaseController public function orderComplete(HorsemanOrderRequest $request) { $globalOrderId = $this->request->input('global_order_id', -1); - $res = $this->orderOnlineService->completeForHorseman($globalOrderId); - return $this->success($res); + $userId = OrderMain::query()->where('global_order_id',$globalOrderId)->value('user_id'); + Db::beginTransaction(); + try { + $this->orderOnlineService->doComplete($globalOrderId, $userId); + $this->separateAccountsService->orderOnlineCompleted($globalOrderId, $userId); + Db::commit(); + return $this->success(true); + } catch (\Exception $e) { + Db::rollBack(); + $this->log->event(LogLabel::ORDER_COMPLETE_LOG, ['exception' => $e->getMessage()]); + throw new ErrorCodeException(ErrorCode::ORDER_COMPLETE_FAIL); + } } } \ No newline at end of file