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.

65 lines
1.6 KiB

  1. <?php
  2. namespace App\JsonRpc;
  3. use App\Commons\Log;
  4. use App\Constants\ErrorCode;
  5. use App\Service\SeparateAccountsServiceInterface;
  6. use Hyperf\DbConnection\Db;
  7. use Hyperf\RpcServer\Annotation\RpcService;
  8. use Hyperf\Di\Annotation\Inject;
  9. use App\Constants\LogLabel;
  10. /**
  11. * @RpcService(name="OrderService", protocol="jsonrpc-http", server="jsonrpc-http", publishTo="")
  12. */
  13. class OrderService implements OrderServiceInterface
  14. {
  15. /**
  16. * @Inject
  17. * @var Log
  18. */
  19. protected $log;
  20. /**
  21. * @Inject
  22. * @var \App\Service\OrderServiceInterface
  23. */
  24. protected $orderService;
  25. /**
  26. * @Inject
  27. * @var SeparateAccountsServiceInterface
  28. */
  29. protected $separateAccountsService;
  30. public function onlineComplete($global_order_id)
  31. {
  32. Db::beginTransaction();
  33. try {
  34. $this->orderService->onlineCompleted($global_order_id);
  35. $this->separateAccountsService->orderOnlineCompleted($global_order_id);
  36. Db::commit();
  37. return [
  38. "status" => 200,
  39. "code" => 0,
  40. "result" => [],
  41. "message" => '调用成功'
  42. ];
  43. } catch (\Exception $e) {
  44. Db::rollBack();
  45. $this->log->event(LogLabel::ONLINE_COMPLETE_LOG, ['exception' => $e->getMessage()]);
  46. return [
  47. "status" => 200,
  48. "code" =>ErrorCode::SEPARATE_ACCOUNTS_ERROR,
  49. "result" => [],
  50. "message" => ErrorCode::getMessage(ErrorCode::SEPARATE_ACCOUNTS_ERROR)
  51. ];
  52. }
  53. }
  54. }