Merge branch 'main' of http://121.196.202.62:3000/wishpal_ironfan/service
This commit is contained in:
commit
4d560e5637
|
@ -4,19 +4,20 @@ import "service/dbstruct"
|
|||
|
||||
// 查询自己返回的实体
|
||||
type ApiListVO struct {
|
||||
Mid *int64 `json:"mid" bson:"_id"` // 用户表Id
|
||||
Name *string `json:"name" bson:"name"` // 用户名
|
||||
UserId *int64 `json:"user_id" bson:"user_id"` // 业务Id
|
||||
Avatar *dbstruct.MediaComponent `json:"avatar" bson:"avatar"` // 头像
|
||||
Level *int64 `json:"level" bson:"level"` // 等级
|
||||
Role *int64 `json:"role" bson:"role"` // 角色
|
||||
CurrentExp *int64 `json:"current_exp" bson:"current_exp"` // 当前经验
|
||||
CurrentLevelExp *int64 `json:"current_level_exp" bson:"current_level_exp"` // 当前等级总经验
|
||||
IsDndModeEnabled *int64 `json:"is_dnd_mode_enabled" bson:"is_dnd_mode_enabled"` // 是否开启勿扰模式
|
||||
GoldNum *int64 `json:"gold_num" bson:"gold_num"` // 金币数量
|
||||
DiamondNum *int64 `json:"diamond_num" bson:"diamond_num"` // 钻石数量
|
||||
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
|
||||
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
|
||||
Mid *int64 `json:"mid" bson:"_id"` // 用户表Id
|
||||
Name *string `json:"name" bson:"name"` // 用户名
|
||||
UserId *int64 `json:"user_id" bson:"user_id"` // 业务Id
|
||||
Avatar *dbstruct.MediaComponent `json:"avatar" bson:"avatar"` // 头像
|
||||
Level *int64 `json:"level" bson:"level"` // 等级
|
||||
Role *int64 `json:"role" bson:"role"` // 角色
|
||||
CurrentExp *int64 `json:"current_exp" bson:"current_exp"` // 当前经验
|
||||
CurrentLevelExp *int64 `json:"current_level_exp" bson:"current_level_exp"` // 当前等级总经验
|
||||
IsDndModeEnabled *int64 `json:"is_dnd_mode_enabled" bson:"is_dnd_mode_enabled"` // 是否开启勿扰模式
|
||||
GoldNum *int64 `json:"gold_num" bson:"gold_num"` // 金币数量
|
||||
DiamondNum *int64 `json:"diamond_num" bson:"diamond_num"` // 钻石数量
|
||||
WithdrawDiamondNum *int64 `json:"withdraw_diamond_num" bson:"withdraw_diamond_num"` // 提现钻石数量
|
||||
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
|
||||
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
|
||||
}
|
||||
|
||||
// 查询别人返回的实体
|
||||
|
@ -46,6 +47,13 @@ func (vo *ApiListVO) CopyAccount(account *dbstruct.Account) *ApiListVO {
|
|||
return vo
|
||||
}
|
||||
|
||||
func (vo *ApiListVO) CopyWallet(wallet *dbstruct.Wallet) *ApiListVO {
|
||||
vo.GoldNum = wallet.Coins
|
||||
vo.DiamondNum = wallet.Diamonds
|
||||
vo.WithdrawDiamondNum = wallet.WithdrawDiamonds
|
||||
return vo
|
||||
}
|
||||
|
||||
func (vo *ApiListOthersVO) CopyAccount(account *dbstruct.Account) *ApiListOthersVO {
|
||||
vo.Mid = account.Mid
|
||||
vo.Name = account.Name
|
||||
|
|
|
@ -116,8 +116,14 @@ type QueryWechatData struct {
|
|||
// h5直接解锁微信
|
||||
type H5DirectUnlockWechatReq struct {
|
||||
base.BaseRequest
|
||||
Uid int64 `json:"uid"` // 主播id
|
||||
PayType string `json:"pay_type"` // 支付类型
|
||||
Uid int64 `json:"uid"` // 主播id
|
||||
PayType string `json:"pay_type"` // 支付类型
|
||||
InviterMid int64
|
||||
}
|
||||
|
||||
type H5DirectUnlockWechatData CreateOrderData
|
||||
type H5DirectUnlockWechatData struct {
|
||||
CoinEnough int `json:"coin_enough"` // 0:不够(用下面的支付宝参数),1:够
|
||||
OrderId string `json:"order_id"` // 订单id
|
||||
AlipayParamStr string `json:"alipay_param_str"` // 支付宝 app支付参数
|
||||
AlipayH5ParamStr string `json:"alipay_h5_param_str"` // 支付宝 h5支付参数
|
||||
}
|
||||
|
|
|
@ -372,6 +372,8 @@ func (s *Service) ApiGetAccountListByMid(ctx *gin.Context, req *accountproto.Api
|
|||
vo = &accountproto.ApiListVO{}
|
||||
vo.CopyAccount(account)
|
||||
|
||||
wallet, _ := _DefaultVas.CheckWalletExist(ctx, util.DerefInt64(req.Mid))
|
||||
vo.CopyWallet(wallet)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -656,6 +656,11 @@ func (v *Vas) OneStepUnlockContact(ctx *gin.Context, req *vasproto.OneStepUnlock
|
|||
return
|
||||
}
|
||||
|
||||
v.CheckWalletExist(ctx, common.OfficialMid)
|
||||
if req.InviterMid > 0 {
|
||||
v.CheckWalletExist(ctx, req.InviterMid)
|
||||
}
|
||||
|
||||
// 是否已经解锁过
|
||||
unlockInfo, _ := v.store.GetUserVasUnlock(ctx, nil, mid, uid, contactProductId)
|
||||
if unlockInfo != nil {
|
||||
|
@ -828,6 +833,36 @@ func (v *Vas) OneStepUnlockContact(ctx *gin.Context, req *vasproto.OneStepUnlock
|
|||
logger.Error("DecCoins fail, mid: %v, coinPrice: %v, err: %v", req.Mid, coinPrice, err)
|
||||
return
|
||||
}
|
||||
|
||||
// 给主播加钻石
|
||||
var (
|
||||
TotalDias = coinPrice
|
||||
StreamerDias = int64(float64(TotalDias) * 0.8)
|
||||
InviterDias = int64(0)
|
||||
OfficialDias = int64(0)
|
||||
)
|
||||
if req.InviterMid > 0 {
|
||||
InviterDias = int64(float64(TotalDias) * 0.05)
|
||||
}
|
||||
OfficialDias = TotalDias - StreamerDias - InviterDias
|
||||
|
||||
err = v.store.IncDiamonds(ctx, tx, req.Uid, StreamerDias)
|
||||
if err != nil {
|
||||
logger.Error("IncDiamonds fail, streamer, mid: %v, dias: %v, err: %v", req.Uid, StreamerDias, err)
|
||||
return
|
||||
}
|
||||
err = v.store.IncDiamonds(ctx, tx, common.OfficialMid, OfficialDias)
|
||||
if err != nil {
|
||||
logger.Error("IncDiamonds fail, official, mid: %v, dias: %v, err: %v", common.OfficialMid, OfficialDias, err)
|
||||
return
|
||||
}
|
||||
if InviterDias > 0 {
|
||||
err = v.store.IncDiamonds(ctx, tx, req.InviterMid, InviterDias)
|
||||
if err != nil {
|
||||
logger.Error("IncDiamonds fail, inviter, mid: %v, dias: %v, err: %v", req.InviterMid, InviterDias, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1314,6 +1349,20 @@ func (v *Vas) H5DirectUnlockWechat(ctx *gin.Context, req *vasproto.H5DirectUnloc
|
|||
return
|
||||
}
|
||||
|
||||
// 检查钱包
|
||||
wallet, _ := v.CheckWalletExist(ctx, req.Mid)
|
||||
|
||||
// 金币够不够
|
||||
if wallet.GetCoins() >= uVas.GetH5WechatCoinPrice() {
|
||||
v.OneStepUnlockContact(ctx, &vasproto.OneStepUnlockContactReq{
|
||||
BaseRequest: req.BaseRequest,
|
||||
ContactProductId: dbstruct.ProductIdH5ContactWechat,
|
||||
Uid: req.Uid,
|
||||
InviterMid: req.InviterMid,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 创建订单
|
||||
cData, err := v.CreateOrder(ctx, &vasproto.CreateOrderReq{
|
||||
BaseRequest: req.BaseRequest,
|
||||
|
|
|
@ -13,6 +13,8 @@ import (
|
|||
|
||||
// 一键解锁
|
||||
func (s *Service) OneStepUnlockContact(ctx *gin.Context, req *vasproto.OneStepUnlockContactReq) (data *vasproto.OneStepUnlockContactData, ec errcode.ErrCode) {
|
||||
// 获取邀请人mid
|
||||
|
||||
lockType, orderId, contact, err := _DefaultVas.OneStepUnlockContact(ctx, req)
|
||||
ec, err = errs.DealVasErr(err)
|
||||
if err != nil {
|
||||
|
@ -222,6 +224,9 @@ func (s *Service) chListCost(ctx *gin.Context, chList []*dbstruct.ConsumeHistory
|
|||
case dbstruct.CHSTypeCostContact:
|
||||
item.Desc = fmt.Sprintf("购买\"%s\"微信", util.DerefString(acnt.Name))
|
||||
item.Change = changeMark + fmt.Sprintf("%d金币", chDB.GetChange())
|
||||
if chDB.GetChange() < 0 {
|
||||
item.Change = fmt.Sprintf("%d金币", chDB.GetChange())
|
||||
}
|
||||
case dbstruct.CHSTypeCostRefund:
|
||||
item.Desc = fmt.Sprintf("购买\"%s\"微信退款", util.DerefString(acnt.Name))
|
||||
item.Change = changeMark + fmt.Sprintf("%d金币", chDB.GetChange())
|
||||
|
@ -247,7 +252,7 @@ func (s *Service) chListCharge(ctx *gin.Context, chList []*dbstruct.ConsumeHisto
|
|||
item.Desc = "充值"
|
||||
item.Change = changeMark + fmt.Sprintf("%d金币", chDB.GetChange())
|
||||
case dbstruct.CHSTypeChargeOp:
|
||||
item.Desc = "后台充值"
|
||||
item.Desc = "运营充值"
|
||||
item.Change = changeMark + fmt.Sprintf("%d金币", chDB.GetChange())
|
||||
case dbstruct.CHSTypeChargeRefund:
|
||||
item.Desc = "退款"
|
||||
|
|
|
@ -7,5 +7,5 @@ const (
|
|||
)
|
||||
|
||||
const (
|
||||
OfficialMid = 10
|
||||
OfficialMid = -1
|
||||
)
|
||||
|
|
|
@ -39,7 +39,7 @@ CREATE TABLE `vas_wallet`
|
|||
);
|
||||
|
||||
-- vas_ch_cost、vas_ch_charge、vas_ch_income、vas_ch_withdraw
|
||||
CREATE TABLE `vas_ch_withdraw`
|
||||
CREATE TABLE `vas_ch_income`
|
||||
(
|
||||
`id` bigint AUTO_INCREMENT COMMENT 'id',
|
||||
`mid` bigint NOT NULL COMMENT '用户id',
|
||||
|
|
|
@ -22,7 +22,7 @@ mix_mongo:
|
|||
mix_mysql:
|
||||
uri: "127.0.0.1:3306"
|
||||
username: "root"
|
||||
password: "11111111"
|
||||
password: "Wishpal@2023"
|
||||
timeout: 3
|
||||
read_timeout_s: 5
|
||||
write_timeout_s: 3
|
||||
|
|
Loading…
Reference in New Issue