互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
2.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package pc
  2. import (
  3. "hudongzhuanjia/controllers"
  4. "hudongzhuanjia/models"
  5. "hudongzhuanjia/utils"
  6. "hudongzhuanjia/utils/code"
  7. "hudongzhuanjia/utils/define"
  8. "strings"
  9. "github.com/ouxuanserver/osmanthuswine/src/core"
  10. )
  11. //签到
  12. type SignCtl struct {
  13. controllers.AuthorCtl
  14. }
  15. //获取二维码
  16. func (t *SignCtl) Qrcode() {
  17. activityId := t.MustGetInt64("activity_id")
  18. uid := t.MustGetUID()
  19. signUpId := t.MustGetInt64("sign_rule_id")
  20. area := new(models.AreaStore)
  21. exist, err := area.GetByCustomerId(uid, activityId)
  22. t.CheckErr(err)
  23. t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常")
  24. //将服务器得地址和activity_id,动态生成二维码
  25. qrcode, err := utils.GenH5Qrcode(define.H5SignIn, map[string]interface{}{
  26. "activity_id": activityId,
  27. "area_id": area.Id,
  28. "customer_id": uid,
  29. "sign_rule_id": signUpId,
  30. })
  31. t.CheckErr(err)
  32. t.JSON(map[string]interface{}{
  33. "qrcode": qrcode,
  34. "logo": "",
  35. })
  36. }
  37. //获取签到模式
  38. func (t *SignCtl) Mode() {
  39. activityId := t.MustGetInt64("activity_id")
  40. //通过activity_id查询ox_sign_rule的id
  41. signUp := new(models.SignUp)
  42. exist, err := signUp.GetByActivityId(activityId)
  43. t.CheckErr(err)
  44. t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到规则不存在")
  45. t.JSON(signUp.MaxModel)
  46. }
  47. func (t *SignCtl) List() {
  48. activityId := t.MustGetInt64("activity_id")
  49. signUps := make([]*models.SignUp, 0)
  50. err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).
  51. Asc("created_at").Find(&signUps)
  52. t.CheckErr(err)
  53. t.JSON(map[string]interface{}{
  54. "total": len(signUps),
  55. "list": signUps,
  56. })
  57. }
  58. type SignResult struct {
  59. models.SignHistory `xorm:"extends"`
  60. User *models.User `json:"user" xorm:"extends"`
  61. }
  62. //处理签到信息
  63. func (t *SignCtl) SignInfo() {
  64. aid := t.MustGetInt64("activity_id")
  65. //activityId := t.MustGetInt64("activity_id")
  66. rehearsalId := t.MustGetInt64("rehearsal_id")
  67. result := make([]*SignResult, 0)
  68. session := core.GetXormAuto().Table(new(models.SignHistory)).Alias("h").
  69. Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0").
  70. Where("h.is_delete=0 and h.activity_id=? and rehearsal_id=?", aid, rehearsalId)
  71. if t.PageSize > 0 { // 增加分页
  72. session.Limit(t.PageSize, t.Page*t.PageSize)
  73. }
  74. count, err := session.FindAndCount(&result)
  75. t.CheckErr(err)
  76. t.JSON(map[string]interface{}{
  77. "list": result,
  78. "sign_up_total": count,
  79. })
  80. }
  81. // 实名签到信息
  82. func (t *SignCtl) RealSignInfo() {
  83. aid := t.MustGetInt64("activity_id")
  84. rid := t.MustGetInt64("rehearsal_id")
  85. results, err := models.GetApplyRealSigns(aid, rid)
  86. t.CheckErr(err)
  87. t.JSON(map[string]interface{}{
  88. "result": results,
  89. "count": len(results),
  90. })
  91. }
  92. func (t *SignCtl) RealSignVerify() {
  93. ids := strings.Split(t.MustGet("real_sign_history_ids"), ",")
  94. history := new(models.SignHistory)
  95. history.Status = 2
  96. err := history.UpdateById(ids, "status")
  97. t.CheckErr(err)
  98. t.SUCCESS("审核成功")
  99. }