@@ -0,0 +1,14 @@ | |||
package db | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" | |||
"xorm.io/xorm" | |||
) | |||
func SecondGetAllPriceTypeList(Db *xorm.Engine) ([]model.SecondNewcomersFreePriceType, error) { | |||
var priceType []model.SecondNewcomersFreePriceType | |||
if err := Db.Find(&priceType); err != nil { | |||
return nil, err | |||
} | |||
return priceType, nil | |||
} |
@@ -0,0 +1,19 @@ | |||
package model | |||
type SecondNewcomersFreePriceType struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
PriceName string `json:"price_name" xorm:"not null comment('价格类型') VARCHAR(255)"` | |||
NeedQuan int `json:"need_quan" xorm:"not null default 0 comment('需要的福利券') INT(11)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否开启') TINYINT(1)"` | |||
IsDel int `json:"is_del" xorm:"not null default 0 INT(11)"` | |||
Auth string `json:"auth" xorm:"not null comment('权限') TEXT"` | |||
NeedUseQuan int `json:"need_use_quan" xorm:"default 1 comment('是否需要使用免单券 0否 1是') INT(1)"` | |||
NeedLimitBuy int `json:"need_limit_buy" xorm:"default 0 comment('是否限购') INT(1)"` | |||
LimitBuyCondition string `json:"limit_buy_condition" xorm:"default '' comment('限购条件') VARCHAR(255)"` | |||
CommissionId string `json:"commission_id" xorm:"default '' VARCHAR(255)"` | |||
LimitStr string `json:"limit_str" xorm:"default '' VARCHAR(255)"` | |||
BuyStr string `json:"buy_str" xorm:"default '' VARCHAR(255)"` | |||
CommissionData string `json:"commission_data" xorm:"default '' VARCHAR(500)"` | |||
} |
@@ -8,6 +8,7 @@ type UserPublicPlatoonLaxinRewardSetting struct { | |||
IsUseRewardLimit int `json:"is_use_reward_limit" xorm:"default 0 comment('是否开启奖励限制(奖励积分只能获取等级与自己一样或等级低的人的奖励积分) ') TINYINT(1)"` | |||
CoinId int `json:"coin_id" xorm:"INT(11)"` | |||
Detail string `json:"detail" xorm:"TEXT"` | |||
LevelDetail string `json:"level_detail" xorm:"TEXT"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"` | |||
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"` | |||
} |
@@ -725,7 +725,7 @@ func getCommissionRatio(typ string, level, peerNum int, grade map[int]*LvGrade) | |||
case "team": | |||
ratio = grade[level].TeamRate | |||
case "same_lv": | |||
if len(grade[level].PeerRate) == 0 { | |||
if len(grade[level].PeerRate) == 0 || len(grade[level].PeerRate) < peerNum+1 { | |||
ratio = 0 | |||
} else { | |||
ratio = grade[level].PeerRate[peerNum] | |||
@@ -748,8 +748,12 @@ func getVirtualCoinRatio(typ string, level, peerNum int, grade map[int]*LvGrade, | |||
switch typ { | |||
case "extend_lv": | |||
if isPostion == 1 { | |||
ratio, ok = grade[level].SecondExtendList[coinId] | |||
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 4) | |||
SecondExtendList, ok1 := grade[level].SecondExtendList.(map[string]string) | |||
if ok1 { | |||
ratio, ok = SecondExtendList[coinId] | |||
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 4) | |||
} | |||
} else { | |||
ratio, ok = grade[level].NewExtendList[coinId] | |||
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 4) | |||
@@ -70,7 +70,10 @@ func getVirtualCoinRatioDsOwn(typ string, level, peerNum int, grade map[int]*LvG | |||
switch typ { | |||
case "extend_lv": | |||
if isPostion == 1 { | |||
ratio, ok = grade[level].SecondExtendList[coinId] | |||
SecondExtendList, ok1 := grade[level].SecondExtendList.(map[string]string) | |||
if ok1 { | |||
ratio, ok = SecondExtendList[coinId] | |||
} | |||
} else { | |||
ratio, ok = grade[level].NewExtendList[coinId] | |||
} | |||
@@ -72,7 +72,7 @@ type LvGrade struct { | |||
TeamRateList map[string]string `json:"team_rate_list"` // 团队最高比例 | |||
NewTeamList map[string]string `json:"new_team_list"` // 新团队比例 | |||
NewExtendList map[string]string `json:"new_extend_list"` // 直推比例 | |||
SecondExtendList map[string]string `json:"second_extend_list"` // 直推比例 | |||
SecondExtendList interface{} `json:"second_extend_list"` // 直推比例 | |||
ToTeamList map[string]string `json:"to_team_list"` // 直推比例 | |||
SameUserCount string `json:"same_user_count"` | |||
SameExtend []map[string]string `json:"same_extend"` | |||
@@ -85,7 +85,7 @@ type LvGrade struct { | |||
TikTokTeamSubsidyOwnBiliType []string `json:"tik_tok_team_subsidy_own_bili_type"` //分销 返利类型 | |||
TikTokTeamSubsidyList []map[string]string `json:"tik_tok_team_subsidy_list"` | |||
ToExtendList map[string]string `json:"to_extend_list"` // | |||
CommonWealthSystem map[string]string `json:"common_wealth_system"` //共富制度比例 | |||
CommonWealthSystem interface{} `json:"common_wealth_system"` //共富制度比例 | |||
} | |||
type LvGradePricePublic struct { | |||
@@ -226,6 +226,7 @@ type LvUser struct { | |||
LevelWeight int // 权重 | |||
Profit float64 // 利润(金额) | |||
SubsidyFee float64 // 补贴(金额) | |||
AdditionalSubsidy float64 | |||
MinLevel int | |||
IsFreeze int | |||
MinProfit float64 // 利润(金额) | |||
@@ -21,6 +21,7 @@ type CommissionParam struct { | |||
TikTokTeamCommission string `json:"tik_tok_team_commission"` | |||
IsTikTokTeamOrder string `json:"is_tik_tok_team_order"` | |||
MinLevel int `json:"min_level"` | |||
DouyinBili string `json:"douyin_bili"` | |||
} | |||
type CommissionFirstParam struct { | |||
CommissionParam CommissionParam `json:"commission_param"` | |||
@@ -36,6 +36,10 @@ type CalcSmallPublicPlatoonRelateLaXinReward struct { | |||
CoinId int `json:"coin_id"` | |||
Value string `json:"value"` | |||
} | |||
type CalcSmallPublicPlatoonRelateLaXinLevel struct { | |||
Id string `json:"id"` | |||
Detail []*CalcSmallPublicPlatoonRelateLaXinDetail `json:"detail"` | |||
} | |||
type CalcSmallPublicPlatoonRelateLaXinDetail struct { | |||
Key int `json:"key"` | |||
@@ -533,7 +533,7 @@ func FindRandUser(engine *xorm.Engine, nums int) (resp []int64, err error) { | |||
var uniqueMap = map[int64]bool{} | |||
var j = 0 | |||
for { | |||
ids := randSeedInt(int64(minM.Id), int64(maxM.Id), nums-len(resp), uniqueMap) | |||
ids := randSeedInt(int64(minM.Id), int64(maxM.Id), nums-len(resp), uniqueMap, &[]int64{}) | |||
var list []model.UserPublicPlatoonRelation | |||
if err1 := engine.In("id", ids). | |||
Find(&list); err1 != nil { | |||
@@ -559,19 +559,20 @@ func FindRandUser(engine *xorm.Engine, nums int) (resp []int64, err error) { | |||
return | |||
} | |||
func randSeedInt(start, end int64, nums int, uniqueMap map[int64]bool) (resp []int64) { | |||
func randSeedInt(start, end int64, nums int, uniqueMap map[int64]bool, resp *[]int64) (res []int64) { | |||
rand.Seed(time.Now().UnixNano()) | |||
for { | |||
result := rand.Int63n(end) + start | |||
if !uniqueMap[result] { | |||
resp = append(resp, result) | |||
*resp = append(*resp, result) | |||
uniqueMap[result] = true | |||
break | |||
} | |||
} | |||
if len(resp) < nums { | |||
randSeedInt(start, end, nums, uniqueMap) | |||
if len(*resp) < nums { | |||
randSeedInt(start, end, nums, uniqueMap, resp) | |||
} | |||
return | |||
res = *resp | |||
return res | |||
} |
@@ -26,8 +26,8 @@ func BatchGetSmallPublicPlatoonRelateCommissionByOrder(engine *xorm.Engine, mast | |||
} | |||
// CalcSmallPublicPlatoonRelateLaXinReward 计算拉新奖励 | |||
func CalcSmallPublicPlatoonRelateLaXinReward(engine *xorm.Engine, masterId string, rewardUid int) ([]*md.CalcSmallPublicPlatoonRelateLaXinReward, error) { | |||
resp, err := svc.CalcSmallPublicPlatoonRelateLaXinReward(engine, masterId, rewardUid) | |||
func CalcSmallPublicPlatoonRelateLaXinReward(engine *xorm.Engine, masterId string, rewardUid, level int) ([]*md.CalcSmallPublicPlatoonRelateLaXinReward, error) { | |||
resp, err := svc.CalcSmallPublicPlatoonRelateLaXinReward(engine, masterId, rewardUid, level) | |||
if err != nil { | |||
return nil, err | |||
} | |||
@@ -34,6 +34,32 @@ func GetAllPlan(eg *xorm.Engine, dbName string) (map[string]*model.PlanReward, m | |||
for _, v := range pvds { | |||
plan[v.Pvd] = v | |||
} | |||
list, _ := db.SecondGetAllPriceTypeList(eg) | |||
for _, v := range list { | |||
var oneRewardPlan map[string]string | |||
err := json.Unmarshal([]byte(v.CommissionData), &oneRewardPlan) | |||
if err == nil { | |||
var tmp = &model.PlanReward{ | |||
Id: 0, | |||
Pvd: "seFree_" + zhios_order_relate_utils.IntToStr(v.Id), | |||
PvdRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["pvd_rate"]) / 100, | |||
SysRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["sys_rate"]) / 100, | |||
RegionRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["region_rate"]) / 100, | |||
GlobalRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["global_rate"]) / 100, | |||
SettleMode: zhios_order_relate_utils.StrToInt(oneRewardPlan["settle_mode"]), | |||
PlanCommissionId: zhios_order_relate_utils.StrToInt(oneRewardPlan["plan_commission_id"]), | |||
PlanSettleId: zhios_order_relate_utils.StrToInt(oneRewardPlan["plan_settle_id"]), | |||
State: 1, | |||
Source: 1, | |||
IntegralOpen: zhios_order_relate_utils.StrToInt(oneRewardPlan["integral_open"]), | |||
MerchantRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["merchant_rate"]) / 100, | |||
PushHandRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["push_hand_rate"]) / 100, | |||
OrderBeforeRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["order_before_rate"]) / 100, | |||
} | |||
plan[tmp.Pvd] = tmp | |||
} | |||
} | |||
commission := make(map[int]*model.PlanCommission, 0) | |||
commissions := db.DbsPlanCommissionByIds(eg) | |||
for _, v := range commissions { | |||
@@ -47,8 +73,14 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo | |||
opt := &comm_plan.PlanOpt{} | |||
// 根据供应商 | |||
rewardOpt := rewardOpts[pvd] | |||
if pvd == "tikTok" && rmd.IsTikTokTeamOrder == "1" && rewardOpts["tikTokTeam"] != nil && rewardOpts["tikTokTeam"].PlanCommissionId > 0 { | |||
rewardOpt = rewardOpts["tikTokTeam"] | |||
if strings.Contains(pvd, "seFree") == false { | |||
if pvd == "tikTok" && rmd.IsTikTokTeamOrder == "1" && rewardOpts["tikTokTeam"] != nil && rewardOpts["tikTokTeam"].PlanCommissionId > 0 { | |||
rewardOpt = rewardOpts["tikTokTeam"] | |||
} | |||
if pvd == "kuaishou" && rmd.IsTikTokTeamOrder == "1" && rewardOpts["kuaishouTeam"] != nil && rewardOpts["kuaishouTeam"].PlanCommissionId > 0 { | |||
rewardOpt = rewardOpts["kuaishouTeam"] | |||
} | |||
} | |||
if rewardOpt == nil { | |||
return nil, zhios_order_relate_logx.Warn("找不到方案记录") | |||
@@ -115,6 +147,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo | |||
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"second_extend_list\":[]", "\"second_extend_list\":{}") | |||
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"to_extend_list\":[]", "\"to_extend_list\":{}") | |||
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"common_wealth_system\":[]", "\"common_wealth_system\":{}") | |||
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"common_wealth_system\":[\"0\"]", "\"common_wealth_system\":{}") | |||
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"to_team_list\":[]", "\"to_team_list\":{}") | |||
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"same_extend\":[[]]", "\"same_extend\":[]") | |||
if strings.Contains(commissionOpt.Data, "\"subsidy_mode_list\":[") { //兼容旧的方案 | |||
@@ -181,10 +214,8 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo | |||
} | |||
if err := json.Unmarshal([]byte(commissionOpt.Data), &subsidyTmp); err != nil { | |||
if masterId == "68823769" { | |||
fmt.Println("===========================分佣方案数据设置错误", commissionOpt) | |||
fmt.Println("===========================分佣方案数据设置错误", err) | |||
} | |||
fmt.Println("===========================分佣方案数据设置错误", commissionOpt) | |||
fmt.Println("===========================分佣方案数据设置错误", err) | |||
return nil, zhios_order_relate_logx.Warn(fmt.Sprintf("%s:分佣方案数据设置错误", masterId)) | |||
} | |||
opt.UserRate = subsidyTmp | |||
@@ -210,7 +241,31 @@ func PlanOpts(eg *xorm.Engine) map[string]*comm_plan.PlanOpt { | |||
if err != nil || allRewardPlan == nil { | |||
return nil | |||
} | |||
list, _ := db.SecondGetAllPriceTypeList(eg) | |||
for _, v := range list { | |||
var oneRewardPlan map[string]string | |||
err := json.Unmarshal([]byte(v.CommissionData), &oneRewardPlan) | |||
if err == nil { | |||
var tmp = &model.PlanReward{ | |||
Id: 0, | |||
Pvd: "seFree_" + zhios_order_relate_utils.IntToStr(v.Id), | |||
PvdRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["pvd_rate"]) / 100, | |||
SysRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["sys_rate"]) / 100, | |||
RegionRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["region_rate"]) / 100, | |||
GlobalRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["global_rate"]) / 100, | |||
SettleMode: zhios_order_relate_utils.StrToInt(oneRewardPlan["settle_mode"]), | |||
PlanCommissionId: zhios_order_relate_utils.StrToInt(oneRewardPlan["plan_commission_id"]), | |||
PlanSettleId: zhios_order_relate_utils.StrToInt(oneRewardPlan["plan_settle_id"]), | |||
State: 1, | |||
Source: 1, | |||
IntegralOpen: zhios_order_relate_utils.StrToInt(oneRewardPlan["integral_open"]), | |||
MerchantRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["merchant_rate"]) / 100, | |||
PushHandRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["push_hand_rate"]) / 100, | |||
OrderBeforeRate: zhios_order_relate_utils.StrToFloat32(oneRewardPlan["order_before_rate"]) / 100, | |||
} | |||
allRewardPlan = append(allRewardPlan, tmp) | |||
} | |||
} | |||
opts := map[string]*comm_plan.PlanOpt{} | |||
for _, v := range allRewardPlan { | |||
if _, ok := commissionPlans[v.PlanCommissionId]; ok && v.State == 1 && v.PlanCommissionId > 0 { | |||
@@ -235,6 +290,7 @@ func PlanOpts(eg *xorm.Engine) map[string]*comm_plan.PlanOpt { | |||
} | |||
} | |||
fmt.Println(opts) | |||
if len(opts) == 0 { | |||
return nil | |||
} | |||
@@ -84,15 +84,15 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b | |||
fmt.Println(com) | |||
fmt.Println(price) | |||
comf := zhios_order_relate_utils.StrToFloat64(com) | |||
if zhios_order_relate_utils.InArr(cfg.Mode, []string{"lv_price_public_platoon", "lv_price", "lv_winery", "extend_price", "niubei_amount"}) && zhios_order_relate_utils.StrToFloat64(rmd.OldPrice) > 0 { //价格为基数 | |||
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" { | |||
//公排 | |||
//佣金扣除抽成后 | |||
fee, _, pvdFee, sysFee := CommFee(comf, cfg, "commission", rmd.IsGoods) | |||
fee, _, pvdFee, sysFee := CommFee(comf, cfg, "commission", rmd) | |||
////积分扣除抽成后 | |||
integralFee, _, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", rmd.IsGoods) | |||
integralFee, _, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", rmd) | |||
//调用公排制度 | |||
userPublicPlatoonSetting, err := db.UserPublicPlatoonSettingGetOneByParams(engine, map[string]interface{}{ | |||
@@ -175,7 +175,7 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b | |||
} | |||
if cfg.Mode == "lv_integral_release" { // | |||
price = rmd.OldPrice | |||
pvdFee, sysFee, _, ulink, err := IntegralRelease(engine, uid, newLevel, returnAllLevel, rmd.IsShowExtend, newProvider, user, comf, price, cfg, rmd.IsGoods, commArr, virtualCoinMoneyRate) | |||
pvdFee, sysFee, _, ulink, err := IntegralRelease(engine, uid, newLevel, returnAllLevel, rmd.IsShowExtend, newProvider, user, comf, price, cfg, rmd, commArr, virtualCoinMoneyRate) | |||
if err != nil { | |||
return 0, 0, 0, 0, nil, nil | |||
} | |||
@@ -195,9 +195,9 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b | |||
userLevel = zhios_order_relate_utils.StrToInt(extraData["agent_lv"]) | |||
} | |||
//佣金扣除抽成后 | |||
fee, _, pvdFee, sysFee := CommFee(comf, cfg, "commission", rmd.IsGoods) | |||
fee, _, pvdFee, sysFee := CommFee(comf, cfg, "commission", rmd) | |||
////积分扣除抽成后 | |||
integralFee, _, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", rmd.IsGoods) | |||
integralFee, _, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", rmd) | |||
var param = map[string]string{ | |||
"commission": zhios_order_relate_utils.Float64ToStr(fee), | |||
"integral": zhios_order_relate_utils.Float64ToStr(integralFee), | |||
@@ -270,9 +270,9 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b | |||
} | |||
func public(engine *xorm.Engine, ulinkParent *comm_plan.LvUser, cfg *comm_plan.PlanOpt, newProvider string, uid int, comf float64, price string, rmd *md.CommissionParam) *comm_plan.LvUser { | |||
//佣金扣除抽成后 | |||
fee, _, _, _ := CommFee(comf, cfg, "commission", rmd.IsGoods) | |||
fee, _, _, _ := CommFee(comf, cfg, "commission", rmd) | |||
////积分扣除抽成后 | |||
integralFee, _, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", rmd.IsGoods) | |||
integralFee, _, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", rmd) | |||
//调用公排制度 | |||
userPublicPlatoonSetting, err := db.UserPublicPlatoonSettingGetOneByParams(engine, map[string]interface{}{ | |||
@@ -320,7 +320,11 @@ func public(engine *xorm.Engine, ulinkParent *comm_plan.LvUser, cfg *comm_plan.P | |||
if zhios_order_relate_utils.StrToInt(coinId) > 0 { //积分更换基数 | |||
pendingAmount = zhios_order_relate_utils.Float64ToStr(integralFee) | |||
} | |||
commonWealthSystem[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(grade.CommonWealthSystem[coinId]) * zhios_order_relate_utils.StrToFloat64(pendingAmount) / 100) | |||
CommonWealthSystems, ok := grade.CommonWealthSystem.(map[string]string) | |||
if ok { | |||
commonWealthSystem[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(CommonWealthSystems[coinId]) * zhios_order_relate_utils.StrToFloat64(pendingAmount) / 100) | |||
} | |||
} | |||
} | |||
//共富收益处理 | |||
@@ -576,12 +580,12 @@ func currentPrice(m *md.CommissionParam, pvd string) string { | |||
return "" | |||
} | |||
} | |||
func CommFee(fee float64, opt *comm_plan.PlanOpt, types, isGoods string) (float64, float64, float64, float64) { | |||
func CommFee(fee float64, opt *comm_plan.PlanOpt, types string, rmd *md.CommissionParam) (float64, float64, float64, float64) { | |||
var feeFirst float64 = 1 | |||
if types == "integral" && opt.IntegralOpen == 0 || opt.Mode == "lv_winery" { //积分抽成后台没开启不用扣 | |||
return fee, feeFirst, 0, 0 | |||
} | |||
isGoods := rmd.IsGoods | |||
if isGoods == "1" { | |||
orderBeforeRate := fee * opt.OrderBeforeRate | |||
orderBeforeRateFirst := feeFirst * opt.OrderBeforeRate | |||
@@ -610,6 +614,9 @@ func CommFee(fee float64, opt *comm_plan.PlanOpt, types, isGoods string) (float6 | |||
for _, v := range opt.RateList { | |||
total -= int64(fee * (v / 100) * 1e4) | |||
} | |||
if zhios_order_relate_utils.StrToFloat64(rmd.DouyinBili) > 0 { | |||
total -= int64(zhios_order_relate_utils.StrToFloat64(rmd.DouyinBili) * 1e4) | |||
} | |||
fee = float64(total) / 1e4 | |||
if fee < 0 { | |||
fee = 0 | |||
@@ -645,10 +652,10 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee | |||
//佣金扣除抽成后 | |||
var feeFirst float64 = 1 | |||
var integralFeeFirst float64 = 1 | |||
fee, feeFirst, pvdFee, sysFee = CommFee(fee, opt, "commission", isGoods) | |||
fee, feeFirst, pvdFee, sysFee = CommFee(fee, opt, "commission", rmd) | |||
//积分扣除抽成后 | |||
var integralSysFee float64 = 0 | |||
integralFee, integralFeeFirst, _, integralSysFee = CommFee(integralFee, opt, "integral", isGoods) | |||
integralFee, integralFeeFirst, _, integralSysFee = CommFee(integralFee, opt, "integral", rmd) | |||
// 计算自购补贴比例 | |||
subsidyFee = 0 | |||
//如果没登录,要找出权重最低的那个 | |||
@@ -764,11 +771,11 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee | |||
//pvd 只是为了判断是会员升级的订单 可不传 | |||
func NiuBeiCalcCommission(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) | |||
fee, _, pvdFee, sysFee = CommFee(fee, opt, "commission", rmd) | |||
//积分扣除抽成后 | |||
var integralSysFee float64 = 0 | |||
integralFee, _, _, integralSysFee = CommFee(integralFee, opt, "integral", isGoods) | |||
integralFeeForPrice, _, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(rmd.OldPrice), opt, "integral", isGoods) | |||
integralFee, _, _, integralSysFee = CommFee(integralFee, opt, "integral", rmd) | |||
integralFeeForPrice, _, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(rmd.OldPrice), opt, "integral", rmd) | |||
// 计算自购补贴比例 | |||
subsidyFee = 0 | |||
//如果没登录,要找出权重最低的那个 | |||
@@ -155,7 +155,7 @@ func benefitUid(engine *xorm.Engine, param *md.SmallPublicPlatoonRelateCommissio | |||
} | |||
func CalcSmallPublicPlatoonRelateLaXinReward(engine *xorm.Engine, masterId string, rewardUid int) (resp []*md.CalcSmallPublicPlatoonRelateLaXinReward, err error) { | |||
func CalcSmallPublicPlatoonRelateLaXinReward(engine *xorm.Engine, masterId string, rewardUid, level int) (resp []*md.CalcSmallPublicPlatoonRelateLaXinReward, err error) { | |||
userPublicPlatoonRelation, err := db.UserSmallPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{ | |||
"key": "uid", | |||
"value": rewardUid, | |||
@@ -185,10 +185,19 @@ func CalcSmallPublicPlatoonRelateLaXinReward(engine *xorm.Engine, masterId strin | |||
//2、解析 detail | |||
var detail []*md.CalcSmallPublicPlatoonRelateLaXinDetail | |||
if err2 := json.Unmarshal([]byte(m.Detail), &detail); err != nil { | |||
if err2 := json.Unmarshal([]byte(m.Detail), &detail); err2 != nil { | |||
return nil, err2 | |||
} | |||
var levelDetail []md.CalcSmallPublicPlatoonRelateLaXinLevel | |||
err2 := json.Unmarshal([]byte(m.LevelDetail), &levelDetail) | |||
if err2 == nil { | |||
for _, v := range levelDetail { | |||
if zhios_order_relate_utils.StrToInt(v.Id) == level && len(v.Detail) > 0 { | |||
detail = v.Detail | |||
} | |||
} | |||
} | |||
fatherPositions := strings.Split(userPublicPlatoonRelation.FatherUid, "-") | |||
var rewardUserLevelWeight int | |||
if m.IsUseRewardLimit == 1 { | |||
@@ -323,9 +332,13 @@ func BatchSmallGetPublicPlatoonRelateByGoods(engine *xorm.Engine, masterId strin | |||
var commonWealthSystem = make(map[string]string) | |||
if lvGrade != nil { | |||
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) / 100) | |||
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) | |||
commonWealthSystem[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.CommonWealthSystem[coinId]) * zhios_order_relate_utils.StrToFloat64(pendingAmount) / 100) | |||
directPush[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.DirectPush[coinId]) * zhios_order_relate_utils.StrToFloat64(pendingAmount) / 100) | |||
} | |||
} | |||
resp[param.Oid] = &md.SmallPublicPlatoonRelateCommissionResp{ | |||
@@ -12,12 +12,12 @@ import ( | |||
"xorm.io/xorm" | |||
) | |||
func IntegralRelease(engine *xorm.Engine, uid, level int, returnAllLevel bool, IsShowExtend, pvd string, user *model.User, comf float64, price string, cfg *comm_plan.PlanOpt, isGoods string, commArr map[string]string, virtualCoinMoneyRate map[int]string) (pvdFee, sysFee, subsidyFee float64, lvUser *comm_plan.LvUser, err error) { | |||
func IntegralRelease(engine *xorm.Engine, uid, level int, returnAllLevel bool, IsShowExtend, pvd string, user *model.User, comf float64, price string, cfg *comm_plan.PlanOpt, rmd *md.CommissionParam, commArr map[string]string, virtualCoinMoneyRate map[int]string) (pvdFee, sysFee, subsidyFee float64, lvUser *comm_plan.LvUser, err error) { | |||
//佣金扣除抽成后 | |||
fee, _, pvdFee, sysFee := CommFee(comf, cfg, "commission", isGoods) | |||
fee, _, pvdFee, sysFee := CommFee(comf, cfg, "commission", rmd) | |||
////积分扣除抽成后 | |||
integralFee, _, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", isGoods) | |||
integralFeeCom, _, _, _ := CommFee(comf, cfg, "integral", isGoods) | |||
integralFee, _, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", rmd) | |||
integralFeeCom, _, _, _ := CommFee(comf, cfg, "integral", rmd) | |||
//常规级差 | |||
var userRelationship *[]md.UserRelation | |||
if returnAllLevel { | |||