互动
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.

126 lines
3.2 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
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. activityId := t.MustGetInt64("activity_id")
  65. activity := &models.Activity{}
  66. exist, err := models.Get(activity, activityId)
  67. t.CheckErr(err)
  68. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  69. result := make([]*SignResult, 0)
  70. session := core.GetXormAuto().Table(new(models.SignHistory)).Alias("h").
  71. Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0").
  72. Where("h.is_delete=0 and h.activity_id=? and rehearsal_id=? and arch_id=?",
  73. activity.Id, activity.RehearsalId, activity.ArchId)
  74. if t.PageSize > 0 { // 增加分页
  75. session.Limit(t.PageSize, t.Page*t.PageSize)
  76. }
  77. count, err := session.FindAndCount(&result)
  78. t.CheckErr(err)
  79. t.JSON(map[string]interface{}{
  80. "list": result,
  81. "sign_up_total": count,
  82. })
  83. }
  84. // 实名签到信息
  85. func (t *SignCtl) RealSignInfo() {
  86. aid := t.MustGetInt64("activity_id")
  87. activity := &models.Activity{}
  88. exist, err := models.Get(activity, aid)
  89. t.CheckErr(err)
  90. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  91. results, err := models.GetApplyRealSigns(activity.Id, activity.ArchId, activity.RehearsalId)
  92. t.CheckErr(err)
  93. t.JSON(map[string]interface{}{
  94. "result": results,
  95. "count": len(results),
  96. })
  97. }
  98. func (t *SignCtl) RealSignVerify() {
  99. ids := strings.Split(t.MustGet("real_sign_history_ids"), ",")
  100. history := new(models.SignHistory)
  101. history.Status = 2
  102. err := history.UpdateByIds(ids, "status")
  103. t.CheckErr(err)
  104. t.SUCCESS("审核成功")
  105. }