feat-IRONFANS-32-20240125-Robin #79
|
@ -1685,7 +1685,7 @@ func (v *Vas) AlipayCallback(ctx *gin.Context, p *vasproto.AlipayCallbackParamIn
|
||||||
}
|
}
|
||||||
case product.Id == dbstruct.ProductIdMembership:
|
case product.Id == dbstruct.ProductIdMembership:
|
||||||
// 解锁会员资格
|
// 解锁会员资格
|
||||||
_, err = v.UnlockMembership(ctx, util.DerefInt64(order.Mid), product, order)
|
_, err = v.UnlockMembership(ctx, util.DerefInt64(order.Mid), product, order, wallet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("UnlockMembership fail, order: %v", util.ToJson(order))
|
logger.Error("UnlockMembership fail, order: %v", util.ToJson(order))
|
||||||
return
|
return
|
||||||
|
@ -2037,12 +2037,13 @@ func (v *Vas) DealOneCoinOrder(ctx *gin.Context, coinOrderId string) (err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解锁会员资格
|
// 解锁会员资格
|
||||||
func (v *Vas) UnlockMembership(ctx *gin.Context, mid int64, product *dbstruct.Product, order *dbstruct.Order) (orderId string, err error) {
|
func (v *Vas) UnlockMembership(ctx *gin.Context, mid int64, product *dbstruct.Product, order *dbstruct.Order, wallet *dbstruct.Wallet) (orderId string, err error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
did = util.DerefString(order.Did)
|
did = util.DerefString(order.Did)
|
||||||
productId = product.Id
|
productId = product.Id
|
||||||
timeNow = time.Now().Unix()
|
timeNow = time.Now().Unix()
|
||||||
|
coinPrice = order.GetCoins()
|
||||||
)
|
)
|
||||||
orderId = util.DerefString(order.ID)
|
orderId = util.DerefString(order.ID)
|
||||||
|
|
||||||
|
@ -2078,6 +2079,26 @@ func (v *Vas) UnlockMembership(ctx *gin.Context, mid int64, product *dbstruct.Pr
|
||||||
inviterWallet, _ = v.CheckWalletExist(ctx, inviterMid)
|
inviterWallet, _ = v.CheckWalletExist(ctx, inviterMid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 增加金币消费历史(伪记录,仅为对账平插入一条消费流水)
|
||||||
|
ch := &dbstruct.ConsumeHistory{
|
||||||
|
Mid: goproto.Int64(mid),
|
||||||
|
Uid: goproto.Int64(mid),
|
||||||
|
Did: goproto.String(did),
|
||||||
|
Type: goproto.Int32(dbstruct.CHTypeCost),
|
||||||
|
SType: goproto.Int32(dbstruct.CHSTypeCostMembership),
|
||||||
|
TypeId: goproto.String(productId),
|
||||||
|
OrderId: goproto.String(orderId),
|
||||||
|
Change: goproto.Int64(-coinPrice),
|
||||||
|
Before: goproto.Int64(util.DerefInt64(wallet.Coins)),
|
||||||
|
After: goproto.Int64(util.DerefInt64(wallet.Coins) - coinPrice),
|
||||||
|
Ct: goproto.Int64(timeNow),
|
||||||
|
}
|
||||||
|
err = v.store.CreateConsumeHistory(ctx, tx, ch)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("CreateConsumeHistory fail, ch: %v, err: %v", util.ToJson(ch), err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 解锁记录
|
// 解锁记录
|
||||||
userVasMembershipUnlock := &dbstruct.UserVasMembershipUnlock{
|
userVasMembershipUnlock := &dbstruct.UserVasMembershipUnlock{
|
||||||
Mid: goproto.Int64(mid),
|
Mid: goproto.Int64(mid),
|
||||||
|
|
|
@ -3,7 +3,6 @@ package service
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"service/api/errcode"
|
"service/api/errcode"
|
||||||
"service/api/errs"
|
"service/api/errs"
|
||||||
vasproto "service/api/proto/vas/proto"
|
vasproto "service/api/proto/vas/proto"
|
||||||
|
@ -12,6 +11,8 @@ import (
|
||||||
"service/dbstruct"
|
"service/dbstruct"
|
||||||
"service/library/logger"
|
"service/library/logger"
|
||||||
"service/library/mycrypto"
|
"service/library/mycrypto"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 一键解锁
|
// 一键解锁
|
||||||
|
@ -248,6 +249,12 @@ func (s *Service) chListCost(ctx *gin.Context, chList []*dbstruct.ConsumeHistory
|
||||||
case dbstruct.CHSTypeCostRefund:
|
case dbstruct.CHSTypeCostRefund:
|
||||||
item.Desc = fmt.Sprintf("购买\"%s\"微信退款", util.DerefString(acnt.Name))
|
item.Desc = fmt.Sprintf("购买\"%s\"微信退款", util.DerefString(acnt.Name))
|
||||||
item.Change = changeMark + fmt.Sprintf("%d金币", chDB.GetChange())
|
item.Change = changeMark + fmt.Sprintf("%d金币", chDB.GetChange())
|
||||||
|
case dbstruct.CHSTypeCostMembership:
|
||||||
|
item.Desc = "购买会员"
|
||||||
|
item.Change = changeMark + fmt.Sprintf("%d金币", chDB.GetChange())
|
||||||
|
if chDB.GetChange() < 0 {
|
||||||
|
item.Change = fmt.Sprintf("%d金币", chDB.GetChange())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
list = append(list, item)
|
list = append(list, item)
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,8 +490,9 @@ const (
|
||||||
CHTypeIncome = 3 // 收入明细(钻石)
|
CHTypeIncome = 3 // 收入明细(钻石)
|
||||||
CHTypeWithdraw = 4 // 提现明细(钻石)
|
CHTypeWithdraw = 4 // 提现明细(钻石)
|
||||||
|
|
||||||
CHSTypeCostContact = 10001 // 消费明细,联系方式
|
CHSTypeCostContact = 10001 // 消费明细,联系方式
|
||||||
CHSTypeCostRefund = 10002 // 消费明细,金币退款
|
CHSTypeCostRefund = 10002 // 消费明细,金币退款
|
||||||
|
CHSTypeCostMembership = 10003 // 消费明细,会员资格解锁(伪金币记录,会员资格解锁中间无转金币过程)
|
||||||
|
|
||||||
CHSTypeChargeUser = 20001 // 充值明细,用户自己冲
|
CHSTypeChargeUser = 20001 // 充值明细,用户自己冲
|
||||||
CHSTypeChargeOp = 20002 // 充值明细,OP充值
|
CHSTypeChargeOp = 20002 // 充值明细,OP充值
|
||||||
|
|
Loading…
Reference in New Issue