contract_service_template.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package fms
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ContractServiceTemplate 合同服务模板表
  7. type ContractServiceTemplate struct {
  8. ServiceTemplateId int `gorm:"primaryKey;column:service_template_id" json:"service_template_id"`
  9. ProductId int `gorm:"column:product_id" json:"product_id" description:"产品id"`
  10. Pid int `gorm:"column:pid" json:"pid" description:"父级id"`
  11. Title string `gorm:"column:title" json:"title" description:"套餐名称"`
  12. Value string `gorm:"column:value" json:"value" description:"对应的数据"`
  13. SelectType string `gorm:"column:select_type" json:"select_type" description:"选择器类型,单选还是多选,radio;单选:checkbox"`
  14. SelectName string `gorm:"column:select_name" json:"select_name" description:"选择器名称"`
  15. TableValue string `gorm:"column:table_value" json:"table_value" description:"表格数据,用于word生成时的json数据"`
  16. Remark string `gorm:"column:remark" json:"remark" description:"表头备注"`
  17. ChartPermissionId int `gorm:"column:chart_permission_id" json:"chart_permission_id" description:"权限id"`
  18. CreateTime time.Time `gorm:"column:create_time" json:"create_time" description:"创建时间"`
  19. ModifyTime time.Time `gorm:"column:modify_time" json:"modify_time" description:"修改时间"`
  20. IsDelete int `gorm:"column:is_delete" json:"-" description:"删除状态: 0-正常; 1-删除"`
  21. }
  22. type ContractServiceTemplateItem struct {
  23. ServiceTemplateId int `json:"service_template_id" description:"套餐模板ID"`
  24. ProductId int `json:"product_id" description:"产品ID"`
  25. Pid int `json:"pid" description:"父级ID"`
  26. ParentTitle string `json:"parent_title" description:"父级套餐名称"`
  27. Title string `json:"title" description:"套餐名称"`
  28. Value string `json:"value" description:"对应的数据"`
  29. SelectType string `json:"select_type" description:"选择器类型:radio-单选; checkbox-多选"`
  30. SelectName string `json:"select_name" description:"选择器名称"`
  31. ChartPermissionId int `json:"chart_permission_id" description:"权限ID"`
  32. }
  33. // ContractServiceListReq CRM系统合同套餐-列表请求体
  34. type ContractServiceListReq struct {
  35. ProductId string `json:"product_id" form:"product_id" description:"产品:空值-全部; 1-FICC; 2-权益"`
  36. }
  37. type ContractServiceTemplateFullName struct {
  38. ContractServiceTemplateItem
  39. ParentTitle string
  40. }
  41. type ContractServiceTemplateFormat struct {
  42. FormatTitle string
  43. ServiceTemplateId int
  44. ServiceTemplatePid int
  45. ServiceProductId int
  46. }
  47. type ContractServiceTemplateFormatList []ContractServiceTemplateFormat
  48. func (c ContractServiceTemplateFormatList) Len() int {
  49. return len(c)
  50. }
  51. func (c ContractServiceTemplateFormatList) Less(i, j int) bool {
  52. return c[i].ServiceTemplateId < c[j].ServiceTemplateId
  53. }
  54. func (c ContractServiceTemplateFormatList) Swap(i, j int) {
  55. c[i], c[j] = c[j], c[i]
  56. }
  57. func GetContractServiceTemplateFullName() (items []*ContractServiceTemplateFullName, err error) {
  58. o := orm.NewOrmUsingDB("fms")
  59. sql := `SELECT t1.*, t2.title as parent_title FROM contract_service_template as t1
  60. left join contract_service_template as t2 on t1.pid = t2.service_template_id
  61. WHERE t1.is_delete = 0 ORDER BY t1.service_template_id ASC `
  62. _,err = o.Raw(sql).QueryRows(&items)
  63. return
  64. }
  65. func GetContractServiceTemplateSecond() (items []*ContractServiceTemplateItem, err error) {
  66. o := orm.NewOrmUsingDB("fms")
  67. sql := `SELECT * FROM contract_service_template
  68. WHERE pid = 0 AND is_delete = 0 ORDER BY service_template_id ASC `
  69. _,err = o.Raw(sql).QueryRows(&items)
  70. return
  71. }
  72. type ContractServiceTemplateMapItems struct {
  73. ContractServiceTemplateItem
  74. Children []*ContractServiceTemplateMapItems `json:"children"`
  75. Detail []*ContractServiceDetail `json:"detail"`
  76. }
  77. // ContractServiceDetail 合同服务内容详情/表单数据
  78. type ContractServiceDetail struct {
  79. Id int `gorm:"primaryKey;column:id" json:"id"`
  80. ContractServiceId int `gorm:"column:contract_service_id" json:"contract_service_id" description:"合同服务id"`
  81. ContractRegisterId int `gorm:"column:contract_register_id" json:"contract_register_id" description:"合同id"`
  82. ServiceTemplateId int `gorm:"column:service_template_id" json:"service_template_id" description:"服务模板id"`
  83. Col1 string `gorm:"column:col_1" json:"col_1" description:"第1列数据"`
  84. Col2 string `gorm:"column:col_2" json:"col_2" description:"第2列数据"`
  85. Col3 string `gorm:"column:col_3" json:"col_3" description:"第3列数据"`
  86. Col4 string `gorm:"column:col_4" json:"col_4" description:"第4列数据"`
  87. Col5 string `gorm:"column:col_5" json:"col_5" description:"第5列数据"`
  88. Col6 string `gorm:"column:col_6" json:"col_6" description:"第6列数据"`
  89. Col7 string `gorm:"column:col_7" json:"col_7" description:"第7列数据"`
  90. CreateTime time.Time `gorm:"column:create_time" json:"create_time" description:"创建时间"`
  91. }
  92. type ContractServiceTemplateList struct {
  93. Title string `json:"title"`
  94. Children []*ContractServiceTemplateMapItems `json:"children"`
  95. }
  96. func GetContractServiceTemplateMapByParentId(parentId int) (items []*ContractServiceTemplateItem, err error) {
  97. o := orm.NewOrmUsingDB("fms")
  98. sql := `SELECT * FROM contract_service_template
  99. WHERE pid = ? AND is_delete = 0 `
  100. _,err = o.Raw(sql, parentId).QueryRows(&items)
  101. return
  102. }