company_operation_record.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package company
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CompanyOperationRecord struct {
  7. Id int `orm:"column(id);pk"`
  8. CompanyId int `description:"客户id"`
  9. CompanyName string `description:"客户名称"`
  10. SellerId int `description:"销售员id"`
  11. SysUserId int `description:"操作者id"`
  12. SysRealName string `description:"操作者名称"`
  13. Remark string `description:"备注"`
  14. Operation string `description:"操作"`
  15. CreateTime time.Time `description:"操作时间"`
  16. ProductId int `description:"产品id"`
  17. ProductName string `description:"产品名称"`
  18. ApproveUserId int `description:"审批人id"`
  19. ApproveRealName string `description:"审批人姓名"`
  20. ApproveContent string `description:"审批人内容"`
  21. ApproveContentExtra string `description:"审批人内容补充"`
  22. ApproveRemark string `description:"审批人内容"`
  23. Status string `description:"状态"`
  24. }
  25. type CompanyOperationRecordList struct {
  26. Id int `orm:"column(id);pk"`
  27. CompanyId int64 `description:"客户id"`
  28. CompanyName string `description:"客户名称"`
  29. SysUserId int `description:"操作者id"`
  30. SysRealName string `description:"操作者名称"`
  31. Remark string `description:"备注"`
  32. Operation string `description:"操作"`
  33. ApproveContent string `description:"详情"`
  34. ApproveContentExtra string `description:"详情补充"`
  35. CreateTime string `description:"操作时间"`
  36. ProductId int
  37. ProductName string
  38. }
  39. //新增客户操作记录
  40. func AddCompanyOperationRecord(item *CompanyOperationRecord) (lastId int64, err error) {
  41. o := orm.NewOrm()
  42. lastId, err = o.Insert(item)
  43. return
  44. }
  45. func GetCompanyOperationRecordList(companyId int) (items []*CompanyOperationRecordList, err error) {
  46. o := orm.NewOrm()
  47. sql := `SELECT * FROM company_operation_record WHERE company_id=? ORDER BY create_time DESC `
  48. _, err = o.Raw(sql, companyId).QueryRows(&items)
  49. return
  50. }
  51. type CompanyOperationRecordListResp struct {
  52. List []*CompanyOperationRecordList
  53. ShowButton bool
  54. }
  55. //获取客户正式转试用的次数
  56. func GetCompanyProductOperationRecordCount(companyId, productId int) (total int64, err error) {
  57. o := orm.NewOrm()
  58. sql := `SELECT count(1) ct FROM company_operation_record
  59. WHERE company_id=? AND product_id=? and operation="try_out" `
  60. err = o.Raw(sql, companyId, productId).QueryRow(&total)
  61. return
  62. }
  63. func UpdateCompanyOperationRecord(item *CompanyOperationRecord) (lastId int64, err error) {
  64. o := orm.NewOrm()
  65. lastId, err = o.Update(item, "approve_content", "approve_content_extra")
  66. return
  67. }
  68. func ReadCompanyOperationRecord(companyId int) (items []*CompanyOperationRecord, err error) {
  69. o := orm.NewOrm()
  70. sql := `SELECT * FROM company_operation_record WHERE company_id=? AND operation='try_out' ORDER BY create_time DESC `
  71. _, err = o.Raw(sql, companyId).QueryRows(&items)
  72. return
  73. }
  74. // GetTryOutCompanyOperationRecordList 获取客户正式转试用变更的操作记录
  75. func GetTryOutCompanyOperationRecordList() (list []*CompanyOperationRecord, err error) {
  76. o := orm.NewOrm()
  77. sql := ` select * from company_operation_record where operation="try_out";`
  78. _, err = o.Raw(sql).QueryRows(&list)
  79. return
  80. }