You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.1 KiB
90 lines
3.1 KiB
<?php
|
|
|
|
|
|
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;
|
|
use App\Request\v3\HorsemanOrderRequest;
|
|
class HorsemanController extends BaseController
|
|
{
|
|
/**
|
|
* @Inject
|
|
* @var HorsemanServiceInterface
|
|
*/
|
|
protected $horsemanService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var OrderOnlineServiceInterface
|
|
*/
|
|
protected $orderOnlineService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var SeparateAccountsServiceInterface
|
|
*/
|
|
protected $separateAccountsService;
|
|
|
|
public function getOrderList(EmployeesRequest $request)
|
|
{
|
|
$employeesId = $this->request->input('employees_id', -1);
|
|
$page = $this->request->input('page',0);
|
|
$pagesize = $this->request->input('pagesize',0);
|
|
$orderMainList = $this->horsemanService->getOrderList($employeesId,$page, $pagesize);
|
|
return $this->success($orderMainList);
|
|
}
|
|
|
|
public function getOrderInfo(HorsemanOrderRequest $request)
|
|
{
|
|
$globalOrderId = $this->request->input('global_order_id', -1);
|
|
$orderMain = $this->orderOnlineService->getOrderInfo($globalOrderId);
|
|
return $this->success(['order' => $orderMain]);
|
|
}
|
|
|
|
public function setHorsemanCoordinate(EmployeesRequest $request)
|
|
{
|
|
$employeesId = $this->request->input('employees_id', -1);
|
|
$coordinate = $this->request->input('coordinate', -1);
|
|
return $this->success($this->horsemanService->setHorsemanCoordinate($employeesId,$coordinate));
|
|
}
|
|
|
|
public function getHorsemanCoordinate(EmployeesRequest $request)
|
|
{
|
|
$employeesId = $this->request->input('employees_id', -1);
|
|
$coordinate = $this->horsemanService->getHorsemanCoordinate($employeesId);
|
|
return $this->success(['coordinate' => $coordinate]);
|
|
}
|
|
|
|
public function getOrderCoordinate()
|
|
{
|
|
$globalOrderId = $this->request->input('global_order_id', -1);
|
|
return $this->success($this->horsemanService->getOrderCoordinate($globalOrderId));
|
|
}
|
|
|
|
public function orderComplete(HorsemanOrderRequest $request)
|
|
{
|
|
$globalOrderId = $this->request->input('global_order_id', -1);
|
|
$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);
|
|
}
|
|
}
|
|
}
|