|
|
@@ -4,6 +4,7 @@ import ( |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/lib/comm_plan" |
|
|
|
"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" |
|
|
|
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
@@ -17,6 +18,9 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b |
|
|
|
if virType == "commission" { |
|
|
|
rmd.GoodsPrice = rmd.Commission |
|
|
|
} |
|
|
|
if rmd.Oid == "" { |
|
|
|
rmd.Oid = "1" |
|
|
|
} |
|
|
|
var ( |
|
|
|
err error |
|
|
|
uid = 0 |
|
|
@@ -53,12 +57,6 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b |
|
|
|
return 0, 0, 0, 0, nil, errors.New("分佣方案未设置") |
|
|
|
} |
|
|
|
|
|
|
|
var userRelationship *[]md.UserRelation |
|
|
|
if returnAllLevel { |
|
|
|
userRelationship, err = UserRelativeNetwork(engine, uid) |
|
|
|
} else { |
|
|
|
userRelationship = nil |
|
|
|
} |
|
|
|
// 获取全部佣金 |
|
|
|
com, price := getCommission(rmd, provider) |
|
|
|
fmt.Println(com) |
|
|
@@ -67,15 +65,73 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b |
|
|
|
if zhios_order_relate_utils.InArr(cfg.Mode, []string{"lv_price", "lv_winery"}) && zhios_order_relate_utils.StrToFloat64(rmd.OldPrice) > 0 { //价格为基数 |
|
|
|
comf = zhios_order_relate_utils.StrToFloat64(rmd.OldPrice) |
|
|
|
} |
|
|
|
// 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 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 { //公排 |
|
|
|
//佣金扣除抽成后 |
|
|
|
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission") |
|
|
|
////积分扣除抽成后 |
|
|
|
//var integralSysFee float64 = 0 |
|
|
|
//integralFee, _, integralSysFee := CommFee(comf, cfg, "integral") |
|
|
|
//调用公排制度 |
|
|
|
var PublicPlatoonRelateCommissionReqList = []*md.PublicPlatoonRelateCommissionReq{ |
|
|
|
{ |
|
|
|
Pvd: newProvider, |
|
|
|
Uid: zhios_order_relate_utils.IntToStr(uid), |
|
|
|
UserLevel: zhios_order_relate_utils.IntToStr(level), |
|
|
|
PendingAmount: zhios_order_relate_utils.Float64ToStr(fee), |
|
|
|
Oid: rmd.Oid, |
|
|
|
}, |
|
|
|
} |
|
|
|
order, err := rule.BatchGetPublicPlatoonRelateCommissionByOrder(engine, masterId, PublicPlatoonRelateCommissionReqList) |
|
|
|
if err != nil || order[rmd.Oid] == nil { |
|
|
|
return 0, 0, 0, 0, nil, nil |
|
|
|
} |
|
|
|
reward := order[rmd.Oid] |
|
|
|
profit := zhios_order_relate_utils.StrToFloat64(reward.SelfRateList["0"]) |
|
|
|
var ulink = &comm_plan.LvUser{} |
|
|
|
//共富收益处理 |
|
|
|
ulink = getRewardLink(reward.CommonWealthBenefitUid, 2, reward.CommonWealthSystem, ulink) |
|
|
|
//直推收益处理 |
|
|
|
ulink = getRewardLink(reward.DirectPushBenefitUid, 1, reward.DirectPush, ulink) |
|
|
|
//自购 |
|
|
|
ulink = getRewardLink(reward.Uid, 0, reward.SelfRateList, ulink) |
|
|
|
return profit, pvdFee, sysFee, 0, nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
func getRewardLink(uid string, diff int, reward map[string]string, ulinkParent *comm_plan.LvUser) *comm_plan.LvUser { |
|
|
|
var SubsidyFee = zhios_order_relate_utils.StrToFloat64(reward["0"]) |
|
|
|
var SubsidyFeeList = make([]*comm_plan.VirtualCoinCommission, 0) |
|
|
|
for k, v := range reward { |
|
|
|
var tmp = &comm_plan.VirtualCoinCommission{ |
|
|
|
Cid: k, |
|
|
|
Val: zhios_order_relate_utils.StrToFloat64(v), |
|
|
|
} |
|
|
|
SubsidyFeeList = append(SubsidyFeeList, tmp) |
|
|
|
} |
|
|
|
if ulink == nil { |
|
|
|
return 0, 0, 0, 0, nil, nil |
|
|
|
//组装数据 |
|
|
|
var ulink = &comm_plan.LvUser{ |
|
|
|
Uid: zhios_order_relate_utils.StrToInt(uid), |
|
|
|
SubsidyFee: SubsidyFee, |
|
|
|
SubsidyFeeList: SubsidyFeeList, |
|
|
|
Diff: diff, |
|
|
|
ParentUser: ulinkParent, |
|
|
|
} |
|
|
|
return ulink.Profit, pvdFee, sysFee, subsidyFee, ulink, nil |
|
|
|
return ulink |
|
|
|
} |
|
|
|
|
|
|
|
func getCommission(d *md.CommissionParam, provider string) (string, string) { |
|
|
|