浏览代码

抽奖,拼团配置

k.zhang 4 月之前
父节点
当前提交
3a96fc9433

+ 4 - 4
apis/shanghu/base.go

@@ -75,9 +75,9 @@ func InitShangHuRouter(engine *gin.RouterGroup) {
 		activeV1.POST("/active/draw/product/create", DrawProductCreate) //抽奖奖品创建
 		activeV1.POST("/active/group/buy/create", GroupBuyCreate)       //拼团创建
 		activeV1.POST("/active/config/create", ActiveConfigCreate)      //创建活动
-		//活动列表
-		activeV1.POST("/active/config/info", ActiveConfigInfo) //活动详情
-		//奖品列表
-		//拼团列表
+		activeV1.POST("/active/config/list", ActiveConfigList)          //活动列表
+		activeV1.POST("/active/config/info", ActiveConfigInfo)          //活动详情
+		activeV1.POST("/active/draw/product/list", DrawProductList)     //奖品列表
+		activeV1.POST("/active/group/buy/list", GroupBuyList)           //拼团列表
 	}
 }

+ 63 - 0
apis/shanghu/merchant.active.config.go

@@ -3,6 +3,7 @@ package shanghu
 import (
 	"duoduo/apis/shanghu/models"
 	"duoduo/models/shanghu"
+	"duoduo/tools"
 	"duoduo/tools/app"
 	"errors"
 	"github.com/gin-gonic/gin"
@@ -26,6 +27,19 @@ func ActiveConfigCreate(c *gin.Context) {
 		return
 	}
 
+	sqlData.ActivityEndTime, err = tools.TimeToInt64(inData.ActivityEndTime, "2006-01-02")
+	if err != nil {
+		app.Error(c, 400, err, err.Error())
+		return
+	}
+
+	sqlData.ActivityStartTime, err = tools.TimeToInt64(inData.ActivityStartTime, "2006-01-02")
+	if err != nil {
+		app.Error(c, 400, err, err.Error())
+		return
+	}
+
+	sqlData.ActiveName = inData.ActiveName
 	sqlData.MerchantOpenID = inData.MerchantOpenID
 	sqlData.CreatedAt = time.Now()
 	sqlData.UpdatedAt = time.Now()
@@ -91,6 +105,9 @@ func ActiveConfigInfo(c *gin.Context) {
 	outData.DrawMode = configInfo.DrawMode
 	outData.GroupBuyUrl = configInfo.GroupBuyUrl
 	outData.DrawOneBiZhong = configInfo.DrawOneBiZhong
+	outData.ActivityEndTime = tools.TimeToStr(configInfo.ActivityEndTime)
+	outData.ActivityStartTime = tools.TimeToStr(configInfo.ActivityStartTime)
+	outData.ActiveName = configInfo.ActiveName
 
 	//中奖商品
 	drawInfoSql.ActiveConfigID = configInfo.ID
@@ -137,8 +154,10 @@ func ActiveConfigInfo(c *gin.Context) {
 		groupBuyInfo.GroupBuyOnePrice = v.GroupBuyOnePrice
 		groupBuyInfo.MerchantOpenID = v.MerchantOpenID
 		groupBuyInfo.OriginalPrice = v.OriginalPrice
+		groupBuyInfo.RebateRate = v.RebateRate
 
 		groupBuyProject.GroupBuyID = v.ID
+
 		projectList, _, err := groupBuyProject.GetGroupBuyProjectList()
 		if err != nil {
 			app.Error(c, 500, err, err.Error())
@@ -159,3 +178,47 @@ func ActiveConfigInfo(c *gin.Context) {
 	app.OK(c, outData, app.Success)
 
 }
+
+// 活动列表
+func ActiveConfigList(c *gin.Context) {
+	var inData models.ActiveConfigListRequest
+	var sqlData shanghu.MerchantActiveConfig
+	var outData []models.ActiveConfigListReply
+
+	err := c.ShouldBindJSON(&inData)
+	if err != nil {
+		app.Error(c, 400, err, err.Error())
+		return
+	}
+	sqlData.MerchantOpenID = inData.OpenId
+	var pageSize = 10
+	var pageIndex = 1
+
+	if inData.PageSize != 0 {
+		pageSize = inData.PageSize
+	}
+	if inData.PageIndex != 0 {
+		pageIndex = inData.PageIndex
+	}
+
+	activeConfigList, count, err := sqlData.GetActiveConfigList(pageSize, pageIndex)
+	if err != nil {
+		app.Error(c, 500, err, err.Error())
+		return
+	}
+
+	for _, v := range activeConfigList {
+		var activeConfig models.ActiveConfigListReply
+
+		activeConfig.ActivityStart = tools.TimeToStr(v.ActivityStartTime)
+		activeConfig.ActivityEnd = tools.TimeToStr(v.ActivityEndTime)
+		activeConfig.ActiveName = v.ActiveName
+		activeConfig.CreatedAt = v.CreatedAt.Format(time.DateTime)
+
+		outData = append(outData, activeConfig)
+
+	}
+
+	app.PageOK(c, outData, count, pageIndex, pageSize, app.Success)
+
+}

+ 49 - 0
apis/shanghu/merchant.active.draw.product.go

@@ -50,3 +50,52 @@ func DrawProductCreate(c *gin.Context) {
 
 	app.OK(c, nil, app.Success)
 }
+
+// 商品列表
+func DrawProductList(c *gin.Context) {
+	var inData models.DrawProductListRequest
+	var sqlData shanghu.MerchantActiveDrawProduct
+	var outData []models.DrawProductListReply
+
+	err := c.ShouldBindJSON(&inData)
+	if err != nil {
+		app.Error(c, 400, err, err.Error())
+		return
+	}
+
+	sqlData.MerchantOpenID = inData.OpenId
+	var pageSize = 10
+	var pageIndex = 1
+
+	if inData.PageSize != 0 {
+		pageSize = inData.PageSize
+	}
+	if inData.PageIndex != 0 {
+		pageIndex = inData.PageIndex
+	}
+
+	drawProductList, count, err := sqlData.GetDrawProductListByOpenId(pageSize, pageIndex)
+
+	if err != nil {
+		app.Error(c, 500, err, err.Error())
+		return
+	}
+
+	for _, v := range drawProductList {
+		var drawProductInfo models.DrawProductListReply
+		drawProductInfo.DrawProductName = v.DrawProductName
+		drawProductInfo.DrawOdds = v.DrawOdds
+		drawProductInfo.MerchantOpenID = v.MerchantOpenID
+		drawProductInfo.DrawUrl = v.DrawUrl
+		drawProductInfo.ActiveConfigID = v.ActiveConfigID
+		drawProductInfo.ID = v.ID
+		drawProductInfo.Stock = v.Stock
+		drawProductInfo.TotalStock = v.TotalStock
+		drawProductInfo.IsPrize = v.IsPrize
+
+		outData = append(outData, drawProductInfo)
+	}
+
+	app.PageOK(c, outData, count, pageIndex, pageSize, app.Success)
+
+}

+ 70 - 0
apis/shanghu/merchant.active.group.buy.go

@@ -34,6 +34,7 @@ func GroupBuyCreate(c *gin.Context) {
 	sqlData.GroupBuyFourPrice = inData.GroupBuyFourPrice
 	sqlData.GroupBuyFourNum = inData.GroupBuyFourNum
 	sqlData.GroupBuyUrl = inData.GroupBuyUrl
+	sqlData.RebateRate = inData.RebateRate
 
 	groupBuyData, err := sqlData.Create()
 	if err != nil {
@@ -60,3 +61,72 @@ func GroupBuyCreate(c *gin.Context) {
 	app.OK(c, nil, app.Success)
 
 }
+
+func GroupBuyList(c *gin.Context) {
+	var inData models.GroupBuyListRequest
+	var sqlData shanghu.MerchantActiveGroupBuy
+	var outData []models.GroupBuyListReply
+
+	err := c.ShouldBindJSON(&inData)
+	if err != nil {
+		app.Error(c, 400, err, err.Error())
+		return
+	}
+
+	sqlData.MerchantOpenID = inData.OpenId
+	var pageSize = 10
+	var pageIndex = 1
+
+	if inData.PageSize != 0 {
+		pageSize = inData.PageSize
+	}
+	if inData.PageIndex != 0 {
+		pageIndex = inData.PageIndex
+	}
+
+	groupBuyInfoList, count, err := sqlData.GetGroupBuyListByOpenId(pageSize, pageIndex)
+	if err != nil {
+		app.Error(c, 500, err, err.Error())
+		return
+	}
+
+	for _, v := range groupBuyInfoList {
+		var groupBuyInfo models.GroupBuyListReply
+		var groupBuyProject shanghu.MerchantActiveGroupByProject
+		groupBuyInfo.GroupBuyName = v.GroupBuyName
+		groupBuyInfo.GroupBuyMode = v.GroupBuyMode
+		groupBuyInfo.GroupBuyUrl = v.GroupBuyUrl
+		groupBuyInfo.GroupBuyThreeNum = v.GroupBuyThreeNum
+		groupBuyInfo.GroupBuyThreePrice = v.GroupBuyThreePrice
+		groupBuyInfo.GroupBuyFourNum = v.GroupBuyFourNum
+		groupBuyInfo.GroupBuyFourPrice = v.GroupBuyFourPrice
+		groupBuyInfo.GroupBuyTwoNum = v.GroupBuyTwoNum
+		groupBuyInfo.GroupBuyTwoPrice = v.GroupBuyTwoPrice
+		groupBuyInfo.GroupBuyOneNum = v.GroupBuyOneNum
+		groupBuyInfo.GroupBuyOnePrice = v.GroupBuyOnePrice
+		groupBuyInfo.MerchantOpenId = v.MerchantOpenID
+		groupBuyInfo.OriginalPrice = v.OriginalPrice
+		groupBuyInfo.RebateRate = v.RebateRate
+		groupBuyInfo.ID = v.ID
+
+		groupBuyProject.GroupBuyID = v.ID
+
+		projectList, _, err := groupBuyProject.GetGroupBuyProjectList()
+		if err != nil {
+			app.Error(c, 500, err, err.Error())
+			return
+		}
+
+		for _, v := range projectList {
+			var groupBuyProjectInfo models.CreateGroupBuyProject
+			groupBuyProjectInfo.ProjectName = v.ProjectName
+			groupBuyProjectInfo.CancelNum = v.CancelNum
+			groupBuyInfo.GroupBuyProject = append(groupBuyInfo.GroupBuyProject, groupBuyProjectInfo)
+		}
+		outData = append(outData, groupBuyInfo)
+
+	}
+
+	app.PageOK(c, outData, count, pageIndex, pageSize, app.Success)
+
+}

+ 35 - 13
apis/shanghu/models/active.config.go

@@ -3,13 +3,16 @@ package models
 import "github.com/shopspring/decimal"
 
 type CreateActiveConfigRequest struct {
-	MerchantOpenID string  `json:"merchant_open_id"`
-	DrawOneBiZhong int64   `json:"draw_one_bi_zhong"`
-	GroupBuyUrl    string  `json:"group_buy_url"`
-	DrawId         []int64 `json:"draw_id"`
-	GroupBuyId     []int64 `json:"group_buy_id"`
-	GroupBuyMode   int     `json:"group_buy_mode"` // 0-不开团 1-虚拟开团 2-真实开团
-	DrawMode       int     `json:"draw_mode"`      //抽奖模式 0-不抽奖,1-盲盒
+	MerchantOpenID    string  `json:"merchant_open_id"`
+	DrawOneBiZhong    int64   `json:"draw_one_bi_zhong"`
+	GroupBuyUrl       string  `json:"group_buy_url"`
+	DrawId            []int64 `json:"draw_id"`
+	GroupBuyId        []int64 `json:"group_buy_id"`
+	GroupBuyMode      int     `json:"group_buy_mode"`      // 0-不开团 1-虚拟开团 2-真实开团
+	DrawMode          int     `json:"draw_mode"`           // 抽奖模式 0-不抽奖,1-盲盒
+	ActivityEndTime   string  `json:"activity_end_time"`   // 活动结束时间
+	ActivityStartTime string  `json:"activity_start_time"` // 活动开始时间
+	ActiveName        string  `json:"active_name"`         // 活动名称
 }
 
 type ActiveConfigRequest struct {
@@ -18,12 +21,15 @@ type ActiveConfigRequest struct {
 }
 
 type ActiveConfigReply struct {
-	DrawOneBiZhong int64          `json:"draw_one_bi_zhong"`
-	GroupBuyUrl    string         `json:"group_buy_url"`
-	GroupBuyMode   int            `json:"group_buy_mode"` // 0-不开团 1-虚拟开团 2-真实开团
-	DrawMode       int            `json:"draw_mode"`      //抽奖模式 0-不抽奖,1-盲盒
-	DrawProduct    []DrawProduct  `json:"draw_product"`   //中奖商品
-	DrawGroupBuy   []DrawGroupBuy `json:"draw_group_buy"` //活动拼团
+	DrawOneBiZhong    int64          `json:"draw_one_bi_zhong"`
+	GroupBuyUrl       string         `json:"group_buy_url"`
+	GroupBuyMode      int            `json:"group_buy_mode"`      // 0-不开团 1-虚拟开团 2-真实开团
+	DrawMode          int            `json:"draw_mode"`           //抽奖模式 0-不抽奖,1-盲盒
+	ActivityEndTime   string         `json:"activity_end_time"`   // 活动结束时间
+	ActivityStartTime string         `json:"activity_start_time"` // 活动开始时间
+	ActiveName        string         `json:"active_name"`         // 活动名称
+	DrawProduct       []DrawProduct  `json:"draw_product"`        //中奖商品
+	DrawGroupBuy      []DrawGroupBuy `json:"draw_group_buy"`      //活动拼团
 }
 
 type DrawProduct struct {
@@ -50,6 +56,9 @@ type DrawGroupBuy struct {
 	GroupBuyFourNum    int               `json:"group_buy_four_num"`    //
 	GroupBuyFourPrice  decimal.Decimal   `json:"group_buy_four_price"`  //
 	GroupBuyUrl        string            `json:"group_buy_url"`         // 图片
+	ActivityEndTime    string            `json:"activity_end_time"`     // 活动结束时间
+	ActivityStartTime  string            `json:"activity_start_time"`   // 活动开始时间
+	RebateRate         int               `json:"rebate_rate"`           // 佣金比例
 	GroupBuyProject    []GroupBuyProject `json:"group_buy_project"`
 }
 
@@ -57,3 +66,16 @@ type GroupBuyProject struct {
 	ProjectName string `json:"project_name"`
 	CancelNum   int    `json:"cancel_num"`
 }
+
+type ActiveConfigListRequest struct {
+	OpenId    string `json:"open_id"`
+	PageSize  int    `json:"page_size"`
+	PageIndex int    `json:"page_index"`
+}
+
+type ActiveConfigListReply struct {
+	ActiveName    string `json:"active_name"`    // 活动名称
+	ActivityEnd   string `json:"activity_end"`   // 活动结束时间
+	ActivityStart string `json:"activity_start"` //活动开始时间
+	CreatedAt     string `json:"created_at"`     //创建时间
+}

+ 32 - 0
apis/shanghu/models/active.draw.product.go

@@ -10,3 +10,35 @@ type CreateDrawProductRequest struct {
 	DrawUrl         string          `json:"draw_url"`          // 中奖图片
 	TotalStock      int             `json:"total_stock"`       // 总库存
 }
+
+type DrawProductListRequest struct {
+	OpenId    string `json:"open_id"`
+	PageSize  int    `json:"page_size"`
+	PageIndex int    `json:"page_index"`
+}
+
+type DrawProductListReply struct {
+	//DrawProductInfo []DrawProductInfo `json:"draw_product_info"`
+	ID              int64           `json:"id"`
+	MerchantOpenID  string          `json:"merchant_open_id"`
+	DrawProductName string          `json:"draw_product_name"` // 抽奖名称
+	DrawOdds        decimal.Decimal `json:"draw_odds"`         // 中奖概率
+	Stock           int             `json:"stock"`             // 剩余库存
+	IsPrize         bool            `json:"is_prize"`          // 是否需要兑奖  谢谢惠顾不需要兑奖
+	DrawUrl         string          `json:"draw_url"`          // 中奖图片
+	TotalStock      int             `json:"total_stock"`       // 总库存
+	ActiveConfigID  int64           `json:"active_config_id"`  // 关联活动
+}
+
+type DrawProductInfo struct {
+	ID              int64           `json:"id"`
+	MerchantOpenID  string          `json:"merchant_open_id"`
+	DrawProductName string          `json:"draw_product_name"` // 抽奖名称
+	DrawOdds        decimal.Decimal `json:"draw_odds"`         // 中奖概率
+	Stock           int             `json:"stock"`             // 剩余库存
+	IsPrize         bool            `json:"is_prize"`          // 是否需要兑奖  谢谢惠顾不需要兑奖
+	DrawUrl         string          `json:"draw_url"`          // 中奖图片
+	TotalStock      int             `json:"total_stock"`       // 总库存
+	ActiveConfigID  int64           `json:"active_config_id"`  // 关联活动
+
+}

+ 46 - 0
apis/shanghu/models/active.group.buy.go

@@ -16,6 +16,7 @@ type CreateGroupBuyRequest struct {
 	GroupBuyFourNum    int                     `json:"group_buy_four_num"`    //
 	GroupBuyFourPrice  decimal.Decimal         `json:"group_buy_four_price"`  //
 	GroupBuyUrl        string                  `json:"group_buy_url"`         // 图片
+	RebateRate         int                     `json:"rebate_rate"`           //佣金比例
 	GroupBuyProject    []CreateGroupBuyProject `json:"group_buy_project"`
 }
 
@@ -23,3 +24,48 @@ type CreateGroupBuyProject struct {
 	ProjectName string `json:"project_name"`
 	CancelNum   int    `json:"cancel_num"`
 }
+
+type GroupBuyListRequest struct {
+	OpenId    string `json:"open_id"`
+	PageSize  int    `json:"page_size"`
+	PageIndex int    `json:"page_index"`
+}
+
+type GroupBuyListReply struct {
+	//GroupBuyInfo []GroupBuyInfo `json:"group_buy_info"`
+	ID                 int64                   `json:"id"`
+	MerchantOpenId     string                  `json:"merchant_open_id"`
+	GroupBuyName       string                  `json:"group_buy_name"`        // 拼团名
+	GroupBuyMode       int                     `json:"group_buy_mode"`        // 拼团模式 1-真实拼团 2-虚拟拼团
+	OriginalPrice      decimal.Decimal         `json:"original_price"`        // 原价
+	GroupBuyOneNum     int                     `json:"group_buy_one_num"`     // 人数
+	GroupBuyOnePrice   decimal.Decimal         `json:"group_buy_one_price"`   // 价格
+	GroupBuyTwoNum     int                     `json:"group_buy_two_num"`     // 人数
+	GroupBuyTwoPrice   decimal.Decimal         `json:"group_buy_two_price"`   // 价格
+	GroupBuyThreeNum   int                     `json:"group_buy_three_num"`   //
+	GroupBuyThreePrice decimal.Decimal         `json:"group_buy_three_price"` //
+	GroupBuyFourNum    int                     `json:"group_buy_four_num"`    //
+	GroupBuyFourPrice  decimal.Decimal         `json:"group_buy_four_price"`  //
+	GroupBuyUrl        string                  `json:"group_buy_url"`         // 图片
+	RebateRate         int                     `json:"rebate_rate"`           //佣金比例
+	GroupBuyProject    []CreateGroupBuyProject `json:"group_buy_project"`     //
+}
+
+type GroupBuyInfo struct {
+	ID                 int64                   `json:"id"`
+	MerchantOpenId     string                  `json:"merchant_open_id"`
+	GroupBuyName       string                  `json:"group_buy_name"`        // 拼团名
+	GroupBuyMode       int                     `json:"group_buy_mode"`        // 拼团模式 1-真实拼团 2-虚拟拼团
+	OriginalPrice      decimal.Decimal         `json:"original_price"`        // 原价
+	GroupBuyOneNum     int                     `json:"group_buy_one_num"`     // 人数
+	GroupBuyOnePrice   decimal.Decimal         `json:"group_buy_one_price"`   // 价格
+	GroupBuyTwoNum     int                     `json:"group_buy_two_num"`     // 人数
+	GroupBuyTwoPrice   decimal.Decimal         `json:"group_buy_two_price"`   // 价格
+	GroupBuyThreeNum   int                     `json:"group_buy_three_num"`   //
+	GroupBuyThreePrice decimal.Decimal         `json:"group_buy_three_price"` //
+	GroupBuyFourNum    int                     `json:"group_buy_four_num"`    //
+	GroupBuyFourPrice  decimal.Decimal         `json:"group_buy_four_price"`  //
+	GroupBuyUrl        string                  `json:"group_buy_url"`         // 图片
+	RebateRate         int                     `json:"rebate_rate"`           //佣金比例
+	GroupBuyProject    []CreateGroupBuyProject `json:"group_buy_project"`
+}

+ 30 - 14
models/shanghu/merchant.active.config.go

@@ -7,20 +7,23 @@ import (
 
 // 活动中奖配置,拼团配置,秒杀配置
 type MerchantActiveConfig struct {
-	ID             int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`
-	ConfigMode     int       `gorm:"column:config_mode;type:int(11)" json:"config_mode"`                // 模式 1-默认模式
-	MerchantOpenID string    `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"` // openid
-	DrawMode       int       `gorm:"column:draw_mode;type:int(11);default:0" json:"draw_mode"`          // 抽奖模式 0-不抽奖,1-盲盒
-	DrawOneBiZhong int64     `gorm:"column:draw_one_bi_zhong;type:bigint(20)" json:"draw_one_bi_zhong"` // 首次必中抽奖商品ID
-	DrawProduct    string    `gorm:"column:draw_product;type:json" json:"draw_product"`                 // 抽奖商品 商品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"` // 删除时间
-	GroupBuyMode   int       `gorm:"column:group_buy_mode;type:int(11)" json:"group_buy_mode"`          // 0-不开团 1-虚拟开团 2-真实开团
-	GroupBuy       string    `gorm:"column:group_buy;type:json" json:"group_buy"`                       // 开团配置
-	GroupBuyUrl    string    `gorm:"column:group_buy_url;type:varchar(255)" json:"group_buy_url"`       // 介绍图url
+	ID                int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`
+	ConfigMode        int       `gorm:"column:config_mode;type:int(11)" json:"config_mode"`                    // 模式 1-默认模式
+	MerchantOpenID    string    `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"`     // openid
+	DrawMode          int       `gorm:"column:draw_mode;type:int(11);default:0" json:"draw_mode"`              // 抽奖模式 0-不抽奖,1-盲盒
+	DrawOneBiZhong    int64     `gorm:"column:draw_one_bi_zhong;type:bigint(20)" json:"draw_one_bi_zhong"`     // 首次必中抽奖商品ID
+	DrawProduct       string    `gorm:"column:draw_product;type:json" json:"draw_product"`                     // 抽奖商品 商品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"`     // 删除时间
+	GroupBuyMode      int       `gorm:"column:group_buy_mode;type:int(11)" json:"group_buy_mode"`              // 0-不开团 1-虚拟开团 2-真实开团
+	GroupBuy          string    `gorm:"column:group_buy;type:json" json:"group_buy"`                           // 开团配置
+	GroupBuyUrl       string    `gorm:"column:group_buy_url;type:varchar(255)" json:"group_buy_url"`           // 介绍图url
+	ActivityEndTime   int64     `gorm:"column:activity_end_time;type:bigint(20)" json:"activity_end_time"`     // 活动结束时间
+	ActivityStartTime int64     `gorm:"column:activity_start_time;type:bigint(20)" json:"activity_start_time"` // 活动开始时间
+	ActiveName        string    `gorm:"column:active_name;type:varchar(255)" json:"active_name"`               // 活动名称
 }
 
 func (m *MerchantActiveConfig) TableName() string {
@@ -51,5 +54,18 @@ func (m *MerchantActiveConfig) GetConfigInfoById() (MerchantActiveConfig, error)
 	}
 
 	return doc, nil
+}
+
+func (m *MerchantActiveConfig) GetActiveConfigList(pageSize int, pageIndex int) ([]MerchantActiveConfig, int, error) {
+	var doc []MerchantActiveConfig
 
+	table := orm.ShMysql.Table(m.TableName())
+
+	table = table.Where("merchant_open_id = ?  ", 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
 }

+ 15 - 1
models/shanghu/merchant.active.draw.product.go

@@ -44,7 +44,7 @@ func (u *MerchantActiveDrawProduct) Create() (MerchantActiveDrawProduct, error)
 }
 
 func (u *MerchantActiveDrawProduct) UpdateConfigId(drawId int64) error {
-	res := orm.ShMysql.Table(u.TableName()).Where("id = ?", drawId).Updates(
+	res := orm.ShMysql.Table(u.TableName()).Where("id = ? and active_config_id = 0", drawId).Updates(
 		map[string]interface{}{
 			"active_config_id": u.ActiveConfigID,
 			"updated_at":       time.Now(),
@@ -73,3 +73,17 @@ func (m *MerchantActiveDrawProduct) GetDrawProductList() ([]MerchantActiveDrawPr
 	table.Count(&count)
 	return doc, count, nil
 }
+
+func (m *MerchantActiveDrawProduct) GetDrawProductListByOpenId(pageSize int, pageIndex int) ([]MerchantActiveDrawProduct, int, error) {
+	var doc []MerchantActiveDrawProduct
+
+	table := orm.ShMysql.Table(m.TableName())
+
+	table = table.Where("merchant_open_id = ? and  active_config_id = 0", 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
+}

+ 16 - 1
models/shanghu/merchant.active.group.buy.go

@@ -29,6 +29,7 @@ type MerchantActiveGroupBuy struct {
 	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"`   // 删除时间
+	RebateRate         int             `gorm:"column:rebate_rate;type:int(11)" json:"rebate_rate"`                  // 佣金比例
 }
 
 func (m *MerchantActiveGroupBuy) TableName() string {
@@ -48,7 +49,7 @@ func (u *MerchantActiveGroupBuy) Create() (MerchantActiveGroupBuy, error) {
 }
 
 func (u *MerchantActiveGroupBuy) UpdateConfigId(groupBuyId int64) error {
-	res := orm.ShMysql.Table(u.TableName()).Where("id = ?", groupBuyId).Updates(
+	res := orm.ShMysql.Table(u.TableName()).Where("id = ? and active_config_id = 0", groupBuyId).Updates(
 		map[string]interface{}{
 			"active_config_id": u.ActiveConfigID,
 			"updated_at":       time.Now(),
@@ -77,3 +78,17 @@ func (m *MerchantActiveGroupBuy) GetGroupBuyList() ([]MerchantActiveGroupBuy, in
 	table.Count(&count)
 	return doc, count, nil
 }
+
+func (m *MerchantActiveGroupBuy) GetGroupBuyListByOpenId(pageSize int, pageIndex int) ([]MerchantActiveGroupBuy, int, error) {
+	var doc []MerchantActiveGroupBuy
+
+	table := orm.ShMysql.Table(m.TableName())
+
+	table = table.Where("merchant_open_id = ? and  active_config_id = 0", 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
+}