// 三级返现 func (this *Order) backFor3R(pt partner.IPartner, m member.IMember, back_fee float32, unixTime int64) { if back_fee == 0 { return } i := 0 mName := m.GetValue().Name saleConf := pt.GetSaleConf() percent := saleConf.CashBackTg2Percent for i < 2 { rl := m.GetRelation() if rl == nil || rl.InvitationMemberId == 0 { break } m = this._memberRep.GetMember(rl.InvitationMemberId) if m == nil { break } if i == 1 { percent = saleConf.CashBackTg1Percent } this.updateMemberAccount(m, pt.GetValue().Name, mName, back_fee*percent, unixTime) i++ } }
func cashBack3R(m member.IMember, order *shopping.ValueOrder, c promotion.ICashBackPromotion, memberRep member.IMemberRep) { var fee1 int var fee2 int dt := c.GetDataTag() fee1, _ = strconv.Atoi(dt["G1"]) fee2, _ = strconv.Atoi(dt["G2"]) var cm member.IMember = m var pm member.IMember = m // fmt.Println("------ START BACK ------") var backFunc = func(m member.IMember, parentM member.IMember, fee int) { // fmt.Println("---------[ back ]",parentM.GetValue().Name,fee) backCashForMember(m, order, fee, parentM.GetValue().Name) } var i int = 0 for true { rl := cm.GetRelation() // fmt.Println("-------- BACK - ID - ",rl.InvitationMemberId) if rl == nil || rl.InvitationMemberId == 0 { break } cm = memberRep.GetMember(rl.InvitationMemberId) // fmt.Println("-------- BACK ",cm == nil) if m == nil { break } if i == 0 { backFunc(cm, pm, fee2) } else if i == 1 { backFunc(cm, pm, fee1) } pm = cm i++ if i > 1 { break } } }
func cashBack3R(level int, m member.IMember, order *shopping.ValueOrder, c promotion.ICashBackPromotion, memberRep member.IMemberRep) { dt := c.GetDataTag() var cm member.IMember = m var pm member.IMember = m // fmt.Println("------ START BACK ------") var backFunc = func(m member.IMember, parentM member.IMember, fee int) { // fmt.Println("---------[ back ]",parentM.GetValue().Name,fee) backCashForMember(m, order, fee, parentM.GetValue().Name) } var i int = 0 for true { rl := cm.GetRelation() // fmt.Println("-------- BACK - ID - ",rl.InvitationMemberId) if rl == nil || rl.RefereesId == 0 { break } cm = memberRep.GetMember(rl.RefereesId) // fmt.Println("-------- BACK ",cm == nil) if m == nil { break } if fee, err := strconv.Atoi(dt[fmt.Sprintf("G%d", i)]); err == nil { //log.Println("[ Back][ Cash] - ",i," back ",fee) backFunc(cm, pm, fee) } pm = cm i++ if i >= level { break } } }