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

105 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
  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. "github.com/ouxuanserver/osmanthuswine/src/core"
  11. )
  12. //霸屏
  13. type BullyScreenCtl struct {
  14. controllers.AuthorCtl
  15. }
  16. //用户霸屏
  17. func (t *BullyScreenCtl) PaScreen() {
  18. activityId := t.MustGetInt64("activity_id")
  19. uid := t.MustGetUID()
  20. content := t.MustGet("content")
  21. second := t.MustGetDouble("second")
  22. style := t.MustGetInt("style")
  23. activity := new(models.Activity)
  24. exist, err := models.GetById(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.GetById(user, uid)
  40. t.CheckErr(err)
  41. t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
  42. //扣除用户的金额
  43. // todo:微信直接付款
  44. // 调用微信统一下单接口
  45. amount := bullyScreenServer.Price * second
  46. var res = make(map[string]interface{}, 0)
  47. res["out_trade_no"] = ""
  48. if activity.RehearsalId == 0 {
  49. res, err = pay_service.UnifiedOrder("欧轩互动-霸屏支付", user.Openid, int64(amount*100), 1, user.Id, activityId)
  50. t.CheckErr(err)
  51. }
  52. history := &models.BullyScreenHistory{
  53. OutTradeNo: res["out_trade_no"].(string),
  54. BullyScreenServerId: bullyScreenServer.Id,
  55. ActivityId: activityId,
  56. UserId: user.Id,
  57. Nickname: user.Nickname,
  58. CustomerId: t.MustGetCustomerId(),
  59. RehearsalId: activity.RehearsalId,
  60. Second: int(second),
  61. Amount: amount,
  62. Style: style,
  63. ReviewTime: 0,
  64. Status: -1,
  65. Content: content,
  66. IsDelete: false,
  67. CreatedAt: time.Now(),
  68. UpdatedAt: time.Now(),
  69. }
  70. if activity.RehearsalId != 0 {
  71. history.Status = 0
  72. }
  73. _, err = core.GetXormAuto().InsertOne(history)
  74. t.CheckErr(err)
  75. t.JSON(res)
  76. }
  77. // 审核列表 [未审核,未通过,已通过]
  78. func (t *BullyScreenCtl) List() {
  79. uid := t.MustGetUID()
  80. activityId := t.MustGetInt64("activity_id")
  81. bss := new(models.BullyScreenServer)
  82. exist, err := bss.GetByActivityId(activityId)
  83. t.CheckErr(err)
  84. t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
  85. list, err := bully_screen_service.GetBullyList(uid, bss.Id)
  86. t.CheckErr(err)
  87. t.JSON(map[string]interface{}{
  88. "total": len(list),
  89. "list": list,
  90. })
  91. }