Browse Source

抽奖,拼团配置

k.zhang 4 months ago
parent
commit
7fb12e6a6c

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

@@ -22,6 +22,8 @@ func ActiveConfigCreate(c *gin.Context) {
 		return
 	}
 
+	//校验总概率
+
 	if inData.GroupBuyMode == 0 && inData.DrawMode == 0 {
 		app.Error(c, 500, errors.New("请选择抽奖与开团"), "请选择抽奖与开团")
 		return

+ 6 - 2
apis/shanghu/merchant.active.draw.product.go

@@ -6,7 +6,6 @@ import (
 	"duoduo/tools/app"
 	"errors"
 	"github.com/gin-gonic/gin"
-	"github.com/shopspring/decimal"
 	"time"
 )
 
@@ -26,11 +25,16 @@ func DrawProductCreate(c *gin.Context) {
 		return
 	}
 
-	if !inData.DrawOdds.GreaterThan(decimal.NewFromFloat(0)) {
+	if inData.DrawOdds <= 0 {
 		app.Error(c, 500, errors.New("中奖率需要大于0"), "中奖率需要大于0")
 		return
 	}
 
+	//if !inData.DrawOdds.GreaterThan(decimal.NewFromFloat(0)) {
+	//	app.Error(c, 500, errors.New("中奖率需要大于0"), "中奖率需要大于0")
+	//	return
+	//}
+
 	sqlData.CreatedAt = time.Now()
 	sqlData.UpdatedAt = time.Now()
 	sqlData.DrawOdds = inData.DrawOdds

+ 6 - 6
apis/shanghu/models/active.config.go

@@ -33,12 +33,12 @@ type ActiveConfigReply struct {
 }
 
 type DrawProduct struct {
-	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"`       // 总库存
+	DrawProductName string `json:"draw_product_name"` // 抽奖名称
+	DrawOdds        int    `json:"draw_odds"`         // 中奖概率
+	Stock           int    `json:"stock"`             // 剩余库存
+	IsPrize         bool   `json:"is_prize"`          // 是否需要兑奖  谢谢惠顾不需要兑奖
+	DrawUrl         string `json:"draw_url"`          // 中奖图片
+	TotalStock      int    `json:"total_stock"`       // 总库存
 
 }
 

+ 15 - 15
apis/shanghu/models/active.draw.product.go

@@ -3,12 +3,12 @@ package models
 import "github.com/shopspring/decimal"
 
 type CreateDrawProductRequest struct {
-	MerchantOpenID  string          `json:"merchant_open_id"`
-	DrawProductName string          `json:"draw_product_name"` // 抽奖名称
-	DrawOdds        decimal.Decimal `json:"draw_odds"`         // 中奖概率
-	IsPrize         bool            `json:"is_prize"`          // 是否需要兑奖  谢谢惠顾不需要兑奖
-	DrawUrl         string          `json:"draw_url"`          // 中奖图片
-	TotalStock      int             `json:"total_stock"`       // 总库存
+	MerchantOpenID  string `json:"merchant_open_id"`
+	DrawProductName string `json:"draw_product_name"` // 抽奖名称
+	DrawOdds        int    `json:"draw_odds"`         // 中奖概率
+	IsPrize         bool   `json:"is_prize"`          // 是否需要兑奖  谢谢惠顾不需要兑奖
+	DrawUrl         string `json:"draw_url"`          // 中奖图片
+	TotalStock      int    `json:"total_stock"`       // 总库存
 }
 
 type DrawProductListRequest struct {
@@ -19,15 +19,15 @@ type DrawProductListRequest struct {
 
 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"`  // 关联活动
+	ID              int64  `json:"id"`
+	MerchantOpenID  string `json:"merchant_open_id"`
+	DrawProductName string `json:"draw_product_name"` // 抽奖名称
+	DrawOdds        int    `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 {

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

@@ -3,27 +3,26 @@ package shanghu
 import (
 	orm "duoduo/database"
 	"errors"
-	"github.com/shopspring/decimal"
 	"time"
 )
 
 // 中奖活动商品 库存,中奖率
 type MerchantActiveDrawProduct struct {
-	ID              int64           `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`
-	MerchantOpenID  string          `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"`
-	DrawProductName string          `gorm:"column:draw_product_name;type:varchar(255)" json:"draw_product_name"` // 抽奖名称
-	DrawOdds        decimal.Decimal `gorm:"column:draw_odds;type:decimal(10,2)" json:"draw_odds"`                // 中奖概率
-	Stock           int             `gorm:"column:stock;type:int(11)" json:"stock"`                              // 剩余库存
-	Version         int             `gorm:"column:version;type:int(11)" json:"version"`                          // Version
-	IsPrize         bool            `gorm:"column:is_prize;type:tinyint(1)" json:"is_prize"`                     // 是否需要兑奖  谢谢惠顾不需要兑奖
-	DrawUrl         string          `gorm:"column:draw_url;type:varchar(255)" json:"draw_url"`                   // 中奖图片
-	TotalStock      int             `gorm:"column:total_stock;type:int(11)" json:"total_stock"`                  // 总库存
-	ActiveConfigID  int64           `gorm:"column:active_config_id;type:bigint(20)" json:"active_config_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"`   // 删除时间
+	ID              int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`
+	MerchantOpenID  string    `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"`
+	DrawProductName string    `gorm:"column:draw_product_name;type:varchar(255)" json:"draw_product_name"` // 抽奖名称
+	DrawOdds        int       `gorm:"column:draw_odds;type:int(11)" json:"draw_odds"`                      // 中奖概率
+	Stock           int       `gorm:"column:stock;type:int(11)" json:"stock"`                              // 剩余库存
+	Version         int       `gorm:"column:version;type:int(11)" json:"version"`                          // Version
+	IsPrize         bool      `gorm:"column:is_prize;type:tinyint(1)" json:"is_prize"`                     // 是否需要兑奖  谢谢惠顾不需要兑奖
+	DrawUrl         string    `gorm:"column:draw_url;type:varchar(255)" json:"draw_url"`                   // 中奖图片
+	TotalStock      int       `gorm:"column:total_stock;type:int(11)" json:"total_stock"`                  // 总库存
+	ActiveConfigID  int64     `gorm:"column:active_config_id;type:bigint(20)" json:"active_config_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"`   // 删除时间
 }
 
 func (m *MerchantActiveDrawProduct) TableName() string {