|
@@ -1,17 +1,51 @@
|
|
|
package project
|
|
|
|
|
|
import (
|
|
|
+ "sfis/db"
|
|
|
"sfis/lock"
|
|
|
+ "sfis/model"
|
|
|
+ "sfis/service"
|
|
|
"testing"
|
|
|
)
|
|
|
|
|
|
+var (
|
|
|
+ projectNameArray = []string{"河南大学", "工程建设", "医疗器械"}
|
|
|
+ winnerArray = []string{""}
|
|
|
+ zbRqArray = []string{""}
|
|
|
+)
|
|
|
+
|
|
|
func Test_ProjectInterface(t *testing.T) {
|
|
|
- leftNumCost := &lock.LeftNumCost{
|
|
|
- AppID: "sfPQRYRQMAAwcGBwYBCgcA",
|
|
|
- ProductID: 1003,
|
|
|
- LeftNum: 199999,
|
|
|
- ProductType: 1,
|
|
|
- DataNumLimitOneTimes: 100,
|
|
|
+ appID := "sfPQRYRQMAAwcGBwYBCgcA"
|
|
|
+ //userName := "赛博英杰"
|
|
|
+ productID := 1003
|
|
|
+ lock.MainLock.Lock()
|
|
|
+ userLock := lock.UserLockMap[appID]
|
|
|
+ lock.MainLock.Unlock()
|
|
|
+ userLock.Lock()
|
|
|
+ userProduct := &model.UserProduct{}
|
|
|
+ db.GetSFISDB().First(userProduct, &model.UserProduct{AppID: appID, ProductID: productID})
|
|
|
+
|
|
|
+ check(&lock.LeftNumCost{
|
|
|
+ AppID: appID,
|
|
|
+ ProductID: productID,
|
|
|
+ LeftNum: userProduct.LeftNum,
|
|
|
+ ProductType: 0,
|
|
|
+ DataNumLimitOneTimes: userProduct.DataNumLimitOneTimes,
|
|
|
+ GetData1: func() (i interface{}, i2 int, err error) {
|
|
|
+ return service.ProjectListData("", "", "", false)
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func check(cost1 lock.Cost) {
|
|
|
+ if b := cost1.Before(); b {
|
|
|
+ data, status, _ := cost1.GetData()
|
|
|
+ if data != nil {
|
|
|
+ data := data.([]map[string]interface{})
|
|
|
+ if len(data) > 0 {
|
|
|
+ cost1.Deduction()
|
|
|
+ cost1.After()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- leftNumCost.Before()
|
|
|
}
|