custom_service.go 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package service
  2. import "XT_Admin_Api/models"
  3. func FindCustomInfo(org_id int64) (admin models.KyyChargeCustom, err error) {
  4. err = ChargeReadDB().Model(&models.KyyChargeCustom{}).Where("xt_org_id = ? AND status = 1", org_id).First(&admin).Error
  5. return
  6. }
  7. func CreateCustom(admin *models.KyyChargeCustom) (err error) {
  8. err = ChargeWriteDB().Model(&models.KyyChargeCustom{}).Create(&admin).Error
  9. return
  10. }
  11. func SaveCustom(admin *models.KyyChargeCustom) (err error) {
  12. err = ChargeWriteDB().Model(&models.KyyChargeCustom{}).Create(&admin).Error
  13. return
  14. }
  15. func GetAllCustoms() (cus []*models.KyyChargeCustom, err error) {
  16. err = ChargeReadDB().Model(&models.KyyChargeCustomTwo{}).Where("status = 1").Find(&cus).Error
  17. return
  18. }
  19. func GetAllPaymentCollections() (cus []*models.KyyChargePaymentCollection, err error) {
  20. err = ChargeReadDB().Model(&models.KyyChargePaymentCollection{}).Where("status = 1").Find(&cus).Error
  21. return
  22. }
  23. func GetAllChargeContacts() (cus []*models.KyyChargeContact, err error) {
  24. err = ChargeReadDB().Model(&models.KyyChargeContact{}).Where("status = 1").Find(&cus).Error
  25. return
  26. }
  27. func GetAllChargeContracts() (cus []*models.KyyChargeContract, err error) {
  28. err = ChargeReadDB().Model(&models.KyyChargeContract{}).Where("status = 1").Find(&cus).Error
  29. return
  30. }
  31. func GetAllChargeDemand() (cus []*models.KyyChargeDemand, err error) {
  32. err = ChargeReadDB().Model(&models.KyyChargeDemand{}).Where("status = 1").Find(&cus).Error
  33. return
  34. }
  35. func GetAllChargeFollow() (cus []*models.KyyChargeFollow, err error) {
  36. err = ChargeReadDB().Model(&models.KyyChargeFollow{}).Where("status = 1").Find(&cus).Error
  37. return
  38. }
  39. func GetAllChargeRenewal() (cus []*models.KyyChargeRenewal, err error) {
  40. err = ChargeReadDB().Model(&models.KyyChargeRenewal{}).Where("status = 1").Find(&cus).Error
  41. return
  42. }
  43. func FindCustomInfoByID(id int64) (admin models.KyyChargeCustom, err error) {
  44. err = ChargeReadDB().Model(&models.KyyChargeCustom{}).
  45. Preload("KyyChargePaymentCollection", "status = 1").
  46. Preload("KyyChargeContact", "status = 1").
  47. Preload("KyyChargeContract", "status = 1").
  48. Preload("KyyChargeDemand", "status = 1").
  49. Preload("KyyChargeFollow", "status = 1").
  50. Preload("KyyChargeRenewal", "status = 1").
  51. Where("id = ? AND status = 1", id).First(&admin).Error
  52. return
  53. }
  54. func FindCustomInfoByIDTwo(id int64) (admin models.KyyChargeCustomThree, err error) {
  55. err = ChargeReadDB().Model(&models.KyyChargeCustomThree{}).
  56. Where("id = ? AND status = 1", id).First(&admin).Error
  57. return
  58. }
  59. func UpdateCustom(custom models.KyyChargeCustom) (err error) {
  60. err = ChargeWriteDB().Save(&custom).Error
  61. return
  62. }
  63. func UpdateCustomTwo(custom models.KyyChargeCustomThree) (err error) {
  64. err = ChargeWriteDB().Save(&custom).Error
  65. return
  66. }
  67. func CreateChargePaymentCollection(cpc *models.KyyChargePaymentCollection) (err error) {
  68. err = ChargeWriteDB().Save(&cpc).Error
  69. return
  70. }
  71. func SaveChargePaymentCollection(cpc *models.KyyChargePaymentCollection) (err error) {
  72. err = ChargeWriteDB().Save(&cpc).Error
  73. return
  74. }
  75. func FindPaymentCollectionInfo(id int64) (cpc models.KyyChargePaymentCollection, err error) {
  76. err = ChargeReadDB().Model(&models.KyyChargePaymentCollection{}).Where("id = ? AND status = 1", id).First(&cpc).Error
  77. return
  78. }
  79. func SaveChargeContact(chargeContact *models.KyyChargeContact) (err error) {
  80. err = ChargeWriteDB().Save(&chargeContact).Error
  81. return
  82. }
  83. func FindChargeContactInfo(id int64) (cpc models.KyyChargeContact, err error) {
  84. err = ChargeReadDB().Model(&models.KyyChargeContact{}).Where("id = ? AND status = 1", id).First(&cpc).Error
  85. return
  86. }
  87. func SaveChargeContract(chargeContract *models.KyyChargeContract) (err error) {
  88. err = ChargeWriteDB().Save(&chargeContract).Error
  89. return
  90. }
  91. func FindChargeContractInfo(id int64) (cpc models.KyyChargeContract, err error) {
  92. err = ChargeReadDB().Model(&models.KyyChargeContract{}).Where("id = ? AND status = 1", id).First(&cpc).Error
  93. return
  94. }
  95. func SaveChargeFollow(chargeFollow *models.KyyChargeFollow) (err error) {
  96. err = ChargeWriteDB().Save(&chargeFollow).Error
  97. return
  98. }
  99. func FindChargeFollowInfo(id int64) (cf models.KyyChargeFollow, err error) {
  100. err = ChargeReadDB().Model(&models.KyyChargeFollow{}).Where("id = ? AND status = 1", id).First(&cf).Error
  101. return
  102. }
  103. func SaveChargeDemand(cd *models.KyyChargeDemand) (err error) {
  104. err = ChargeWriteDB().Save(&cd).Error
  105. return
  106. }
  107. func FindChargeDemandInfo(id int64) (cd models.KyyChargeDemand, err error) {
  108. err = ChargeReadDB().Model(&models.KyyChargeDemand{}).Where("id = ? AND status = 1", id).First(&cd).Error
  109. return
  110. }
  111. func SaveChargeRenewal(chargeRenewal *models.KyyChargeRenewal) (err error) {
  112. err = ChargeWriteDB().Save(&chargeRenewal).Error
  113. return
  114. }
  115. func FindChargeRenewalInfo(id int64) (chargeRenewal models.KyyChargeRenewal, err error) {
  116. err = ChargeReadDB().Model(&models.KyyChargeRenewal{}).Where("id = ? AND status = 1", id).First(&chargeRenewal).Error
  117. return
  118. }