public function getSigns() { $datas = UserSignModel::orderBy('id', 'desc')->paginate($this->limit); $datas->limit = $this->limit; return $datas; }
/** * 会员签到情况 */ public function signs() { $date = date('Ym', time()); //当前月份 $fromdate = $date . '01000000'; //当前月初 //推算月份 $yuefen = ltrim(date('m', time()), '0'); if ($yuefen == 2) { $month = date('Y', time()) % 4 == 0 ? 29 : 28; } elseif (in_array($yuefen, [1, 3, 5, 7, 8, 10, 12])) { $month = 31; } elseif (in_array($yuefen, [4, 6, 9, 11])) { $month = 30; } $todate = isset($month) ? $date . $month . '240000' : $date . '00240000'; $signs = UserSignModel::where('uid', $this->userid)->get(); //签到总数 $userParam = UserParamsModel::where('uid', $this->userid)->first(); //当月签到情况 $datas = UserSignModel::where('uid', $this->userid)->where('created_at', '>', strtotime($fromdate))->where('created_at', '<', strtotime($todate))->orderBy('id', 'desc')->get(); //当天签到情况 $fromday = date('Ymd', time()) . '000000'; //当天凌晨0点 $today = date('Ymd', time()) . '240000'; //当天夜里24点 $day = UserSignModel::where('uid', $this->userid)->where('created_at', '>', strtotime($fromday))->where('created_at', '<', strtotime($today))->first(); $datas->signsCount = count($signs); $datas->rewardCount = $userParam->sign; $datas->day = $date ? 1 : 0; return $datas; }
/** * 查询当前用户当天签到情况 */ public function getDaySign() { $userSign = UserSignModel::where('uid', $this->userid)->where('created_at', '>', strtotime($this->fromtime))->where('created_at', '<', strtotime($this->totime))->first(); return $userSign ? $userSign : ''; }