diff --git a/lib/comm_plan/winery.go b/lib/comm_plan/winery.go index 95d5673..1655828 100644 --- a/lib/comm_plan/winery.go +++ b/lib/comm_plan/winery.go @@ -82,23 +82,27 @@ Loop: var isBreak bool zeroList := make(map[string]struct{}) if node.ParentUser.Diff == 1 { - //找出前两个人 如果不是就分团队奖 如果是就再找 - sql := `SELECT u.uid,u.first_arrive_at FROM user_profile up - LEFT JOIN user u on u.uid=up.uid - WHERE up.parent_uid=? ORDER BY u.first_arrive_at asc,u.uid asc LIMIT 2` - nativeString, err := db.QueryNativeString(eg, sql, node.ParentUser.ParentUser.Uid) - if err != nil { - return zhios_order_relate_logx.Warn("sql error") - } //定位 isPostion := 0 - if len(nativeString) > 0 { - for _, v := range nativeString { - if zhios_order_relate_utils.StrToInt(v["uid"]) == node.ParentUser.Uid { - isPostion = 1 + if node.ParentUser.ParentUser != nil { + //找出前两个人 如果不是就分团队奖 如果是就再找 + sql := `SELECT u.uid,u.first_arrive_at FROM user_profile up + LEFT JOIN user u on u.uid=up.uid + WHERE up.parent_uid=? ORDER BY u.first_arrive_at asc,u.uid asc LIMIT 2` + nativeString, err := db.QueryNativeString(eg, sql, node.ParentUser.ParentUser.Uid) + if err != nil { + return zhios_order_relate_logx.Warn("sql error") + } + + if len(nativeString) > 0 { + for _, v := range nativeString { + if zhios_order_relate_utils.StrToInt(v["uid"]) == node.ParentUser.Uid { + isPostion = 1 + } } } } + commission, _, amountList, teamRatioList := CalReturnAmountAndRatioExtendWinery(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "extend_lv", totalAmt, integralTotalAmt, opt, isPostion) //佣金 node.ParentUser.Profit = commission