Переглянути джерело

Merge branch 'yun-group-buy' of k.zhang/duoduo into yun-test

k.zhang 2 місяців тому
батько
коміт
88bac79824

+ 0 - 1
apis/shanghu/base.go

@@ -91,7 +91,6 @@ func InitShangHuRouter(engine *gin.RouterGroup) {
 		activeV1.POST("/active/pay/callback", ActivePayCallBack)          //支付回调
 		activeV1.POST("/active/draw/num", InvitedDrawNum)                 //邀请次数
 		activeV1.POST("/client/user/set", ActiveOpenIdSet)                //活动 创建用户
-
 		//待核销金额
 		//
 

+ 44 - 8
apis/shanghu/merchant.active.config.go

@@ -138,7 +138,9 @@ func ActiveConfigInfo(c *gin.Context) {
 	var outData models.ActiveConfigReply
 	var drawInfoSql shanghu.MerchantActiveDrawProduct
 	var groupBuy shanghu.MerchantActiveGroupBuy
-	var merchant shanghu.Merchant
+	var drawNumSql shanghu.ClientActiveDrawNum
+	var draw shanghu.ClientActiveDrawLog
+	//var merchant shanghu.Merchant
 
 	err := c.ShouldBindJSON(&inData)
 	if err != nil {
@@ -228,17 +230,47 @@ func ActiveConfigInfo(c *gin.Context) {
 		}
 
 		outData.DrawGroupBuy = append(outData.DrawGroupBuy, groupBuyInfo)
-
 	}
 
-	merchant.OpenId = inData.MerchantOpenID
-	merchantInfo, err := merchant.GetMerchant()
-	if err != nil {
-		app.Error(c, 500, err, err.Error())
-		return
+	//次数
+	if inData.ClientOpenID != "" {
+
+		// 校验抽奖次数
+		drawNumSql.ActiveConfigID = inData.ActiveConfigId
+		drawNumSql.ClientOpenID = inData.ClientOpenID
+		drawNum, err := drawNumSql.GetDrawNum()
+		if err != nil {
+			app.Error(c, 500, err, err.Error())
+			return
+		}
+
+		//校验数量
+		draw.ActiveConfigID = inData.ActiveConfigId
+		draw.ClientOpenID = inData.ClientOpenID
+		clientDrawNum, err := draw.GetClientActiveDrawLogNum()
+		if err != nil {
+			app.Error(c, 500, err, err.Error())
+			return
+		}
+
+		outData.DrawNum = drawNum + 1 - clientDrawNum
+
+		//if drawNum+1 < clientDrawNum {
+		//	app.Error(c, 500, errors.New("抽奖次数用完"), "抽奖次数用完")
+		//	return
+		//}
+
 	}
 
-	outData.MerchantName = merchantInfo.MerchantName
+	//获取商家信息
+	//merchant.OpenId = inData.MerchantOpenID
+	//merchantInfo, err := merchant.GetMerchant()
+	//if err != nil {
+	//	app.Error(c, 500, err, err.Error())
+	//	return
+	//}
+
+	//outData.MerchantName = merchantInfo.MerchantName
 
 	app.OK(c, outData, app.Success)
 
@@ -888,6 +920,10 @@ func ActivePayCallBack(c *gin.Context) {
 		return
 	}
 
+	// 加款到余额
+	// 加款到余额  分账
+	// 分账失败重复分
+
 	c.XML(http.StatusOK, successResp)
 
 }

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

@@ -19,6 +19,7 @@ type CreateActiveConfigRequest struct {
 type ActiveConfigRequest struct {
 	ActiveConfigId int64  `json:"active_config_id"`
 	MerchantOpenID string `json:"merchant_open_id"`
+	ClientOpenID   string `json:"client_open_id"`
 }
 
 type ActiveConfigReply struct {
@@ -31,6 +32,7 @@ type ActiveConfigReply struct {
 	ActivityStartTime string         `json:"activity_start_time"` //活动开始时间
 	ActiveName        string         `json:"active_name"`         //活动名称
 	BackgroundImage   string         `json:"background_image"`    // 海报
+	DrawNum           int            `json:"draw_num"`            //抽奖次数
 	DrawProduct       []DrawProduct  `json:"draw_product"`        //中奖商品
 	DrawGroupBuy      []DrawGroupBuy `json:"draw_group_buy"`      //活动拼团
 }

+ 24 - 0
models/shanghu/active.account.log.go

@@ -0,0 +1,24 @@
+package shanghu
+
+import "time"
+
+type ActiveAccountLog struct {
+	ID                int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`           // 主键
+	ReviewAmountAfter string    `gorm:"column:review_amount_after;type:decimal(10,2)" json:"review_amount_after"` // 审核资金 交易后
+	ReviewAmountPre   string    `gorm:"column:review_amount_pre;type:decimal(10,2)" json:"review_amount_pre"`     // 审核资金 交易前
+	AmountPre         string    `gorm:"column:amount_pre;type:decimal(10,2)" json:"amount_pre"`                   // 交易前
+	AmountAfter       string    `gorm:"column:amount_after;type:decimal(10,2)" json:"amount_after"`               // 交易后
+	TransType         int       `gorm:"column:trans_type;type:int(11)" json:"trans_type"`                         // 交易类型  1-买卡入待审核 2-核销入账  3-提现
+	MerchantOpenID    string    `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"`        // 商户openid
+	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            string    `gorm:"column:amount;type:decimal(10,2)" json:"amount"`                           // 交易金额
+	PayTransID        int64     `gorm:"column:pay_trans_id;type:bigint(20)" json:"pay_trans_id"`                  // 交易id
+}
+
+func (m *ActiveAccountLog) TableName() string {
+	return "active_account_log"
+}

+ 10 - 10
models/shanghu/active.pay.callback.log.go

@@ -6,16 +6,16 @@ import (
 )
 
 type ActivePayCallbackLog struct {
-	ID           int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`
-	CallBackLog  string    `gorm:"column:call_back_log;type:text" json:"call_back_log"`
-	ErrLog       string    `gorm:"column:err_log;type:varchar(255)" json:"err_log"`               // 处理失败原因
-	OutTradeNo   string    `gorm:"column:out_trade_no;type:varchar(255)" json:"out_trade_no"`     // 交易id
-	ThirdTradeNo string    `gorm:"column:third_trade_no;type:varchar(255)" json:"third_trade_no"` // 微信交易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)" json:"deleted_at"`          // 删除时间
+	ID           int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`    //
+	CallBackLog  string    `gorm:"column:call_back_log;type:text" json:"call_back_log"`               //
+	ErrLog       string    `gorm:"column:err_log;type:varchar(255)" json:"err_log"`                   // 处理失败原因
+	OutTradeNo   string    `gorm:"column:out_trade_no;type:varchar(255)" json:"out_trade_no"`         // 交易id
+	ThirdTradeNo string    `gorm:"column:third_trade_no;type:varchar(255)" json:"third_trade_no"`     // 微信交易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 *ActivePayCallbackLog) TableName() string {

+ 20 - 0
models/shanghu/actvie.client.account.go

@@ -0,0 +1,20 @@
+package shanghu
+
+import "time"
+
+type ActiveClientAccount 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"`     //
+	ReviewAmount string    `gorm:"column:review_amount;type:decimal(10,2)" json:"review_amount"`      // 待核销金额
+	Version      int       `gorm:"column:version;type:int(11)" json:"version"`                        // Version
+	Amount       string    `gorm:"column:amount;type:decimal(10,2)" json:"amount"`                    // 可提现金额
+	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 *ActiveClientAccount) TableName() string {
+	return "active_client_account"
+}