getMemberId()); if(!static::$current){ throw new MemberNotLoginException('请登录', $_SERVER['QUERY_STRING']); } } return static::$current; } /** * 会员-会员优惠券1:多关系 * @param null $backType * @return mixed */ public function hasManyMemberCoupon($backType = null) { return $this->hasMany(MemberCoupon::class, 'uid', 'uid') ->where('used', 0)->with(['belongsToCoupon'=> function ($query) use ($backType) { if (isset($backType)) { $query->where('coupon_method', $backType); } }]); } public function defaultAddress() { return $this->hasOne(app(MemberAddressRepository::class)->model(), 'uid', 'uid')->where('isdefault', 1); } public function orderGoods() { return $this->hasMany(OrderGoods::class, 'uid', 'uid'); } public function yzMember() { return $this->hasOne(self::getNearestModel('MemberShopInfo'), 'member_id', 'uid'); } public function memberCarts() { return $this->hasMany(app('OrderManager')->make('MemberCart'), 'member_id', 'uid')->with('member'); } }