正在显示
4 个修改的文件
包含
69 行增加
和
6 行删除
@@ -213,9 +213,6 @@ func (status *UnClaimedStatus) ChooseSuccessfulBidder(task *Task, successfulBidd | @@ -213,9 +213,6 @@ func (status *UnClaimedStatus) ChooseSuccessfulBidder(task *Task, successfulBidd | ||
213 | return fmt.Errorf("无效的竞标信息") | 213 | return fmt.Errorf("无效的竞标信息") |
214 | } else { | 214 | } else { |
215 | winBidTime := time.Now() | 215 | winBidTime := time.Now() |
216 | - if winBidTime.Before(task.BidInfo.BidEndTime) { | ||
217 | - return fmt.Errorf("竞标还没有结束") | ||
218 | - } | ||
219 | task.BidInfo.SuccessfulBidder = successfulBidder | 216 | task.BidInfo.SuccessfulBidder = successfulBidder |
220 | task.BidInfo.WinBidTime = winBidTime | 217 | task.BidInfo.WinBidTime = winBidTime |
221 | task.TaskStatus = TASK_STATUS_UNDERWAY | 218 | task.TaskStatus = TASK_STATUS_UNDERWAY |
@@ -156,7 +156,7 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int | @@ -156,7 +156,7 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int | ||
156 | query = query.Where(`task.participators @> '[{"uid":?}]'`, participator) | 156 | query = query.Where(`task.participators @> '[{"uid":?}]'`, participator) |
157 | } | 157 | } |
158 | if taskIds, ok := queryOptions["taskIds"]; ok { | 158 | if taskIds, ok := queryOptions["taskIds"]; ok { |
159 | - query = query.Where(`task.task_id IN (?)`, pg.In(taskIds.([]int64))) | 159 | + query = query.Where(`task.id IN (?)`, pg.In(taskIds.([]int64))) |
160 | } | 160 | } |
161 | if offRangTime, ok := queryOptions["offRangTime"]; ok { | 161 | if offRangTime, ok := queryOptions["offRangTime"]; ok { |
162 | query = query.Join("JOIN off_task_records ON off_task_record.task_id = task.id") | 162 | query = query.Join("JOIN off_task_records ON off_task_record.task_id = task.id") |
@@ -183,7 +183,12 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int | @@ -183,7 +183,12 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int | ||
183 | } else { | 183 | } else { |
184 | query = query.Limit(20) | 184 | query = query.Limit(20) |
185 | } | 185 | } |
186 | - if count, err := query.Order("id DESC").SelectAndCount(); err != nil { | 186 | + if sortByReleaseTime, ok := queryOptions["sortByReleaseTime"]; ok && (sortByReleaseTime == "ASC" || sortByReleaseTime == "DESC") { |
187 | + query = query.Order(fmt.Sprintf("task.release_time %s", sortByReleaseTime.(string))) | ||
188 | + } else { | ||
189 | + query = query.Order("task.id DESC") | ||
190 | + } | ||
191 | + if count, err := query.SelectAndCount(); err != nil { | ||
187 | return 0, tasks, err | 192 | return 0, tasks, err |
188 | } else { | 193 | } else { |
189 | for _, taskModel := range taskModels { | 194 | for _, taskModel := range taskModels { |
1 | +package service_gateway | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "fmt" | ||
6 | + "github.com/astaxie/beego/httplib" | ||
7 | + "strconv" | ||
8 | + "strings" | ||
9 | + "time" | ||
10 | +) | ||
11 | + | ||
12 | +type httplibBaseServiceGateway struct { | ||
13 | + baseURL string | ||
14 | + connectTimeout time.Duration | ||
15 | + readWriteTimeout time.Duration | ||
16 | +} | ||
17 | + | ||
18 | +func (serviceGateway *httplibBaseServiceGateway) createRequest(url string, method string) *httplib.BeegoHTTPRequest { | ||
19 | + var request *httplib.BeegoHTTPRequest | ||
20 | + switch method { | ||
21 | + case "get": | ||
22 | + request = httplib.Get(url) | ||
23 | + break | ||
24 | + case "post": | ||
25 | + request = httplib.Post(url) | ||
26 | + break | ||
27 | + case "put": | ||
28 | + request = httplib.Put(url) | ||
29 | + break | ||
30 | + case "delete": | ||
31 | + request = httplib.Delete(url) | ||
32 | + break | ||
33 | + case "head": | ||
34 | + request = httplib.Head(url) | ||
35 | + break | ||
36 | + default: | ||
37 | + request = httplib.Get(url) | ||
38 | + } | ||
39 | + return request.SetTimeout(serviceGateway.connectTimeout, serviceGateway.readWriteTimeout) | ||
40 | +} | ||
41 | + | ||
42 | +func (serviceGateway *httplibBaseServiceGateway) responseHandle(response map[string]interface{}) (map[string]interface{}, error) { | ||
43 | + data := make(map[string]interface{}) | ||
44 | + var err error | ||
45 | + if code, ok := response["code"]; ok { | ||
46 | + code := code.(float64) | ||
47 | + if code == 0 { | ||
48 | + data = response["data"].(map[string]interface{}) | ||
49 | + } else { | ||
50 | + msg := response["msg"].(string) | ||
51 | + err = fmt.Errorf(strings.Join([]string{strconv.FormatFloat(code, 'f', -1, 64), msg}, " ")) | ||
52 | + } | ||
53 | + } else { | ||
54 | + jsonBytes, marshalErr := json.Marshal(response) | ||
55 | + if marshalErr != nil { | ||
56 | + err = marshalErr | ||
57 | + } | ||
58 | + err = fmt.Errorf("无法解析的网关服务数据返回格式:%s", string(jsonBytes)) | ||
59 | + } | ||
60 | + return data, err | ||
61 | +} |
@@ -48,7 +48,7 @@ var _ = Describe("获取个人任务统计", func() { | @@ -48,7 +48,7 @@ var _ = Describe("获取个人任务统计", func() { | ||
48 | "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, customer_value, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | 48 | "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, customer_value, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", |
49 | 4, 101, "竞标任务1", 2, &domain.EmployeeInfo{ | 49 | 4, 101, "竞标任务1", 2, &domain.EmployeeInfo{ |
50 | Uid: 2499036607974745099, | 50 | Uid: 2499036607974745099, |
51 | - }, 2, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) | 51 | + }, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) |
52 | Expect(err3).NotTo(HaveOccurred()) | 52 | Expect(err3).NotTo(HaveOccurred()) |
53 | _, err4 := pG.DB.QueryOne( | 53 | _, err4 := pG.DB.QueryOne( |
54 | pg.Scan(), | 54 | pg.Scan(), |
-
请 注册 或 登录 后发表评论