|
|
@@ -5,6 +5,7 @@ import ( |
|
|
|
"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" |
|
|
|
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" |
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"xorm.io/xorm" |
|
|
@@ -96,7 +97,12 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b |
|
|
|
Oid: rmd.Oid, |
|
|
|
}, |
|
|
|
} |
|
|
|
order, err := BatchGetPublicPlatoonRelateCommissionByOrder(engine, masterId, PublicPlatoonRelateCommissionReqList) |
|
|
|
var order = make(map[string]*md.PublicPlatoonRelateCommissionResp) |
|
|
|
if rmd.IsGoods == "1" { |
|
|
|
order, err = BatchGetPublicPlatoonRelateCommissionByGoods(engine, masterId, PublicPlatoonRelateCommissionReqList) |
|
|
|
} else { |
|
|
|
order, err = BatchGetPublicPlatoonRelateCommissionByOrder(engine, masterId, PublicPlatoonRelateCommissionReqList) |
|
|
|
} |
|
|
|
if err != nil || order[rmd.Oid] == nil { |
|
|
|
return 0, 0, 0, 0, nil, nil |
|
|
|
} |
|
|
@@ -408,3 +414,64 @@ func convertList2Map(a []*comm_plan.VirtualCoinCommission) (b map[string]float64 |
|
|
|
} |
|
|
|
return b |
|
|
|
} |
|
|
|
|
|
|
|
// BatchGetPublicPlatoonRelateCommission 批量分佣 商品显示 |
|
|
|
func BatchGetPublicPlatoonRelateCommissionByGoods(engine *xorm.Engine, masterId string, PublicPlatoonRelateCommissionReqList []*md.PublicPlatoonRelateCommissionReq) (map[string]*md.PublicPlatoonRelateCommissionResp, error) { |
|
|
|
var resp = make(map[string]*md.PublicPlatoonRelateCommissionResp) |
|
|
|
for _, param := range PublicPlatoonRelateCommissionReqList { |
|
|
|
// 根据供应商 |
|
|
|
rewardOpt, err := db.DbsPlanRewardByPvd(engine, param.Pvd) |
|
|
|
if err != nil { |
|
|
|
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{} |
|
|
|
continue |
|
|
|
} |
|
|
|
if rewardOpt == nil { |
|
|
|
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{} |
|
|
|
continue |
|
|
|
} |
|
|
|
if rewardOpt.State == 0 { |
|
|
|
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{} |
|
|
|
continue |
|
|
|
} |
|
|
|
if rewardOpt.PlanCommissionId == 0 { |
|
|
|
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{} |
|
|
|
continue |
|
|
|
} |
|
|
|
fmt.Println("抽成设置:", zhios_order_relate_utils.SerializeStr(rewardOpt)) |
|
|
|
fmt.Println("commission id:", rewardOpt.PlanCommissionId) |
|
|
|
|
|
|
|
//TODO::计算共富收益 |
|
|
|
commissionOpt, err := db.DbsPlanCommissionById(engine, rewardOpt.PlanCommissionId) |
|
|
|
if err != nil || commissionOpt == nil || commissionOpt.Id == 0 { |
|
|
|
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{} |
|
|
|
continue |
|
|
|
} |
|
|
|
var subsidyTmp = make(map[string]*md.LvGrade) |
|
|
|
var tmp map[string]*md.LvGrade |
|
|
|
if err := json.Unmarshal([]byte(commissionOpt.Data), &tmp); err != nil { |
|
|
|
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{} |
|
|
|
continue |
|
|
|
} |
|
|
|
for _, v := range tmp { |
|
|
|
subsidyTmp[zhios_order_relate_utils.IntToStr(v.Lv)] = v |
|
|
|
} |
|
|
|
lvGrade := subsidyTmp[param.UserLevel] |
|
|
|
var directPush = make(map[string]string) |
|
|
|
var selfRateList = make(map[string]string) |
|
|
|
var commonWealthSystem = make(map[string]string) |
|
|
|
for _, coinId := range lvGrade.ReturnType { |
|
|
|
selfRateList[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.SelfRateList[coinId]) * zhios_order_relate_utils.StrToFloat64(param.PendingAmount) / 100) |
|
|
|
commonWealthSystem[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.CommonWealthSystem[coinId]) * zhios_order_relate_utils.StrToFloat64(param.PendingAmount) / 100) |
|
|
|
directPush[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.DirectPush[coinId]) * zhios_order_relate_utils.StrToFloat64(param.PendingAmount)) |
|
|
|
} |
|
|
|
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{ |
|
|
|
Uid: param.Uid, |
|
|
|
PendingAmount: param.PendingAmount, |
|
|
|
Oid: param.Oid, |
|
|
|
SelfRateList: selfRateList, |
|
|
|
CommonWealthSystem: commonWealthSystem, |
|
|
|
DirectPush: directPush, |
|
|
|
} |
|
|
|
} |
|
|
|
return resp, nil |
|
|
|
} |