Sfoglia il codice sorgente

update 共富制度

tags/v1.8.0
DengBiao 2 anni fa
parent
commit
7864fc0629
1 ha cambiato i file con 21 aggiunte e 28 eliminazioni
  1. +21
    -28
      rule/small_public_platoon_relate_commission.go

+ 21
- 28
rule/small_public_platoon_relate_commission.go Vedi File

@@ -302,6 +302,24 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl

}

//2、查找对应pid的 user_public_platoon_relation 记录
var m1 model.UserSmallPublicPlatoonRelation
if has, err := engine.Where("uid=?", fatherUid).Get(&m1); err != nil || has == false {
return userSmallPublicPlatoonRelation, err
}
var fatherUidStr string
if m1.FatherUid == "" {
//TODO::顶级
fatherUidStr = zhios_order_relate_utils.IntToStr(m1.Id)
} else {
fatherUids := strings.Split(m1.FatherUid, "-")
if len(fatherUids) > userPublicPlatoonSetting.SeveralRows {
fatherUidStr = zhios_order_relate_utils.IntToStr(m1.Id) + "-" + strings.Join(fatherUids[0:userPublicPlatoonSetting.SeveralRows:len(fatherUids)], "-")
} else {
fatherUidStr = zhios_order_relate_utils.IntToStr(m1.Id) + "-" + m1.FatherUid
}
}

if userPublicPlatoonSetting.SettleDay == 0 {
userPublicPlatoonSetting.SettleDay = 30
}
@@ -309,6 +327,7 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
// 3、插入 user_public_platoon_relation 记录
now := time.Now()
userSmallPublicPlatoonRelation.Uid = uid
userSmallPublicPlatoonRelation.FatherUid = fatherUidStr

userSmallPublicPlatoonRelation.FatherUid1 = standardSmallPublicPlatoonRelation.FatherUid1
userSmallPublicPlatoonRelation.FatherUid2 = standardSmallPublicPlatoonRelation.FatherUid2
@@ -355,38 +374,12 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
userSmallPublicPlatoonRelation.CreateAt = now //
userSmallPublicPlatoonRelation.UpdateAt = now
userSmallPublicPlatoonRelation.HasSonNum = 0
insertId, err := db.UserSmallPublicPlatoonRelationInsert(engine, &userSmallPublicPlatoonRelation)
_, err = db.UserSmallPublicPlatoonRelationInsert(engine, &userSmallPublicPlatoonRelation)
if err != nil {
return model.UserSmallPublicPlatoonRelation{}, err
}

// 4、回更 father_uid 字段
var m1 model.UserSmallPublicPlatoonRelation
if has, err := engine.Where("uid=?", fatherUid).Get(&m1); err != nil || has == false {
return userSmallPublicPlatoonRelation, err
}
var fatherUidStr string
if m1.FatherUid == "" {
//TODO::顶级
fatherUidStr = zhios_order_relate_utils.IntToStr(insertId)
} else {
fatherUids := strings.Split(m1.FatherUid, "-")
if len(fatherUids) > userPublicPlatoonSetting.SeveralRows {
fatherUidStr = zhios_order_relate_utils.IntToStr(insertId) + "-" + strings.Join(fatherUids[0:userPublicPlatoonSetting.SeveralRows:len(fatherUids)], "-")
} else {
fatherUidStr = zhios_order_relate_utils.IntToStr(insertId) + "-" + m1.FatherUid
}
}
userSmallPublicPlatoonRelation.FatherUid = fatherUidStr
affected, err := db.UserSmallPublicPlatoonRelationUpdate(engine.NewSession(), userSmallPublicPlatoonRelation.Id, &userSmallPublicPlatoonRelation, "father_uid")
if err != nil {
return model.UserSmallPublicPlatoonRelation{}, err
}
if affected == 0 {
return model.UserSmallPublicPlatoonRelation{}, errors.New("更新 user_small_public_platoon_relation 记录失败")
}

// 5、改变直属父级的 has_son_num 数量
// 4、改变直属父级的 has_son_num 数量
update, err := engine.Where("uid = ?", fatherUid).SetExpr("has_son_num", "has_son_num + 1").Update(new(model.UserSmallPublicPlatoonRelation))
if err != nil {
return userSmallPublicPlatoonRelation, err


Caricamento…
Annulla
Salva