作者 yangfu

修改 1.机会编码修改

... ... @@ -39,10 +39,10 @@ func GetChanceCode(chanceId int64, chanceTypeId int, templateId int64) (rsp stri
}
log.Warn(fmt.Sprintf("get chance code retry(%v): cursn:%v cid:%v cc:%v tc:%v",
loopTime, currentSN, chanceId, ChanceTypeCode, TemplateCode))
time.Sleep(time.Millisecond * 500)
time.Sleep(time.Millisecond * 1000)
loopTime++
}
rsp = fmt.Sprintf("%v%v%v", ChanceTypeCode, TemplateCode, Num)
rsp = fmt.Sprintf("%v", Num) //fmt.Sprintf("%v%v%v", ChanceTypeCode, TemplateCode, Num)
return
}
... ...
package agg
import (
"fmt"
"opp/tests"
"strings"
"sync"
"testing"
)
func Test_GetChanceCode(t *testing.T) {
tests.Init()
code, err := GetChanceCode(1, 1, 1)
if err != nil {
t.Fatal(err)
}
print := func(index int, code string) {
t.Log(fmt.Sprintf("getChanceCode index:%v code:%v", index, code))
}
print(-1, code)
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
index := i
go func(in int) {
defer wg.Done()
c, e := GetChanceCode(1, 1, 1)
if e != nil {
t.Fatal(e)
}
if !strings.EqualFold(code, c) {
t.Fatal("In:", code, "out:", c, "not equal")
}
print(in, c)
}(index)
}
wg.Wait()
}
... ...