supplier_payment.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package db
  2. import (
  3. "context"
  4. "youngee_b_api/model/gorm_model"
  5. )
  6. // GetSupplierPaymentInfoById 根据服务商ID查询提现账号信息
  7. func GetSupplierPaymentInfoById(ctx context.Context, supplierId int) (*gorm_model.SupplierPaymentInfo, error) {
  8. db := GetWriteDB(ctx)
  9. var supplierPaymentInfo *gorm_model.SupplierPaymentInfo
  10. whereCondition := gorm_model.SupplierPaymentInfo{SupplierID: supplierId}
  11. err := db.Model(gorm_model.SupplierPaymentInfo{}).Where(whereCondition).Find(&supplierPaymentInfo).Error
  12. if err != nil {
  13. return nil, err
  14. }
  15. return supplierPaymentInfo, nil
  16. }
  17. // CreateSupplierPayment 新建提现收款信息
  18. func CreateSupplierPayment(ctx context.Context, paymentInfo *gorm_model.SupplierPaymentInfo) error {
  19. db := GetWriteDB(ctx)
  20. err := db.Create(&paymentInfo).Error
  21. if err != nil {
  22. return err
  23. }
  24. return nil
  25. }
  26. // UpdateSupplierPayment 更新提现收款信息
  27. func UpdateSupplierPayment(ctx context.Context, paymentInfo *gorm_model.SupplierPaymentInfo) error {
  28. db := GetWriteDB(ctx)
  29. whereCondition := gorm_model.SupplierPaymentInfo{PaymentInfoID: paymentInfo.PaymentInfoID}
  30. err := db.Model(&gorm_model.SupplierPaymentInfo{}).Where(whereCondition).Updates(paymentInfo).Error
  31. if err != nil {
  32. return err
  33. }
  34. return nil
  35. }