首页 > 其他 > 详细

签到功能表的基本逻辑

时间:2022-05-27 21:45:54      阅读:16      评论:0      收藏:0      [点我收藏+]
 1          //今天0点时间
 2         $time = strtotime(date(‘y-m-d‘));
 3         //昨天0点时间
 4         $prevtime = strtotime(date(‘y-m-d‘)) - 86400;
 5         //明天0点时间
 6         $nexttime = strtotime(date(‘y-m-d‘)) + 86400;
 7         $user_id = 4;
 8         $getSian = \app\sign\model\Sign::getSign($user_id);
 9         if (empty($getSian)) {
10             $create = [
11                 ‘user_id‘ => $user_id,
12                 ‘sign_time‘ => strtotime(date(‘y-m-d h:m:s‘)),
13                 ‘integral‘ => 200,
14                 ‘day‘ => 1
15             ];
16             $addSign = \app\sign\model\Sign::addSign($create);
17             echo ‘第一次签到‘;
18             die();
19            }
20         //今天是否签到
21         if ($getSian[‘sign_time‘] > $time && $getSian[‘sign_time‘] < $nexttime) {
22             echo ‘今天已签到‘;
23             die();
24         }
25         //断签
26         if ($getSian[‘sign_time‘] < $prevtime) {
27             $update = [
28                 ‘id‘ => $getSian[‘id‘],
29                 ‘user_id‘ => $getSian[‘user_id‘],
30                 ‘sign_time‘ => strtotime(date(‘y-m-d h:m:s‘)),
31                 ‘integral‘ => 200,
32                 ‘day‘ => 1
33             ];
34             $addSign = \app\sign\model\Sign::updateSign($update);
35             echo ‘断签重新签到‘;
36             die();
37         }
38         //签到
39         if ($getSian[‘sign_time‘] > $prevtime && $getSian[‘sign_time‘] < $time) {
40             $update = [
41                 ‘id‘ => $getSian[‘id‘],
42                 ‘user_id‘ => $getSian[‘user_id‘],
43                 ‘sign_time‘ => strtotime(date(‘y-m-d h:m:s‘)),
44                 ‘integral‘ => $getSian[‘integral‘] + 50,
45                 ‘day‘ => $getSian[‘day‘] + 1
46             ];
47             $addSign = \app\sign\model\Sign::updateSign($update);
48             echo ‘连续签到‘;
49             die();
50         }

 

签到功能表的基本逻辑

原文:https://www.cnblogs.com/hao1997918/p/15351041.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!