mCardItem = $item; } public function topcard_id(): int { return intval($this->mCardItem['topcard_id']); } public function member_id(): int { return intval($this->mCardItem['member_id']); } public function card_no(): string { return $this->mCardItem['card_no']; } public function card_type(): int { return intval($this->mCardItem['card_type']); } public function add_time(): int { return intval($this->mCardItem['add_time']); } public function total_amount(): float { return round(floatval($this->mCardItem['total_amount']), 2); } public function month_total() { $stamp = month_stamp(); if ($this->month_stamp() != $stamp) { return 0.00; } else { return round(doubleval($this->mCardItem['month_amount']), 2); } } public function month_stamp(): int { return intval($this->mCardItem['month_stamp']); } public function can_edit() { $amount = $this->total_amount(); return intval($amount) == 0 ? 1 : 0; } public function format() { $ret = []; $ret['topcard_id'] = $this->topcard_id(); $ret['card_no'] = $this->card_no(); $ret['card_type'] = $this->card_type(); $ret['car_desc'] = $this->car_desc(); $ret['total_amount'] = $this->total_amount(); $ret['month_total'] = $this->month_total(); $ret['add_time'] = $this->add_time(); $ret['can_edit'] = $this->can_edit(); return $ret; } private function car_desc() { switch ($this->card_type()) { case PetroChinaCard: return '中石油' ; case SinopecCard: return '中石化' ; case PhoneCard: return '电话卡' ; } return '未知卡类型'; } }