activity_vivo_points_set.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxActivityVivoPointsSet struct {
  7. PointSetId int `orm:"column(point_set_id);pk";comment:"主键id"`
  8. ActivityId int `comment:"活动ID"`
  9. PointsObject string `comment:"扣点设置方式 1:同报名参会时的扣点数、2:输入其余点数"`
  10. PointsNum string `comment:"扣点数量"`
  11. GoodsMoney string `comment:"商品总价"`
  12. Source string `comment:"来源 activityvideo 活动视频、activityvoice 活动音频"`
  13. CreateTime time.Time `comment:"创建时间"`
  14. ModifyTime time.Time `comment:"更新时间"`
  15. }
  16. type CygxActivityVivoPointsResp struct {
  17. IsPay int `comment:"是否付费查看 ,1是。0否,默认否"`
  18. PointSetId int `orm:"column(point_set_id);pk";comment:"主键id"`
  19. ActivityId int `comment:"活动ID"`
  20. PointsObject string `comment:"扣点设置方式 1:同报名参会时的扣点数、2:输入其余点数"`
  21. PointsNum string `comment:"扣点数量"`
  22. GoodsMoney string `comment:"商品总价"`
  23. Source string `comment:"来源 activityvideo 活动视频、activityvoice 活动音频"`
  24. }
  25. type CygxActivityVivoPointsSetReq struct {
  26. IsPay int `comment:"是否付费查看 ,1是。0否,默认否"`
  27. PointsObject string `comment:"扣点设置方式 1:同报名参会时的扣点数、2:输入其余点数"`
  28. PointsNum string `comment:"扣点数量"`
  29. GoodsMoney string `comment:"商品总价"`
  30. }
  31. // 根据活动ID判断音视频是否设置了扣点
  32. func GetCygxActivityVivoPointsSetCountByActivityId(activityId int) (count int, err error) {
  33. o := orm.NewOrmUsingDB("hz_cygx")
  34. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity_vivo_points_set WHERE activity_id =? `
  35. err = o.Raw(sqlCount, activityId).QueryRow(&count)
  36. return
  37. }
  38. func GetCygxActivityVivoPointsSetByActivityId(activityId int) (item *CygxActivityVivoPointsResp, err error) {
  39. o := orm.NewOrmUsingDB("hz_cygx")
  40. sql := `SELECT * FROM cygx_activity_vivo_points_set WHERE activity_id = ? `
  41. err = o.Raw(sql, activityId).QueryRow(&item)
  42. return
  43. }
  44. // 添加
  45. func AddCygxActivityVivoPointsSet(item *CygxActivityVivoPointsSet) (err error) {
  46. o := orm.NewOrmUsingDB("hz_cygx")
  47. _, err = o.Insert(item)
  48. return
  49. }
  50. // 编辑
  51. func EditCygxActivityVivoPointsSet(item *CygxActivityVivoPointsSet) (err error) {
  52. o := orm.NewOrmUsingDB("hz_cygx")
  53. updateParams := make(map[string]interface{})
  54. updateParams["PointsObject"] = item.PointsObject
  55. updateParams["PointsNum"] = item.PointsNum
  56. updateParams["GoodsMoney"] = item.GoodsMoney
  57. updateParams["Source"] = item.Source
  58. updateParams["ModifyTime"] = time.Now()
  59. ptrStructOrTableName := "cygx_activity_vivo_points_set"
  60. whereParam := map[string]interface{}{"activity_id": item.ActivityId}
  61. qs := o.QueryTable(ptrStructOrTableName)
  62. for expr, exprV := range whereParam {
  63. qs = qs.Filter(expr, exprV)
  64. }
  65. _, err = qs.Update(updateParams)
  66. return
  67. }