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

97 lines
2.7 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
  1. package client
  2. import (
  3. "hudongzhuanjia/controllers"
  4. "hudongzhuanjia/libs/filter"
  5. "hudongzhuanjia/models"
  6. bully_screen_service "hudongzhuanjia/services/bully_reward"
  7. "hudongzhuanjia/services/pay"
  8. "hudongzhuanjia/utils/code"
  9. "time"
  10. )
  11. //霸屏
  12. type BullyScreenCtl struct {
  13. controllers.AuthorCtl
  14. }
  15. //用户霸屏
  16. func (t *BullyScreenCtl) PaScreen() {
  17. activityId := t.MustGetInt64("activity_id")
  18. uid := t.MustGetUID()
  19. content := t.MustGet("content")
  20. second := t.MustGetDouble("second")
  21. style := t.MustGetInt("style")
  22. activity := new(models.Activity)
  23. exist, err := models.Get(activity, activityId)
  24. t.CheckErr(err)
  25. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  26. t.CheckRunning(activity.Status)
  27. //检查内容是否包含敏感
  28. if ok, _ := filter.Validate(content); !ok {
  29. t.ERROR("内容包含敏感字", code.MSG_ERR)
  30. }
  31. //查询该活动的的霸屏服务id
  32. bullyScreenServer := new(models.BullyScreenServer)
  33. exist, err = bullyScreenServer.GetByActivityId(activityId)
  34. t.CheckErr(err)
  35. t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
  36. //查询用户信息
  37. user := new(models.User)
  38. exist, err = models.Get(user, uid)
  39. t.CheckErr(err)
  40. t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
  41. amount := bullyScreenServer.Price * second
  42. var res = make(map[string]interface{}, 0)
  43. res["out_trade_no"] = ""
  44. if activity.RehearsalId == 0 {
  45. res, err = pay_service.UnifiedOrder("欧轩互动-霸屏支付", user.Openid, int64(amount*100), 1, user.Id,
  46. activityId, time.Now().Add(1*time.Hour).Unix())
  47. t.CheckErr(err)
  48. }
  49. history := models.BullyScreenHistory{
  50. OutTradeNo: res["out_trade_no"].(string),
  51. BullyScreenServerId: bullyScreenServer.Id,
  52. ActivityId: activityId,
  53. UserId: user.Id,
  54. Nickname: user.Nickname,
  55. CustomerId: t.MustGetCustomerId(),
  56. RehearsalId: activity.RehearsalId,
  57. Second: int(second),
  58. Amount: amount,
  59. Style: style,
  60. ReviewTime: 0,
  61. Status: -1,
  62. Content: content,
  63. }
  64. if activity.RehearsalId != 0 {
  65. history.Status = 0
  66. }
  67. _, err = models.Add(&history)
  68. t.CheckErr(err)
  69. t.JSON(res)
  70. }
  71. // 审核列表 [未审核,未通过,已通过]
  72. func (t *BullyScreenCtl) List() {
  73. uid := t.MustGetUID()
  74. activityId := t.MustGetInt64("activity_id")
  75. bss := new(models.BullyScreenServer)
  76. exist, err := bss.GetByActivityId(activityId)
  77. t.CheckErr(err)
  78. t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
  79. list, err := bully_screen_service.GetBullyList(uid, bss.Id)
  80. t.CheckErr(err)
  81. t.JSON(map[string]interface{}{
  82. "total": len(list),
  83. "list": list,
  84. })
  85. }