contract_relation.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package contract
  2. import "github.com/beego/beego/v2/client/orm"
  3. // ContractRelation 合同关系表结构体
  4. type ContractRelation struct {
  5. ContractId int `description:"业务合同id"`
  6. PaymentOnBehalfContractId int `description:"代付合同id"`
  7. }
  8. type RelationContractList struct {
  9. ContractId int `description:"合同id"`
  10. CompanyName string `description:"甲方名称"`
  11. PaymentOnBehalfContractId int `description:"代付合同id"`
  12. Price float64 `description:"付款金额"`
  13. Service []*ContractServiceAndDetail
  14. //ContractId int `description:"合同id"`
  15. }
  16. // GetContractRelationListByRelationContractIds 根据业务合同id集合获取对应的业务合同基础信息
  17. func GetContractRelationListByRelationContractIds(contractIdStr string) (list []*RelationContractList, err error) {
  18. o := orm.NewOrm()
  19. sql := `select b.contract_id,a.company_name,b.payment_on_behalf_contract_id from contract a join contract_relation b on a.contract_id=b.payment_on_behalf_contract_id where a.status in ("已签回","已审批") AND a.is_delete = 0 AND b.contract_id in (` + contractIdStr + `) order by a.contract_id asc`
  20. _, err = o.Raw(sql).QueryRows(&list)
  21. return
  22. }
  23. // GetContractRelationListByPaymentOnBehalfContractIds 根据代付合同id集合获取对应的业务合同基础信息
  24. func GetContractRelationListByPaymentOnBehalfContractIds(contractIdStr string) (list []*RelationContractList, err error) {
  25. o := orm.NewOrm()
  26. sql := `select a.contract_id,a.company_name,b.payment_on_behalf_contract_id from contract a join contract_relation b on a.contract_id=b.contract_id where a.status in ("已签回","已审批") AND a.is_delete = 0 AND b.payment_on_behalf_contract_id in (` + contractIdStr + `) order by a.contract_id asc`
  27. _, err = o.Raw(sql).QueryRows(&list)
  28. return
  29. }
  30. // GetContractRelationListByRelationContractId 根据业务合同id获取对应的代付合同基础信息
  31. func GetContractRelationListByRelationContractId(contractId int) (list []*RelationContractList, err error) {
  32. o := orm.NewOrm()
  33. sql := `select b.contract_id,a.company_name,b.payment_on_behalf_contract_id from contract a join contract_relation b on a.contract_id=b.payment_on_behalf_contract_id where a.status in ("已签回","已审批") AND a.is_delete = 0 AND b.contract_id =? order by a.contract_id asc`
  34. _, err = o.Raw(sql, contractId).QueryRows(&list)
  35. return
  36. }
  37. // GetContractRelationListByPaymentOnBehalfContractId 根据代付合同id获取对应的业务合同基础信息
  38. func GetContractRelationListByPaymentOnBehalfContractId(contractId int) (list []*RelationContractList, err error) {
  39. o := orm.NewOrm()
  40. sql := `select a.contract_id,a.company_name,b.payment_on_behalf_contract_id from contract a join contract_relation b on a.contract_id=b.contract_id where a.status in ("已签回","已审批") AND a.is_delete = 0 AND b.payment_on_behalf_contract_id =? order by a.contract_id asc`
  41. _, err = o.Raw(sql, contractId).QueryRows(&list)
  42. return
  43. }
  44. // GetContractRelationListByContractId 根据业务合同id获取已经给他代付过的合同列表
  45. func GetContractRelationListByContractId(contractId int) (list []*RelationContractList, err error) {
  46. o := orm.NewOrm()
  47. sql := `select b.contract_id,a.company_name,b.payment_on_behalf_contract_id,a.price from contract a join contract_relation b on a.contract_id=b.payment_on_behalf_contract_id where a.status in ("已签回","已审批","待审批") AND a.is_delete = 0 AND b.contract_id =? order by a.contract_id asc`
  48. _, err = o.Raw(sql, contractId).QueryRows(&list)
  49. return
  50. }