custom_service.go 5.0KB

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