@@ -122,7 +122,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo | |||
if commissionOpt == nil || commissionOpt.Id == 0 { | |||
return nil, errors.New("佣金方案有误") | |||
} | |||
if _, ok := comm_plan.Fn[commissionOpt.Mode]; !ok && zhios_order_relate_utils.InArr(commissionOpt.Mode, []string{"public_platoon", "extend_price", "lv_integral_release"}) == false { | |||
if _, ok := comm_plan.Fn[commissionOpt.Mode]; !ok && zhios_order_relate_utils.InArr(commissionOpt.Mode, []string{"public_platoon_level", "public_platoon", "extend_price", "lv_integral_release"}) == false { | |||
return nil, zhios_order_relate_logx.Warn("分佣模式不存在") | |||
} | |||
opt.Pvd = pvd | |||
@@ -156,7 +156,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo | |||
} else { | |||
opt.VirtualCoinMoneyRatioList = virtualCoinMoneyRate | |||
} | |||
if zhios_order_relate_utils.InArr(commissionOpt.Mode, []string{"public_platoon", "extend_price", "lv_integral_release"}) { //公排 | |||
if zhios_order_relate_utils.InArr(commissionOpt.Mode, []string{"public_platoon_level", "public_platoon", "extend_price", "lv_integral_release"}) { //公排 | |||
return opt, nil | |||
} | |||
@@ -143,3 +143,103 @@ func benefitUidByBig(engine *xorm.Engine, param *md.PublicPlatoonRelateCommissio | |||
return nowBenefitUid, nil, nil | |||
} | |||
func BatchGetPublicPlatoonRelateCommissionByOrderLevel(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 { | |||
return nil, err | |||
} | |||
if rewardOpt == nil { | |||
return nil, zhios_order_relate_logx.Warn("找不到方案记录") | |||
} | |||
if rewardOpt.State == 0 { | |||
return nil, zhios_order_relate_logx.Warn("抽成方案未开启") | |||
} | |||
if rewardOpt.PlanCommissionId == 0 { | |||
return nil, zhios_order_relate_logx.Warn("抽成方案未设置佣金方案id") | |||
} | |||
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 { | |||
return nil, err | |||
} | |||
var subsidyTmp = make(map[string]*md.LvGrade) | |||
var tmp map[string]*md.LvGrade | |||
if err := json.Unmarshal([]byte(commissionOpt.Data), &tmp); err != nil { | |||
return nil, zhios_order_relate_logx.Warn(fmt.Sprintf("%s:分佣方案数据设置错误", masterId)) | |||
} | |||
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) | |||
if lvGrade != nil { | |||
for _, coinId := range lvGrade.ReturnType { | |||
var pendingAmount = param.PendingAmount | |||
if zhios_order_relate_utils.StrToInt(coinId) > 0 { //积分更换基数 | |||
pendingAmount = param.PendingIntegral | |||
} | |||
selfRateList[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.SelfRateList[coinId]) * zhios_order_relate_utils.StrToFloat64(pendingAmount) / 100) | |||
} | |||
} | |||
nowBenefitUid, _, err := benefitUidByBig(engine, param) | |||
if err != nil { | |||
return nil, err | |||
} | |||
recommendUid := "" | |||
userProfile, _ := db.UserProfileFindByID(engine, param.Uid) | |||
if userProfile != nil && userProfile.ParentUid > 0 { | |||
recommendUid = zhios_order_relate_utils.IntToStr(userProfile.ParentUid) | |||
} | |||
//直推獎勵 | |||
if zhios_order_relate_utils.StrToInt(recommendUid) > 0 { | |||
parentUid, _ := db.UserFindByID(engine, recommendUid) | |||
lvGrade1 := subsidyTmp[zhios_order_relate_utils.IntToStr(parentUid.Level)] | |||
if lvGrade1 != nil { | |||
for _, coinId := range lvGrade1.ReturnType { | |||
var pendingAmount = param.PendingAmount | |||
if zhios_order_relate_utils.StrToInt(coinId) > 0 { //积分更换基数 | |||
pendingAmount = param.PendingIntegral | |||
} | |||
directPush[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.DirectPush[coinId]) * zhios_order_relate_utils.StrToFloat64(pendingAmount) / 100) | |||
} | |||
} | |||
} | |||
//共富简历 | |||
if zhios_order_relate_utils.StrToInt(nowBenefitUid) > 0 { | |||
parentUid, _ := db.UserFindByID(engine, nowBenefitUid) | |||
lvGrade1 := subsidyTmp[zhios_order_relate_utils.IntToStr(parentUid.Level)] | |||
if lvGrade1 != nil { | |||
for _, coinId := range lvGrade1.ReturnType { | |||
var pendingAmount = param.PendingAmount | |||
if zhios_order_relate_utils.StrToInt(coinId) > 0 { //积分更换基数 | |||
pendingAmount = param.PendingIntegral | |||
} | |||
commonWealthSystem[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.CommonWealthSystem[coinId]) * zhios_order_relate_utils.StrToFloat64(pendingAmount) / 100) | |||
} | |||
} | |||
} | |||
/// | |||
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{ | |||
Uid: param.Uid, | |||
CommonWealthBenefitUid: nowBenefitUid, | |||
DirectPushBenefitUid: recommendUid, | |||
PendingAmount: param.PendingAmount, | |||
PendingIntegral: param.PendingIntegral, | |||
Oid: param.Oid, | |||
SelfRateList: selfRateList, | |||
CommonWealthSystem: commonWealthSystem, | |||
DirectPush: directPush, | |||
} | |||
} | |||
return resp, nil | |||
} |
@@ -86,7 +86,7 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b | |||
if zhios_order_relate_utils.InArr(cfg.Mode, []string{"lv_price_public_platoon", "lv_price", "lv_price_other", "lv_winery", "extend_price", "niubei_amount"}) && zhios_order_relate_utils.StrToFloat64(rmd.OldPrice) > 0 { //价格为基数 | |||
comf = zhios_order_relate_utils.StrToFloat64(rmd.OldPrice) | |||
} | |||
if cfg.Mode == "public_platoon" { | |||
if cfg.Mode == "public_platoon" || cfg.Mode == "public_platoon_level" { | |||
//公排 | |||
//佣金扣除抽成后 | |||
fee, _, pvdFee, sysFee := CommFee(comf, cfg, "commission", rmd) | |||
@@ -117,7 +117,11 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b | |||
if rmd.IsGoods == "1" { | |||
order, err = BatchSmallGetPublicPlatoonRelateByGoods(engine, masterId, PublicPlatoonRelateCommissionReqList) | |||
} else { | |||
order, err = BatchSmallGetPublicPlatoonRelateCommission(engine, masterId, PublicPlatoonRelateCommissionReqList) | |||
if cfg.Mode == "public_platoon_level" { | |||
order, err = BatchSmallGetPublicPlatoonRelateCommissionLevel(engine, masterId, PublicPlatoonRelateCommissionReqList) | |||
} else { | |||
order, err = BatchSmallGetPublicPlatoonRelateCommission(engine, masterId, PublicPlatoonRelateCommissionReqList) | |||
} | |||
} | |||
if err != nil || order[rmd.Oid] == nil { | |||
return 0, 0, 0, 0, nil, nil | |||
@@ -142,7 +146,13 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b | |||
if rmd.IsGoods == "1" { | |||
order, err = BatchGetPublicPlatoonRelateCommissionByGoods(engine, masterId, PublicPlatoonRelateCommissionReqList) | |||
} else { | |||
order, err = BatchGetPublicPlatoonRelateCommissionByOrder(engine, masterId, PublicPlatoonRelateCommissionReqList) | |||
if cfg.Mode == "public_platoon_level" { | |||
order, err = BatchGetPublicPlatoonRelateCommissionByOrderLevel(engine, masterId, PublicPlatoonRelateCommissionReqList) | |||
} else { | |||
order, err = BatchGetPublicPlatoonRelateCommissionByOrder(engine, masterId, PublicPlatoonRelateCommissionReqList) | |||
} | |||
} | |||
if err != nil || order[rmd.Oid] == nil { | |||
return 0, 0, 0, 0, nil, nil | |||
@@ -355,3 +355,102 @@ func BatchSmallGetPublicPlatoonRelateByGoods(engine *xorm.Engine, masterId strin | |||
} | |||
return resp, nil | |||
} | |||
func BatchSmallGetPublicPlatoonRelateCommissionLevel(engine *xorm.Engine, masterId string, PublicPlatoonRelateCommissionReqList []*md.SmallPublicPlatoonRelateCommissionReq) (map[string]*md.SmallPublicPlatoonRelateCommissionResp, error) { | |||
var resp = make(map[string]*md.SmallPublicPlatoonRelateCommissionResp) | |||
for _, param := range PublicPlatoonRelateCommissionReqList { | |||
// 根据供应商 | |||
rewardOpt, err := db.DbsPlanRewardByPvd(engine, param.Pvd) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if rewardOpt == nil { | |||
return nil, zhios_order_relate_logx.Warn("找不到方案记录") | |||
} | |||
if rewardOpt.State == 0 { | |||
return nil, zhios_order_relate_logx.Warn("抽成方案未开启") | |||
} | |||
if rewardOpt.PlanCommissionId == 0 { | |||
return nil, zhios_order_relate_logx.Warn("抽成方案未设置佣金方案id") | |||
} | |||
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 { | |||
return nil, err | |||
} | |||
var subsidyTmp = make(map[string]*md.LvGrade) | |||
var tmp map[string]*md.LvGrade | |||
if err := json.Unmarshal([]byte(commissionOpt.Data), &tmp); err != nil { | |||
return nil, zhios_order_relate_logx.Warn(fmt.Sprintf("%s:分佣方案数据设置错误", masterId)) | |||
} | |||
for _, v := range tmp { | |||
subsidyTmp[zhios_order_relate_utils.IntToStr(v.Lv)] = v | |||
} | |||
var directPush = make(map[string]string) | |||
var selfRateList = make(map[string]string) | |||
var commonWealthSystem = make(map[string]string) | |||
lvGrade := subsidyTmp[param.UserLevel] | |||
if lvGrade != nil { | |||
for _, coinId := range lvGrade.ReturnType { | |||
var pendingAmount = param.PendingAmount | |||
if zhios_order_relate_utils.StrToInt(coinId) > 0 { //积分更换基数 | |||
pendingAmount = param.PendingIntegral | |||
} | |||
selfRateList[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.SelfRateList[coinId]) * zhios_order_relate_utils.StrToFloat64(pendingAmount) / 100) | |||
} | |||
} | |||
//TODO::本次消费产生的共富收益给到谁 | |||
nowBenefitUid, _, err := benefitUid(engine, param) | |||
if err != nil { | |||
return nil, err | |||
} | |||
recommendUid := "" | |||
userProfile, _ := db.UserProfileFindByID(engine, param.Uid) | |||
if userProfile != nil && userProfile.ParentUid > 0 { | |||
recommendUid = zhios_order_relate_utils.IntToStr(userProfile.ParentUid) | |||
} | |||
//直推獎勵 | |||
if zhios_order_relate_utils.StrToInt(recommendUid) > 0 { | |||
parentUid, _ := db.UserFindByID(engine, recommendUid) | |||
lvGrade1 := subsidyTmp[zhios_order_relate_utils.IntToStr(parentUid.Level)] | |||
if lvGrade1 != nil { | |||
for _, coinId := range lvGrade1.ReturnType { | |||
var pendingAmount = param.PendingAmount | |||
if zhios_order_relate_utils.StrToInt(coinId) > 0 { //积分更换基数 | |||
pendingAmount = param.PendingIntegral | |||
} | |||
directPush[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.DirectPush[coinId]) * zhios_order_relate_utils.StrToFloat64(pendingAmount) / 100) | |||
} | |||
} | |||
} | |||
//共富简历 | |||
if zhios_order_relate_utils.StrToInt(nowBenefitUid) > 0 { | |||
parentUid, _ := db.UserFindByID(engine, nowBenefitUid) | |||
lvGrade1 := subsidyTmp[zhios_order_relate_utils.IntToStr(parentUid.Level)] | |||
if lvGrade1 != nil { | |||
for _, coinId := range lvGrade1.ReturnType { | |||
var pendingAmount = param.PendingAmount | |||
if zhios_order_relate_utils.StrToInt(coinId) > 0 { //积分更换基数 | |||
pendingAmount = param.PendingIntegral | |||
} | |||
commonWealthSystem[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.CommonWealthSystem[coinId]) * zhios_order_relate_utils.StrToFloat64(pendingAmount) / 100) | |||
} | |||
} | |||
} | |||
resp[param.Oid] = &md.SmallPublicPlatoonRelateCommissionResp{ | |||
Uid: param.Uid, | |||
CommonWealthBenefitUid: nowBenefitUid, | |||
DirectPushBenefitUid: recommendUid, | |||
PendingAmount: param.PendingAmount, | |||
Oid: param.Oid, | |||
SelfRateList: selfRateList, | |||
CommonWealthSystem: commonWealthSystem, | |||
DirectPush: directPush, | |||
} | |||
} | |||
return resp, nil | |||
} |