package service import "XT_Admin_Api/models" func FindCustomInfo(org_id int64) (admin models.KyyChargeCustom, err error) { err = ChargeReadDB().Model(&models.KyyChargeCustom{}).Where("xt_org_id = ? AND status = 1", org_id).First(&admin).Error return } func CreateCustom(admin *models.KyyChargeCustom) (err error) { err = ChargeWriteDB().Model(&models.KyyChargeCustom{}).Create(&admin).Error return } func SaveCustom(admin *models.KyyChargeCustom) (err error) { err = ChargeWriteDB().Model(&models.KyyChargeCustom{}).Create(&admin).Error return } func SaveCustomTwo(admin models.KyyChargeCustomThree) (err error) { err = ChargeWriteDB().Model(&models.KyyChargeCustomThree{}).Save(&admin).Error return } func GetAllCustoms() (cus []*models.KyyChargeCustom, err error) { err = ChargeReadDB().Model(&models.KyyChargeCustomTwo{}).Where("status = 1").Find(&cus).Error return } func GetAllPaymentCollections() (cus []*models.KyyChargePaymentCollection, err error) { err = ChargeReadDB().Model(&models.KyyChargePaymentCollection{}).Where("status = 1").Find(&cus).Error return } func GetAllChargeContacts() (cus []*models.KyyChargeContact, err error) { err = ChargeReadDB().Model(&models.KyyChargeContact{}).Where("status = 1").Find(&cus).Error return } func GetAllChargeContracts() (cus []*models.KyyChargeContract, err error) { err = ChargeReadDB().Model(&models.KyyChargeContract{}).Where("status = 1").Find(&cus).Error return } func GetAllChargeDemand() (cus []*models.KyyChargeDemand, err error) { err = ChargeReadDB().Model(&models.KyyChargeDemand{}).Where("status = 1").Find(&cus).Error return } func GetAllChargeFollow() (cus []*models.KyyChargeFollow, err error) { err = ChargeReadDB().Model(&models.KyyChargeFollow{}).Where("status = 1").Find(&cus).Error return } func GetAllChargeRenewal() (cus []*models.KyyChargeRenewal, err error) { err = ChargeReadDB().Model(&models.KyyChargeRenewal{}).Where("status = 1").Find(&cus).Error return } func FindCustomInfoByID(id int64) (admin models.KyyChargeCustom, err error) { err = ChargeReadDB().Model(&models.KyyChargeCustom{}). Preload("KyyChargePaymentCollection", "status = 1"). Preload("KyyChargeContact", "status = 1"). Preload("KyyChargeContract", "status = 1"). Preload("KyyChargeDemand", "status = 1"). Preload("KyyChargeFollow", "status = 1"). Preload("KyyChargeRenewal", "status = 1"). Where("id = ? AND status = 1", id).First(&admin).Error return } func FindCustomInfoByIDTwo(id int64) (admin models.KyyChargeCustomThree, err error) { err = ChargeReadDB().Model(&models.KyyChargeCustomThree{}). Where("id = ? AND status = 1", id).First(&admin).Error return } func UpdateCustom(custom models.KyyChargeCustom) (err error) { err = ChargeWriteDB().Save(&custom).Error return } func UpdateCustomTwo(custom models.KyyChargeCustomThree) (err error) { err = ChargeWriteDB().Save(&custom).Error return } func CreateChargePaymentCollection(cpc *models.KyyChargePaymentCollection) (err error) { err = ChargeWriteDB().Save(&cpc).Error return } func SaveChargePaymentCollection(cpc *models.KyyChargePaymentCollection) (err error) { err = ChargeWriteDB().Save(&cpc).Error return } func FindPaymentCollectionInfo(id int64) (cpc models.KyyChargePaymentCollection, err error) { err = ChargeReadDB().Model(&models.KyyChargePaymentCollection{}).Where("id = ? AND status = 1", id).First(&cpc).Error return } func SaveChargeContact(chargeContact *models.KyyChargeContact) (err error) { err = ChargeWriteDB().Save(&chargeContact).Error return } func FindChargeContactInfo(id int64) (cpc models.KyyChargeContact, err error) { err = ChargeReadDB().Model(&models.KyyChargeContact{}).Where("id = ? AND status = 1", id).First(&cpc).Error return } func SaveChargeContract(chargeContract *models.KyyChargeContract) (err error) { err = ChargeWriteDB().Save(&chargeContract).Error return } func FindChargeContractInfo(id int64) (cpc models.KyyChargeContract, err error) { err = ChargeReadDB().Model(&models.KyyChargeContract{}).Where("id = ? AND status = 1", id).First(&cpc).Error return } func SaveChargeFollow(chargeFollow *models.KyyChargeFollow) (err error) { err = ChargeWriteDB().Save(&chargeFollow).Error return } func CheckChargeFollowTwo(ids []int64) (err error) { err = ChargeWriteDB().Model(&models.KyyChargeFollow{}).Where("id in (?)", ids).Updates(map[string]interface{}{"is_check": 1}).Error return } func FindChargeFollowInfo(id int64) (cf models.KyyChargeFollow, err error) { err = ChargeReadDB().Model(&models.KyyChargeFollow{}).Where("id = ? AND status = 1", id).First(&cf).Error return } func FindChargeFollowInfoTwo(id int64) (cf []models.KyyChargeFollow, err error) { err = ChargeReadDB().Model(&models.KyyChargeFollow{}).Where("custom_id = ? AND status = 1", id).First(&cf).Error return } func SaveChargeDemand(cd *models.KyyChargeDemand) (err error) { err = ChargeWriteDB().Save(&cd).Error return } func FindChargeDemandInfo(id int64) (cd models.KyyChargeDemand, err error) { err = ChargeReadDB().Model(&models.KyyChargeDemand{}).Where("id = ? AND status = 1", id).First(&cd).Error return } func SaveChargeRenewal(chargeRenewal *models.KyyChargeRenewal) (err error) { err = ChargeWriteDB().Save(&chargeRenewal).Error return } func FindChargeRenewalInfo(id int64) (chargeRenewal models.KyyChargeRenewal, err error) { err = ChargeReadDB().Model(&models.KyyChargeRenewal{}).Where("id = ? AND status = 1", id).First(&chargeRenewal).Error return }