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.
 
 

87 lines
2.2 KiB

<?php
namespace App\JsonRpc;
use App\Commons\Log;
use App\Constants\v3\ErrorCode;
use App\Exception\ErrorCodeException;
use App\Service\v3\Interfaces\SeparateAccountsServiceInterface;
use Hyperf\DbConnection\Db;
use Hyperf\RpcServer\Annotation\RpcService;
use Hyperf\Di\Annotation\Inject;
use App\Constants\v3\LogLabel;
/**
* @RpcService(name="OrderOnlineService", protocol="jsonrpc-http", server="jsonrpc-http", publishTo="")
*/
class OrderOnlineService implements OrderOnlineServiceInterface
{
/**
* @Inject
* @var Log
*/
protected $log;
/**
* @Inject
* @var \App\Service\v3\Interfaces\OrderOnlineServiceInterface
*/
protected $orderOnlineService;
/**
* @Inject
* @var SeparateAccountsServiceInterface
*/
protected $separateAccountsService;
public function onlineComplete($orderMainId, $userId)
{
Db::beginTransaction();
try {
$this->orderOnlineService->doComplete($orderMainId, $userId);
$this->separateAccountsService->orderOnlineCompleted($orderMainId, $userId);
Db::commit();
return [
"status" => 200,
"code" => 0,
"result" => [],
"message" => '调用成功'
];
} catch (\Exception $e) {
Db::rollBack();
$this->log->event(LogLabel::ORDER_COMPLETE_LOG, ['exception' => $e->getMessage()]);
throw new ErrorCodeException(ErrorCode::ORDER_COMPLETE_FAIL, $e->getMessage());
}
}
/**
* 线上订单退款
* 申请退款 state = 8
* 退款成功 state = 9
*/
public function onlineRefund($global_order_id){
$result = [
"status" => 200,
"code" => ErrorCode::ORDER_FAILURE,
"result" => [],
"message" => ''
];
$res = $this->orderOnlineService->onlineRefund($global_order_id);
if($res['code'] > 0){
$result['result'] = $res;
$result['message'] = '退款失败';
}else{
$result['code'] = 0;
$result['result'] = $res;
$result['message'] = '退款成功';
};
return $result;
}
}