互动
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
  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. res, err := pay_service.UnifiedOrder("欧轩互动-霸屏支付", user.Openid, int64(amount*100), 1, user.Id, activityId)
  47. t.CheckErr(err)
  48. history := &models.BullyScreenHistory{
  49. OutTradeNo: res["out_trade_no"].(string),
  50. BullyScreenServerId: bullyScreenServer.Id,
  51. ActivityId: activityId,
  52. UserId: user.Id,
  53. Nickname: user.Nickname,
  54. CustomerId: t.MustGetCustomerId(),
  55. RehearsalId: activity.RehearsalId,
  56. Second: int(second),
  57. Amount: amount,
  58. Style: style,
  59. ReviewTime: 0,
  60. Status: -1,
  61. Content: content,
  62. IsDelete: false,
  63. CreatedAt: time.Now(),
  64. UpdatedAt: time.Now(),
  65. }
  66. _, err = core.GetXormAuto().InsertOne(history)
  67. t.CheckErr(err)
  68. t.JSON(res)
  69. }
  70. // 审核列表 [未审核,未通过,已通过]
  71. func (t *BullyScreenCtl) List() {
  72. uid := t.MustGetUID()
  73. activityId := t.MustGetInt64("activity_id")
  74. bss := new(models.BullyScreenServer)
  75. exist, err := bss.GetByActivityId(activityId)
  76. t.CheckErr(err)
  77. t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
  78. list, err := bully_screen_service.GetBullyList(uid, bss.Id)
  79. t.CheckErr(err)
  80. t.JSON(map[string]interface{}{
  81. "total": len(list),
  82. "list": list,
  83. })
  84. }