|
@@ -76,45 +76,43 @@ func BatchGetPublicPlatoonRelateCommissionByOrder(engine *xorm.Engine, masterId |
|
|
if userPublicPlatoonRelation == nil { |
|
|
if userPublicPlatoonRelation == nil { |
|
|
return nil, errors.New("未查询到公排关系记录") |
|
|
return nil, errors.New("未查询到公排关系记录") |
|
|
} |
|
|
} |
|
|
fatherPositions := strings.Split(userPublicPlatoonRelation.FatherUid, "-") |
|
|
|
|
|
var fatherPosition string |
|
|
|
|
|
userPublicPlatoonRelation.ReturnCommissionNum++ |
|
|
|
|
|
//if len(fatherPositions) < userPublicPlatoonSetting.SeveralRows { |
|
|
|
|
|
remainder1 := (userPublicPlatoonRelation.ReturnCommissionNum) % len(fatherPositions) |
|
|
|
|
|
if remainder1 == 0 { |
|
|
|
|
|
fatherPosition = fatherPositions[len(fatherPositions)-1] |
|
|
|
|
|
|
|
|
if userPublicPlatoonRelation.FatherUid == "" { |
|
|
|
|
|
//TODO::原始创始人 |
|
|
|
|
|
nowBenefitUid = "" |
|
|
} else { |
|
|
} else { |
|
|
fatherPosition = fatherPositions[remainder1-1] |
|
|
|
|
|
} |
|
|
|
|
|
//} else { |
|
|
|
|
|
// remainder2 := (userPublicPlatoonRelation.ReturnCommissionNum) % userPublicPlatoonSetting.SeveralRows |
|
|
|
|
|
// if remainder2 == 0 { |
|
|
|
|
|
// fatherPosition = fatherPositions[userPublicPlatoonSetting.SeveralRows-1] |
|
|
|
|
|
// } else { |
|
|
|
|
|
// fatherPosition = fatherPositions[remainder2-1] |
|
|
|
|
|
// } |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
fatherPositions := strings.Split(userPublicPlatoonRelation.FatherUid, "-") |
|
|
|
|
|
var fatherPosition string |
|
|
|
|
|
userPublicPlatoonRelation.ReturnCommissionNum++ |
|
|
|
|
|
|
|
|
nowBenefitUsers, err := db.UserPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{ |
|
|
|
|
|
"key": "position", |
|
|
|
|
|
"value": fatherPosition, |
|
|
|
|
|
}) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
if nowBenefitUsers == nil { |
|
|
|
|
|
return nil, errors.New("未查询到父级公排关系记录") |
|
|
|
|
|
} |
|
|
|
|
|
nowBenefitUid = zhios_order_relate_utils.AnyToString(nowBenefitUsers.Uid) |
|
|
|
|
|
|
|
|
remainder1 := (userPublicPlatoonRelation.ReturnCommissionNum) % len(fatherPositions) |
|
|
|
|
|
if remainder1 == 0 { |
|
|
|
|
|
fatherPosition = fatherPositions[len(fatherPositions)-1] |
|
|
|
|
|
} else { |
|
|
|
|
|
fatherPosition = fatherPositions[remainder1-1] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//TODO::更新 公排关系记录 中 `return_commission_num` |
|
|
|
|
|
affected, err := db.UserPublicPlatoonRelationUpdate(engine.NewSession(), userPublicPlatoonRelation.Id, userPublicPlatoonRelation, "return_commission_num") |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
if affected == 0 { |
|
|
|
|
|
return nil, errors.New("更新公排关系记录失败") |
|
|
|
|
|
|
|
|
nowBenefitUsers, err := db.UserPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{ |
|
|
|
|
|
"key": "position", |
|
|
|
|
|
"value": fatherPosition, |
|
|
|
|
|
}) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
if nowBenefitUsers == nil { |
|
|
|
|
|
return nil, errors.New("未查询到父级公排关系记录") |
|
|
|
|
|
} |
|
|
|
|
|
nowBenefitUid = zhios_order_relate_utils.AnyToString(nowBenefitUsers.Uid) |
|
|
|
|
|
|
|
|
|
|
|
//TODO::更新 公排关系记录 中 `return_commission_num` |
|
|
|
|
|
affected, err := db.UserPublicPlatoonRelationUpdate(engine.NewSession(), userPublicPlatoonRelation.Id, userPublicPlatoonRelation, "return_commission_num") |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
if affected == 0 { |
|
|
|
|
|
return nil, errors.New("更新公排关系记录失败") |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{ |
|
|
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{ |
|
|
Uid: param.Uid, |
|
|
Uid: param.Uid, |
|
|
CommonWealthBenefitUid: nowBenefitUid, |
|
|
CommonWealthBenefitUid: nowBenefitUid, |
|
|