addBehavior( new SoftDelete([ 'field' => 'deleted', 'value' => 1, ]) ); } public function beforeCreate() { $this->status = self::STATUS_PENDING; $this->sn = date('YmdHis') . rand(1000, 9999); $this->created_at = time(); } public function beforeUpdate() { $this->updated_at = time(); } public function afterFetch() { $this->amount = (float)$this->amount; } public static function channelTypes() { $list = [ self::CHANNEL_ALIPAY => '支付宝', self::CHANNEL_WXPAY => '微信', ]; return $list; } public static function statusTypes() { $list = [ self::STATUS_PENDING => '待支付', self::STATUS_FINISHED => '已完成', self::STATUS_CLOSED => '已关闭', self::STATUS_REFUNDED => '已退款', ]; return $list; } }