|
@@ -68,6 +68,9 @@ func CommOrderRelateInsert(eg *xorm.Engine, oid int64, pvd string, createTime in |
|
|
Level: level, |
|
|
Level: level, |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
if mapData["reward_type"] == "2" { |
|
|
|
|
|
data = make([]*model.TaskOrdListRelate, 0) |
|
|
|
|
|
} |
|
|
mode := mapData["mode"] |
|
|
mode := mapData["mode"] |
|
|
for lvUser.ParentUser != nil { |
|
|
for lvUser.ParentUser != nil { |
|
|
lvUser = lvUser.ParentUser |
|
|
lvUser = lvUser.ParentUser |
|
@@ -105,7 +108,7 @@ func CommOrderRelateInsert(eg *xorm.Engine, oid int64, pvd string, createTime in |
|
|
return |
|
|
return |
|
|
} else { |
|
|
} else { |
|
|
// 插入虚拟币数据 |
|
|
// 插入虚拟币数据 |
|
|
vcrData := CommCombineVirtualCoinRelateData(oldLvUser, oid, pvd, oldLevel, mapData["mode"]) |
|
|
|
|
|
|
|
|
vcrData := CommCombineVirtualCoinRelateData(oldLvUser, oid, pvd, oldLevel, mapData) |
|
|
err2 := db2.DbInsertBatch(eg, vcrData) |
|
|
err2 := db2.DbInsertBatch(eg, vcrData) |
|
|
for _, item := range vcrData { |
|
|
for _, item := range vcrData { |
|
|
fmt.Println(item) |
|
|
fmt.Println(item) |
|
@@ -122,67 +125,72 @@ func ConvertList2Map(a []*comm_plan.VirtualCoinCommission) (b map[string]float64 |
|
|
} |
|
|
} |
|
|
return b |
|
|
return b |
|
|
} |
|
|
} |
|
|
func CommCombineVirtualCoinRelateData(lvUser *comm_plan.LvUser, oid int64, pvd string, level int, mode string) []*model.VirtualCoinRelate { |
|
|
|
|
|
|
|
|
func CommCombineVirtualCoinRelateData(lvUser *comm_plan.LvUser, oid int64, pvd string, level int, mapData map[string]string) []*model.VirtualCoinRelate { |
|
|
|
|
|
mode := mapData["mode"] |
|
|
|
|
|
|
|
|
var data []*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 mapData["reward_type"] != "2" { |
|
|
|
|
|
//可能没有极差返利 只有补贴 |
|
|
|
|
|
profitList := lvUser.ProfitList |
|
|
|
|
|
if len(profitList) == 0 { |
|
|
|
|
|
profitList = lvUser.SubsidyFeeList |
|
|
} |
|
|
} |
|
|
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) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if profitList != nil { |
|
|
|
|
|
var subsidyFeeList map[string]float64 |
|
|
|
|
|
if lvUser.SubsidyFeeList != nil && len(lvUser.ProfitList) > 0 { |
|
|
|
|
|
subsidyFeeList = ConvertList2Map(lvUser.SubsidyFeeList) |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
for _, item := range profitList { |
|
|
|
|
|
|
|
|
|
|
|
if lvUser.Uid == 0 { |
|
|
|
|
|
continue |
|
|
|
|
|
|
|
|
var coinList = make([]string, 0) |
|
|
|
|
|
for _, v := range profitList { |
|
|
|
|
|
coinList = append(coinList, v.Cid) |
|
|
} |
|
|
} |
|
|
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 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) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
if mode == "public_platoon" && level > 1 { |
|
|
|
|
|
profit = "0" |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
for _, item := range profitList { |
|
|
|
|
|
|
|
|
|
|
|
if lvUser.Uid == 0 { |
|
|
|
|
|
continue |
|
|
} |
|
|
} |
|
|
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, |
|
|
|
|
|
|
|
|
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) |
|
|
} |
|
|
} |
|
|
data = append(data, virtualCoinRelate) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if lvUser.ParentUser != nil { |
|
|
if lvUser.ParentUser != nil { |
|
|
level += 1 |
|
|
level += 1 |
|
|
data = append(data, CommCombineVirtualCoinRelateData(lvUser.ParentUser, oid, pvd, level, mode)...) |
|
|
|
|
|
|
|
|
data = append(data, CommCombineVirtualCoinRelateData(lvUser.ParentUser, oid, pvd, level, mapData)...) |
|
|
} |
|
|
} |
|
|
return data |
|
|
return data |
|
|
} |
|
|
} |
|
@@ -209,6 +217,9 @@ func SettleDone(eg *xorm.Engine, pvd string, oid int64, masterId string, mapData |
|
|
appName = set.Val |
|
|
appName = set.Val |
|
|
} |
|
|
} |
|
|
for _, item := range ol { |
|
|
for _, item := range ol { |
|
|
|
|
|
if mapData["reward_type"] == "2" && item.Level == 0 { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
//佣金不为空 |
|
|
//佣金不为空 |
|
|
if item.Amount > 0 { |
|
|
if item.Amount > 0 { |
|
|
//公排 |
|
|
//公排 |
|
@@ -236,6 +247,9 @@ func SettleDone(eg *xorm.Engine, pvd string, oid int64, masterId string, mapData |
|
|
} |
|
|
} |
|
|
// 虚拟币相关操作 |
|
|
// 虚拟币相关操作 |
|
|
for _, item := range vcrList { |
|
|
for _, item := range vcrList { |
|
|
|
|
|
if mapData["reward_type"] == "2" && item.Level == 0 { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
if utils.StrToFloat64(item.Amount) > 0 { |
|
|
if utils.StrToFloat64(item.Amount) > 0 { |
|
|
if utils.InArr(item.Mode, []string{"lv_commission_public_platoon", "lv_price_public_platoon"}) && item.ExtendType == 5 { |
|
|
if utils.InArr(item.Mode, []string{"lv_commission_public_platoon", "lv_price_public_platoon"}) && item.ExtendType == 5 { |
|
|
fmt.Println("======================555") |
|
|
fmt.Println("======================555") |
|
|