rai_company_user_bill.go 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package rai_serve
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // 权益服务明细表
  7. type CygxRaiCompanyUserBill 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. MonthStartDate string `comment:"月份开始日期"`
  26. MonthEndDate string `comment:"月份结束日期"`
  27. ChartPermissionId int `description:"行业id"`
  28. ChartPermissionName string `description:"行业名称"`
  29. CreateTime time.Time `comment:"创建时间"`
  30. ViewTime string `comment:"浏览时间"`
  31. ActivityId int `description:"活动ID"`
  32. RecordId int `description:"日志ID"`
  33. }
  34. // 列表
  35. func GetCygxRaiCompanyUserBillListAll(condition string, pars []interface{}) (items []*CygxRaiCompanyUserBill, err error) {
  36. if condition == "" {
  37. return
  38. }
  39. o := orm.NewOrm()
  40. sql := `SELECT * FROM cygx_rai_company_user_bill WHERE 1= 1 `
  41. if condition != "" {
  42. sql += condition
  43. }
  44. _, err = o.Raw(sql, pars).QueryRows(&items)
  45. return
  46. }
  47. // AddCygxRaiCompanyUserBilllMulti 批量添加
  48. func AddCygxRaiCompanyUserBilllMulti(items []*CygxRaiCompanyUserBill) (err error) {
  49. if len(items) == 0 {
  50. return
  51. }
  52. o, err := orm.NewOrm().Begin()
  53. if err != nil {
  54. return
  55. }
  56. defer func() {
  57. if err == nil {
  58. o.Commit()
  59. } else {
  60. o.Rollback()
  61. }
  62. }()
  63. if len(items) > 0 {
  64. //批量添加流水信息
  65. _, err = o.InsertMulti(len(items), items)
  66. }
  67. return
  68. }
  69. // UpdateActivitySignupDetailMulti 批量修改
  70. func UpdateCygxRaiCompanyUserBillMulti(items []*CygxRaiCompanyUserBill) (err error) {
  71. o := orm.NewOrm()
  72. p, err := o.Raw(` UPDATE cygx_rai_company_user_bill SET
  73. month_start_date = ?,
  74. month_end_date = ?
  75. WHERE bill_id = ? `).Prepare()
  76. if err != nil {
  77. return
  78. }
  79. defer func() {
  80. _ = p.Close() // 别忘记关闭 statement
  81. }()
  82. for _, v := range items {
  83. _, err = p.Exec(
  84. v.MonthStartDate,
  85. v.MonthEndDate,
  86. v.BillId)
  87. if err != nil {
  88. return
  89. }
  90. }
  91. return
  92. }