init($array); } /** * @param $array * @return $this */ private function init($array) { foreach ($array as $key => $value) { if (!property_exists($this, $key)) { continue; } $this->{$key} = $value; } return $this; } /** * @param $field * @return mixed */ public function get($field) { return $this->$field; } /** * @return bool * 是否已完成支付 */ public function isPaid() { return $this->state == self::RED_HAT_STATUS_PAID; } /** * @return bool * 是否已抢完 */ public function isSnatched() { return $this->state == self::RED_HAT_STATUS_SNATCHED; } /** * @return bool */ public function isExpired() { return $this->state == self::RED_HAT_STATUS_EXPIRED; } /** * @return bool */ public function isRefunded() { return $this->state == self::RED_HAT_STATUS_REFUNDED; } }