<?php
namespace Payment\Query\Ali; use Payment\Common\Ali\AliBaseStrategy; use Payment\Common\Ali\Data\Query\TransferQueryData; use Payment\Common\PayException; use Payment\Config; use Payment\Utils\ArrayUtil; class AliTransferQuery extends AliBaseStrategy { protected $method = 'alipay.fund.trans.order.query'; public function getBuildDataClass() { $this->config->method = $this->method; return TransferQueryData::class; } protected function retData(array $data) { $reqData = parent::retData($data); try { $ret = $this->sendReq($reqData); } catch (PayException $e) { throw $e; } if ($this->config->returnRaw) { $ret['channel'] = Config::ALI_TRANSFER; return $ret; } return $this->createBackData($ret); } protected function createBackData(array $data) { if ($data['code'] !== '10000') { return $retData = [ 'is_success' => 'F', 'error' => $data['sub_msg'], 'channel' => Config::ALI_TRANSFER, ]; } $retData = [ 'is_success' => 'T', 'response' => [ 'transaction_id' => ArrayUtil::get($data, 'order_id'), 'status' => strtolower(ArrayUtil::get($data, 'status')), 'pay_date' => ArrayUtil::get($data, 'pay_date'), 'arrival_time_end' => ArrayUtil::get($data, 'arrival_time_end'), 'amount' => ArrayUtil::get($data, 'order_fee'), 'trans_no' => ArrayUtil::get($data, 'out_biz_no'), 'channel' => Config::ALI_TRANSFER, ] ]; if (isset($data['error_code'])) { $retData['response']['error_code'] = ArrayUtil::get($data, 'error_code'); $retData['response']['fail_reason'] = ArrayUtil::get($data, 'fail_reason'); } return $retData; } } 