Sfoglia il codice sorgente

update 共富制度

tags/v1.7.9
DengBiao 2 anni fa
parent
commit
886d600079
2 ha cambiato i file con 30 aggiunte e 22 eliminazioni
  1. +28
    -21
      rule/small_public_platoon_relate_commission.go
  2. +2
    -1
      svc/small_public_platoon_relate_commission.go

+ 28
- 21
rule/small_public_platoon_relate_commission.go Vedi File

@@ -302,24 +302,6 @@ 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.Uid)
} else {
fatherUids := strings.Split(m1.FatherUid, "-")
if len(fatherUids) > userPublicPlatoonSetting.SeveralRows {
fatherUidStr = zhios_order_relate_utils.IntToStr(m1.Uid) + "-" + strings.Join(fatherUids[0:userPublicPlatoonSetting.SeveralRows:len(fatherUids)], "-")
} else {
fatherUidStr = zhios_order_relate_utils.IntToStr(m1.Uid) + "-" + m1.FatherUid
}
}

if userPublicPlatoonSetting.SettleDay == 0 {
userPublicPlatoonSetting.SettleDay = 30
}
@@ -327,7 +309,6 @@ 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
@@ -374,12 +355,38 @@ func smallPublicPlatoon(engine *xorm.Engine, uid, recommendUid int, userPublicPl
userSmallPublicPlatoonRelation.CreateAt = now //
userSmallPublicPlatoonRelation.UpdateAt = now
userSmallPublicPlatoonRelation.HasSonNum = 0
_, err = db.UserSmallPublicPlatoonRelationInsert(engine, &userSmallPublicPlatoonRelation)
insertId, err := db.UserSmallPublicPlatoonRelationInsert(engine, &userSmallPublicPlatoonRelation)
if err != nil {
return model.UserSmallPublicPlatoonRelation{}, err
}

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


+ 2
- 1
svc/small_public_platoon_relate_commission.go Vedi File

@@ -85,7 +85,7 @@ func BatchSmallGetPublicPlatoonRelateCommission(engine *xorm.Engine, masterId st
}

nowBenefitUsers, err := db.UserSmallPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{
"key": "position",
"key": "id",
"value": fatherPosition,
})
if err != nil {
@@ -124,6 +124,7 @@ func BatchSmallGetPublicPlatoonRelateCommission(engine *xorm.Engine, masterId st
}
return resp, nil
}

func BatchSmallGetPublicPlatoonRelateByGoods(engine *xorm.Engine, masterId string, PublicPlatoonRelateCommissionReqList []*md.SmallPublicPlatoonRelateCommissionReq) (map[string]*md.SmallPublicPlatoonRelateCommissionResp, error) {
var resp = make(map[string]*md.SmallPublicPlatoonRelateCommissionResp)
for _, param := range PublicPlatoonRelateCommissionReqList {


Caricamento…
Annulla
Salva