فهرست منبع

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

k.zhang 1 ماه پیش
والد
کامیت
6176323ad9
4فایلهای تغییر یافته به همراه30 افزوده شده و 8 حذف شده
  1. 7 1
      apis/shanghu/active.pay.go
  2. 3 3
      apis/shanghu/base.go
  3. 1 1
      models/shanghu/active.account.log.go
  4. 19 3
      models/shanghu/merchant.account.go

+ 7 - 1
apis/shanghu/active.pay.go

@@ -8,6 +8,7 @@ import (
 	"encoding/base64"
 	"encoding/json"
 	"errors"
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/skip2/go-qrcode"
 	"time"
@@ -345,10 +346,14 @@ func GroupBuyCancel(c *gin.Context) {
 			return
 		}
 
+		activeCancel.ClientOpenID = transInfo.ClientOpenID
+		activeCancel.ActiveConfigID = transInfo.ActiveConfigID
+
 		cancelNum := activeCancel.GetActiveCancelNum()
+		fmt.Println("cancelNum = ", cancelNum)
 		if projectInfo.CancelNum >= cancelNum+v.CancelNum && v.CancelNum > 0 {
 			isCancel = true
-			for i := 0; i < projectInfo.CancelNum; i++ {
+			for i := 0; i < v.CancelNum; i++ {
 				var activeCancelLogInfo shanghu.ActiveCancelLog
 				activeCancelLogInfo.ActiveConfigID = transInfo.ActiveConfigID
 				activeCancelLogInfo.ClientOpenID = transInfo.ClientOpenID
@@ -379,6 +384,7 @@ func GroupBuyCancel(c *gin.Context) {
 		}
 	} else { // 需要分账
 		// 分账中
+		fmt.Println("分账中...")
 		payTrans.ID = transInfo.ID
 		payTrans.AccountStatus = shanghu.ClientActivePayTransAccountStatusSettlePending
 		err = payTrans.UpdateAccountStatusByID()

+ 3 - 3
apis/shanghu/base.go

@@ -97,9 +97,9 @@ func InitShangHuRouter(engine *gin.RouterGroup) {
 		activeV1.POST("/active/group.buy.cancel/info", GroupBuyCancelInfo)  //核销详情
 		activeV1.POST("/active/group.buy/code", GroupBuyPayCode)            //拼团核销码
 		activeV1.POST("/active/group.buy/pay", GetGroupBuyPayList)          //购买拼团列表
-		//提现
-		activeV1.POST("/active/draw/count", ActiveDrawCount)  //邀请客户数量统计
-		activeV1.POST("/client/user/info", GetActiveUserInfo) //client 用户信息
+		activeV1.POST("/active/draw/count", ActiveDrawCount)                //邀请客户数量统计
+		activeV1.POST("/client/user/info", GetActiveUserInfo)               //client 用户信息
+		//c端提现
 
 	}
 }

+ 1 - 1
models/shanghu/active.account.log.go

@@ -17,7 +17,7 @@ type ActiveClientAccountLog struct {
 	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"`                     // 删除时间
+	DeletedAt         time.Time       `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"`        // 删除时间
 	Amount            decimal.Decimal `gorm:"column:amount;type:decimal(10,2)" json:"amount"`                           // 交易金额
 	PayTransID        int64           `gorm:"column:pay_trans_id;type:bigint(20)" json:"pay_trans_id"`                  // 交易id
 }

+ 19 - 3
models/shanghu/merchant.account.go

@@ -3,6 +3,7 @@ package shanghu
 import (
 	orm "duoduo/database"
 	"errors"
+	"fmt"
 	"github.com/shopspring/decimal"
 	"time"
 )
@@ -56,6 +57,21 @@ func (m *MerchantAccount) ActiveCancelSettle(log []ActiveCancelLog, merchantAcco
 	var err error
 	var merchantAccountLog MerchantAccountLog
 	var clientAccountLog ActiveClientAccountLog
+	fmt.Println("merchantAccount =", merchantAccount)
+	fmt.Println("activeClientAccount =", activeClientAccount)
+
+	err = orm.ShMysql.Table("merchant_account").Select("*").Where("merchant_open_id = ?", merchantAccount.MerchantOpenID).First(&merchantAccount).Error
+	if err != nil {
+		return err
+	}
+
+	err = orm.ShMysql.Table("active_client_account").Select("*").Where("client_open_id = ?", activeClientAccount.ClientOpenID).First(&activeClientAccount).Error
+	if err != nil {
+		return err
+	}
+
+	fmt.Println("merchantAccount =", merchantAccount)
+	fmt.Println("activeClientAccount =", activeClientAccount)
 
 	tx := orm.ShMysql.Begin()
 	defer func() {
@@ -112,9 +128,9 @@ func (m *MerchantAccount) ActiveCancelSettle(log []ActiveCancelLog, merchantAcco
 	//}
 
 	// 客户加款
-	if activeClientAccount.ID > 0 {
+	if payTrans.InvitationCode != YuanShiMa && payTrans.InvitationCode != "" {
 		clientAmountAdd := activeClientAccount.Amount.Add(payTrans.ClientAmount)
-		clientResult := tx.Table("active_client_account").Model(&activeClientAccount).Where("client_open_id = ? and version = ?", merchantAccount.MerchantOpenID, merchantAccount.Version).Updates(
+		clientResult := tx.Table("active_client_account").Model(&activeClientAccount).Where("client_open_id = ? and version = ?", activeClientAccount.ClientOpenID, activeClientAccount.Version).Updates(
 			map[string]interface{}{
 				"amount":     clientAmountAdd,
 				"version":    activeClientAccount.Version + 1,
@@ -138,7 +154,7 @@ func (m *MerchantAccount) ActiveCancelSettle(log []ActiveCancelLog, merchantAcco
 		clientAccountLog.Amount = payTrans.ClientAmount
 		clientAccountLog.PayTransID = payTrans.ID
 		clientAccountLog.TransType = ActiveClientAccountLogTransTypeGroupBuy
-		err = tx.Table("merchant_account_log").Create(&merchantAccountLog).Error
+		err = tx.Table("active_client_account_log").Create(&clientAccountLog).Error
 		if err != nil {
 			return err
 		}