| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 | 
							- package shanghu
 
- import (
 
- 	orm "duoduo/database"
 
- 	"time"
 
- )
 
- type ActiveCancelLog 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"`
 
- 	ActiveConfigID   int64     `gorm:"column:active_config_id;type:bigint(20)" json:"active_config_id"`       // 活动id
 
- 	GroupByProjectID int64     `gorm:"column:group_by_project_id;type:bigint(20)" json:"group_by_project_id"` // 拼团商品id
 
- 	SeckillID        int64     `gorm:"column:seckill_id;type:bigint(20)" json:"seckill_id"`                   // 秒杀id
 
- 	UpdateBy         int64     `gorm:"column:update_by;type:bigint(20)" json:"update_by"`
 
- 	CreateBy         int64     `gorm:"column:create_by;type:bigint(20)" json:"create_by"`
 
- 	CreatedAt        time.Time `gorm:"column:created_at;type:datetime" json:"created_at"`
 
- 	UpdatedAt        time.Time `gorm:"column:updated_at;type:datetime" json:"updated_at"`
 
- 	DeletedAt        time.Time `gorm:"column:deleted_at;type:datetime;default:null" json:"deleted_at"`
 
- }
 
- func (m *ActiveCancelLog) TableName() string {
 
- 	return "active_cancel_log"
 
- }
 
- // 统计cancel数量
 
- func (m *ActiveCancelLog) GetActiveCancelNum() int {
 
- 	var count int
 
- 	tableCount := orm.ShMysql.Table(m.TableName()).Where("active_config_id = ? and client_open_id = ?", m.ActiveConfigID, m.ClientOpenID)
 
- 	tableCount.Count(&count)
 
- 	return count
 
- }
 
- func (m *ActiveCancelLog) TXActiveCancelLogCreate(log []ActiveCancelLog) error {
 
- 	var err error
 
- 	tx := orm.ShMysql.Begin()
 
- 	defer func() {
 
- 		if err != nil {
 
- 			tx.Rollback()
 
- 		} else {
 
- 			tx.Commit()
 
- 		}
 
- 	}()
 
- 	for i := 0; i < len(log); i++ {
 
- 		err = tx.Table(log[i].TableName()).Create(&log[i]).Error
 
- 		if err != nil {
 
- 			return err
 
- 		}
 
- 	}
 
- 	return nil
 
- }
 
 
  |