| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 | package shanghuimport (	orm "duoduo/database"	"github.com/shopspring/decimal"	"time")type MerchantRechargeClientAccountLog struct {	ID             int64           `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`    	AmountPre      decimal.Decimal `gorm:"column:amount_pre;type:decimal(10,2)" json:"amount_pre"`            	AmountAfter    decimal.Decimal `gorm:"column:amount_after;type:decimal(10,2)" json:"amount_after"`        	TransType      int             `gorm:"column:trans_type;type:int(11)" json:"trans_type"`                  	MerchantOpenID string          `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"` 	ClientOpenID   string          `gorm:"column:client_open_id;type:varchar(255)" json:"client_open_id"`     	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"` 	Amount         decimal.Decimal `gorm:"column:amount;type:decimal(10,2)" json:"amount"`                    	PayTransID     int64           `gorm:"column:pay_trans_id;type:bigint(20)" json:"pay_trans_id"`           	Operator       string          `gorm:"column:operator;type:varchar(255)" json:"operator"`                 }func (m *MerchantRechargeClientAccountLog) TableName() string {	return "merchant_recharge_client_account_log"}func (u *MerchantRechargeClientAccountLog) Create() (MerchantRechargeClientAccountLog, error) {	var doc MerchantRechargeClientAccountLog	var err error	doc = *u	err = orm.ShMysql.Table(u.TableName()).Create(&doc).Error	if err != nil {		return doc, err	}	return doc, nil}func (m *MerchantRechargeClientAccountLog) MerchantRechargeClientAccountLogList(pageSize int, pageIndex int) ([]MerchantRechargeClientAccountLog, int, error) {	var doc []MerchantRechargeClientAccountLog	table := orm.ShMysql.Table(m.TableName())	table = table.Where("merchant_open_id = ?  and trans_type = 1", m.MerchantOpenID)	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 *MerchantRechargeClientAccountLog) GetMerchantRechargeClientAccountLog() ([]MerchantRechargeClientAccountLog, error) {	var doc []MerchantRechargeClientAccountLog	table := orm.ShMysql.Table(m.TableName())	table = table.Where("merchant_open_id = ? and client_open_id = ? and type = 1 ", m.MerchantOpenID, m.ClientOpenID)	if err := table.Select("merchant_open_id,client_open_id,type,trans_type").Group("merchant_open_id,client_open_id,type,trans_type").Order("id desc").Find(&doc).Error; err != nil {		return nil, err	}	return doc, nil}func (m *MerchantRechargeClientAccountLog) MerchantRechargeClientAccountLogListByClient(pageSize int, pageIndex int) ([]MerchantRechargeClientAccountLog, int, error) {	var doc []MerchantRechargeClientAccountLog	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 *MerchantRechargeClientAccountLog) MerchantRechargeAccountLogList(pageSize int, pageIndex int) ([]MerchantRechargeClientAccountLog, int, error) {	var doc []MerchantRechargeClientAccountLog	table := orm.ShMysql.Table(m.TableName())	table = table.Where("merchant_open_id = ? and type = 2 ", m.MerchantOpenID)	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}
 |