Files
kiri-wchat/wchat/qq/result/RedHatResult.php
T

103 lines
1.5 KiB
PHP
Raw Normal View History

2019-12-02 17:53:08 +08:00
<?php
2020-03-05 12:41:49 +08:00
namespace wchat\qq\result;
2019-12-02 17:53:08 +08:00
/**
* Class RedHatResult
* @package qq\result
*/
class RedHatResult
{
2022-09-09 16:42:55 +08:00
public mixed $result;
public mixed $res_info;
2019-12-02 17:53:08 +08:00
2022-09-09 16:42:55 +08:00
public mixed $listid;
public mixed $state;
public mixed $total_num;
public mixed $recv_num;
public mixed $total_amount;
public mixed $recv_amount;
public mixed $recv_details;
public mixed $uin;
2019-12-02 17:53:08 +08:00
const RED_HAT_STATUS_PAID = 1;
const RED_HAT_STATUS_SNATCHED = 2;
const RED_HAT_STATUS_EXPIRED = 3;
const RED_HAT_STATUS_REFUNDED = 4;
/**
* RedHatResult constructor.
* @param array $array
*/
public function __construct(array $array)
{
$this->init($array);
}
/**
* @param $array
2022-09-09 16:42:55 +08:00
* @return void
2019-12-02 17:53:08 +08:00
*/
2022-09-09 16:42:55 +08:00
private function init($array): void
2019-12-02 17:53:08 +08:00
{
foreach ($array as $key => $value) {
if (!property_exists($this, $key)) {
continue;
}
$this->{$key} = $value;
}
}
/**
* @param $field
* @return mixed
*/
2022-09-09 16:42:55 +08:00
public function get($field): mixed
2019-12-02 17:53:08 +08:00
{
return $this->$field;
}
/**
* @return bool
* 是否已完成支付
*/
2022-09-09 16:42:55 +08:00
public function isPaid(): bool
2019-12-02 17:53:08 +08:00
{
return $this->state == self::RED_HAT_STATUS_PAID;
}
/**
* @return bool
* 是否已抢完
*/
2022-09-09 16:42:55 +08:00
public function isSnatched(): bool
2019-12-02 17:53:08 +08:00
{
return $this->state == self::RED_HAT_STATUS_SNATCHED;
}
/**
* @return bool
*/
2022-09-09 16:42:55 +08:00
public function isExpired(): bool
2019-12-02 17:53:08 +08:00
{
return $this->state == self::RED_HAT_STATUS_EXPIRED;
}
/**
* @return bool
*/
2022-09-09 16:42:55 +08:00
public function isRefunded(): bool
2019-12-02 17:53:08 +08:00
{
return $this->state == self::RED_HAT_STATUS_REFUNDED;
}
}