diff --git a/lib/comm_plan/init.go b/lib/comm_plan/init.go index ad66003..4c04ab6 100644 --- a/lib/comm_plan/init.go +++ b/lib/comm_plan/init.go @@ -10,6 +10,7 @@ var Fn = map[string]func(opt *PlanOpt, totalAmt, integralTotalAmt float64, userL "lv_winery": CalcAll, "lv_price_other": CalcOther, } + type NiuBeiIntegralReleaseO2oRatio struct { Ratio string `json:"ratio"` Key string `json:"key"` @@ -39,31 +40,34 @@ type PlanOpt struct { // 级差结构 type LvGrade struct { - Lv int `json:"lv"` // 级别 - SubsidyMode int `json:"subsidy_mode"` // 补贴计算方式, 0按佣金计算,1按平台利润计算 - SubsidyEnable int `json:"subsidy_enable"` // 是否开启补贴计算方式 0关闭, 1开启 - SubsidySelfRate float64 `json:"subsidy_self_rate"` // 自购补贴比例 - SubsidyShareRate float64 `json:"subsidy_share_rate"` // 分享补贴比例 - PayMode int `json:"pay_mode"` // 0团队内部支出, 1平台系统支出 - SelfRate float64 `json:"self_rate"` // 自购比例 - TeamRate float64 `json:"team_rate"` // 团队分成比例 - PeerRate []float64 `json:"peer_rate"` // 同级分成比例 - UserLvUpSubsidyEnable int `json:"user_lv_up_subsidy_enable"` //分销补贴开关 - UserLvUpSubsidyMode int `json:"user_lv_up_subsidy_mode"` //补贴方式 0比例 1固定金额 - UserSubsidyType string `json:"user_subsidy_type"` // 补贴模式 up_lv 推荐会员补贴 buy_goods 购买商品 - UserSubsidyBaseCoinId string `json:"user_subsidy_base_coin_id"` // 补贴计算基数 - UserLvUpSubsidyList []interface{} `json:"user_lv_up_subsidy_list"` //会员费分销补贴相应方式的列表 - PeerRateList []map[string]string `json:"peer_rate_list"` //同级比例 - BuyDeliverList map[string]string `json:"buy_deliver_list"` //酒庄制度 - ReturnType []string `json:"return_type"` //返利类型 - SelfRateList map[string]string `json:"self_rate_list"` // 自购比例 - TeamRateList map[string]string `json:"team_rate_list"` // 团队最高比例 - SubsidyModeList map[string]interface{} `json:"subsidy_mode_list"` // 各币种返佣模式:bili:比例 money:固定金额 + Lv int `json:"lv"` // 级别 + SubsidyMode int `json:"subsidy_mode"` // 补贴计算方式, 0按佣金计算,1按平台利润计算 + SubsidyEnable int `json:"subsidy_enable"` // 是否开启补贴计算方式 0关闭, 1开启 + TikTokTeamSubsidyEnable int `json:"tik_tok_team_subsidy_enable"` // 是否开启补贴计算方式 0关闭, 1开启 + SubsidySelfRate float64 `json:"subsidy_self_rate"` // 自购补贴比例 + SubsidyShareRate float64 `json:"subsidy_share_rate"` // 分享补贴比例 + PayMode int `json:"pay_mode"` // 0团队内部支出, 1平台系统支出 + SelfRate float64 `json:"self_rate"` // 自购比例 + TeamRate float64 `json:"team_rate"` // 团队分成比例 + PeerRate []float64 `json:"peer_rate"` // 同级分成比例 + UserLvUpSubsidyEnable int `json:"user_lv_up_subsidy_enable"` //分销补贴开关 + UserLvUpSubsidyMode int `json:"user_lv_up_subsidy_mode"` //补贴方式 0比例 1固定金额 + UserSubsidyType string `json:"user_subsidy_type"` // 补贴模式 up_lv 推荐会员补贴 buy_goods 购买商品 + UserSubsidyBaseCoinId string `json:"user_subsidy_base_coin_id"` // 补贴计算基数 + UserLvUpSubsidyList []interface{} `json:"user_lv_up_subsidy_list"` //会员费分销补贴相应方式的列表 + PeerRateList []map[string]string `json:"peer_rate_list"` //同级比例 + BuyDeliverList map[string]string `json:"buy_deliver_list"` //酒庄制度 + ReturnType []string `json:"return_type"` //返利类型 + SelfRateList map[string]string `json:"self_rate_list"` // 自购比例 + TeamRateList map[string]string `json:"team_rate_list"` // 团队最高比例 + SubsidyModeList map[string]interface{} `json:"subsidy_mode_list"` // 各币种返佣模式:bili:比例 money:固定金额 //SubsidyBlockIconsMode string `json:"subsidy_block_icons_mode"` //分销 区块币返利类型 bili 比例 money 固定金额 //SubsidyCommissionMode string `json:"subsidy_commission_mode"` //分销 佣金返利类型 bili 比例 money 固定金额 //SubsidyIntegralMode string `json:"subsidy_integral_mode"` //分销 积分返利类型 bili 比例 money 固定金额 - SubsidyReturnType []string `json:"subsidy_return_type"` //分销 返利类型 - SubsidyOwnBiliList []map[string]string `json:"subsidy_own_bili_list"` + SubsidyReturnType []string `json:"subsidy_return_type"` //分销 返利类型 + SubsidyOwnBiliList []map[string]string `json:"subsidy_own_bili_list"` + TikTokTeamSubsidyOwnBiliType []string `json:"tik_tok_team_subsidy_own_bili_type"` //分销 返利类型 + TikTokTeamSubsidyList []map[string]string `json:"tik_tok_team_subsidy_list"` } type UserLvUpSubsidyList struct { Lv int `json:"lv"` // 等级 @@ -127,13 +131,14 @@ type LvUser struct { //IntegralSubsidyFee float64 // 积分补贴 //BlockIconsProfit float64 // 区块币利润 //BlockIconsSubsidyFee float64 // 区块币补贴 - ProfitList []*VirtualCoinCommission // 各币种对用的数量 - SubsidyFeeList []*VirtualCoinCommission // 各币种对应的补贴数量 - OwnSubsidyFeeList map[string]float64 // 各币种对应的补贴数量 - OwnbuyReturnType int //0有返利 1没有返利 - Diff int // 与当前用户级别差 - OldDiff int // 旧的与当前用户级别差 - ParentUser *LvUser // 父用户 + ProfitList []*VirtualCoinCommission // 各币种对用的数量 + SubsidyFeeList []*VirtualCoinCommission // 各币种对应的补贴数量 + OwnSubsidyFeeList map[string]float64 // 各币种对应的补贴数量 + TikTokOwnSubsidyFeeList map[string]float64 // 各币种对应的补贴数量 + OwnbuyReturnType int //0有返利 1没有返利 + Diff int // 与当前用户级别差 + OldDiff int // 旧的与当前用户级别差 + ParentUser *LvUser // 父用户 } // 虚拟币分佣结构体 diff --git a/md/commission_parameter.go b/md/commission_parameter.go index 7bcf182..a7709c1 100644 --- a/md/commission_parameter.go +++ b/md/commission_parameter.go @@ -2,22 +2,23 @@ package md // MoreDetailResponse is for response detail type CommissionParam struct { - OldPrice string `json:"old_price"` - GoodsPrice string `json:"goods_price"` - Commission string `json:"commission"` - CommissionRate string `json:"commission_rate"` - CouponPrice string `json:"coupon_price"` - WlGoodsPrice string `json:"wl_goods_price"` //卷后价 - LowerPrice string `json:"lower_price"` - LowestCouponPrice string `json:"lowestCouponPrice"` - MinGroupPrice string `json:"min_group_price"` - PaidPrice string `json:"paid_price"` - Oid string `json:"oid"` //标记 - IsGoods string `json:"is_goods"` - ShowLevel string `json:"show_level"` - IsShowExtend string `json:"is_show_extend"` - GoodsCommission string `json:"goods_commission"` - GoodsType string `json:"goods_type"` + OldPrice string `json:"old_price"` + GoodsPrice string `json:"goods_price"` + Commission string `json:"commission"` + CommissionRate string `json:"commission_rate"` + CouponPrice string `json:"coupon_price"` + WlGoodsPrice string `json:"wl_goods_price"` //卷后价 + LowerPrice string `json:"lower_price"` + LowestCouponPrice string `json:"lowestCouponPrice"` + MinGroupPrice string `json:"min_group_price"` + PaidPrice string `json:"paid_price"` + Oid string `json:"oid"` //标记 + IsGoods string `json:"is_goods"` + ShowLevel string `json:"show_level"` + IsShowExtend string `json:"is_show_extend"` + GoodsCommission string `json:"goods_commission"` + GoodsType string `json:"goods_type"` + TikTokTeamCommission string `json:"tik_tok_team_commission"` } type CommissionFirstParam struct { CommissionParam CommissionParam `json:"commission_param"` diff --git a/svc/reward_commission.go b/svc/reward_commission.go index 531396b..51cee68 100644 --- a/svc/reward_commission.go +++ b/svc/reward_commission.go @@ -243,7 +243,7 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b return ulink.Profit, pvdFee, sysFee, subsidyFee, ulink, 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, rmd.IsGoods) + pvdFee, sysFee, subsidyFee, ulink, err := CalcCommission(uid, level, 0, ownbuyReturnType, comf, zhios_order_relate_utils.StrToFloat64(price), isShare, cfg, userRelationship, newProvider, newLevel, engine, rmd.IsGoods, rmd) if err != nil { return 0, 0, 0, 0, nil, nil } @@ -492,7 +492,7 @@ func CommFee(fee float64, opt *comm_plan.PlanOpt, types, isGoods string) (float6 // 根据用户计算对应的手续费 //ownbuyReturnType 0返利 1不返利 (免单商品是淘礼金商品的时候用的) //pvd 只是为了判断是会员升级的订单 可不传 -func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee float64, isShare bool, opt *comm_plan.PlanOpt, userRelationShip *[]md.UserRelation, pvd string, newLevel int, eg *xorm.Engine, isGoods string) (pvdFee, sysFee, subsidyFee float64, lvUser *comm_plan.LvUser, err error) { +func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee float64, isShare bool, opt *comm_plan.PlanOpt, userRelationShip *[]md.UserRelation, pvd string, newLevel int, eg *xorm.Engine, isGoods string, rmd *md.CommissionParam) (pvdFee, sysFee, subsidyFee float64, lvUser *comm_plan.LvUser, err error) { //佣金扣除抽成后 fee, pvdFee, sysFee = CommFee(fee, opt, "commission", isGoods) //积分扣除抽成后 @@ -523,6 +523,9 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee if ok { subsidyFee = subsidyFee1 } + // 抖团服务费金额的补贴 + tikTokSubsidyFeeList := getTikTokOwnSubsidy(opt, level, isShare, rmd) + // 获取用户的关系网 //userRelationShip, err := UserRelativeNetwork(eg, uid) // 如果获取用户关系失败或者佣金方案不存在, 那么只计算当前用户的佣金, 平台佣金, 以及供应商方的佣金 @@ -537,7 +540,7 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee amountList[k].Val = ratioListMap[v.Cid] * v.Val } //重新计算佣金 - return pvdFee, sysFee, subsidyFee, &comm_plan.LvUser{OwnSubsidyFeeList: subsidyFeeList, Uid: uid, Lv: level, OldDiff: oldDiff, Profit: commission, ProfitList: amountList, Diff: 0}, nil + return pvdFee, sysFee, subsidyFee, &comm_plan.LvUser{TikTokOwnSubsidyFeeList: tikTokSubsidyFeeList, OwnSubsidyFeeList: subsidyFeeList, Uid: uid, Lv: level, OldDiff: oldDiff, Profit: commission, ProfitList: amountList, Diff: 0}, nil } //查出所有等级替换权重 @@ -548,7 +551,7 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee levelWeight = v1.LevelWeight } } - lvUser = &comm_plan.LvUser{OwnSubsidyFeeList: subsidyFeeList, Uid: uid, Lv: level, Diff: 0, OldDiff: oldDiff, NewLv: newLevel, LevelWeight: levelWeight, OwnbuyReturnType: ownbuyReturnType} + lvUser = &comm_plan.LvUser{TikTokOwnSubsidyFeeList: tikTokSubsidyFeeList, OwnSubsidyFeeList: subsidyFeeList, Uid: uid, Lv: level, Diff: 0, OldDiff: oldDiff, NewLv: newLevel, LevelWeight: levelWeight, OwnbuyReturnType: ownbuyReturnType} var node = lvUser //关系链处理 for _, v := range *userRelationShip { @@ -698,7 +701,32 @@ func getOwnSubsidy(opt *comm_plan.PlanOpt, level int, isShare bool, fee, sysFee, } return res } - +func getTikTokOwnSubsidy(opt *comm_plan.PlanOpt, level int, isShare bool, rmd *md.CommissionParam) map[string]float64 { + var res = make(map[string]float64) + if zhios_order_relate_utils.StrToFloat64(rmd.TikTokTeamCommission) == 0 { + return res + } + if opt.UserRate[level].SubsidyEnable != 1 { + return res + } + if opt.UserRate[level].TikTokTeamSubsidyEnable != 1 { + return res + } + if len(opt.UserRate[level].TikTokTeamSubsidyList) == 0 { + return res + } + for _, v := range opt.UserRate[level].TikTokTeamSubsidyList { + var newFee = zhios_order_relate_utils.StrToFloat64(rmd.TikTokTeamCommission) + var subsidyFee float64 = 0 + subsidyFee = newFee * (zhios_order_relate_utils.StrToFloat64(v["self_bili"]) / 100) + if isShare { + subsidyFee = newFee * (zhios_order_relate_utils.StrToFloat64(v["share_bili"]) / 100) + } + subsidyFee = zhios_order_relate_utils.FloatFormat(subsidyFee, 6) + res[v["coin_id"]] = subsidyFee + } + return res +} func convertList2Map(a []*comm_plan.VirtualCoinCommission) (b map[string]float64) { b = make(map[string]float64) for _, i := range a {