where ('id',$params['lottery_money_id'])->first (); if(empty($lottery)){ return -51004; } $lottery = $lottery->toArray(); $sdefaultDate = date("Y-m-d"); //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期 $first=1; //获取当前周的第几天 周日是 0 周一到周六是 1 - 6 $w=date('w',strtotime($sdefaultDate)); //获取本周开始日期,如果$w是0,则表示周日,减去 6 天 $week_start=date('Y-m-d',strtotime("$sdefaultDate -".($w ? $w - $first : 6).' days')); //本周结束日期 $week_end=date('Y-m-d',strtotime("$week_start +6 days")); $info = lm("Lottery_money_log","Api")->where('lottery_money_type',$lottery['type']); if(empty($params['account_identity'])){ return -51005; }else{ $info = $info->where('account_identity',$params['account_identity']); } $info = $info->where('create_time','>=',$week_start.' 00:00:00')->where('create_time','<=',$week_end.' 23:59:59')->orderBy('create_time','asc')->get(); $info = $info->toArray(); foreach ($info as $key => $value) { $info[$key]['week'] = date("w",strtotime($value['create_time'])); $info[$key]['time'] = substr($value['create_time'],0,10); } $arr = array(); $arr['list'] = $info; if(count($info) >= 7 ){ $num = 7; }else{ $num = count($info); } $arr['num'] = $num; return $arr; } //今日签到 function todaySignin($params){ if(empty($params['account_identity'])){ return -51005; } $info = lm("Lottery_money_log","Api")->where('account_identity',$params['account_identity'])->where('lottery_money_type','sign')->where('create_time','>=',date('Y-m-d 00:00:00',time()))->where('create_time','<=',date('Y-m-d 23:59:59',time()))->first(); if(empty($info)){ $arr['money'] = 0; $arr['active'] = 0; }else{ $info = $info->toArray(); $arr['money'] = $info['money']; $arr['active'] = 1; $arr['create_time'] = $info['create_time']; } return $arr; } }