|
@@ -25,17 +25,20 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b |
|
|
rmd.Oid = "1" |
|
|
rmd.Oid = "1" |
|
|
} |
|
|
} |
|
|
var ( |
|
|
var ( |
|
|
err error |
|
|
|
|
|
uid = 0 |
|
|
|
|
|
level = 0 |
|
|
|
|
|
newLevel = 0 |
|
|
|
|
|
|
|
|
err error |
|
|
|
|
|
uid = 0 |
|
|
|
|
|
level = 0 |
|
|
|
|
|
userLevel = 0 |
|
|
|
|
|
newLevel = 0 |
|
|
) |
|
|
) |
|
|
user, _ := db.UserFindByID(engine, userId) |
|
|
user, _ := db.UserFindByID(engine, userId) |
|
|
if user != nil { |
|
|
if user != nil { |
|
|
uid = user.Uid |
|
|
uid = user.Uid |
|
|
level = user.Level |
|
|
level = user.Level |
|
|
newLevel = user.Level |
|
|
newLevel = user.Level |
|
|
|
|
|
userLevel = user.Level |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 获取抽成方案 |
|
|
// 获取抽成方案 |
|
|
newProvider := provider |
|
|
newProvider := provider |
|
|
if newProvider == md.PVD_TM { //抽成方案只有淘宝的要替换回来 |
|
|
if newProvider == md.PVD_TM { //抽成方案只有淘宝的要替换回来 |
|
@@ -65,26 +68,10 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b |
|
|
fmt.Println(com) |
|
|
fmt.Println(com) |
|
|
fmt.Println(price) |
|
|
fmt.Println(price) |
|
|
comf := zhios_order_relate_utils.StrToFloat64(com) |
|
|
comf := zhios_order_relate_utils.StrToFloat64(com) |
|
|
if zhios_order_relate_utils.InArr(cfg.Mode, []string{"lv_price", "lv_winery"}) && zhios_order_relate_utils.StrToFloat64(rmd.OldPrice) > 0 { //价格为基数 |
|
|
|
|
|
|
|
|
if zhios_order_relate_utils.InArr(cfg.Mode, []string{"lv_price", "lv_winery", "extend_price"}) && zhios_order_relate_utils.StrToFloat64(rmd.OldPrice) > 0 { //价格为基数 |
|
|
comf = zhios_order_relate_utils.StrToFloat64(rmd.OldPrice) |
|
|
comf = zhios_order_relate_utils.StrToFloat64(rmd.OldPrice) |
|
|
} |
|
|
} |
|
|
if cfg.Mode != "public_platoon" { //公排走另一个制度 |
|
|
|
|
|
var userRelationship *[]md.UserRelation |
|
|
|
|
|
if returnAllLevel { |
|
|
|
|
|
userRelationship, err = UserRelativeNetwork(engine, uid) |
|
|
|
|
|
} else { |
|
|
|
|
|
userRelationship = nil |
|
|
|
|
|
} |
|
|
|
|
|
// userRelationship == nil 是只返回第一层 即用户自己的 |
|
|
|
|
|
pvdFee, sysFee, subsidyFee, ulink, err := CalcCommission(uid, level, 0, ownbuyReturnType, comf, zhios_order_relate_utils.StrToFloat64(price), isShare, cfg, userRelationship, newProvider, newLevel, engine) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return 0, 0, 0, 0, nil, nil |
|
|
|
|
|
} |
|
|
|
|
|
if ulink == nil { |
|
|
|
|
|
return 0, 0, 0, 0, nil, nil |
|
|
|
|
|
} |
|
|
|
|
|
return ulink.Profit, pvdFee, sysFee, subsidyFee, ulink, nil |
|
|
|
|
|
} else { //公排 |
|
|
|
|
|
|
|
|
if cfg.Mode == "public_platoon" { //公排 |
|
|
//佣金扣除抽成后 |
|
|
//佣金扣除抽成后 |
|
|
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission") |
|
|
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission") |
|
|
////积分扣除抽成后 |
|
|
////积分扣除抽成后 |
|
@@ -124,6 +111,51 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b |
|
|
ulink = getRewardLink(reward.Uid, 0, reward.SelfRateList, ulink, "own", cfg) |
|
|
ulink = getRewardLink(reward.Uid, 0, reward.SelfRateList, ulink, "own", cfg) |
|
|
return profit, pvdFee, sysFee, 0, ulink, nil |
|
|
return profit, pvdFee, sysFee, 0, ulink, nil |
|
|
} |
|
|
} |
|
|
|
|
|
if cfg.Mode == "extend_price" { //直推奖励 |
|
|
|
|
|
var ulink = &comm_plan.LvUser{} |
|
|
|
|
|
if rmd.IsGoods == "1" { //自购没奖励,就不计算了 |
|
|
|
|
|
return 0, 0, 0, 0, ulink, nil |
|
|
|
|
|
} |
|
|
|
|
|
if newProvider == md.PVD_REGIONAL_AGENT_PAY { |
|
|
|
|
|
userLevel = zhios_order_relate_utils.StrToInt(extraData["agent_lv"]) |
|
|
|
|
|
} |
|
|
|
|
|
//佣金扣除抽成后 |
|
|
|
|
|
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission") |
|
|
|
|
|
////积分扣除抽成后 |
|
|
|
|
|
integralFee, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral") |
|
|
|
|
|
var param = map[string]string{ |
|
|
|
|
|
"commission": zhios_order_relate_utils.Float64ToStr(fee), |
|
|
|
|
|
"integral": zhios_order_relate_utils.Float64ToStr(integralFee), |
|
|
|
|
|
"level": zhios_order_relate_utils.IntToStr(userLevel), |
|
|
|
|
|
"uid": zhios_order_relate_utils.IntToStr(uid), |
|
|
|
|
|
"source": newProvider, |
|
|
|
|
|
} |
|
|
|
|
|
reward, parentUid := ExtendPriceReward(engine, param, cfg) |
|
|
|
|
|
//直推收益处理 |
|
|
|
|
|
if parentUid > 0 { |
|
|
|
|
|
ulink = getRewardLink(zhios_order_relate_utils.IntToStr(parentUid), 1, reward, ulink, "extend", cfg) |
|
|
|
|
|
} |
|
|
|
|
|
//自购 |
|
|
|
|
|
ulink = getRewardLink(zhios_order_relate_utils.IntToStr(uid), 0, map[string]string{}, ulink, "own", cfg) |
|
|
|
|
|
return 0, pvdFee, sysFee, 0, ulink, nil |
|
|
|
|
|
} |
|
|
|
|
|
//常规级差 |
|
|
|
|
|
|
|
|
|
|
|
var userRelationship *[]md.UserRelation |
|
|
|
|
|
if returnAllLevel { |
|
|
|
|
|
userRelationship, err = UserRelativeNetwork(engine, uid) |
|
|
|
|
|
} else { |
|
|
|
|
|
userRelationship = nil |
|
|
|
|
|
} |
|
|
|
|
|
// userRelationship == nil 是只返回第一层 即用户自己的 |
|
|
|
|
|
pvdFee, sysFee, subsidyFee, ulink, err := CalcCommission(uid, level, 0, ownbuyReturnType, comf, zhios_order_relate_utils.StrToFloat64(price), isShare, cfg, userRelationship, newProvider, newLevel, engine) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return 0, 0, 0, 0, nil, nil |
|
|
|
|
|
} |
|
|
|
|
|
if ulink == nil { |
|
|
|
|
|
return 0, 0, 0, 0, nil, nil |
|
|
|
|
|
} |
|
|
|
|
|
return ulink.Profit, pvdFee, sysFee, subsidyFee, ulink, nil |
|
|
} |
|
|
} |
|
|
func getRewardLink(uid string, diff int, reward map[string]string, ulinkParent *comm_plan.LvUser, types string, cfg *comm_plan.PlanOpt) *comm_plan.LvUser { |
|
|
func getRewardLink(uid string, diff int, reward map[string]string, ulinkParent *comm_plan.LvUser, types string, cfg *comm_plan.PlanOpt) *comm_plan.LvUser { |
|
|
var SubsidyFee = zhios_order_relate_utils.StrToFloat64(reward["0"]) |
|
|
var SubsidyFee = zhios_order_relate_utils.StrToFloat64(reward["0"]) |
|
|