rai_serve_bill.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package rai_serve
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // 权益服务明细表
  7. type CygxRaiServeBill struct {
  8. BillId int `orm:"column(bill_id);pk" description:"服务明细主键ID"`
  9. Content string `comment:"服务内容说明"`
  10. ServeTypeId int `comment:"服务类型ID"`
  11. ServeTypeName string `comment:"服务类型"`
  12. UserId int `comment:"用户ID"`
  13. Mobile string `comment:"手机号"`
  14. Email string `comment:"邮箱"`
  15. CompanyId int `comment:"公司ID"`
  16. CompanyName string `comment:"公司名称"`
  17. RealName string `comment:"用户实际名称"`
  18. RegisterPlatform int `comment:"来源 1小程序,2:网页"`
  19. ServeCount float64 `comment:"服务量小计"`
  20. IsKp int `comment:"是否是KP,1:是、0:否"`
  21. SourceId int `comment:"来源ID"`
  22. Source string `comment:"来源 "`
  23. WeekStartDate string `comment:"周一开始日期"`
  24. WeekEndDate string `comment:"周日结束日期"`
  25. ChartPermissionId int `description:"行业id"`
  26. ChartPermissionName string `description:"行业名称"`
  27. CreateTime time.Time `comment:"创建时间"`
  28. ViewTime string `comment:"浏览时间"`
  29. }
  30. // Redis对列消息中的结构体
  31. type RaiServeBillRedis struct {
  32. Content string `comment:"服务内容说明"`
  33. UserId int `comment:"用户ID"`
  34. ComapnyId int `comment:"公司ID"`
  35. SourceId int `comment:"来源ID"`
  36. Source string `comment:"来源"`
  37. RegisterPlatform int `comment:"来源 1小程序,2:网页"`
  38. ViewTime time.Time `comment:"浏览时间"`
  39. }
  40. // 添加
  41. func AddCygxRaiServeBill(item *CygxRaiServeBill) (err error) {
  42. o := orm.NewOrm()
  43. _, err = o.Insert(item)
  44. return
  45. }
  46. func GetCygxRaiServeBillCountByUserAndSource(userId, sourceId int, source string) (count int, err error) {
  47. o := orm.NewOrm()
  48. sql := ` SELECT COUNT(1) AS count FROM cygx_rai_serve_bill WHERE user_id = ? AND source_id = 2 AND source = ? `
  49. err = o.Raw(sql, userId, sourceId, source).QueryRow(&count)
  50. return
  51. }
  52. // 列表
  53. func GetCygxRaiServeBillListAll(condition string, pars []interface{}) (items []*CygxRaiServeBill, err error) {
  54. if condition == "" {
  55. return
  56. }
  57. o := orm.NewOrm()
  58. sql := `SELECT * FROM cygx_rai_serve_bill WHERE 1= 1 `
  59. if condition != "" {
  60. sql += condition
  61. }
  62. _, err = o.Raw(sql, pars).QueryRows(&items)
  63. return
  64. }
  65. // AddCygxRaiServeBillMulti 批量添加
  66. func AddCygxRaiServeBillMulti(items []*CygxRaiServeBill) (err error) {
  67. if len(items) == 0 {
  68. return
  69. }
  70. o, err := orm.NewOrm().Begin()
  71. if err != nil {
  72. return
  73. }
  74. defer func() {
  75. if err == nil {
  76. o.Commit()
  77. } else {
  78. o.Rollback()
  79. }
  80. }()
  81. if len(items) > 0 {
  82. //批量添加流水信息
  83. _, err = o.InsertMulti(len(items), items)
  84. }
  85. return
  86. }