123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace refill\by_online_cb;
- class record
- {
- private $mRecord;
- public function __construct($record)
- {
- $this->mRecord = $record;
- }
- public function charge_id() {
- return trim($this->mRecord['CHARGE_ID']);
- }
- public function trade_id() {
- return trim($this->mRecord['OUT_TRADE_ID']);
- }
- public function fee()
- {
- return intval($this->mRecord['RECV_FEE']);
- }
- public function charge_time()
- {
- if(empty($this->mRecord['RECV_TIME'])) {
- return false;
- } else {
- return strtotime($this->mRecord['RECV_TIME']);
- }
- }
- public function canceled()
- {
- $deal_tag = $this->deal_tag();
- return ($deal_tag === 2);
- }
- private function deal_tag()
- {
- return intval($this->mRecord['DEAL_TAG'] ?? 0);
- }
- public function successed()
- {
- $deal_tag = $this->deal_tag();
- return ($deal_tag === 1);
- }
- }
- class response
- {
- private $mResult;
- private $mRecords = [];
- private $respCode;
- public function __construct($resp)
- {
- $this->respCode = intval($resp['respCode']);
- $this->mResult = $resp['result'];
- ksort($this->mResult);
- if(isset($this->mResult['data']))
- {
- $items = $this->mResult['data'];
- foreach ( $items as $item)
- {
- ksort($item);
- $this->mRecords[] = $item;
- }
- unset($this->mResult['data']);
- }
- else
- {
- $keys = ["DEAL_INFO","MONTH","DEAL_TAG","USER_ID_OUT","SERIAL_NUMBER_OUT",
- "DEAL_TIME","RECV_FEE","RECV_TIME","BIND_SERIAL_NUMBER","OUT_TRADE_ID",
- "GROUP_ID","CHARGE_ID","CANCEL_CHARGE_ID","ACCT_ID_OUT","CANCEL_TAG",
- "CANCEL_TIME","REMARK","LOCAL_SN","KITE_ORDER_NUM","CUST_NAME"];
- $item = [];
- foreach ($keys as $key) {
- $item[$key] = $this->mResult[$key] ?? "";
- }
- ksort($item);
- $this->mRecords[] = $item;
- foreach ($keys as $key) {
- unset($this->mResult[$key]);
- }
- }
- }
- public function find_record($charge_id)
- {
- foreach ($this->mRecords as $record)
- {
- $chid = $record['CHARGE_ID'];
- if($chid == $charge_id) {
- return new record($record);
- }
- }
- return false;
- }
- }
|