| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | 
							- package shanghu
 
- import (
 
- 	orm "duoduo/database"
 
- 	"github.com/shopspring/decimal"
 
- 	"time"
 
- )
 
- type MerchantRechargeClientAccount struct {
 
- 	ID             int64           `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` // 主键
 
- 	ClientOpenID   string          `gorm:"column:client_open_id;type:varchar(255)" json:"client_open_id"`
 
- 	MerchantOpenID string          `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"` // Open-id
 
- 	Version        int             `gorm:"column:version;type:int(11)" json:"version"`                        // Version
 
- 	Amount         decimal.Decimal `gorm:"column:amount;type:decimal(10,2)" json:"amount"`                    // 可提现金额
 
- 	CreateBy       int64           `gorm:"column:create_by;type:bigint(20)" json:"create_by"`                 // 创建者
 
- 	UpdateBy       int64           `gorm:"column:update_by;type:bigint(20)" json:"update_by"`                 // 更新者
 
- 	CreatedAt      time.Time       `gorm:"column:created_at;type:datetime(3)" json:"created_at"`              // 创建时间
 
- 	UpdatedAt      time.Time       `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`              // 最后更新时间
 
- 	DeletedAt      time.Time       `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
 
- }
 
- func (m *MerchantRechargeClientAccount) TableName() string {
 
- 	return "merchant_recharge_client_account"
 
- }
 
- // list 接口使用
 
- func (m *MerchantRechargeClientAccount) MerchantRechargeClientAccountList(pageSize int, pageIndex int) ([]MerchantRechargeClientAccount, int, error) {
 
- 	var doc []MerchantRechargeClientAccount
 
- 	table := orm.ShMysql.Table(m.TableName())
 
- 	table = table.Where("client_open_id = ? ", m.ClientOpenID)
 
- 	var count int
 
- 	if err := table.Select("*").Order("id desc").Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
 
- 		return nil, 0, err
 
- 	}
 
- 	table.Count(&count)
 
- 	return doc, count, nil
 
- }
 
- func (m *MerchantRechargeClientAccount) MerchantRechargeClientAccount() (MerchantRechargeClientAccount, error) {
 
- 	var doc MerchantRechargeClientAccount
 
- 	table := orm.ShMysql.Table(m.TableName())
 
- 	table = table.Where("client_open_id = ? and merchant_open_id = ?", m.ClientOpenID, m.MerchantOpenID)
 
- 	if err := table.Select("*").Order("id desc").First(&doc).Error; err != nil {
 
- 		return doc, err
 
- 	}
 
- 	return doc, nil
 
- }
 
- func (m *MerchantRechargeClientAccount) GetMerchantRechargeClientAccount() (MerchantRechargeClientAccount, error) {
 
- 	var doc MerchantRechargeClientAccount
 
- 	table := orm.ShMysql.Table(m.TableName())
 
- 	table = table.Where("id = ?", m.ID)
 
- 	if err := table.Select("*").First(&doc).Error; err != nil {
 
- 		return doc, err
 
- 	}
 
- 	return doc, nil
 
- }
 
 
  |