Kaynağa Gözat

抽奖次数与加盟

k.zhang 3 gün önce
ebeveyn
işleme
2931035371

+ 1 - 0
apis/shanghu/base.go

@@ -101,5 +101,6 @@ func InitShangHuRouter(engine *gin.RouterGroup) {
 		activeV1.POST("/client/user/info", GetActiveUserInfo)               //client 用户信息
 		activeV1.POST("/active/cash/out", ActiveCashOut)                    //c端提现
 		activeV1.POST("/active/client/amount", GetActiveAmount)             //余额
+		activeV1.POST("/join/create", CreateMerchantJoin)                   //加盟
 	}
 }

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

@@ -102,6 +102,7 @@ func ActiveConfigCreate(c *gin.Context) {
 	sqlData.GroupBuy = `{}`
 	sqlData.DrawProduct = `{}`
 	sqlData.BackgroundImage = inData.BackgroundImage
+	sqlData.ActiveDrawNum = inData.ActiveDrawNum
 
 	configData, err := sqlData.Create()
 	if err != nil {

+ 27 - 0
apis/shanghu/merchant.join.go

@@ -0,0 +1,27 @@
+package shanghu
+
+import (
+	"duoduo/apis/shanghu/models"
+	"duoduo/models/shanghu"
+	"duoduo/tools/app"
+	"errors"
+	"github.com/gin-gonic/gin"
+)
+
+func CreateMerchantJoin(c *gin.Context) {
+	var inData models.CreateMerchantJoinRequest
+	var sqlData shanghu.MerchantJoin
+
+	err := c.ShouldBindJSON(&inData)
+	if err != nil {
+		app.Error(c, 400, err, err.Error())
+		return
+	}
+
+	sqlData.OpenID = inData.OpenId
+	if sqlData.GetNum() > 20 {
+		app.Error(c, 500, errors.New("提交次数太多"), "提交次数太多")
+		return
+	}
+
+}

+ 1 - 0
apis/shanghu/models/active.config.go

@@ -14,6 +14,7 @@ type CreateActiveConfigRequest struct {
 	ActivityStartTime string  `json:"activity_start_time"` // 活动开始时间
 	ActiveName        string  `json:"active_name"`         // 活动名称
 	BackgroundImage   string  `json:"background_image"`    // 海报
+	ActiveDrawNum     int     `json:"active_draw_num"`     //抽奖次数
 }
 
 type ActiveConfigRequest struct {

+ 8 - 0
apis/shanghu/models/merchant.join.go

@@ -0,0 +1,8 @@
+package models
+
+type CreateMerchantJoinRequest struct {
+	Type    int    `json:"type"`
+	OpenId  string `json:"open_id"`
+	WX      string `json:"wx"`
+	message string `json:"message"`
+}

+ 1 - 0
models/shanghu/merchant.active.config.go

@@ -30,6 +30,7 @@ type MerchantActiveConfig struct {
 	Y                 string    `gorm:"column:y;type:varchar(255)" json:"y"`                                   //
 	H                 string    `gorm:"column:h;type:varchar(255)" json:"h"`                                   //
 	BackgroundImage   string    `gorm:"column:background_image;type:varchar(255)" json:"background_image"`     // 背景图
+	ActiveDrawNum     int       `gorm:"column:active_draw_num;type:int(11)" json:"active_draw_num"`            // 抽奖次数
 
 }
 

+ 45 - 0
models/shanghu/merchant.join.go

@@ -0,0 +1,45 @@
+package shanghu
+
+import (
+	orm "duoduo/database"
+	"time"
+)
+
+type MerchantJoin struct {
+	ID        int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`    // 主键
+	Type      int       `gorm:"column:type;type:int(11)" json:"type"`                              // 1-商家 2-销售 3-创业人员
+	Message   string    `gorm:"column:message;type:varchar(255)" json:"message"`                   //
+	Wx        string    `gorm:"column:wx;type:varchar(255)" json:"wx"`                             // 联系方式
+	OpenID    string    `gorm:"column:open_id;type:varchar(255)" json:"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"` // 删除时间
+}
+
+func (m *MerchantJoin) TableName() string {
+	return "merchant_join"
+}
+
+func (m *MerchantJoin) Create() (MerchantJoin, error) {
+	var doc MerchantJoin
+	var err error
+
+	doc = *m
+	err = orm.ShMysql.Table(m.TableName()).Create(&doc).Error
+	if err != nil {
+		return doc, err
+	}
+
+	return doc, nil
+}
+
+func (m *MerchantJoin) GetNum() int {
+	var count int
+
+	tableCount := orm.ShMysql.Table(m.TableName()).Where("open_id = ? ", m.OpenID)
+	tableCount.Count(&count)
+	return count
+
+}