会员签到,增加金币
()
| 422 | |
| 423 | //会员签到,增加金币 |
| 424 | func (this *UserController) Sign() { |
| 425 | |
| 426 | if this.IsLogin == 0 { |
| 427 | this.ResponseJson(false, "签到失败,请先登录") |
| 428 | } |
| 429 | |
| 430 | var data = models.Sign{ |
| 431 | Uid: this.IsLogin, |
| 432 | Date: time.Now().Format("20060102"), |
| 433 | } |
| 434 | _, err := orm.NewOrm().Insert(&data) |
| 435 | if err != nil { |
| 436 | this.ResponseJson(false, "签到失败,您今天已签到") |
| 437 | } |
| 438 | |
| 439 | if err = models.Regulate(models.GetTableUserInfo(), "Coin", this.Sys.Sign, fmt.Sprintf("Id=%v", this.IsLogin)); err == nil { |
| 440 | log := models.CoinLog{ |
| 441 | Uid: this.IsLogin, |
| 442 | Coin: this.Sys.Sign, |
| 443 | Log: fmt.Sprintf("签到成功,获得 %v 个金币", this.Sys.Sign), |
| 444 | } |
| 445 | models.NewCoinLog().LogRecord(log) |
| 446 | } |
| 447 | this.ResponseJson(true, fmt.Sprintf("恭喜您,今日签到成功,领取了 %v 个金币", this.Sys.Sign)) |
| 448 | } |
| 449 | |
| 450 | // 检测用户是否已登录 |
| 451 | func (this *UserController) CheckLogin() { |
nothing calls this directly
no test coverage detected