contract_relation.go 3.6 KB

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