custom_service.go 4.3KB

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