0 ? date('Y-m-d H:i:s', $data['expire_time']) : '长期有效'; } /** * 关联供应商表 */ public function supplier() { return $this->belongsTo('app\common\model\supplier\Supplier', 'shop_supplier_id', 'shop_supplier_id'); } /** * 关联年卡计划表 */ public function plan() { return $this->belongsTo('app\common\model\supplier\member\Plan', 'plan_id', 'plan_id'); } /** * 判断是否过期 */ public function isExpired() { return $this->expire_time < time(); } /** * 获取供应商当前有效的年卡 */ public static function getCurrentMember($supplierId, $appId) { return self::where([ 'shop_supplier_id' => $supplierId, 'app_id' => $appId, 'is_expire' => 0 ])->where('expire_time', '>', time())->find(); } /** * 获取详情 */ public static function detail($memberId) { return (new static())->where('member_id', '=', $memberId)->where('is_expire', '=', 0)->find(); } }