|
|
@@ -7,13 +7,12 @@ import ( |
|
|
|
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"strings" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
// getRewardCommission is 获取制度后的佣金 |
|
|
|
// 返回:单个佣金、层级佣金、错误 |
|
|
|
func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare bool, userId, provider, masterId string, returnAllLevel bool, extraData map[string]string,virType string) (float64, float64, float64, float64, *comm_plan.LvUser, error) { |
|
|
|
func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare bool, userId, provider, masterId string, returnAllLevel bool, extraData map[string]string, virType string) (float64, float64, float64, float64, *comm_plan.LvUser, error) { |
|
|
|
|
|
|
|
if virType == "commission" { |
|
|
|
rmd.GoodsPrice = rmd.Commission |
|
|
@@ -281,6 +280,9 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee |
|
|
|
var node = lvUser |
|
|
|
//关系链处理 |
|
|
|
for _, v := range *userRelationShip { |
|
|
|
if v.Uid == 0 { |
|
|
|
continue |
|
|
|
} |
|
|
|
for _, v1 := range levelList { |
|
|
|
levelId := v.Level |
|
|
|
if v1.Id == levelId { |
|
|
@@ -338,56 +340,6 @@ func getOwnSubsidy(opt *comm_plan.PlanOpt, level int, isShare bool, fee, sysFee, |
|
|
|
return res |
|
|
|
} |
|
|
|
|
|
|
|
func getBili(eg *xorm.Engine, types string) float64 { |
|
|
|
//读取佣金与 区块币比例 |
|
|
|
biliList, _ := db.SysCfgGetOne(eg, types) |
|
|
|
var bili float64 = 1 |
|
|
|
if biliList != nil && biliList.Val != "" { |
|
|
|
list := strings.Split(biliList.Val, ":") |
|
|
|
if len(list) == 2 { |
|
|
|
bili = zhios_order_relate_utils.StrToFloat64(list[0]) / zhios_order_relate_utils.StrToFloat64(list[1]) |
|
|
|
bili = zhios_order_relate_utils.FloatFormat(bili, 6) |
|
|
|
} |
|
|
|
} |
|
|
|
return bili |
|
|
|
} |
|
|
|
// |
|
|
|
////分佣记录写入 |
|
|
|
//func OrderRelateInsert(eg *xorm.Engine, userId int, oid int64, pvd string, createTime int, CommissionParam *md.CommissionParam, masterId string) { |
|
|
|
// _, _, _, _, lvUser, _ := GetRewardCommission(eg, CommissionParam, false, zhios_order_relate_utils.IntToStr(userId), pvd, masterId, true, map[string]string{}) |
|
|
|
// fmt.Println(lvUser) |
|
|
|
// if lvUser == nil { |
|
|
|
// return |
|
|
|
// } |
|
|
|
// level := 0 |
|
|
|
// profit := zhios_order_relate_utils.FloatFormat(lvUser.Profit+lvUser.SubsidyFee, 6) |
|
|
|
// //更新订单表的用户佣金 |
|
|
|
// if pvd == "regional_agent_pay" { |
|
|
|
// _, _ = db.RegionalAgentOrdUpdate(eg, map[string]interface{}{ |
|
|
|
// "key": "ord_id", |
|
|
|
// "value": oid, |
|
|
|
// }, &model2.RegionalAgentUserOrd{UserCommission: zhios_order_relate_utils.Float64ToStr(profit)}) |
|
|
|
// } |
|
|
|
// if pvd == "userlvup" { |
|
|
|
// _, _ = levelDb.UserLevelUpgradeOrdUpdate(eg, map[string]interface{}{ |
|
|
|
// "key": "ord_id", |
|
|
|
// "value": oid, |
|
|
|
// }, &levelModel.UserLevelUpgradeOrd{UserCommission: zhios_order_relate_utils.Float64ToStr(profit)}) |
|
|
|
// } |
|
|
|
// data := []*model.OrdListRelate{{Oid: oid, Uid: lvUser.Uid, Amount: profit, Pvd: pvd, CreateAt: createTime, Level: level}} |
|
|
|
// for lvUser.ParentUser != nil { |
|
|
|
// lvUser = lvUser.ParentUser |
|
|
|
// fmt.Println(lvUser) |
|
|
|
// level = level + 1 |
|
|
|
// profit = zhios_order_relate_utils.FloatFormat(lvUser.Profit+lvUser.SubsidyFee, 6) |
|
|
|
// data = append(data, &model.OrdListRelate{Oid: oid, Uid: lvUser.Uid, Amount: profit, Pvd: pvd, CreateAt: createTime, Level: level}) |
|
|
|
// } |
|
|
|
// err := commDb.DbInsertBatch(eg, data) |
|
|
|
// if err != nil { |
|
|
|
// return |
|
|
|
// } |
|
|
|
// return |
|
|
|
//} |
|
|
|
func convertList2Map(a []*comm_plan.VirtualCoinCommission) (b map[string]float64) { |
|
|
|
b = make(map[string]float64) |
|
|
|
for _, i := range a { |
|
|
|