company_contract.go 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package company
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CompanyContractPermission struct {
  7. Id int `orm:"column(id);pk" description:"客户合同id"`
  8. CompanyId int `description:"客户id"`
  9. CompanyContractId int `description:"合同id"`
  10. ChartPermissionId int `description:"权限id"`
  11. IsUpgrade int `description:"是否升级,1是,0否"`
  12. ExpensiveYx int `description:"权益研选: 0-3w; 1-5w"`
  13. StartDate string `description:"开始日期"`
  14. EndDate string `description:"结束日期"`
  15. CreateTime time.Time `description:"创建时间"`
  16. ModifyTime time.Time `description:"修改时间"`
  17. Points float64 `description:"研选扣点包点数"`
  18. }
  19. type CompanyContract struct {
  20. CompanyContractId int `orm:"column(company_contract_id);pk" description:"客户合同id"`
  21. ContractType string `description:"合同类型:枚举值:'新签合同','续约合同','补充协议'"`
  22. ProductId int `description:"产品id"`
  23. ProductName string `description:"产品名称"`
  24. CompanyId int `description:"客户id"`
  25. CompanyProductId int `description:"客户产品id"`
  26. ContractCode string `description:"合同编码"`
  27. StartDate string `description:"合同开始时间"`
  28. EndDate string `description:"合同结束时间"`
  29. Money float64 `description:"合同金额"`
  30. PayMethod string `description:"支付方式"`
  31. PayChannel string `description:"支付渠道"`
  32. ImgUrl string `description:"合同图片,多个用#隔开"`
  33. CreateTime time.Time `description:"合同创建时间"`
  34. ModifyTime time.Time `description:"合同修改时间"`
  35. Status int `description:"状态"`
  36. Source string `description:"合同来源,枚举值:上传附件、系统合同,默认上传附件"`
  37. PackageType int `description:"套餐类型,0:无,1:大套餐,2:小套餐"`
  38. RaiPackageType int `description:"权益套餐类型: 0-无; 1-70w大套餐; 2-45w大套餐"`
  39. RaiContractType string `description:"权益合同类型:枚举值:'新签合同','续约合同','补充协议'"`
  40. }
  41. func GetCompanyContractPermissionCheck(companyContractId, permissionId int) (count int, err error) {
  42. o := orm.NewOrmUsingDB("weekly_report")
  43. sql := `SELECT COUNT(1) AS count FROM company_contract_permission AS a WHERE a.company_contract_id=? AND a.chart_permission_id=? `
  44. err = o.Raw(sql, companyContractId, permissionId).QueryRow(&count)
  45. return
  46. }
  47. // 通过查询条件获取详情
  48. func GetCompanyContractPermissionDetail(condition string, pars []interface{}) (item *CompanyContractPermission, err error) {
  49. if condition == "" {
  50. return
  51. }
  52. o := orm.NewOrmUsingDB("weekly_report")
  53. sql := `SELECT * FROM company_contract_permission WHERE 1 = 1 ` + condition
  54. err = o.Raw(sql, pars).QueryRow(&item)
  55. return
  56. }
  57. // 获取合同对应的权限列表
  58. func GetCompanyContractPermissionList(condition string, pars []interface{}) (items []*CompanyContractPermission, err error) {
  59. o := orm.NewOrmUsingDB("weekly_report")
  60. sql := `SELECT * FROM company_contract_permission WHERE 1 = 1 `
  61. if condition != "" {
  62. sql += condition
  63. }
  64. _, err = o.Raw(sql, pars).QueryRows(&items)
  65. return
  66. }
  67. // 通过查询条件获取详情
  68. func GetCompanyContractList(condition string, pars []interface{}) (items []*CompanyContract, err error) {
  69. if condition == "" {
  70. return
  71. }
  72. o := orm.NewOrmUsingDB("weekly_report")
  73. sql := `SELECT * FROM company_contract WHERE 1 = 1 ` + condition
  74. _, err = o.Raw(sql, pars).QueryRows(&items)
  75. return
  76. }
  77. // 通过查询条件获取最后一个合同
  78. func GetCompanyContractLastList(condition string, pars []interface{}) (items []*CompanyContract, err error) {
  79. if condition == "" {
  80. return
  81. }
  82. o := orm.NewOrmUsingDB("weekly_report")
  83. sql := `SELECT MAX( company_contract_id ) as company_contract_id FROM company_contract WHERE 1 = 1 ` + condition
  84. _, err = o.Raw(sql, pars).QueryRows(&items)
  85. return
  86. }