def check_in(self): self.last_check_in_time = self.last_check_in_time or 0 old_time = self.last_check_in_time last_midnight = get_today_start_timestamp() # 今日未签到 if self.last_check_in_time < last_midnight: self.last_check_in_time = int(time.time()) # 三天内有签到,连击 if old_time > last_midnight - config.USER_CHECKIN_COUNTER_INTERVAL: self.check_in_his += 1 else: self.check_in_his = 1 self.save() # 签到加分 credit = self.credit exp = self.exp self.credit += 5 self.exp += 5 self.save() ManageLog.add_by_credit_changed_sys(self.id.tobytes(), credit, self.credit, note='每日签到') ManageLog.add_by_exp_changed_sys(self.id.tobytes(), exp, self.exp, note='每日签到') return { 'credit': 5, 'exp': 5, 'time': self.last_check_in_time, 'check_in_his': self.check_in_his }
def daily_access_reward(self): self.access_time = self.access_time or 0 old_time = self.access_time self.update_access_time() if old_time < get_today_start_timestamp(): exp = self.exp self.exp += 5 self.save() ManageLog.add_by_exp_changed_sys(self.id.tobytes(), exp, self.exp, note='每日登录') return {'exp': 5}