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

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