contract_service.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package contract
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. //合同的服务内容
  7. type ContractService struct {
  8. ContractServiceId int `orm:"column(contract_service_id);pk"`
  9. ContractId int `description:"合同id"`
  10. ProductId int `description:"产品id,1:ficc;2:权益"`
  11. ServiceTemplateId int `description:"合同服务模板id"`
  12. Title string `description:"套餐名称"`
  13. Value string `description:"套餐的值"`
  14. TableValue string `description:"表格数据,用于word生成时的json数据"`
  15. HasDetail string `description:"是否有详情,枚举值:是、否;默认:否"`
  16. ChartPermissionId int `description:"权限id"`
  17. CreateTime time.Time `description:"合同添加时间"`
  18. }
  19. //合同的服务内容
  20. type ContractServiceAndDetail struct {
  21. ContractServiceId int `orm:"column(contract_service_id);pk"`
  22. ContractId int `description:"合同id"`
  23. ProductId int `description:"产品id,1:ficc;2:权益"`
  24. ServiceTemplateId int `description:"合同服务模板id"`
  25. Title string `description:"套餐标题"`
  26. Value string `description:"套餐的值"`
  27. HasDetail string `description:"是否有详情,枚举值:是、否;默认:否"`
  28. TableValue string `description:"表格数据,用于word生成时的json数据"`
  29. ChartPermissionId int `description:"权限id"`
  30. DetailList []*ContractServiceDetail
  31. }
  32. // GetContractServiceAndDetailList 根据id获取合同列表数据
  33. func GetContractServiceAndDetailList(contractId int) (list []*ContractServiceAndDetail, err error) {
  34. o := orm.NewOrm()
  35. sql := "select * from contract_service where contract_id = ? "
  36. _, err = o.Raw(sql, contractId).QueryRows(&list)
  37. return
  38. }
  39. // GetContractServiceAndDetailListByIds 根据id集合获取合同列表数据
  40. func GetContractServiceAndDetailListByIds(contractIds string) (list []*ContractServiceAndDetail, err error) {
  41. o := orm.NewOrm()
  42. sql := `select * from contract_service where contract_id in (` + contractIds + `) `
  43. _, err = o.Raw(sql).QueryRows(&list)
  44. return
  45. }
  46. // GetContractServiceListByIds 根据合同IDs获取合同服务列表
  47. func GetContractServiceListByIds(contractIds string) (list []*ContractService, err error) {
  48. o := orm.NewOrm()
  49. sql := `SELECT * FROM contract_service WHERE contract_id IN (` + contractIds + `) `
  50. _, err = o.Raw(sql).QueryRows(&list)
  51. return
  52. }
  53. // MultiCreateContractService 批量新增合同套餐
  54. func MultiCreateContractService(list []*ContractService) (err error) {
  55. listLen := len(list)
  56. if listLen == 0 {
  57. return
  58. }
  59. o := orm.NewOrm()
  60. _, err = o.InsertMulti(listLen, list)
  61. return
  62. }