|
@@ -0,0 +1,415 @@ |
|
|
|
|
|
package svc |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
|
db2 "applet/app/db" |
|
|
|
|
|
"applet/app/db/model" |
|
|
|
|
|
"applet/app/utils" |
|
|
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/lib/comm_plan" |
|
|
|
|
|
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" |
|
|
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule" |
|
|
|
|
|
svc2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/svc" |
|
|
|
|
|
"fmt" |
|
|
|
|
|
"github.com/jinzhu/copier" |
|
|
|
|
|
"time" |
|
|
|
|
|
"xorm.io/xorm" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func GetLvUser(engine *xorm.Engine, CommissionParam md2.CommissionFirstParam, oid int64, masterId string, mapData map[string]string) { |
|
|
|
|
|
commArr := rule.GetComm(engine) |
|
|
|
|
|
plan, commission, virtualCoinMoneyRate := svc2.GetAllPlan(engine, masterId) |
|
|
|
|
|
var CommissionParam1 md2.CommissionParam |
|
|
|
|
|
comm := CommissionParam.CommissionParam |
|
|
|
|
|
err2 := copier.Copy(&CommissionParam1, &comm) |
|
|
|
|
|
fmt.Println(err2) |
|
|
|
|
|
_, _, _, _, lvUser, err := svc2.GetRewardCommission(engine, &CommissionParam1, false, CommissionParam.Uid, CommissionParam.Provider, masterId, true, mapData, commArr, plan, commission, virtualCoinMoneyRate) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CommOrderRelateInsert(engine, oid, CommissionParam.Provider, int(time.Now().Unix()), lvUser, mapData) |
|
|
|
|
|
sql := `SELECT id from user_virtual_coin_flow where ord_id='%d'` |
|
|
|
|
|
sql = fmt.Sprintf(sql, oid) |
|
|
|
|
|
nativeString, _ := db2.QueryNativeString(engine, sql) |
|
|
|
|
|
has := false |
|
|
|
|
|
if len(nativeString) > 0 && utils.StrToInt(nativeString[0]["id"]) > 0 { |
|
|
|
|
|
has = true |
|
|
|
|
|
} |
|
|
|
|
|
sql1 := `SELECT id from fin_user_flow where ord_id='%d'` |
|
|
|
|
|
sql1 = fmt.Sprintf(sql1, oid) |
|
|
|
|
|
nativeString1, _ := db2.QueryNativeString(engine, sql1) |
|
|
|
|
|
has1 := false |
|
|
|
|
|
if len(nativeString1) > 0 && utils.StrToInt(nativeString1[0]["id"]) > 0 { |
|
|
|
|
|
has1 = true |
|
|
|
|
|
} |
|
|
|
|
|
fmt.Println("===========任务4=============", masterId, CommissionParam.Uid, oid, has, has1) |
|
|
|
|
|
if has == false && has1 == false { |
|
|
|
|
|
fmt.Println("===========任务5=============", masterId, CommissionParam.Uid, oid, has, has1) |
|
|
|
|
|
SettleDone(engine, CommissionParam.Provider, oid, masterId, mapData) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 分佣表插入获取到的数据 |
|
|
|
|
|
func CommOrderRelateInsert(eg *xorm.Engine, oid int64, pvd string, createTime int, lvUser *comm_plan.LvUser, mapData map[string]string) { |
|
|
|
|
|
level := 0 |
|
|
|
|
|
oldLevel := 0 |
|
|
|
|
|
fmt.Println(lvUser) |
|
|
|
|
|
profit := utils.FloatFormat(lvUser.Profit+lvUser.SubsidyFee, 6) |
|
|
|
|
|
oldLvUser := lvUser |
|
|
|
|
|
data := []*model.TaskOrdListRelate{ |
|
|
|
|
|
{ |
|
|
|
|
|
Oid: oid, |
|
|
|
|
|
Uid: lvUser.Uid, |
|
|
|
|
|
Amount: profit, |
|
|
|
|
|
Pvd: pvd, |
|
|
|
|
|
CreateAt: createTime, |
|
|
|
|
|
Level: level, |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
|
|
|
mode := mapData["mode"] |
|
|
|
|
|
for lvUser.ParentUser != nil { |
|
|
|
|
|
lvUser = lvUser.ParentUser |
|
|
|
|
|
if lvUser.Uid == 0 { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
fmt.Println(lvUser) |
|
|
|
|
|
level = level + 1 |
|
|
|
|
|
profit = utils.FloatFormat(lvUser.Profit+lvUser.SubsidyFee, 6) |
|
|
|
|
|
var additionalSubsidy float64 = 0 |
|
|
|
|
|
if utils.InArr(mode, []string{"lv_winery", "public_platoon"}) { |
|
|
|
|
|
profit = utils.FloatFormat(lvUser.Profit, 6) |
|
|
|
|
|
additionalSubsidy = lvUser.SubsidyFee |
|
|
|
|
|
} |
|
|
|
|
|
data = append(data, &model.TaskOrdListRelate{ |
|
|
|
|
|
Oid: oid, |
|
|
|
|
|
Uid: lvUser.Uid, |
|
|
|
|
|
Amount: profit, |
|
|
|
|
|
Pvd: pvd, |
|
|
|
|
|
CreateAt: createTime, |
|
|
|
|
|
Level: level, |
|
|
|
|
|
Mode: mode, |
|
|
|
|
|
AdditionalSubsidy: utils.Float64ToStrByPrec(additionalSubsidy, 9), |
|
|
|
|
|
ExtendType: lvUser.ExtendType, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
for _, v := range data { |
|
|
|
|
|
if utils.StrToInt(mapData["coin_id_type"]) > 0 { |
|
|
|
|
|
v.Amount = 0 |
|
|
|
|
|
v.Info = "任务没佣金设置,不返佣金" |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
err1 := db2.DbInsertBatch(eg, data) |
|
|
|
|
|
if err1 != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} else { |
|
|
|
|
|
// 插入虚拟币数据 |
|
|
|
|
|
vcrData := CommCombineVirtualCoinRelateData(oldLvUser, oid, pvd, oldLevel, mapData["mode"]) |
|
|
|
|
|
err2 := db2.DbInsertBatch(eg, vcrData) |
|
|
|
|
|
for _, item := range vcrData { |
|
|
|
|
|
fmt.Println(item) |
|
|
|
|
|
} |
|
|
|
|
|
if err2 != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
func ConvertList2Map(a []*comm_plan.VirtualCoinCommission) (b map[string]float64) { |
|
|
|
|
|
b = make(map[string]float64) |
|
|
|
|
|
for _, i := range a { |
|
|
|
|
|
b[i.Cid] = i.Val |
|
|
|
|
|
} |
|
|
|
|
|
return b |
|
|
|
|
|
} |
|
|
|
|
|
func CommCombineVirtualCoinRelateData(lvUser *comm_plan.LvUser, oid int64, pvd string, level int, mode string) []*model.VirtualCoinRelate { |
|
|
|
|
|
var data []*model.VirtualCoinRelate |
|
|
|
|
|
//可能没有极差返利 只有补贴 |
|
|
|
|
|
profitList := lvUser.ProfitList |
|
|
|
|
|
if len(profitList) == 0 { |
|
|
|
|
|
profitList = lvUser.SubsidyFeeList |
|
|
|
|
|
} |
|
|
|
|
|
if profitList != nil { |
|
|
|
|
|
var subsidyFeeList map[string]float64 |
|
|
|
|
|
if lvUser.SubsidyFeeList != nil && len(lvUser.ProfitList) > 0 { |
|
|
|
|
|
subsidyFeeList = ConvertList2Map(lvUser.SubsidyFeeList) |
|
|
|
|
|
} |
|
|
|
|
|
var coinList = make([]string, 0) |
|
|
|
|
|
for _, v := range profitList { |
|
|
|
|
|
coinList = append(coinList, v.Cid) |
|
|
|
|
|
} |
|
|
|
|
|
if utils.InArr(mode, []string{"lv_winery", "public_platoon"}) && lvUser.SubsidyFeeList != nil { //补贴类型 没有的要补上 |
|
|
|
|
|
subsidyFeeList = ConvertList2Map(lvUser.SubsidyFeeList) |
|
|
|
|
|
for _, v := range lvUser.SubsidyFeeList { |
|
|
|
|
|
if utils.InArr(v.Cid, coinList) == false && v.Val > 0 { |
|
|
|
|
|
v.Val = 0 |
|
|
|
|
|
profitList = append(profitList, v) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
for _, item := range profitList { |
|
|
|
|
|
|
|
|
|
|
|
if lvUser.Uid == 0 { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
if item.Cid != "0" && item.Cid != "commission" { |
|
|
|
|
|
//加上补贴 |
|
|
|
|
|
subsidyFee := subsidyFeeList[item.Cid] |
|
|
|
|
|
var additionalSubsidy float64 = 0 |
|
|
|
|
|
profit := utils.Float64ToStrByPrec(item.Val+subsidyFee, 9) |
|
|
|
|
|
if utils.InArr(mode, []string{"lv_winery", "public_platoon"}) { |
|
|
|
|
|
profit = utils.Float64ToStrByPrec(item.Val, 9) |
|
|
|
|
|
additionalSubsidy = subsidyFee |
|
|
|
|
|
} |
|
|
|
|
|
if mode == "public_platoon" && level > 1 { |
|
|
|
|
|
profit = "0" |
|
|
|
|
|
} |
|
|
|
|
|
var virtualCoinRelate = &model.VirtualCoinRelate{ |
|
|
|
|
|
Oid: oid, |
|
|
|
|
|
Uid: lvUser.Uid, |
|
|
|
|
|
CoinId: utils.StrToInt(item.Cid), |
|
|
|
|
|
Amount: profit, |
|
|
|
|
|
Pvd: pvd, |
|
|
|
|
|
CreateAt: int(time.Now().Unix()), |
|
|
|
|
|
Level: level, |
|
|
|
|
|
Mode: mode, |
|
|
|
|
|
AdditionalSubsidy: utils.Float64ToStrByPrec(additionalSubsidy, 6), |
|
|
|
|
|
ExtendType: lvUser.ExtendType, |
|
|
|
|
|
} |
|
|
|
|
|
data = append(data, virtualCoinRelate) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if lvUser.ParentUser != nil { |
|
|
|
|
|
level += 1 |
|
|
|
|
|
data = append(data, CommCombineVirtualCoinRelateData(lvUser.ParentUser, oid, pvd, level, mode)...) |
|
|
|
|
|
} |
|
|
|
|
|
return data |
|
|
|
|
|
} |
|
|
|
|
|
func SettleDone(eg *xorm.Engine, pvd string, oid int64, masterId string, mapData map[string]string) bool { |
|
|
|
|
|
fmt.Println("=======================任务=============", masterId, oid, pvd) |
|
|
|
|
|
ol, err := db2.TaskOrderRelateListByOid(eg, oid, pvd) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
// 查询虚拟币 virtual_coin_relate 表 |
|
|
|
|
|
vcrList, err := db2.GetVirtualCoinRelateListWithOrdId(eg, oid, pvd) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
session := eg.NewSession() |
|
|
|
|
|
defer session.Close() |
|
|
|
|
|
if err := session.Begin(); err != nil { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
set, _ := db2.SysCfgGetOne(eg, "app_name_cn") |
|
|
|
|
|
var appName = "" |
|
|
|
|
|
if set != nil { |
|
|
|
|
|
appName = set.Val |
|
|
|
|
|
} |
|
|
|
|
|
for _, item := range ol { |
|
|
|
|
|
//佣金不为空 |
|
|
|
|
|
if item.Amount > 0 { |
|
|
|
|
|
//公排 |
|
|
|
|
|
if utils.InArr(item.Mode, []string{"lv_commission_public_platoon", "lv_price_public_platoon"}) && item.ExtendType == 5 { |
|
|
|
|
|
fmt.Println("======================555") |
|
|
|
|
|
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(oid), item.Uid, 0, item.Amount) |
|
|
|
|
|
fmt.Println("======================666", bools) |
|
|
|
|
|
if bools == false { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
_ = CommSettleMoney(session, item, appName, masterId) |
|
|
|
|
|
} |
|
|
|
|
|
if utils.StrToFloat64(item.AdditionalSubsidy) > 0 { |
|
|
|
|
|
if item.Mode == "public_platoon" { //公排 |
|
|
|
|
|
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(oid), item.Uid, 0, utils.StrToFloat64(item.AdditionalSubsidy)) |
|
|
|
|
|
if bools == false { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 虚拟币相关操作 |
|
|
|
|
|
for _, item := range vcrList { |
|
|
|
|
|
if utils.StrToFloat64(item.Amount) > 0 { |
|
|
|
|
|
if utils.InArr(item.Mode, []string{"lv_commission_public_platoon", "lv_price_public_platoon"}) && item.ExtendType == 5 { |
|
|
|
|
|
fmt.Println("======================555") |
|
|
|
|
|
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(oid), item.Uid, item.CoinId, utils.StrToFloat64(item.Amount)) |
|
|
|
|
|
fmt.Println("======================666", bools) |
|
|
|
|
|
if bools == false { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
_ = CommSettleVirtualCoin(session, item) |
|
|
|
|
|
} |
|
|
|
|
|
//公排 |
|
|
|
|
|
if item.Mode == "public_platoon" && utils.StrToFloat64(item.AdditionalSubsidy) > 0 { |
|
|
|
|
|
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(oid), item.Uid, item.CoinId, utils.StrToFloat64(item.AdditionalSubsidy)) |
|
|
|
|
|
if bools == false { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 提交事务 |
|
|
|
|
|
err = session.Commit() |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
func CommSettleMoney(session *xorm.Session, item *model.TaskOrdListRelate, appName, masterId string) bool { |
|
|
|
|
|
now := time.Now() |
|
|
|
|
|
beforeAmount := "0" |
|
|
|
|
|
afterAmount := "0" |
|
|
|
|
|
var affected int64 = 0 |
|
|
|
|
|
userProfile, err := db2.UserProfileFindByIdWithSession(session, item.Uid) |
|
|
|
|
|
if userProfile == nil { |
|
|
|
|
|
} |
|
|
|
|
|
if err != nil || userProfile == nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取余额更新锁 |
|
|
|
|
|
cb, err := HandleBalanceDistributedLock(masterId, utils.IntToStr(item.Uid), "mall_settle_order") |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
fmt.Println(err.Error()) |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
// 释放锁 |
|
|
|
|
|
if cb != nil { |
|
|
|
|
|
defer cb() |
|
|
|
|
|
} |
|
|
|
|
|
// 开始写入流水 |
|
|
|
|
|
var orderAction int |
|
|
|
|
|
if item.Level == 0 { |
|
|
|
|
|
orderAction = 10 // 自购 |
|
|
|
|
|
} else { |
|
|
|
|
|
orderAction = 11 // 推广 |
|
|
|
|
|
} |
|
|
|
|
|
ItemTitle := "任务分佣" |
|
|
|
|
|
finUserFlow := model.FinUserFlow{ |
|
|
|
|
|
Type: 0, |
|
|
|
|
|
Uid: item.Uid, |
|
|
|
|
|
Amount: utils.Float64ToStrByPrec(item.Amount, 8), |
|
|
|
|
|
BeforeAmount: beforeAmount, |
|
|
|
|
|
AfterAmount: afterAmount, |
|
|
|
|
|
OrdType: "task_center", |
|
|
|
|
|
OrdId: utils.AnyToString(item.Oid), |
|
|
|
|
|
OrdAction: orderAction, |
|
|
|
|
|
OrdDetail: "", |
|
|
|
|
|
State: 2, |
|
|
|
|
|
OtherId: item.Id, |
|
|
|
|
|
OrdTitle: ItemTitle, |
|
|
|
|
|
OrdTime: int(now.Unix()), |
|
|
|
|
|
CreateAt: now, |
|
|
|
|
|
UpdateAt: now, |
|
|
|
|
|
} |
|
|
|
|
|
// 更新用户余额 |
|
|
|
|
|
finUserFlow.BeforeAmount = userProfile.FinValid |
|
|
|
|
|
userProfile.FinValid = utils.Float64ToStrByPrec(utils.AnyToFloat64(userProfile.FinValid)+utils.AnyToFloat64(item.Amount), 8) |
|
|
|
|
|
userProfile.FinTotal = userProfile.FinTotal + utils.StrToFloat32(utils.Float64ToStrByPrec(item.Amount, 8)) |
|
|
|
|
|
affected, err = db2.UserProfileUpdateWithSession(session, item.Uid, userProfile) |
|
|
|
|
|
finUserFlow.AfterAmount = userProfile.FinValid |
|
|
|
|
|
has, errs := db2.InsertCommWithSession( |
|
|
|
|
|
session, &finUserFlow) |
|
|
|
|
|
if affected == 0 || err != nil || errs != nil || has == 0 { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
if utils.InArr(item.Mode, []string{"public_platoon", "lv_commission_public_platoon", "lv_price_public_platoon"}) { //公排的加一条流水 |
|
|
|
|
|
kind := 4 |
|
|
|
|
|
title := "自购奖" |
|
|
|
|
|
if item.Level == 1 { |
|
|
|
|
|
kind = 5 |
|
|
|
|
|
title = "直推奖" |
|
|
|
|
|
} |
|
|
|
|
|
bools := PublicPlatoonAddRecordWithSession(session, title, utils.Int64ToStr(item.Oid), item.Uid, 0, kind, 0, item.Amount, beforeAmount) |
|
|
|
|
|
if bools == false { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func CommSettleVirtualCoin(session *xorm.Session, virtualCoinRelateItem *model.VirtualCoinRelate) bool { |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
|
|
beforeAmount = "0" |
|
|
|
|
|
afterAmount = "0" |
|
|
|
|
|
) |
|
|
|
|
|
// 查询用户虚拟币余额表记录,有则更新,无则新增一条记录 |
|
|
|
|
|
userVirtualAmount, err := db2.GetUserVirtualAmountOne(session, virtualCoinRelateItem.Uid, virtualCoinRelateItem.CoinId) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if userVirtualAmount == nil { // 没有记录则新增一条 |
|
|
|
|
|
userVirtualAmount = &model.UserVirtualAmount{ |
|
|
|
|
|
Uid: virtualCoinRelateItem.Uid, |
|
|
|
|
|
CoinId: virtualCoinRelateItem.CoinId, |
|
|
|
|
|
Amount: virtualCoinRelateItem.Amount, |
|
|
|
|
|
} |
|
|
|
|
|
afterAmount = virtualCoinRelateItem.Amount |
|
|
|
|
|
has, errs := db2.InsertCommWithSession( |
|
|
|
|
|
session, userVirtualAmount) |
|
|
|
|
|
if errs != nil || has == 0 { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} else { // 更新 |
|
|
|
|
|
beforeAmount = userVirtualAmount.Amount |
|
|
|
|
|
amount := utils.StrToFloat64(userVirtualAmount.Amount) + utils.StrToFloat64(virtualCoinRelateItem.Amount) |
|
|
|
|
|
userVirtualAmount.Amount = utils.Float64ToStrByPrec(amount, 6) |
|
|
|
|
|
afterAmount = userVirtualAmount.Amount |
|
|
|
|
|
affected, err := session.Where("id = ?", userVirtualAmount.Id).Update(userVirtualAmount) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
if affected == 0 { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
var title = "任务分佣结算" |
|
|
|
|
|
// 用户虚拟币流水表新增记录 |
|
|
|
|
|
var userVirtualCoinFlow = model.UserVirtualCoinFlow{ |
|
|
|
|
|
Uid: virtualCoinRelateItem.Uid, |
|
|
|
|
|
CoinId: virtualCoinRelateItem.CoinId, |
|
|
|
|
|
Direction: 1, |
|
|
|
|
|
Title: title, |
|
|
|
|
|
OrdId: utils.Int64ToStr(virtualCoinRelateItem.Oid), |
|
|
|
|
|
Amout: virtualCoinRelateItem.Amount, |
|
|
|
|
|
BeforeAmout: beforeAmount, |
|
|
|
|
|
AfterAmout: afterAmount, |
|
|
|
|
|
SysFee: "0", |
|
|
|
|
|
CreateTime: time.Now(), |
|
|
|
|
|
} |
|
|
|
|
|
has, errs := db2.InsertCommWithSession( |
|
|
|
|
|
session, &userVirtualCoinFlow) |
|
|
|
|
|
if errs != nil || has == 0 { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
if utils.InArr(virtualCoinRelateItem.Mode, []string{"public_platoon", "lv_commission_public_platoon", "lv_price_public_platoon"}) { //公排的加一条流水 |
|
|
|
|
|
kind := 4 |
|
|
|
|
|
title := "自购奖" |
|
|
|
|
|
if virtualCoinRelateItem.Level == 1 { |
|
|
|
|
|
kind = 5 |
|
|
|
|
|
title = "直推奖" |
|
|
|
|
|
} |
|
|
|
|
|
bools := PublicPlatoonAddRecordWithSession(session, title, utils.Int64ToStr(virtualCoinRelateItem.Oid), virtualCoinRelateItem.Uid, virtualCoinRelateItem.CoinId, kind, 0, utils.StrToFloat64(virtualCoinRelateItem.Amount), beforeAmount) |
|
|
|
|
|
if bools == false { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return true |
|
|
|
|
|
} |