|
@@ -2,6 +2,7 @@ package svc |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" |
|
|
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" |
|
|
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" |
|
|
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" |
|
|
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" |
|
|
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" |
|
@@ -145,6 +146,91 @@ func BatchSmallGetPublicPlatoonRelateCommission(engine *xorm.Engine, masterId st |
|
|
return resp, nil |
|
|
return resp, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func CalcSmallPublicPlatoonRelateLaXinReward(engine *xorm.Engine, masterId string, rewardUid int) (resp []*md.CalcSmallPublicPlatoonRelateLaXinReward, err error) { |
|
|
|
|
|
userPublicPlatoonRelation, err := db.UserSmallPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{ |
|
|
|
|
|
"key": "uid", |
|
|
|
|
|
"value": rewardUid, |
|
|
|
|
|
}) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
if userPublicPlatoonRelation == nil { |
|
|
|
|
|
return nil, errors.New("未查询到公排关系记录") |
|
|
|
|
|
} |
|
|
|
|
|
if userPublicPlatoonRelation.FatherUid == "" { |
|
|
|
|
|
//TODO::原始创始人 |
|
|
|
|
|
return |
|
|
|
|
|
} else { |
|
|
|
|
|
//1、查询 user_public_platoon_laxin_reward_setting |
|
|
|
|
|
var m model.UserPublicPlatoonLaxinRewardSetting |
|
|
|
|
|
has, err1 := engine.Where("id >= 1").Get(&m) |
|
|
|
|
|
if err1 != nil { |
|
|
|
|
|
return nil, zhios_order_relate_logx.Error(err1) |
|
|
|
|
|
} |
|
|
|
|
|
if has == false { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if m.IsUse == 0 { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//2、解析 detail |
|
|
|
|
|
var detail []*md.CalcSmallPublicPlatoonRelateLaXinDetail |
|
|
|
|
|
if err2 := json.Unmarshal([]byte(m.Detail), &detail); err != nil { |
|
|
|
|
|
return nil, err2 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fatherPositions := strings.Split(userPublicPlatoonRelation.FatherUid, "-") |
|
|
|
|
|
var rewardUserLevelWeight int |
|
|
|
|
|
if m.IsUseRewardLimit == 1 { |
|
|
|
|
|
//3、判断是否开启奖励限制 |
|
|
|
|
|
rewardUser, err3 := db.UserFindByID(engine, rewardUid) |
|
|
|
|
|
if err3 != nil { |
|
|
|
|
|
return nil, err3 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rewardUserLevel, err4 := db.UserLevelByID(engine, rewardUser.Level) |
|
|
|
|
|
if err4 != nil { |
|
|
|
|
|
return nil, err4 |
|
|
|
|
|
} |
|
|
|
|
|
if rewardUserLevel == nil { |
|
|
|
|
|
return nil, errors.New("未查询到对应等级") |
|
|
|
|
|
} |
|
|
|
|
|
rewardUserLevelWeight = rewardUserLevel.LevelWeight |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for k, v := range fatherPositions { |
|
|
|
|
|
if m.IsUseRewardLimit == 1 { |
|
|
|
|
|
//查询对应用户的等级 |
|
|
|
|
|
tmpUser, err3 := db.UserFindByID(engine, v) |
|
|
|
|
|
if err3 != nil { |
|
|
|
|
|
return nil, err3 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tmpUserLevel, err4 := db.UserLevelByID(engine, tmpUser.Level) |
|
|
|
|
|
if err4 != nil { |
|
|
|
|
|
return nil, err4 |
|
|
|
|
|
} |
|
|
|
|
|
if tmpUserLevel == nil { |
|
|
|
|
|
return nil, errors.New("未查询到奖励用户对应等级") |
|
|
|
|
|
} |
|
|
|
|
|
if tmpUserLevel.LevelWeight < rewardUserLevelWeight { |
|
|
|
|
|
//奖励人等级小于 |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
value, _ := zhios_order_relate_utils.InterfaceToString(detail[k].Val) |
|
|
|
|
|
tmp := md.CalcSmallPublicPlatoonRelateLaXinReward{ |
|
|
|
|
|
Uid: v, |
|
|
|
|
|
CoinId: m.CoinId, |
|
|
|
|
|
Value: value, |
|
|
|
|
|
} |
|
|
|
|
|
resp = append(resp, &tmp) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return resp, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func BatchSmallGetPublicPlatoonRelateByGoods(engine *xorm.Engine, masterId string, PublicPlatoonRelateCommissionReqList []*md.SmallPublicPlatoonRelateCommissionReq) (map[string]*md.SmallPublicPlatoonRelateCommissionResp, error) { |
|
|
func BatchSmallGetPublicPlatoonRelateByGoods(engine *xorm.Engine, masterId string, PublicPlatoonRelateCommissionReqList []*md.SmallPublicPlatoonRelateCommissionReq) (map[string]*md.SmallPublicPlatoonRelateCommissionResp, error) { |
|
|
var resp = make(map[string]*md.SmallPublicPlatoonRelateCommissionResp) |
|
|
var resp = make(map[string]*md.SmallPublicPlatoonRelateCommissionResp) |
|
|
for _, param := range PublicPlatoonRelateCommissionReqList { |
|
|
for _, param := range PublicPlatoonRelateCommissionReqList { |
|
|