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.
92 lines
2.3 KiB
92 lines
2.3 KiB
<?php
|
|
|
|
namespace App\JsonRpc;
|
|
|
|
use App\Commons\Log;
|
|
use App\Constants\ErrorCode;
|
|
use App\Service\SeparateAccountsServiceInterface;
|
|
use Hyperf\DbConnection\Db;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use App\Constants\LogLabel;
|
|
|
|
/**
|
|
* @RpcService(name="OrderService", protocol="jsonrpc-http", server="jsonrpc-http", publishTo="")
|
|
*/
|
|
class OrderService implements OrderServiceInterface
|
|
{
|
|
|
|
/**
|
|
* @Inject
|
|
* @var Log
|
|
*/
|
|
protected $log;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var \App\Service\OrderServiceInterface
|
|
*/
|
|
protected $orderService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var SeparateAccountsServiceInterface
|
|
*/
|
|
protected $separateAccountsService;
|
|
|
|
public function onlineComplete($global_order_id)
|
|
{
|
|
Db::beginTransaction();
|
|
try {
|
|
|
|
$this->orderService->onlineCompleted($global_order_id);
|
|
$this->separateAccountsService->orderOnlineCompleted($global_order_id);
|
|
|
|
Db::commit();
|
|
return [
|
|
"status" => 200,
|
|
"code" => 0,
|
|
"result" => [],
|
|
"message" => '调用成功'
|
|
];
|
|
} catch (\Exception $e) {
|
|
|
|
Db::rollBack();
|
|
$this->log->event(LogLabel::ONLINE_COMPLETE_LOG, ['exception' => $e->getMessage()]);
|
|
return [
|
|
"status" => 200,
|
|
"code" =>ErrorCode::SEPARATE_ACCOUNTS_ERROR,
|
|
"result" => [],
|
|
"message" => ErrorCode::getMessage(ErrorCode::SEPARATE_ACCOUNTS_ERROR)
|
|
];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 线上订单退款
|
|
* 申请退款 state = 8
|
|
* 退款成功 state = 9
|
|
*/
|
|
public function onlineRefund($global_order_id){
|
|
Db::beginTransaction();
|
|
try{
|
|
|
|
return [
|
|
"status" => 200,
|
|
"code" => 0,
|
|
"result" => $this->orderService->onlineRefund($global_order_id),
|
|
// 'result' => $global_order_id,
|
|
"message" => '退款成功'
|
|
];
|
|
} catch (\Exception $e){
|
|
Db::rollBack();
|
|
return [
|
|
"status" => 200,
|
|
"code" => ErrorCode::ORDER_FAILURE,
|
|
"result" => [],
|
|
"message" => $e->getMessage()
|
|
];
|
|
}
|
|
}
|
|
}
|