Browse Source

update 共富制度

tags/v1.4.9
DengBiao 2 years ago
parent
commit
13541a96be
1 changed files with 33 additions and 35 deletions
  1. +33
    -35
      svc/public_platoon_relate_commission.go

+ 33
- 35
svc/public_platoon_relate_commission.go View File

@@ -76,45 +76,43 @@ func BatchGetPublicPlatoonRelateCommissionByOrder(engine *xorm.Engine, masterId
if userPublicPlatoonRelation == nil {
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 {
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{
Uid: param.Uid,
CommonWealthBenefitUid: nowBenefitUid,


Loading…
Cancel
Save