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

124 lines
3.0 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
4 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 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. )
  10. //签到
  11. type SignCtl struct {
  12. controllers.AuthorCtl
  13. }
  14. //获取二维码
  15. func (t *SignCtl) Qrcode() {
  16. activityId := t.MustGetInt("activity_id")
  17. uid := t.GetAccountId()
  18. signUpId := t.MustGetInt("sign_rule_id")
  19. area := new(models.AreaStore)
  20. exist, err := area.GetByCustomerId(uid, activityId)
  21. t.CheckErr(err)
  22. t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常")
  23. //将服务器得地址和activity_id,动态生成二维码
  24. qrcode, err := utils.GenH5Qrcode(define.H5SignIn, map[string]interface{}{
  25. "activity_id": activityId,
  26. "area_id": area.Id,
  27. "customer_id": uid,
  28. "sign_rule_id": signUpId,
  29. })
  30. t.CheckErr(err)
  31. t.JSON(map[string]interface{}{
  32. "qrcode": qrcode,
  33. "logo": "",
  34. })
  35. }
  36. //获取签到模式
  37. func (t *SignCtl) Mode() {
  38. activityId := t.MustGetInt("activity_id")
  39. //通过activity_id查询ox_sign_rule的id
  40. signUp := new(models.SignUp)
  41. exist, err := signUp.GetByActivityId(activityId)
  42. t.CheckErr(err)
  43. t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到规则不存在")
  44. t.JSON(signUp.MaxModel)
  45. }
  46. func (t *SignCtl) List() {
  47. activityId := t.MustGetInt("activity_id")
  48. sus, err := models.ListSignUp(activityId)
  49. t.CheckErr(err)
  50. t.JSON(map[string]interface{}{
  51. "total": len(sus),
  52. "list": sus,
  53. })
  54. }
  55. type SignResult struct {
  56. models.SignHistory `xorm:"extends"`
  57. User *models.User `json:"user" xorm:"extends"`
  58. }
  59. //处理签到信息
  60. func (t *SignCtl) SignInfo() {
  61. activityId := t.MustGetInt("activity_id")
  62. activity := &models.Activity{}
  63. exist, err := models.Get(activity, activityId)
  64. t.CheckErr(err)
  65. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  66. count, result, err := models.GetSignHistories(activity.Id, activity.RehearsalId, activity.ArchId, t.Page, t.PageSize)
  67. t.CheckErr(err)
  68. t.JSON(map[string]interface{}{
  69. "list": result,
  70. "sign_up_total": count,
  71. })
  72. }
  73. // 实名签到信息
  74. func (t *SignCtl) RealSignInfo() {
  75. aid := t.MustGetInt("activity_id")
  76. activity := &models.Activity{}
  77. exist, err := models.Get(activity, aid)
  78. t.CheckErr(err)
  79. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  80. results, err := models.GetApplyRealSigns(activity.Id, activity.ArchId, activity.RehearsalId)
  81. t.CheckErr(err)
  82. total, err := new(models.RealSignList).Count(activity.Id)
  83. t.CheckErr(err)
  84. signTotal, err := new(models.SignHistory).Count(activity.Id, activity.ArchId, activity.RehearsalId, 2)
  85. t.CheckErr(err)
  86. t.JSON(map[string]interface{}{
  87. "result": results,
  88. "count": len(results),
  89. "total": total,
  90. "sign_total": signTotal,
  91. "no_sign_total": total - signTotal,
  92. })
  93. }
  94. // 审核实名签到
  95. func (t *SignCtl) RealSignVerify() {
  96. ids := strings.Split(t.MustGet("real_sign_history_ids"), ",")
  97. history := new(models.SignHistory)
  98. history.Status = 2
  99. err := history.UpdateByIds(ids, "status")
  100. t.CheckErr(err)
  101. t.SUCCESS("审核成功")
  102. }