where(['user_id' => $userId]) ->count(); return $result; } public function getRenewProductCount($userId) { $allData = $this ->field(['userProduct_dayNumber', 'userProduct_buyTime']) ->where(['user_id' => $userId]) ->select(); $count = 0; foreach ($allData as $key => $value) { $numberDay = $value->userProduct_dayNumber - 15; $remindDate = date("Y-m-d",strtotime($numberDay . " day")); if ($value->userProduct_buyTime >= $remindDate) { $count++; } } return $count; } }