作者 linmadan

添加指派任务,驳回记录,重构代码兼容新版本需求

正在显示 60 个修改的文件 包含 2284 行增加239 行删除
@@ -6,6 +6,22 @@ import ( @@ -6,6 +6,22 @@ import (
6 domainService "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/domain_service" 6 domainService "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/domain_service"
7 ) 7 )
8 8
  9 +func CreateRejectTaskReceiverService(options map[string]interface{}) (service.RejectTaskReceiverService, error) {
  10 + var transactionContext *pgTransaction.TransactionContext
  11 + if value, ok := options["transactionContext"]; ok {
  12 + transactionContext = value.(*pgTransaction.TransactionContext)
  13 + }
  14 + return domainService.NewRejectTaskReceiverService(transactionContext)
  15 +}
  16 +
  17 +func CreateConfirmRobTaskService(options map[string]interface{}) (service.ConfirmRobTaskService, error) {
  18 + var transactionContext *pgTransaction.TransactionContext
  19 + if value, ok := options["transactionContext"]; ok {
  20 + transactionContext = value.(*pgTransaction.TransactionContext)
  21 + }
  22 + return domainService.NewConfirmRobTaskService(transactionContext)
  23 +}
  24 +
9 func CreateReleaseTaskService(options map[string]interface{}) (service.ReleaseTaskService, error) { 25 func CreateReleaseTaskService(options map[string]interface{}) (service.ReleaseTaskService, error) {
10 var transactionContext *pgTransaction.TransactionContext 26 var transactionContext *pgTransaction.TransactionContext
11 if value, ok := options["transactionContext"]; ok { 27 if value, ok := options["transactionContext"]; ok {
@@ -61,3 +61,11 @@ func CreateProjectBelongRepository(options map[string]interface{}) (domain.Proje @@ -61,3 +61,11 @@ func CreateProjectBelongRepository(options map[string]interface{}) (domain.Proje
61 } 61 }
62 return repository.NewProjectBelongRepository(transactionContext) 62 return repository.NewProjectBelongRepository(transactionContext)
63 } 63 }
  64 +
  65 +func CreateRejectTaskRecordRepository(options map[string]interface{}) (domain.RejectTaskRecordRepository, error) {
  66 + var transactionContext *pg.TransactionContext
  67 + if value, ok := options["transactionContext"]; ok {
  68 + transactionContext = value.(*pg.TransactionContext)
  69 + }
  70 + return repository.NewRejectTaskRecordRepository(transactionContext)
  71 +}
@@ -3,6 +3,7 @@ package command @@ -3,6 +3,7 @@ package command
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" 5 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  6 + "time"
6 7
7 "github.com/astaxie/beego/validation" 8 "github.com/astaxie/beego/validation"
8 ) 9 )
@@ -22,6 +23,8 @@ type AcceptanceTaskCommand struct { @@ -22,6 +23,8 @@ type AcceptanceTaskCommand struct {
22 SolveReport string `json:"solveReport,omitempty"` 23 SolveReport string `json:"solveReport,omitempty"`
23 // 解决图片URL列表 24 // 解决图片URL列表
24 SolvePictureUrls []string `json:"solvePictureUrls,omitempty"` 25 SolvePictureUrls []string `json:"solvePictureUrls,omitempty"`
  26 + // 实际完成时间
  27 + ActualCompletionTime time.Time `json:"actualCompletionTime"`
25 } 28 }
26 29
27 //func (acceptanceTaskCommand *AcceptanceTaskCommand) Valid(validation *validation.Validation) { 30 //func (acceptanceTaskCommand *AcceptanceTaskCommand) Valid(validation *validation.Validation) {
@@ -2,6 +2,7 @@ package command @@ -2,6 +2,7 @@ package command
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
5 6
6 "github.com/astaxie/beego/validation" 7 "github.com/astaxie/beego/validation"
7 ) 8 )
@@ -13,12 +14,10 @@ type ChooseSuccessfulBidderCommand struct { @@ -13,12 +14,10 @@ type ChooseSuccessfulBidderCommand struct {
13 Operator int64 `json:"operator" valid:"Required"` 14 Operator int64 `json:"operator" valid:"Required"`
14 // 中标者uid 15 // 中标者uid
15 SuccessfulBidder int64 `json:"successfulBidder" valid:"Required"` 16 SuccessfulBidder int64 `json:"successfulBidder" valid:"Required"`
  17 + // 计划完成时间
  18 + PlannedCompletionTime time.Time `json:"plannedCompletionTime" valid:"Required"`
16 } 19 }
17 20
18 -//func (chooseSuccessfulBidderCommand *ChooseSuccessfulBidderCommand) Valid(validation *validation.Validation) {  
19 -// validation.SetError("CustomValid", "未实现的自定义认证")  
20 -//}  
21 -  
22 func (chooseSuccessfulBidderCommand *ChooseSuccessfulBidderCommand) ValidateCommand() error { 21 func (chooseSuccessfulBidderCommand *ChooseSuccessfulBidderCommand) ValidateCommand() error {
23 valid := validation.Validation{} 22 valid := validation.Validation{}
24 b, err := valid.Valid(chooseSuccessfulBidderCommand) 23 b, err := valid.Valid(chooseSuccessfulBidderCommand)
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +
  7 + "github.com/astaxie/beego/validation"
  8 +)
  9 +
  10 +type ConfirmRobTaskCommand struct {
  11 + // 任务ID
  12 + TaskId int64 `json:"taskId" valid:"Required"`
  13 + // 操作人uid
  14 + Operator int64 `json:"operator" valid:"Required"`
  15 + // 计划完成时间
  16 + PlannedCompletionTime time.Time `json:"plannedCompletionTime" valid:"Required"`
  17 +}
  18 +
  19 +func (confirmRobTaskCommand *ConfirmRobTaskCommand) ValidateCommand() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(confirmRobTaskCommand)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
@@ -14,17 +14,19 @@ type CreateTaskCommand struct { @@ -14,17 +14,19 @@ type CreateTaskCommand struct {
14 // 任务名称 14 // 任务名称
15 TaskName string `json:"taskName" valid:"Required"` 15 TaskName string `json:"taskName" valid:"Required"`
16 // 任务类型 16 // 任务类型
17 - TaskType int `json:"taskType" valid:"Required"` 17 + TaskType int `json:"taskType,omitempty"`
18 // 任务发起者uid 18 // 任务发起者uid
19 Sponsor int64 `json:"sponsor" valid:"Required"` 19 Sponsor int64 `json:"sponsor" valid:"Required"`
20 // 引用类型 20 // 引用类型
21 ReferenceResourceType int `json:"referenceResourceType,omitempty"` 21 ReferenceResourceType int `json:"referenceResourceType,omitempty"`
22 // 引用资源项列表 22 // 引用资源项列表
23 ReferenceResourceItems []*domain.ReferenceResourceItem `json:"referenceResourceItems,omitempty"` 23 ReferenceResourceItems []*domain.ReferenceResourceItem `json:"referenceResourceItems,omitempty"`
  24 + // 项目归属
  25 + ProjectBelong int `json:"projectBelong,omitempty"`
24 // 客户价值列表 26 // 客户价值列表
25 - CustomerValue []string `json:"customerValue,omitempty"` 27 + CustomerValues []int `json:"customerValues,omitempty"`
26 // 任务性质 28 // 任务性质
27 - TaskNature string `json:"taskNature,omitempty"` 29 + TaskNature int `json:"taskNature,omitempty"`
28 // 奖励素币 30 // 奖励素币
29 SuMoney float64 `json:"suMoney,omitempty"` 31 SuMoney float64 `json:"suMoney,omitempty"`
30 // 验收标准 32 // 验收标准
@@ -39,12 +41,14 @@ type CreateTaskCommand struct { @@ -39,12 +41,14 @@ type CreateTaskCommand struct {
39 BidStartTime time.Time `json:"bidStartTime,omitempty"` 41 BidStartTime time.Time `json:"bidStartTime,omitempty"`
40 // 竞标结束时间 42 // 竞标结束时间
41 BidEndTime time.Time `json:"bidEndTime,omitempty"` 43 BidEndTime time.Time `json:"bidEndTime,omitempty"`
  44 + // 是否截止时间前一天提醒
  45 + IsRemind bool `json:"isRemind,omitempty"`
  46 + // 计划完成时间
  47 + PlannedCompletionTime time.Time `json:"plannedCompletionTime,omitempty"`
  48 + // 指派人员uid
  49 + AssignedPerson int64 `json:"assignedPerson,omitempty"`
42 } 50 }
43 51
44 -//func (createTaskCommand *CreateTaskCommand) Valid(validation *validation.Validation) {  
45 -// validation.SetError("CustomValid", "未实现的自定义认证")  
46 -//}  
47 -  
48 func (createTaskCommand *CreateTaskCommand) ValidateCommand() error { 52 func (createTaskCommand *CreateTaskCommand) ValidateCommand() error {
49 valid := validation.Validation{} 53 valid := validation.Validation{}
50 b, err := valid.Valid(createTaskCommand) 54 b, err := valid.Valid(createTaskCommand)
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type RejectTaskReceiverCommand struct {
  10 + // 任务ID
  11 + TaskId int64 `json:"taskId" valid:"Required"`
  12 + // 操作人uid
  13 + Operator int64 `json:"operator" valid:"Required"`
  14 + // 驳回理由
  15 + RejectReason string `json:"rejectReason" valid:"Required"`
  16 +}
  17 +
  18 +func (rejectTaskReceiverCommand *RejectTaskReceiverCommand) ValidateCommand() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(rejectTaskReceiverCommand)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
@@ -14,10 +14,12 @@ type SearchOffTaskRecordCommand struct { @@ -14,10 +14,12 @@ type SearchOffTaskRecordCommand struct {
14 TaskContentMatch string `json:"taskContentMatch,omitempty"` 14 TaskContentMatch string `json:"taskContentMatch,omitempty"`
15 // 任务类型 15 // 任务类型
16 TaskType int `json:"taskType,omitempty"` 16 TaskType int `json:"taskType,omitempty"`
  17 + // 项目归属
  18 + ProjectBelongs []int `json:"projectBelongs,omitempty"`
17 // 客户价值 19 // 客户价值
18 - CustomerValue []string `json:"customerValue,omitempty"` 20 + CustomerValues []int `json:"customerValues,omitempty"`
19 // 任务性质 21 // 任务性质
20 - TaskNature string `json:"taskNature,omitempty"` 22 + TaskNatures []int `json:"taskNatures,omitempty"`
21 // 关闭任务时间区间-开始时间 23 // 关闭任务时间区间-开始时间
22 OffStartTime time.Time `json:"offStartTime,omitempty"` 24 OffStartTime time.Time `json:"offStartTime,omitempty"`
23 // 关闭任务时间区间-截止时间 25 // 关闭任务时间区间-截止时间
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +
  7 + "github.com/astaxie/beego/validation"
  8 +)
  9 +
  10 +type SearchRejectTaskRecordCommand struct {
  11 + // 公司ID
  12 + CompanyId int64 `json:"companyId" valid:"Required"`
  13 + // 任务内容匹配
  14 + TaskContentMatch string `json:"taskContentMatch,omitempty"`
  15 + // 任务类型
  16 + TaskType int `json:"taskType,omitempty"`
  17 + // 项目归属
  18 + ProjectBelongs []int `json:"projectBelongs,omitempty"`
  19 + // 客户价值
  20 + CustomerValues []int `json:"customerValues,omitempty"`
  21 + // 任务性质
  22 + TaskNatures []int `json:"taskNatures,omitempty"`
  23 + // 驳回任务时间区间-开始时间
  24 + RejectStartTime time.Time `json:"rejectStartTime,omitempty"`
  25 + // 驳回任务时间区间-截止时间
  26 + RejectEndTime time.Time `json:"rejectEndTime,omitempty"`
  27 + // 查询偏离量
  28 + Offset int `json:"offset,omitempty"`
  29 + // 查询限制
  30 + Limit int `json:"limit,omitempty"`
  31 +}
  32 +
  33 +func (searchRejectTaskRecordCommand *SearchRejectTaskRecordCommand) ValidateCommand() error {
  34 + valid := validation.Validation{}
  35 + b, err := valid.Valid(searchRejectTaskRecordCommand)
  36 + if err != nil {
  37 + return err
  38 + }
  39 + if !b {
  40 + for _, validErr := range valid.Errors {
  41 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  42 + }
  43 + }
  44 + return nil
  45 +}
@@ -9,7 +9,7 @@ import ( @@ -9,7 +9,7 @@ import (
9 type SearchTaskCommand struct { 9 type SearchTaskCommand struct {
10 // 公司ID 10 // 公司ID
11 CompanyId int64 `json:"companyId" valid:"Required"` 11 CompanyId int64 `json:"companyId" valid:"Required"`
12 - // 任务发起者 12 + // 任务发起者UID
13 Sponsor int64 `json:"sponsor,omitempty"` 13 Sponsor int64 `json:"sponsor,omitempty"`
14 // 任务内容匹配 14 // 任务内容匹配
15 TaskContentMatch string `json:"taskContentMatch,omitempty"` 15 TaskContentMatch string `json:"taskContentMatch,omitempty"`
@@ -17,36 +17,38 @@ type SearchTaskCommand struct { @@ -17,36 +17,38 @@ type SearchTaskCommand struct {
17 TaskType int `json:"taskType,omitempty"` 17 TaskType int `json:"taskType,omitempty"`
18 // 任务状态 18 // 任务状态
19 TaskStatus int `json:"taskStatus,omitempty"` 19 TaskStatus int `json:"taskStatus,omitempty"`
  20 + // 项目归属
  21 + ProjectBelongs []int `json:"projectBelongs,omitempty"`
20 // 客户价值 22 // 客户价值
21 - CustomerValue []string `json:"customerValue,omitempty"` 23 + CustomerValues []int `json:"customerValues,omitempty"`
22 // 任务性质 24 // 任务性质
23 - TaskNature string `json:"taskNature,omitempty"` 25 + TaskNatures []int `json:"taskNatures,omitempty"`
24 // 是否悬赏任务 26 // 是否悬赏任务
25 IsRewardTake bool `json:"isRewardTake,omitempty"` 27 IsRewardTake bool `json:"isRewardTake,omitempty"`
26 // 竞标参与者UID 28 // 竞标参与者UID
27 Bidder int64 `json:"bidder,omitempty"` 29 Bidder int64 `json:"bidder,omitempty"`
28 // 竞标时间(1全部,2已截止,3未截止) 30 // 竞标时间(1全部,2已截止,3未截止)
29 BidTimeMatch int `json:"bidTimeMatch,omitempty"` 31 BidTimeMatch int `json:"bidTimeMatch,omitempty"`
30 - // 任务领取人 32 + // 任务领取人UID
31 Receiver int64 `json:"receiver,omitempty"` 33 Receiver int64 `json:"receiver,omitempty"`
32 - // 任务参与者 34 + // 任务参与者UID
33 Participator int64 `json:"participator,omitempty"` 35 Participator int64 `json:"participator,omitempty"`
34 - //是否过滤关闭状态任务 36 + // 指派人员UID
  37 + AssignedPerson int64 `json:"assignedPerson,omitempty"`
  38 + // 是否过滤关闭状态任务
35 IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"` 39 IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"`
36 - //是否过滤待发布状态任务 40 + // 是否过滤待发布状态任务
37 IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"` 41 IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"`
38 - //按创建任务时间排序(ASC,DESC) 42 + // 按创建任务时间排序(ASC,DESC)
39 SortByCreateTime string `json:"sortByCreateTime,omitempty"` 43 SortByCreateTime string `json:"sortByCreateTime,omitempty"`
40 - //按发布任务时间排序(ASC,DESC) 44 + // 按发布任务时间排序(ASC,DESC)
41 SortByReleaseTime string `json:"sortByReleaseTime,omitempty"` 45 SortByReleaseTime string `json:"sortByReleaseTime,omitempty"`
42 - //按领取任务时间排序(ASC,DESC) 46 + // 按领取任务时间排序(ASC,DESC)
43 SortByReceiveTime string `json:"sortByReceiveTime,omitempty"` 47 SortByReceiveTime string `json:"sortByReceiveTime,omitempty"`
44 - //按完成任务操作时间排序(ASC,DESC) 48 + // 按完成任务操作时间排序(ASC,DESC)
45 SortByCompleteTime string `json:"sortByCompleteTime,omitempty"` 49 SortByCompleteTime string `json:"sortByCompleteTime,omitempty"`
46 - //按验收方验收时间排序(ASC,DESC) 50 + // 按验收方验收时间排序(ASC,DESC)
47 SortByAcceptanceTime string `json:"sortByAcceptanceTime,omitempty"` 51 SortByAcceptanceTime string `json:"sortByAcceptanceTime,omitempty"`
48 - //按参与竞标时间排序(ASC,DESC)  
49 - SortByBidTime string `json:"sortByBidTime,omitempty"`  
50 // 查询偏离量 52 // 查询偏离量
51 Offset int `json:"offset,omitempty"` 53 Offset int `json:"offset,omitempty"`
52 // 查询限制 54 // 查询限制
@@ -17,10 +17,12 @@ type UpdateTaskCommand struct { @@ -17,10 +17,12 @@ type UpdateTaskCommand struct {
17 ReferenceResourceType int `json:"referenceResourceType,omitempty"` 17 ReferenceResourceType int `json:"referenceResourceType,omitempty"`
18 // 引用资源项列表 18 // 引用资源项列表
19 ReferenceResourceItems []*domain.ReferenceResourceItem `json:"referenceResourceItems,omitempty"` 19 ReferenceResourceItems []*domain.ReferenceResourceItem `json:"referenceResourceItems,omitempty"`
  20 + // 项目归属
  21 + ProjectBelong int `json:"projectBelong,omitempty"`
20 // 客户价值列表 22 // 客户价值列表
21 - CustomerValue []string `json:"customerValue,omitempty"` 23 + CustomerValues []int `json:"customerValues,omitempty"`
22 // 任务性质 24 // 任务性质
23 - TaskNature string `json:"taskNature,omitempty"` 25 + TaskNature int `json:"taskNature,omitempty"`
24 // 奖励素币 26 // 奖励素币
25 SuMoney float64 `json:"suMoney,omitempty"` 27 SuMoney float64 `json:"suMoney,omitempty"`
26 // 验收标准 28 // 验收标准
@@ -35,12 +37,14 @@ type UpdateTaskCommand struct { @@ -35,12 +37,14 @@ type UpdateTaskCommand struct {
35 BidStartTime time.Time `json:"bidStartTime,omitempty"` 37 BidStartTime time.Time `json:"bidStartTime,omitempty"`
36 // 竞标结束时间 38 // 竞标结束时间
37 BidEndTime time.Time `json:"bidEndTime,omitempty"` 39 BidEndTime time.Time `json:"bidEndTime,omitempty"`
  40 + // 是否截止时间前一天提醒
  41 + IsRemind bool `json:"isRemind,omitempty"`
  42 + // 计划完成时间
  43 + PlannedCompletionTime time.Time `json:"plannedCompletionTime,omitempty"`
  44 + // 指派人员uid
  45 + AssignedPerson int64 `json:"assignedPerson,omitempty"`
38 } 46 }
39 47
40 -//func (updateTaskCommand *UpdateTaskCommand) Valid(validation *validation.Validation) {  
41 -// validation.SetError("CustomValid", "未实现的自定义认证")  
42 -//}  
43 -  
44 func (updateTaskCommand *UpdateTaskCommand) ValidateCommand() error { 48 func (updateTaskCommand *UpdateTaskCommand) ValidateCommand() error {
45 valid := validation.Validation{} 49 valid := validation.Validation{}
46 b, err := valid.Valid(updateTaskCommand) 50 b, err := valid.Valid(updateTaskCommand)
  1 +package dto
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  5 + "time"
  6 +)
  7 +
  8 +type OffTaskRecordDto struct {
  9 + // 关闭任务记录ID
  10 + OffTaskRecordId int64 `json:"offTaskRecordId"`
  11 + // 任务
  12 + Task *TaskDto `json:"task"`
  13 + // 操作人
  14 + Operator *domain.EmployeeInfo `json:"operator"`
  15 + // 关闭理由
  16 + OffReason string `json:"offReason"`
  17 + // 创建时间
  18 + CreateTime time.Time `json:"createTime"`
  19 +}
  20 +
  21 +func (dto *OffTaskRecordDto) LoadDto(offTaskRecord *domain.OffTaskRecord, projectBelongMap map[int]*domain.ProjectBelong, customerValueMap map[int]*domain.CustomerValue, taskNatureMap map[int]*domain.TaskNature) error {
  22 + dto.OffTaskRecordId = offTaskRecord.OffTaskRecordId
  23 + taskDto := &TaskDto{}
  24 + if err := taskDto.LoadDto(offTaskRecord.Task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
  25 + return err
  26 + }
  27 + dto.Task = taskDto
  28 + dto.Operator = offTaskRecord.Operator
  29 + dto.OffReason = offTaskRecord.OffReason
  30 + dto.CreateTime = offTaskRecord.CreateTime
  31 + return nil
  32 +}
  1 +package dto
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  5 + "time"
  6 +)
  7 +
  8 +type RejectTaskRecordDto struct {
  9 + // 关闭任务记录ID
  10 + RejectTaskRecordId int64 `json:"rejectTaskRecordId"`
  11 + // 任务
  12 + Task *TaskDto `json:"task"`
  13 + // 操作人
  14 + Operator *domain.EmployeeInfo `json:"operator"`
  15 + // 关闭理由
  16 + RejectReason string `json:"rejectReason"`
  17 + // 创建时间
  18 + CreateTime time.Time `json:"createTime"`
  19 +}
  20 +
  21 +func (dto *RejectTaskRecordDto) LoadDto(rejectTaskRecord *domain.RejectTaskRecord, projectBelongMap map[int]*domain.ProjectBelong, customerValueMap map[int]*domain.CustomerValue, taskNatureMap map[int]*domain.TaskNature) error {
  22 + dto.RejectTaskRecordId = rejectTaskRecord.RejectTaskRecordId
  23 + taskDto := &TaskDto{}
  24 + if err := taskDto.LoadDto(rejectTaskRecord.Task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
  25 + return err
  26 + }
  27 + dto.Task = taskDto
  28 + dto.Operator = rejectTaskRecord.Operator
  29 + dto.RejectReason = rejectTaskRecord.RejectReason
  30 + dto.CreateTime = rejectTaskRecord.CreateTime
  31 + return nil
  32 +}
  1 +package dto
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  6 + "time"
  7 +)
  8 +
  9 +type TaskDto struct {
  10 + // 任务ID
  11 + TaskId int64 `json:"taskId"`
  12 + // 公司ID
  13 + CompanyId int64 `json:"companyId"`
  14 + // 任务名称
  15 + TaskName string `json:"taskName"`
  16 + // 任务类型Type
  17 + TaskType int `json:"taskType"`
  18 + // 任务发起者
  19 + Sponsor *domain.EmployeeInfo `json:"sponsor"`
  20 + // 任务状态
  21 + TaskStatus int `json:"taskStatus"`
  22 + // 引用资源
  23 + ReferenceResource *domain.ReferenceResource `json:"referenceResource"`
  24 + // 项目归属
  25 + ProjectBelong *domain.ProjectBelong `json:"projectBelong"`
  26 + // 客户价值列表
  27 + CustomerValues []*domain.CustomerValue `json:"customerValues"`
  28 + // 任务性质
  29 + TaskNature *domain.TaskNature `json:"taskNature"`
  30 + // 奖励素币
  31 + SuMoney float64 `json:"suMoney"`
  32 + // 验收标准
  33 + AcceptanceStandard string `json:"acceptanceStandard"`
  34 + // 任务描述
  35 + TaskDescription string `json:"taskDescription"`
  36 + // 任务图片URL列表
  37 + TaskPictureUrls []string `json:"taskPictureUrls"`
  38 + // 是否悬赏任务
  39 + IsRewardTake bool `json:"isRewardTake"`
  40 + // 抢单任务信息
  41 + RobInfo *domain.RobInfo `json:"robInfo"`
  42 + // 竞标任务信息
  43 + BidInfo *domain.BidInfo `json:"bidInfo"`
  44 + // 任务参与者列表
  45 + Participators []*domain.EmployeeInfo `json:"participators"`
  46 + // 任务贡献占比
  47 + TaskPercentage []*domain.TaskPercentageItem `json:"taskPercentage"`
  48 + // 解决报告
  49 + SolveReport string `json:"solveReport"`
  50 + // 解决图片URL列表
  51 + SolvePictureUrls []string `json:"solvePictureUrls"`
  52 + // 指派人员
  53 + AssignedPerson *domain.EmployeeInfo `json:"assignedPerson"`
  54 + // 计划完成时间
  55 + PlannedCompletionTime time.Time `json:"plannedCompletionTime"`
  56 + // 实际完成时间
  57 + ActualCompletionTime time.Time `json:"actualCompletionTime"`
  58 + // 创建时间
  59 + CreateTime time.Time `json:"createTime"`
  60 + // 发布任务时间
  61 + ReleaseTime time.Time `json:"releaseTime"`
  62 + // 领取任务时间
  63 + ReceiveTime time.Time `json:"receiveTime"`
  64 + // 完成任务操作时间
  65 + CompleteTime time.Time `json:"completeTime"`
  66 + // 验收方验收时间
  67 + AcceptanceTime time.Time `json:"acceptanceTime"`
  68 +}
  69 +
  70 +func (dto *TaskDto) LoadDto(task *domain.Task, projectBelongMap map[int]*domain.ProjectBelong, customerValueMap map[int]*domain.CustomerValue, taskNatureMap map[int]*domain.TaskNature) error {
  71 + dto.TaskId = task.TaskId
  72 + dto.CompanyId = task.CompanyId
  73 + dto.TaskName = task.TaskName
  74 + dto.TaskType = task.TaskType
  75 + dto.Sponsor = task.Sponsor
  76 + dto.TaskStatus = task.TaskStatus
  77 + dto.ReferenceResource = task.ReferenceResource
  78 + if task.ProjectBelong != 0 {
  79 + if projectBelong, ok := projectBelongMap[task.ProjectBelong]; ok {
  80 + dto.ProjectBelong = projectBelong
  81 + } else {
  82 + return fmt.Errorf("无效的项目归属")
  83 + }
  84 + }
  85 + if len(task.CustomerValues) > 0 {
  86 + for _, customerValueId := range task.CustomerValues {
  87 + if customerValue, ok := customerValueMap[customerValueId]; ok {
  88 + dto.CustomerValues = append(dto.CustomerValues, customerValue)
  89 + } else {
  90 + return fmt.Errorf("无效的客户价值")
  91 + }
  92 + }
  93 + }
  94 + if task.TaskNature != 0 {
  95 + if taskNature, ok := taskNatureMap[task.TaskNature]; ok {
  96 + dto.TaskNature = taskNature
  97 + } else {
  98 + return fmt.Errorf("无效的任务性质")
  99 + }
  100 + }
  101 + dto.SuMoney = task.SuMoney
  102 + dto.AcceptanceStandard = task.AcceptanceStandard
  103 + dto.TaskDescription = task.TaskDescription
  104 + dto.TaskPictureUrls = task.TaskPictureUrls
  105 + dto.IsRewardTake = task.IsRewardTake
  106 + dto.RobInfo = task.RobInfo
  107 + dto.BidInfo = task.BidInfo
  108 + dto.Participators = task.Participators
  109 + dto.TaskPercentage = task.TaskPercentage
  110 + dto.SolveReport = task.SolveReport
  111 + dto.SolvePictureUrls = task.SolvePictureUrls
  112 + dto.AssignedPerson = task.AssignedPerson
  113 + dto.PlannedCompletionTime = task.PlannedCompletionTime
  114 + dto.ActualCompletionTime = task.ActualCompletionTime
  115 + dto.CreateTime = task.CreateTime
  116 + dto.ReleaseTime = task.ReleaseTime
  117 + dto.ReceiveTime = task.ReceiveTime
  118 + dto.CompleteTime = task.CompleteTime
  119 + dto.AcceptanceTime = task.AcceptanceTime
  120 + return nil
  121 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type GetRejectTaskRecordQuery struct {
  10 + // 驳回任务记录ID
  11 + RejectTaskRecordId int64 `json:"rejectTaskRecordId" valid:"Required"`
  12 +}
  13 +
  14 +func (getRejectTaskRecordQuery *GetRejectTaskRecordQuery) ValidateQuery() error {
  15 + valid := validation.Validation{}
  16 + b, err := valid.Valid(getRejectTaskRecordQuery)
  17 + if err != nil {
  18 + return err
  19 + }
  20 + if !b {
  21 + for _, validErr := range valid.Errors {
  22 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  23 + }
  24 + }
  25 + return nil
  26 +}
@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/event/subscriber" 7 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/event/subscriber"
8 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" 8 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/command" 9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/command"
  10 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/dto"
10 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/query" 11 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/query"
11 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" 12 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
12 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service" 13 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
@@ -18,6 +19,74 @@ import ( @@ -18,6 +19,74 @@ import (
18 type TaskService struct { 19 type TaskService struct {
19 } 20 }
20 21
  22 +// 对抢单任务进行确认
  23 +func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.ConfirmRobTaskCommand) (interface{}, error) {
  24 + if err := confirmRobTaskCommand.ValidateCommand(); err != nil {
  25 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  26 + }
  27 + transactionContext, err := factory.CreateTransactionContext(nil)
  28 + if err != nil {
  29 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  30 + }
  31 + if err := transactionContext.StartTransaction(); err != nil {
  32 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  33 + }
  34 + defer func() {
  35 + transactionContext.RollbackTransaction()
  36 + }()
  37 + var confirmRobTaskService service.ConfirmRobTaskService
  38 + if value, err := factory.CreateConfirmRobTaskService(map[string]interface{}{
  39 + "transactionContext": transactionContext,
  40 + }); err != nil {
  41 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  42 + } else {
  43 + confirmRobTaskService = value
  44 + //confirmRobTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
  45 + }
  46 + if task, err := confirmRobTaskService.Confirm(confirmRobTaskCommand.TaskId, confirmRobTaskCommand.Operator, confirmRobTaskCommand.PlannedCompletionTime); err != nil {
  47 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  48 + } else {
  49 + if err := transactionContext.CommitTransaction(); err != nil {
  50 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  51 + }
  52 + return task, nil
  53 + }
  54 +}
  55 +
  56 +// 驳回任务领取人
  57 +func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *command.RejectTaskReceiverCommand) (interface{}, error) {
  58 + if err := rejectTaskReceiverCommand.ValidateCommand(); err != nil {
  59 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  60 + }
  61 + transactionContext, err := factory.CreateTransactionContext(nil)
  62 + if err != nil {
  63 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  64 + }
  65 + if err := transactionContext.StartTransaction(); err != nil {
  66 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  67 + }
  68 + defer func() {
  69 + transactionContext.RollbackTransaction()
  70 + }()
  71 + var rejectTaskReceiverService service.RejectTaskReceiverService
  72 + if value, err := factory.CreateRejectTaskReceiverService(map[string]interface{}{
  73 + "transactionContext": transactionContext,
  74 + }); err != nil {
  75 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  76 + } else {
  77 + rejectTaskReceiverService = value
  78 + //rejectTaskReceiverService.Subscribe(&subscriber.AbilityServiceSubscriber{})
  79 + }
  80 + if task, err := rejectTaskReceiverService.Reject(rejectTaskReceiverCommand.TaskId, rejectTaskReceiverCommand.Operator, rejectTaskReceiverCommand.RejectReason); err != nil {
  81 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  82 + } else {
  83 + if err := transactionContext.CommitTransaction(); err != nil {
  84 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  85 + }
  86 + return task, nil
  87 + }
  88 +}
  89 +
21 // 对任务进行抢单 90 // 对任务进行抢单
22 func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand) (interface{}, error) { 91 func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand) (interface{}, error) {
23 if err := robTaskCommand.ValidateCommand(); err != nil { 92 if err := robTaskCommand.ValidateCommand(); err != nil {
@@ -109,7 +178,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom @@ -109,7 +178,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom
109 chooseSuccessfulBidderService = value 178 chooseSuccessfulBidderService = value
110 chooseSuccessfulBidderService.Subscribe(&subscriber.AbilityServiceSubscriber{}) 179 chooseSuccessfulBidderService.Subscribe(&subscriber.AbilityServiceSubscriber{})
111 } 180 }
112 - if task, err := chooseSuccessfulBidderService.Choose(chooseSuccessfulBidderCommand.TaskId, chooseSuccessfulBidderCommand.SuccessfulBidder, chooseSuccessfulBidderCommand.Operator); err != nil { 181 + if task, err := chooseSuccessfulBidderService.Choose(chooseSuccessfulBidderCommand.TaskId, chooseSuccessfulBidderCommand.SuccessfulBidder, chooseSuccessfulBidderCommand.Operator, chooseSuccessfulBidderCommand.PlannedCompletionTime); err != nil {
113 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 182 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
114 } else { 183 } else {
115 if err := transactionContext.CommitTransaction(); err != nil { 184 if err := transactionContext.CommitTransaction(); err != nil {
@@ -244,7 +313,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac @@ -244,7 +313,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
244 acceptanceTaskService = value 313 acceptanceTaskService = value
245 acceptanceTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{}) 314 acceptanceTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
246 } 315 }
247 - if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls); err != nil { 316 + if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls, acceptanceTaskCommand.ActualCompletionTime); err != nil {
248 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 317 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
249 } else { 318 } else {
250 if err := transactionContext.CommitTransaction(); err != nil { 319 if err := transactionContext.CommitTransaction(); err != nil {
@@ -277,15 +346,77 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask @@ -277,15 +346,77 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
277 } else { 346 } else {
278 taskRepository = value 347 taskRepository = value
279 } 348 }
  349 + var projectBelongRepository domain.ProjectBelongRepository
  350 + if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
  351 + "transactionContext": transactionContext,
  352 + }); err != nil {
  353 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  354 + } else {
  355 + projectBelongRepository = value
  356 + }
  357 + projectBelongMap := make(map[int]*domain.ProjectBelong)
  358 + if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
  359 + "companyId": searchTaskCommand.CompanyId,
  360 + }); err != nil {
  361 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  362 + } else {
  363 + for _, projectBelong := range projectBelongs {
  364 + projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
  365 + }
  366 + }
  367 + var customerValueRepository domain.CustomerValueRepository
  368 + if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
  369 + "transactionContext": transactionContext,
  370 + }); err != nil {
  371 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  372 + } else {
  373 + customerValueRepository = value
  374 + }
  375 + customerValueMap := make(map[int]*domain.CustomerValue)
  376 + if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
  377 + "companyId": searchTaskCommand.CompanyId,
  378 + }); err != nil {
  379 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  380 + } else {
  381 + for _, customerValue := range customerValues {
  382 + customerValueMap[customerValue.CustomerValueId] = customerValue
  383 + }
  384 + }
  385 + var taskNatureRepository domain.TaskNatureRepository
  386 + if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
  387 + "transactionContext": transactionContext,
  388 + }); err != nil {
  389 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  390 + } else {
  391 + taskNatureRepository = value
  392 + }
  393 + taskNatureMap := make(map[int]*domain.TaskNature)
  394 + if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
  395 + "companyId": searchTaskCommand.CompanyId,
  396 + }); err != nil {
  397 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  398 + } else {
  399 + for _, taskNature := range taskNatures {
  400 + taskNatureMap[taskNature.TaskNatureId] = taskNature
  401 + }
  402 + }
280 if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(searchTaskCommand)); err != nil { 403 if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(searchTaskCommand)); err != nil {
281 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 404 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
282 } else { 405 } else {
  406 + var taskDtos []*dto.TaskDto
  407 + for _, task := range tasks {
  408 + taskDto := &dto.TaskDto{}
  409 + if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
  410 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  411 + }
  412 + taskDtos = append(taskDtos, taskDto)
  413 + }
283 if err := transactionContext.CommitTransaction(); err != nil { 414 if err := transactionContext.CommitTransaction(); err != nil {
284 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 415 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
285 } 416 }
286 return map[string]interface{}{ 417 return map[string]interface{}{
287 "count": count, 418 "count": count,
288 - "tasks": tasks, 419 + "tasks": taskDtos,
289 }, nil 420 }, nil
290 } 421 }
291 } 422 }
@@ -305,6 +436,60 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * @@ -305,6 +436,60 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
305 defer func() { 436 defer func() {
306 transactionContext.RollbackTransaction() 437 transactionContext.RollbackTransaction()
307 }() 438 }()
  439 + var projectBelongRepository domain.ProjectBelongRepository
  440 + if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
  441 + "transactionContext": transactionContext,
  442 + }); err != nil {
  443 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  444 + } else {
  445 + projectBelongRepository = value
  446 + }
  447 + projectBelongMap := make(map[int]*domain.ProjectBelong)
  448 + if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
  449 + "companyId": searchOffTaskRecordCommand.CompanyId,
  450 + }); err != nil {
  451 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  452 + } else {
  453 + for _, projectBelong := range projectBelongs {
  454 + projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
  455 + }
  456 + }
  457 + var customerValueRepository domain.CustomerValueRepository
  458 + if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
  459 + "transactionContext": transactionContext,
  460 + }); err != nil {
  461 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  462 + } else {
  463 + customerValueRepository = value
  464 + }
  465 + customerValueMap := make(map[int]*domain.CustomerValue)
  466 + if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
  467 + "companyId": searchOffTaskRecordCommand.CompanyId,
  468 + }); err != nil {
  469 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  470 + } else {
  471 + for _, customerValue := range customerValues {
  472 + customerValueMap[customerValue.CustomerValueId] = customerValue
  473 + }
  474 + }
  475 + var taskNatureRepository domain.TaskNatureRepository
  476 + if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
  477 + "transactionContext": transactionContext,
  478 + }); err != nil {
  479 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  480 + } else {
  481 + taskNatureRepository = value
  482 + }
  483 + taskNatureMap := make(map[int]*domain.TaskNature)
  484 + if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
  485 + "companyId": searchOffTaskRecordCommand.CompanyId,
  486 + }); err != nil {
  487 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  488 + } else {
  489 + for _, taskNature := range taskNatures {
  490 + taskNatureMap[taskNature.TaskNatureId] = taskNature
  491 + }
  492 + }
308 var taskRepository domain.TaskRepository 493 var taskRepository domain.TaskRepository
309 if value, err := factory.CreateTaskRepository(map[string]interface{}{ 494 if value, err := factory.CreateTaskRepository(map[string]interface{}{
310 "transactionContext": transactionContext, 495 "transactionContext": transactionContext,
@@ -326,8 +511,9 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * @@ -326,8 +511,9 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
326 "taskStatus": domain.TASK_STATUS_CLOSED, 511 "taskStatus": domain.TASK_STATUS_CLOSED,
327 "taskContentMatch": searchOffTaskRecordCommand.TaskContentMatch, 512 "taskContentMatch": searchOffTaskRecordCommand.TaskContentMatch,
328 "taskType": searchOffTaskRecordCommand.TaskType, 513 "taskType": searchOffTaskRecordCommand.TaskType,
329 - "customerValue": searchOffTaskRecordCommand.CustomerValue,  
330 - "taskNature": searchOffTaskRecordCommand.TaskNature, 514 + "projectBelongs": searchOffTaskRecordCommand.ProjectBelongs,
  515 + "customerValues": searchOffTaskRecordCommand.CustomerValues,
  516 + "taskNatures": searchOffTaskRecordCommand.TaskNatures,
331 }) 517 })
332 if err != nil { 518 if err != nil {
333 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 519 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -345,19 +531,25 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * @@ -345,19 +531,25 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
345 }); err != nil { 531 }); err != nil {
346 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 532 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
347 } else { 533 } else {
348 - if err := transactionContext.CommitTransaction(); err != nil {  
349 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
350 - } 534 + var offTaskRecordDtos []*dto.OffTaskRecordDto
351 for _, offTaskRecord := range offTaskRecords { 535 for _, offTaskRecord := range offTaskRecords {
352 for _, task := range tasks { 536 for _, task := range tasks {
353 if offTaskRecord.Task.TaskId == task.TaskId { 537 if offTaskRecord.Task.TaskId == task.TaskId {
354 offTaskRecord.Task = task 538 offTaskRecord.Task = task
355 } 539 }
356 } 540 }
  541 + offTaskRecordDto := &dto.OffTaskRecordDto{}
  542 + if err := offTaskRecordDto.LoadDto(offTaskRecord, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
  543 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  544 + }
  545 + offTaskRecordDtos = append(offTaskRecordDtos, offTaskRecordDto)
  546 + }
  547 + if err := transactionContext.CommitTransaction(); err != nil {
  548 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
357 } 549 }
358 return map[string]interface{}{ 550 return map[string]interface{}{
359 "count": count, 551 "count": count,
360 - "offTaskRecords": offTaskRecords, 552 + "offTaskRecords": offTaskRecordDtos,
361 }, nil 553 }, nil
362 } 554 }
363 } 555 }
@@ -399,6 +591,176 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge @@ -399,6 +591,176 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge
399 } 591 }
400 } 592 }
401 593
  594 +// 搜索驳回任务记录
  595 +func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCommand *command.SearchRejectTaskRecordCommand) (interface{}, error) {
  596 + if err := searchRejectTaskRecordCommand.ValidateCommand(); err != nil {
  597 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  598 + }
  599 + transactionContext, err := factory.CreateTransactionContext(nil)
  600 + if err != nil {
  601 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  602 + }
  603 + if err := transactionContext.StartTransaction(); err != nil {
  604 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  605 + }
  606 + defer func() {
  607 + transactionContext.RollbackTransaction()
  608 + }()
  609 + var projectBelongRepository domain.ProjectBelongRepository
  610 + if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
  611 + "transactionContext": transactionContext,
  612 + }); err != nil {
  613 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  614 + } else {
  615 + projectBelongRepository = value
  616 + }
  617 + projectBelongMap := make(map[int]*domain.ProjectBelong)
  618 + if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
  619 + "companyId": searchRejectTaskRecordCommand.CompanyId,
  620 + }); err != nil {
  621 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  622 + } else {
  623 + for _, projectBelong := range projectBelongs {
  624 + projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
  625 + }
  626 + }
  627 + var customerValueRepository domain.CustomerValueRepository
  628 + if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
  629 + "transactionContext": transactionContext,
  630 + }); err != nil {
  631 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  632 + } else {
  633 + customerValueRepository = value
  634 + }
  635 + customerValueMap := make(map[int]*domain.CustomerValue)
  636 + if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
  637 + "companyId": searchRejectTaskRecordCommand.CompanyId,
  638 + }); err != nil {
  639 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  640 + } else {
  641 + for _, customerValue := range customerValues {
  642 + customerValueMap[customerValue.CustomerValueId] = customerValue
  643 + }
  644 + }
  645 + var taskNatureRepository domain.TaskNatureRepository
  646 + if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
  647 + "transactionContext": transactionContext,
  648 + }); err != nil {
  649 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  650 + } else {
  651 + taskNatureRepository = value
  652 + }
  653 + taskNatureMap := make(map[int]*domain.TaskNature)
  654 + if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
  655 + "companyId": searchRejectTaskRecordCommand.CompanyId,
  656 + }); err != nil {
  657 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  658 + } else {
  659 + for _, taskNature := range taskNatures {
  660 + taskNatureMap[taskNature.TaskNatureId] = taskNature
  661 + }
  662 + }
  663 + var taskRepository domain.TaskRepository
  664 + if value, err := factory.CreateTaskRepository(map[string]interface{}{
  665 + "transactionContext": transactionContext,
  666 + }); err != nil {
  667 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  668 + } else {
  669 + taskRepository = value
  670 + }
  671 + var rejectTaskRecordRepository domain.RejectTaskRecordRepository
  672 + if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{
  673 + "transactionContext": transactionContext,
  674 + }); err != nil {
  675 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  676 + } else {
  677 + rejectTaskRecordRepository = value
  678 + }
  679 + _, tasks, err := taskRepository.Find(map[string]interface{}{
  680 + "companyId": searchRejectTaskRecordCommand.CompanyId,
  681 + "taskStatus": domain.TASK_STATUS_CLOSED,
  682 + "taskContentMatch": searchRejectTaskRecordCommand.TaskContentMatch,
  683 + "taskType": searchRejectTaskRecordCommand.TaskType,
  684 + "projectBelongs": searchRejectTaskRecordCommand.ProjectBelongs,
  685 + "customerValues": searchRejectTaskRecordCommand.CustomerValues,
  686 + "taskNatures": searchRejectTaskRecordCommand.TaskNatures,
  687 + })
  688 + if err != nil {
  689 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  690 + }
  691 + var taskIds []int64
  692 + for _, task := range tasks {
  693 + taskIds = append(taskIds, task.TaskId)
  694 + }
  695 + if count, rejectTaskRecords, err := rejectTaskRecordRepository.Find(map[string]interface{}{
  696 + "taskIds": taskIds,
  697 + "rejectStartTime": searchRejectTaskRecordCommand.RejectStartTime,
  698 + "rejectEndTime": searchRejectTaskRecordCommand.RejectEndTime,
  699 + "offset": searchRejectTaskRecordCommand.Offset,
  700 + "limit": searchRejectTaskRecordCommand.Limit,
  701 + }); err != nil {
  702 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  703 + } else {
  704 + var rejectTaskRecordDtos []*dto.RejectTaskRecordDto
  705 + for _, rejectTaskRecord := range rejectTaskRecords {
  706 + for _, task := range tasks {
  707 + if rejectTaskRecord.Task.TaskId == task.TaskId {
  708 + rejectTaskRecord.Task = task
  709 + }
  710 + }
  711 + rejectTaskRecordDto := &dto.RejectTaskRecordDto{}
  712 + if err := rejectTaskRecordDto.LoadDto(rejectTaskRecord, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
  713 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  714 + }
  715 + rejectTaskRecordDtos = append(rejectTaskRecordDtos, rejectTaskRecordDto)
  716 + }
  717 + if err := transactionContext.CommitTransaction(); err != nil {
  718 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  719 + }
  720 + return map[string]interface{}{
  721 + "count": count,
  722 + "offTaskRecords": rejectTaskRecordDtos,
  723 + }, nil
  724 + }
  725 +}
  726 +
  727 +// 返回驳回任务记录
  728 +func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *query.GetRejectTaskRecordQuery) (interface{}, error) {
  729 + if err := getRejectTaskRecordQuery.ValidateQuery(); err != nil {
  730 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  731 + }
  732 + transactionContext, err := factory.CreateTransactionContext(nil)
  733 + if err != nil {
  734 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  735 + }
  736 + if err := transactionContext.StartTransaction(); err != nil {
  737 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  738 + }
  739 + defer func() {
  740 + transactionContext.RollbackTransaction()
  741 + }()
  742 + var rejectTaskRecordRepository domain.RejectTaskRecordRepository
  743 + if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{
  744 + "transactionContext": transactionContext,
  745 + }); err != nil {
  746 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  747 + } else {
  748 + rejectTaskRecordRepository = value
  749 + }
  750 + rejectTaskRecord, err := rejectTaskRecordRepository.FindOne(map[string]interface{}{"rejectTaskRecordId": getRejectTaskRecordQuery.RejectTaskRecordId})
  751 + if err != nil {
  752 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  753 + }
  754 + if rejectTaskRecord == nil {
  755 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getRejectTaskRecordQuery.RejectTaskRecordId)))
  756 + } else {
  757 + if err := transactionContext.CommitTransaction(); err != nil {
  758 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  759 + }
  760 + return rejectTaskRecord, nil
  761 + }
  762 +}
  763 +
402 // 创建新任务 764 // 创建新任务
403 func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTaskCommand) (interface{}, error) { 765 func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTaskCommand) (interface{}, error) {
404 if err := createTaskCommand.ValidateCommand(); err != nil { 766 if err := createTaskCommand.ValidateCommand(); err != nil {
@@ -439,6 +801,19 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -439,6 +801,19 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
439 if sponsor == nil { 801 if sponsor == nil {
440 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者") 802 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者")
441 } 803 }
  804 + var assignedPerson *domain.EmployeeInfo
  805 + if createTaskCommand.AssignedPerson != 0 {
  806 + employee, err := employeeRepository.FindOne(map[string]interface{}{
  807 + "uid": createTaskCommand.AssignedPerson,
  808 + })
  809 + if err != nil {
  810 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  811 + }
  812 + if employee == nil {
  813 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
  814 + }
  815 + assignedPerson = employee.EmployeeInfo
  816 + }
442 newTask := &domain.Task{ 817 newTask := &domain.Task{
443 TaskStatus: domain.TASK_STATUS_UNRELEASED, 818 TaskStatus: domain.TASK_STATUS_UNRELEASED,
444 CompanyId: createTaskCommand.CompanyId, 819 CompanyId: createTaskCommand.CompanyId,
@@ -449,14 +824,17 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -449,14 +824,17 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
449 ReferenceResourceType: createTaskCommand.ReferenceResourceType, 824 ReferenceResourceType: createTaskCommand.ReferenceResourceType,
450 ReferenceResourceItems: createTaskCommand.ReferenceResourceItems, 825 ReferenceResourceItems: createTaskCommand.ReferenceResourceItems,
451 }, 826 },
452 - CustomerValue: createTaskCommand.CustomerValue,  
453 - TaskNature: createTaskCommand.TaskNature,  
454 - SuMoney: createTaskCommand.SuMoney,  
455 - AcceptanceStandard: createTaskCommand.AcceptanceStandard,  
456 - TaskDescription: createTaskCommand.TaskDescription,  
457 - TaskPictureUrls: createTaskCommand.TaskPictureUrls,  
458 - IsRewardTake: createTaskCommand.IsRewardTake,  
459 - CreateTime: time.Now(), 827 + ProjectBelong: createTaskCommand.ProjectBelong,
  828 + CustomerValues: createTaskCommand.CustomerValues,
  829 + TaskNature: createTaskCommand.TaskNature,
  830 + SuMoney: createTaskCommand.SuMoney,
  831 + AcceptanceStandard: createTaskCommand.AcceptanceStandard,
  832 + TaskDescription: createTaskCommand.TaskDescription,
  833 + TaskPictureUrls: createTaskCommand.TaskPictureUrls,
  834 + IsRewardTake: createTaskCommand.IsRewardTake,
  835 + AssignedPerson: assignedPerson,
  836 + PlannedCompletionTime: createTaskCommand.PlannedCompletionTime,
  837 + CreateTime: time.Now(),
460 } 838 }
461 var taskRepository domain.TaskRepository 839 var taskRepository domain.TaskRepository
462 if value, err := factory.CreateTaskRepository(map[string]interface{}{ 840 if value, err := factory.CreateTaskRepository(map[string]interface{}{
@@ -487,7 +865,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -487,7 +865,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
487 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 865 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
488 } else { 866 } else {
489 if createTaskCommand.TaskType == domain.TASK_TYPE_BID { 867 if createTaskCommand.TaskType == domain.TASK_TYPE_BID {
490 - if err := taskDao.AddBidInfo(task.TaskId, createTaskCommand.BidStartTime, createTaskCommand.BidEndTime); err != nil { 868 + if err := taskDao.AddBidInfo(task.TaskId, createTaskCommand.BidStartTime, createTaskCommand.BidEndTime, createTaskCommand.IsRemind); err != nil {
491 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 869 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
492 } 870 }
493 } 871 }
@@ -545,10 +923,68 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter @@ -545,10 +923,68 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
545 if task == nil { 923 if task == nil {
546 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getTaskQuery.TaskId))) 924 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getTaskQuery.TaskId)))
547 } else { 925 } else {
  926 + var projectBelongRepository domain.ProjectBelongRepository
  927 + if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
  928 + "transactionContext": transactionContext,
  929 + }); err != nil {
  930 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  931 + } else {
  932 + projectBelongRepository = value
  933 + }
  934 + projectBelongMap := make(map[int]*domain.ProjectBelong)
  935 + if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
  936 + "companyId": task.CompanyId,
  937 + }); err != nil {
  938 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  939 + } else {
  940 + for _, projectBelong := range projectBelongs {
  941 + projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
  942 + }
  943 + }
  944 + var customerValueRepository domain.CustomerValueRepository
  945 + if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
  946 + "transactionContext": transactionContext,
  947 + }); err != nil {
  948 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  949 + } else {
  950 + customerValueRepository = value
  951 + }
  952 + customerValueMap := make(map[int]*domain.CustomerValue)
  953 + if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
  954 + "companyId": task.CompanyId,
  955 + }); err != nil {
  956 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  957 + } else {
  958 + for _, customerValue := range customerValues {
  959 + customerValueMap[customerValue.CustomerValueId] = customerValue
  960 + }
  961 + }
  962 + var taskNatureRepository domain.TaskNatureRepository
  963 + if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
  964 + "transactionContext": transactionContext,
  965 + }); err != nil {
  966 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  967 + } else {
  968 + taskNatureRepository = value
  969 + }
  970 + taskNatureMap := make(map[int]*domain.TaskNature)
  971 + if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
  972 + "companyId": task.CompanyId,
  973 + }); err != nil {
  974 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  975 + } else {
  976 + for _, taskNature := range taskNatures {
  977 + taskNatureMap[taskNature.TaskNatureId] = taskNature
  978 + }
  979 + }
  980 + taskDto := &dto.TaskDto{}
  981 + if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
  982 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  983 + }
548 if err := transactionContext.CommitTransaction(); err != nil { 984 if err := transactionContext.CommitTransaction(); err != nil {
549 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 985 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
550 } 986 }
551 - return task, nil 987 + return taskDto, nil
552 } 988 }
553 } 989 }
554 990
@@ -619,7 +1055,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -619,7 +1055,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
619 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1055 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
620 } else { 1056 } else {
621 if task.TaskType == domain.TASK_TYPE_BID { 1057 if task.TaskType == domain.TASK_TYPE_BID {
622 - if err := taskDao.UpdateBidInfo(updateTaskCommand.TaskId, updateTaskCommand.BidStartTime, updateTaskCommand.BidEndTime); err != nil { 1058 + if err := taskDao.UpdateBidInfo(updateTaskCommand.TaskId, updateTaskCommand.BidStartTime, updateTaskCommand.BidEndTime, updateTaskCommand.IsRemind); err != nil {
623 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1059 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
624 } 1060 }
625 } 1061 }
@@ -12,6 +12,8 @@ type BidInfo struct { @@ -12,6 +12,8 @@ type BidInfo struct {
12 BidStartTime time.Time `json:"bidStartTime"` 12 BidStartTime time.Time `json:"bidStartTime"`
13 // 竞标结束时间 13 // 竞标结束时间
14 BidEndTime time.Time `json:"bidEndTime"` 14 BidEndTime time.Time `json:"bidEndTime"`
  15 + //是否截止时间前一天提醒
  16 + IsRemind bool `json:"isRemind"`
15 // 中标时间 17 // 中标时间
16 WinBidTime time.Time `json:"winBidTime"` 18 WinBidTime time.Time `json:"winBidTime"`
17 } 19 }
@@ -23,10 +23,12 @@ type TaskReleased struct { @@ -23,10 +23,12 @@ type TaskReleased struct {
23 TaskStatus int `json:"taskStatus"` 23 TaskStatus int `json:"taskStatus"`
24 // 引用资源 24 // 引用资源
25 ReferenceResource *domain.ReferenceResource `json:"referenceResource"` 25 ReferenceResource *domain.ReferenceResource `json:"referenceResource"`
  26 + // 项目归属
  27 + ProjectBelong int `json:"projectBelong"`
26 // 客户价值列表 28 // 客户价值列表
27 - CustomerValue []string `json:"customerValue"` 29 + CustomerValues []int `json:"customerValues"`
28 // 任务性质 30 // 任务性质
29 - TaskNature string `json:"taskNature"` 31 + TaskNature int `json:"taskNature"`
30 // 奖励素币 32 // 奖励素币
31 SuMoney float64 `json:"suMoney"` 33 SuMoney float64 `json:"suMoney"`
32 // 验收标准 34 // 验收标准
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +// 驳回任务记录
  6 +type RejectTaskRecord struct {
  7 + // 驳回任务记录ID
  8 + RejectTaskRecordId int64 `json:"rejectTaskRecordId"`
  9 + // 任务
  10 + Task *Task `json:"task"`
  11 + // 操作人
  12 + Operator *EmployeeInfo `json:"operator"`
  13 + // 驳回理由
  14 + RejectReason string `json:"rejectReason"`
  15 + // 创建时间
  16 + CreateTime time.Time `json:"createTime"`
  17 +}
  18 +
  19 +type RejectTaskRecordRepository interface {
  20 + Save(rejectTaskRecord *RejectTaskRecord) (*RejectTaskRecord, error)
  21 + Remove(rejectTaskRecord *RejectTaskRecord) (*RejectTaskRecord, error)
  22 + FindOne(queryOptions map[string]interface{}) (*RejectTaskRecord, error)
  23 + Find(queryOptions map[string]interface{}) (int64, []*RejectTaskRecord, error)
  24 +}
  25 +
  26 +func (rejectTaskRecord *RejectTaskRecord) Identify() interface{} {
  27 + if rejectTaskRecord.RejectTaskRecordId == 0 {
  28 + return nil
  29 + }
  30 + return rejectTaskRecord.RejectTaskRecordId
  31 +}
  32 +
  33 +func (rejectTaskRecord *RejectTaskRecord) Update(data map[string]interface{}) error {
  34 + if rejectReason, ok := data["rejectReason"]; ok && rejectReason != "" {
  35 + rejectTaskRecord.RejectReason = rejectReason.(string)
  36 + }
  37 + return nil
  38 +}
@@ -3,9 +3,10 @@ package service @@ -3,9 +3,10 @@ package service
3 import ( 3 import (
4 coreDomain "github.com/linmadan/egglib-go/core/domain" 4 coreDomain "github.com/linmadan/egglib-go/core/domain"
5 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" 5 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  6 + "time"
6 ) 7 )
7 8
8 type AcceptanceTaskService interface { 9 type AcceptanceTaskService interface {
9 coreDomain.DomainEventPublisher 10 coreDomain.DomainEventPublisher
10 - Acceptance(taskId int64, operatorUid int64, participators []int64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string) (*domain.Task, error) 11 + Acceptance(taskId int64, operatorUid int64, participators []int64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) (*domain.Task, error)
11 } 12 }
@@ -3,9 +3,10 @@ package service @@ -3,9 +3,10 @@ package service
3 import ( 3 import (
4 coreDomain "github.com/linmadan/egglib-go/core/domain" 4 coreDomain "github.com/linmadan/egglib-go/core/domain"
5 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" 5 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  6 + "time"
6 ) 7 )
7 8
8 type ChooseSuccessfulBidderService interface { 9 type ChooseSuccessfulBidderService interface {
9 coreDomain.DomainEventPublisher 10 coreDomain.DomainEventPublisher
10 - Choose(taskId int64, successfulBidderUid int64, operatorUid int64) (*domain.Task, error) 11 + Choose(taskId int64, successfulBidderUid int64, operatorUid int64, plannedCompletionTime time.Time) (*domain.Task, error)
11 } 12 }
  1 +package service
  2 +
  3 +import (
  4 + coreDomain "github.com/linmadan/egglib-go/core/domain"
  5 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  6 + "time"
  7 +)
  8 +
  9 +type ConfirmRobTaskService interface {
  10 + coreDomain.DomainEventPublisher
  11 + Confirm(taskId int64, operatorUid int64, plannedCompletionTime time.Time) (*domain.Task, error)
  12 +}
  1 +package service
  2 +
  3 +import (
  4 + coreDomain "github.com/linmadan/egglib-go/core/domain"
  5 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  6 +)
  7 +
  8 +type RejectTaskReceiverService interface {
  9 + coreDomain.DomainEventPublisher
  10 + Reject(taskId int64, operatorUid int64, rejectReason string) (*domain.Task, error)
  11 +}
@@ -42,10 +42,12 @@ type Task struct { @@ -42,10 +42,12 @@ type Task struct {
42 TaskStatus int `json:"taskStatus"` 42 TaskStatus int `json:"taskStatus"`
43 // 引用资源 43 // 引用资源
44 ReferenceResource *ReferenceResource `json:"referenceResource"` 44 ReferenceResource *ReferenceResource `json:"referenceResource"`
  45 + // 项目归属
  46 + ProjectBelong int `json:"projectBelong"`
45 // 客户价值列表 47 // 客户价值列表
46 - CustomerValue []string `json:"customerValue"` 48 + CustomerValues []int `json:"customerValues"`
47 // 任务性质 49 // 任务性质
48 - TaskNature string `json:"taskNature"` 50 + TaskNature int `json:"taskNature"`
49 // 奖励素币 51 // 奖励素币
50 SuMoney float64 `json:"suMoney"` 52 SuMoney float64 `json:"suMoney"`
51 // 验收标准 53 // 验收标准
@@ -68,6 +70,12 @@ type Task struct { @@ -68,6 +70,12 @@ type Task struct {
68 SolveReport string `json:"solveReport"` 70 SolveReport string `json:"solveReport"`
69 // 解决图片URL列表 71 // 解决图片URL列表
70 SolvePictureUrls []string `json:"solvePictureUrls"` 72 SolvePictureUrls []string `json:"solvePictureUrls"`
  73 + // 指派人员
  74 + AssignedPerson *EmployeeInfo `json:"assignedPerson"`
  75 + // 计划完成时间
  76 + PlannedCompletionTime time.Time `json:"plannedCompletionTime"`
  77 + // 实际完成时间
  78 + ActualCompletionTime time.Time `json:"actualCompletionTime"`
71 // 创建时间 79 // 创建时间
72 CreateTime time.Time `json:"createTime"` 80 CreateTime time.Time `json:"createTime"`
73 // 发布任务时间 81 // 发布任务时间
@@ -87,10 +95,12 @@ type TaskStatus interface { @@ -87,10 +95,12 @@ type TaskStatus interface {
87 Release(task *Task) error 95 Release(task *Task) error
88 Rob(task *Task, receiver *EmployeeInfo) error 96 Rob(task *Task, receiver *EmployeeInfo) error
89 Bib(task *Task, bidder *EmployeeInfo) error 97 Bib(task *Task, bidder *EmployeeInfo) error
90 - ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error 98 + ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error
91 ApplyComplete(task *Task) error 99 ApplyComplete(task *Task) error
92 Off(task *Task) error 100 Off(task *Task) error
93 - Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error 101 + Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error
  102 + ConfirmTask(task *Task, plannedCompletionTime time.Time) error
  103 + RejectReceiver(task *Task) error
94 } 104 }
95 105
96 type UnReleasedStatus struct{} 106 type UnReleasedStatus struct{}
@@ -105,11 +115,14 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) @@ -105,11 +115,14 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{})
105 if referenceResourceItems, ok := data["referenceResourceItems"]; ok { 115 if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
106 task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem) 116 task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
107 } 117 }
108 - if customerValue, ok := data["customerValue"]; ok {  
109 - task.CustomerValue = customerValue.([]string) 118 + if projectBelong, ok := data["projectBelong"]; ok {
  119 + task.ProjectBelong = projectBelong.(int)
  120 + }
  121 + if customerValues, ok := data["customerValues"]; ok {
  122 + task.CustomerValues = customerValues.([]int)
110 } 123 }
111 if taskNature, ok := data["taskNature"]; ok { 124 if taskNature, ok := data["taskNature"]; ok {
112 - task.TaskNature = taskNature.(string) 125 + task.TaskNature = taskNature.(int)
113 } 126 }
114 if suMoney, ok := data["suMoney"]; ok { 127 if suMoney, ok := data["suMoney"]; ok {
115 task.SuMoney = suMoney.(float64) 128 task.SuMoney = suMoney.(float64)
@@ -121,6 +134,9 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) @@ -121,6 +134,9 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{})
121 if bidEndTime, ok := data["bidEndTime"]; ok { 134 if bidEndTime, ok := data["bidEndTime"]; ok {
122 task.BidInfo.BidEndTime = bidEndTime.(time.Time) 135 task.BidInfo.BidEndTime = bidEndTime.(time.Time)
123 } 136 }
  137 + if isRemind, ok := data["isRemind"]; ok {
  138 + task.BidInfo.IsRemind = isRemind.(bool)
  139 + }
124 } 140 }
125 if acceptanceStandard, ok := data["acceptanceStandard"]; ok { 141 if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
126 task.AcceptanceStandard = acceptanceStandard.(string) 142 task.AcceptanceStandard = acceptanceStandard.(string)
@@ -134,13 +150,26 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) @@ -134,13 +150,26 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{})
134 if isRewardTake, ok := data["isRewardTake"]; ok { 150 if isRewardTake, ok := data["isRewardTake"]; ok {
135 task.IsRewardTake = isRewardTake.(bool) 151 task.IsRewardTake = isRewardTake.(bool)
136 } 152 }
  153 + if task.TaskType == TASK_TYPE_DESIGNATE {
  154 + if plannedCompletionTime, ok := data["plannedCompletionTime"]; ok {
  155 + task.PlannedCompletionTime = plannedCompletionTime.(time.Time)
  156 + }
  157 + if assignedPerson, ok := data["assignedPerson"]; ok {
  158 + task.AssignedPerson = assignedPerson.(*EmployeeInfo)
  159 + }
  160 + }
137 return nil 161 return nil
138 } 162 }
139 163
140 func (status *UnReleasedStatus) Release(task *Task) error { 164 func (status *UnReleasedStatus) Release(task *Task) error {
141 task.ReleaseTime = time.Now() 165 task.ReleaseTime = time.Now()
142 - task.TaskStatus = TASK_STATUS_UNCLAIMED  
143 - task.CurrentStatus = &UnClaimedStatus{} 166 + if task.TaskType == TASK_TYPE_DESIGNATE {
  167 + task.TaskStatus = TASK_STATUS_UNDERWAY
  168 + task.CurrentStatus = &UnderwayStatus{}
  169 + } else {
  170 + task.TaskStatus = TASK_STATUS_UNCLAIMED
  171 + task.CurrentStatus = &UnClaimedStatus{}
  172 + }
144 return nil 173 return nil
145 } 174 }
146 175
@@ -152,7 +181,7 @@ func (status *UnReleasedStatus) Bib(task *Task, bidder *EmployeeInfo) error { @@ -152,7 +181,7 @@ func (status *UnReleasedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
152 return fmt.Errorf("待发布的任务不允许竞标") 181 return fmt.Errorf("待发布的任务不允许竞标")
153 } 182 }
154 183
155 -func (status *UnReleasedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error { 184 +func (status *UnReleasedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
156 return fmt.Errorf("待发布的任务不允许选择竞标任务的中标人") 185 return fmt.Errorf("待发布的任务不允许选择竞标任务的中标人")
157 } 186 }
158 187
@@ -164,10 +193,18 @@ func (status *UnReleasedStatus) Off(task *Task) error { @@ -164,10 +193,18 @@ func (status *UnReleasedStatus) Off(task *Task) error {
164 return fmt.Errorf("待发布的任务不允许关闭") 193 return fmt.Errorf("待发布的任务不允许关闭")
165 } 194 }
166 195
167 -func (status *UnReleasedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error { 196 +func (status *UnReleasedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
168 return fmt.Errorf("待发布的任务不允许验收") 197 return fmt.Errorf("待发布的任务不允许验收")
169 } 198 }
170 199
  200 +func (status *UnReleasedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
  201 + return fmt.Errorf("待发布的任务不允许确认任务领取人")
  202 +}
  203 +
  204 +func (status *UnReleasedStatus) RejectReceiver(task *Task) error {
  205 + return fmt.Errorf("待发布的任务不允许驳回任务领取人")
  206 +}
  207 +
171 type UnClaimedStatus struct{} 208 type UnClaimedStatus struct{}
172 209
173 func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error { 210 func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error {
@@ -188,8 +225,8 @@ func (status *UnClaimedStatus) Rob(task *Task, receiver *EmployeeInfo) error { @@ -188,8 +225,8 @@ func (status *UnClaimedStatus) Rob(task *Task, receiver *EmployeeInfo) error {
188 ReceiveTime: currentTime, 225 ReceiveTime: currentTime,
189 } 226 }
190 task.ReceiveTime = currentTime 227 task.ReceiveTime = currentTime
191 - task.TaskStatus = TASK_STATUS_UNDERWAY  
192 - task.CurrentStatus = &UnderwayStatus{} 228 + task.TaskStatus = TASK_STATUS_UNCONFIRMED
  229 + task.CurrentStatus = &UnConfirmedStatus{}
193 return nil 230 return nil
194 } 231 }
195 232
@@ -216,7 +253,7 @@ func (status *UnClaimedStatus) Bib(task *Task, bidder *EmployeeInfo) error { @@ -216,7 +253,7 @@ func (status *UnClaimedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
216 } 253 }
217 } 254 }
218 255
219 -func (status *UnClaimedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error { 256 +func (status *UnClaimedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
220 if task.TaskType != TASK_TYPE_BID { 257 if task.TaskType != TASK_TYPE_BID {
221 return fmt.Errorf("类型不符合的任务不允许选择竞中标人") 258 return fmt.Errorf("类型不符合的任务不允许选择竞中标人")
222 } 259 }
@@ -228,6 +265,7 @@ func (status *UnClaimedStatus) ChooseSuccessfulBidder(task *Task, successfulBidd @@ -228,6 +265,7 @@ func (status *UnClaimedStatus) ChooseSuccessfulBidder(task *Task, successfulBidd
228 task.BidInfo.WinBidTime = winBidTime 265 task.BidInfo.WinBidTime = winBidTime
229 task.ReceiveTime = winBidTime 266 task.ReceiveTime = winBidTime
230 task.TaskStatus = TASK_STATUS_UNDERWAY 267 task.TaskStatus = TASK_STATUS_UNDERWAY
  268 + task.PlannedCompletionTime = plannedCompletionTime
231 task.CurrentStatus = &UnderwayStatus{} 269 task.CurrentStatus = &UnderwayStatus{}
232 return nil 270 return nil
233 } 271 }
@@ -243,10 +281,18 @@ func (status *UnClaimedStatus) Off(task *Task) error { @@ -243,10 +281,18 @@ func (status *UnClaimedStatus) Off(task *Task) error {
243 return nil 281 return nil
244 } 282 }
245 283
246 -func (status *UnClaimedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error { 284 +func (status *UnClaimedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
247 return fmt.Errorf("待领取的任务不允许验收") 285 return fmt.Errorf("待领取的任务不允许验收")
248 } 286 }
249 287
  288 +func (status *UnClaimedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
  289 + return fmt.Errorf("待领取的任务不允许确认任务领取人")
  290 +}
  291 +
  292 +func (status *UnClaimedStatus) RejectReceiver(task *Task) error {
  293 + return fmt.Errorf("待领取的任务不允许驳回任务领取人")
  294 +}
  295 +
250 type UnderwayStatus struct{} 296 type UnderwayStatus struct{}
251 297
252 func (status *UnderwayStatus) Update(task *Task, data map[string]interface{}) error { 298 func (status *UnderwayStatus) Update(task *Task, data map[string]interface{}) error {
@@ -265,7 +311,7 @@ func (status *UnderwayStatus) Bib(task *Task, bidder *EmployeeInfo) error { @@ -265,7 +311,7 @@ func (status *UnderwayStatus) Bib(task *Task, bidder *EmployeeInfo) error {
265 return fmt.Errorf("进行中的任务不允许竞标") 311 return fmt.Errorf("进行中的任务不允许竞标")
266 } 312 }
267 313
268 -func (status *UnderwayStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error { 314 +func (status *UnderwayStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
269 return fmt.Errorf("进行中的任务不允许选择竞标任务的中标人") 315 return fmt.Errorf("进行中的任务不允许选择竞标任务的中标人")
270 } 316 }
271 317
@@ -282,10 +328,32 @@ func (status *UnderwayStatus) Off(task *Task) error { @@ -282,10 +328,32 @@ func (status *UnderwayStatus) Off(task *Task) error {
282 return nil 328 return nil
283 } 329 }
284 330
285 -func (status *UnderwayStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error { 331 +func (status *UnderwayStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
286 return fmt.Errorf("进行中的任务不允许验收") 332 return fmt.Errorf("进行中的任务不允许验收")
287 } 333 }
288 334
  335 +func (status *UnderwayStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
  336 + return fmt.Errorf("进行中的任务不允许确认任务领取人")
  337 +}
  338 +
  339 +func (status *UnderwayStatus) RejectReceiver(task *Task) error {
  340 + if task.TaskType == TASK_TYPE_DESIGNATE {
  341 + return fmt.Errorf("类型不符合的任务不允许驳回领取人")
  342 + }
  343 + if task.TaskType == TASK_TYPE_ROB {
  344 + task.RobInfo.Receiver = nil
  345 + task.RobInfo.ReceiveTime = time.Time{}
  346 + }
  347 + if task.TaskType == TASK_TYPE_BID {
  348 + task.BidInfo.SuccessfulBidder = nil
  349 + task.BidInfo.WinBidTime = time.Time{}
  350 + }
  351 + task.ReceiveTime = time.Time{}
  352 + task.TaskStatus = TASK_STATUS_UNCLAIMED
  353 + task.CurrentStatus = &UnClaimedStatus{}
  354 + return nil
  355 +}
  356 +
289 type UnAcceptanceStatus struct{} 357 type UnAcceptanceStatus struct{}
290 358
291 func (status *UnAcceptanceStatus) Update(task *Task, data map[string]interface{}) error { 359 func (status *UnAcceptanceStatus) Update(task *Task, data map[string]interface{}) error {
@@ -304,7 +372,7 @@ func (status *UnAcceptanceStatus) Bib(task *Task, bidder *EmployeeInfo) error { @@ -304,7 +372,7 @@ func (status *UnAcceptanceStatus) Bib(task *Task, bidder *EmployeeInfo) error {
304 return fmt.Errorf("待验收的任务不允许竞标") 372 return fmt.Errorf("待验收的任务不允许竞标")
305 } 373 }
306 374
307 -func (status *UnAcceptanceStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error { 375 +func (status *UnAcceptanceStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
308 return fmt.Errorf("待验收的任务不允许选择竞标任务的中标人") 376 return fmt.Errorf("待验收的任务不允许选择竞标任务的中标人")
309 } 377 }
310 378
@@ -318,7 +386,7 @@ func (status *UnAcceptanceStatus) Off(task *Task) error { @@ -318,7 +386,7 @@ func (status *UnAcceptanceStatus) Off(task *Task) error {
318 return nil 386 return nil
319 } 387 }
320 388
321 -func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error { 389 +func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
322 task.Participators = participators 390 task.Participators = participators
323 task.TaskPercentage = taskPercentage 391 task.TaskPercentage = taskPercentage
324 task.SolveReport = solveReport 392 task.SolveReport = solveReport
@@ -333,12 +401,21 @@ func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*Employ @@ -333,12 +401,21 @@ func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*Employ
333 } 401 }
334 } 402 }
335 } 403 }
  404 + task.ActualCompletionTime = actualCompletionTime
336 task.TaskStatus = TASK_STATUS_COMPLETED 405 task.TaskStatus = TASK_STATUS_COMPLETED
337 task.AcceptanceTime = time.Now() 406 task.AcceptanceTime = time.Now()
338 task.CurrentStatus = &CompletedStatus{} 407 task.CurrentStatus = &CompletedStatus{}
339 return nil 408 return nil
340 } 409 }
341 410
  411 +func (status *UnAcceptanceStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
  412 + return fmt.Errorf("待验收的任务不允许确认任务领取人")
  413 +}
  414 +
  415 +func (status *UnAcceptanceStatus) RejectReceiver(task *Task) error {
  416 + return fmt.Errorf("待验收的任务不允许驳回任务领取人")
  417 +}
  418 +
342 type CompletedStatus struct{} 419 type CompletedStatus struct{}
343 420
344 func (status *CompletedStatus) Update(task *Task, data map[string]interface{}) error { 421 func (status *CompletedStatus) Update(task *Task, data map[string]interface{}) error {
@@ -357,7 +434,7 @@ func (status *CompletedStatus) Bib(task *Task, bidder *EmployeeInfo) error { @@ -357,7 +434,7 @@ func (status *CompletedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
357 return fmt.Errorf("已完成的任务不允许竞标") 434 return fmt.Errorf("已完成的任务不允许竞标")
358 } 435 }
359 436
360 -func (status *CompletedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error { 437 +func (status *CompletedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
361 return fmt.Errorf("已完成的任务不允许选择竞标任务的中标人") 438 return fmt.Errorf("已完成的任务不允许选择竞标任务的中标人")
362 } 439 }
363 440
@@ -369,10 +446,18 @@ func (status *CompletedStatus) Off(task *Task) error { @@ -369,10 +446,18 @@ func (status *CompletedStatus) Off(task *Task) error {
369 return fmt.Errorf("已完成的任务不允许申请完成任务") 446 return fmt.Errorf("已完成的任务不允许申请完成任务")
370 } 447 }
371 448
372 -func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error { 449 +func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
373 return fmt.Errorf("已完成的任务不允许验收") 450 return fmt.Errorf("已完成的任务不允许验收")
374 } 451 }
375 452
  453 +func (status *CompletedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
  454 + return fmt.Errorf("已完成的任务不允许确认任务领取人")
  455 +}
  456 +
  457 +func (status *CompletedStatus) RejectReceiver(task *Task) error {
  458 + return fmt.Errorf("已完成的任务不允许驳回任务领取人")
  459 +}
  460 +
376 type ClosedStatus struct{} 461 type ClosedStatus struct{}
377 462
378 func (status *ClosedStatus) Update(task *Task, data map[string]interface{}) error { 463 func (status *ClosedStatus) Update(task *Task, data map[string]interface{}) error {
@@ -391,7 +476,7 @@ func (status *ClosedStatus) Bib(task *Task, bidder *EmployeeInfo) error { @@ -391,7 +476,7 @@ func (status *ClosedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
391 return fmt.Errorf("已关闭的任务不允许竞标") 476 return fmt.Errorf("已关闭的任务不允许竞标")
392 } 477 }
393 478
394 -func (status *ClosedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error { 479 +func (status *ClosedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
395 return fmt.Errorf("已关闭的任务不允许选择竞标任务的中标人") 480 return fmt.Errorf("已关闭的任务不允许选择竞标任务的中标人")
396 } 481 }
397 482
@@ -403,10 +488,73 @@ func (status *ClosedStatus) Off(task *Task) error { @@ -403,10 +488,73 @@ func (status *ClosedStatus) Off(task *Task) error {
403 return fmt.Errorf("已关闭的任务不允许关闭") 488 return fmt.Errorf("已关闭的任务不允许关闭")
404 } 489 }
405 490
406 -func (status *ClosedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error { 491 +func (status *ClosedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
407 return fmt.Errorf("已关闭的任务不允许验收") 492 return fmt.Errorf("已关闭的任务不允许验收")
408 } 493 }
409 494
  495 +func (status *ClosedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
  496 + return fmt.Errorf("已关闭的任务不允许确认任务领取人")
  497 +}
  498 +
  499 +func (status *ClosedStatus) RejectReceiver(task *Task) error {
  500 + return fmt.Errorf("已关闭的任务不允许驳回任务领取人")
  501 +}
  502 +
  503 +type UnConfirmedStatus struct{}
  504 +
  505 +func (status *UnConfirmedStatus) Update(task *Task, data map[string]interface{}) error {
  506 + return fmt.Errorf("待确认的任务不允许编辑")
  507 +}
  508 +
  509 +func (status *UnConfirmedStatus) Release(task *Task) error {
  510 + return fmt.Errorf("待确认的任务不允许重新发布")
  511 +}
  512 +
  513 +func (status *UnConfirmedStatus) Rob(task *Task, receiver *EmployeeInfo) error {
  514 + return fmt.Errorf("待确认的任务不允许抢单")
  515 +}
  516 +
  517 +func (status *UnConfirmedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
  518 + return fmt.Errorf("待确认的任务不允许竞标")
  519 +}
  520 +
  521 +func (status *UnConfirmedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
  522 + return fmt.Errorf("待确认的任务不允许选择竞标任务的中标人")
  523 +}
  524 +
  525 +func (status *UnConfirmedStatus) ApplyComplete(task *Task) error {
  526 + return fmt.Errorf("待确认的任务不允许申请完成任务")
  527 +}
  528 +
  529 +func (status *UnConfirmedStatus) Off(task *Task) error {
  530 + task.TaskStatus = TASK_STATUS_CLOSED
  531 + task.CurrentStatus = &ClosedStatus{}
  532 + return nil
  533 +}
  534 +
  535 +func (status *UnConfirmedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
  536 + return fmt.Errorf("待确认的任务不允许验收")
  537 +}
  538 +
  539 +func (status *UnConfirmedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
  540 + task.PlannedCompletionTime = plannedCompletionTime
  541 + task.TaskStatus = TASK_STATUS_UNDERWAY
  542 + task.CurrentStatus = &UnderwayStatus{}
  543 + return nil
  544 +}
  545 +
  546 +func (status *UnConfirmedStatus) RejectReceiver(task *Task) error {
  547 + if task.TaskType != TASK_TYPE_ROB {
  548 + return fmt.Errorf("类型不符合的任务不允许在待确认状态下驳回领取人")
  549 + }
  550 + task.RobInfo.Receiver = nil
  551 + task.RobInfo.ReceiveTime = time.Time{}
  552 + task.ReceiveTime = time.Time{}
  553 + task.TaskStatus = TASK_STATUS_UNCLAIMED
  554 + task.CurrentStatus = &UnClaimedStatus{}
  555 + return nil
  556 +}
  557 +
410 type TaskRepository interface { 558 type TaskRepository interface {
411 Save(task *Task) (*Task, error) 559 Save(task *Task) (*Task, error)
412 Remove(task *Task) (*Task, error) 560 Remove(task *Task) (*Task, error)
@@ -437,8 +585,8 @@ func (task *Task) Bib(bidder *EmployeeInfo) error { @@ -437,8 +585,8 @@ func (task *Task) Bib(bidder *EmployeeInfo) error {
437 return task.CurrentStatus.Bib(task, bidder) 585 return task.CurrentStatus.Bib(task, bidder)
438 } 586 }
439 587
440 -func (task *Task) ChooseSuccessfulBidder(successfulBidder *EmployeeInfo) error {  
441 - return task.CurrentStatus.ChooseSuccessfulBidder(task, successfulBidder) 588 +func (task *Task) ChooseSuccessfulBidder(successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
  589 + return task.CurrentStatus.ChooseSuccessfulBidder(task, successfulBidder, plannedCompletionTime)
442 } 590 }
443 591
444 func (task *Task) ApplyComplete() error { 592 func (task *Task) ApplyComplete() error {
@@ -449,6 +597,14 @@ func (task *Task) Off() error { @@ -449,6 +597,14 @@ func (task *Task) Off() error {
449 return task.CurrentStatus.Off(task) 597 return task.CurrentStatus.Off(task)
450 } 598 }
451 599
452 -func (task *Task) Acceptance(participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error {  
453 - return task.CurrentStatus.Acceptance(task, participators, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls) 600 +func (task *Task) Acceptance(participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
  601 + return task.CurrentStatus.Acceptance(task, participators, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls, actualCompletionTime)
  602 +}
  603 +
  604 +func (task *Task) ConfirmTask(plannedCompletionTime time.Time) error {
  605 + return task.CurrentStatus.ConfirmTask(task, plannedCompletionTime)
  606 +}
  607 +
  608 +func (task *Task) RejectReceiver() error {
  609 + return task.CurrentStatus.RejectReceiver(task)
454 } 610 }
@@ -23,21 +23,21 @@ func (dao *TaskDao) AddRobInfo(taskId int64, receiver *domain.EmployeeInfo) erro @@ -23,21 +23,21 @@ func (dao *TaskDao) AddRobInfo(taskId int64, receiver *domain.EmployeeInfo) erro
23 return err 23 return err
24 } 24 }
25 25
26 -func (dao *TaskDao) AddBidInfo(taskId int64, bidStartTime time.Time, bidEndTime time.Time) error { 26 +func (dao *TaskDao) AddBidInfo(taskId int64, bidStartTime time.Time, bidEndTime time.Time, isRemind bool) error {
27 tx := dao.transactionContext.PgTx 27 tx := dao.transactionContext.PgTx
28 _, err := tx.QueryOne( 28 _, err := tx.QueryOne(
29 pg.Scan(), 29 pg.Scan(),
30 - "INSERT INTO bid_infos (task_id, bid_start_time, bid_end_time) VALUES (?, ?, ?)",  
31 - taskId, bidStartTime, bidEndTime) 30 + "INSERT INTO bid_infos (task_id, bid_start_time, bid_end_time, is_remind) VALUES (?, ?, ?, ?)",
  31 + taskId, bidStartTime, bidEndTime, isRemind)
32 return err 32 return err
33 } 33 }
34 34
35 -func (dao *TaskDao) UpdateBidInfo(taskId int64, bidStartTime time.Time, bidEndTime time.Time) error { 35 +func (dao *TaskDao) UpdateBidInfo(taskId int64, bidStartTime time.Time, bidEndTime time.Time, isRemind bool) error {
36 tx := dao.transactionContext.PgTx 36 tx := dao.transactionContext.PgTx
37 _, err := tx.QueryOne( 37 _, err := tx.QueryOne(
38 pg.Scan(), 38 pg.Scan(),
39 - "UPDATE bid_infos SET bid_start_time=?, bid_end_time=? WHERE task_id=?",  
40 - bidStartTime, bidEndTime, taskId) 39 + "UPDATE bid_infos SET bid_start_time=?, bid_end_time=?, is_remind=? WHERE task_id=?",
  40 + bidStartTime, bidEndTime, isRemind, taskId)
41 return err 41 return err
42 } 42 }
43 43
@@ -16,7 +16,7 @@ type AcceptanceTaskService struct { @@ -16,7 +16,7 @@ type AcceptanceTaskService struct {
16 transactionContext *pgTransaction.TransactionContext 16 transactionContext *pgTransaction.TransactionContext
17 } 17 }
18 18
19 -func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64, participators []int64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string) (*domain.Task, error) { 19 +func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64, participators []int64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) (*domain.Task, error) {
20 var employeeRepository domain.EmployeeRepository 20 var employeeRepository domain.EmployeeRepository
21 var taskRepository domain.TaskRepository 21 var taskRepository domain.TaskRepository
22 var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository 22 var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
@@ -72,7 +72,7 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 @@ -72,7 +72,7 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
72 participatorInfos = append(participatorInfos, participator.EmployeeInfo) 72 participatorInfos = append(participatorInfos, participator.EmployeeInfo)
73 } 73 }
74 } 74 }
75 - if err := task.Acceptance(participatorInfos, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls); err != nil { 75 + if err := task.Acceptance(participatorInfos, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls, actualCompletionTime); err != nil {
76 return nil, err 76 return nil, err
77 } 77 }
78 for _, taskPercentageItem := range taskPercentage { 78 for _, taskPercentageItem := range taskPercentage {
@@ -16,7 +16,7 @@ type ChooseSuccessfulBidderService struct { @@ -16,7 +16,7 @@ type ChooseSuccessfulBidderService struct {
16 transactionContext *pgTransaction.TransactionContext 16 transactionContext *pgTransaction.TransactionContext
17 } 17 }
18 18
19 -func (service *ChooseSuccessfulBidderService) Choose(taskId int64, successfulBidderUid int64, operatorUid int64) (*domain.Task, error) { 19 +func (service *ChooseSuccessfulBidderService) Choose(taskId int64, successfulBidderUid int64, operatorUid int64, plannedCompletionTime time.Time) (*domain.Task, error) {
20 var employeeRepository domain.EmployeeRepository 20 var employeeRepository domain.EmployeeRepository
21 var taskRepository domain.TaskRepository 21 var taskRepository domain.TaskRepository
22 var taskDao *dao.TaskDao 22 var taskDao *dao.TaskDao
@@ -65,7 +65,7 @@ func (service *ChooseSuccessfulBidderService) Choose(taskId int64, successfulBid @@ -65,7 +65,7 @@ func (service *ChooseSuccessfulBidderService) Choose(taskId int64, successfulBid
65 if successfulBidder == nil { 65 if successfulBidder == nil {
66 return nil, fmt.Errorf("无效的中标人") 66 return nil, fmt.Errorf("无效的中标人")
67 } 67 }
68 - if err := task.ChooseSuccessfulBidder(successfulBidder.EmployeeInfo); err != nil { 68 + if err := task.ChooseSuccessfulBidder(successfulBidder.EmployeeInfo, plannedCompletionTime); err != nil {
69 return nil, err 69 return nil, err
70 } 70 }
71 if err := taskDao.SetSuccessfulBidder(taskId, task.BidInfo.SuccessfulBidder, task.BidInfo.WinBidTime); err != nil { 71 if err := taskDao.SetSuccessfulBidder(taskId, task.BidInfo.SuccessfulBidder, task.BidInfo.WinBidTime); err != nil {
  1 +package domain_service
  2 +
  3 +import (
  4 + "fmt"
  5 + coreDomain "github.com/linmadan/egglib-go/core/domain"
  6 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  7 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"
  9 + "time"
  10 +)
  11 +
  12 +type ConfirmRobTaskService struct {
  13 + coreDomain.BaseEventPublisher
  14 + transactionContext *pgTransaction.TransactionContext
  15 +}
  16 +
  17 +func (service *ConfirmRobTaskService) Confirm(taskId int64, operatorUid int64, plannedCompletionTime time.Time) (*domain.Task, error) {
  18 + var employeeRepository domain.EmployeeRepository
  19 + var taskRepository domain.TaskRepository
  20 + if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil {
  21 + return nil, err
  22 + } else {
  23 + employeeRepository = repository
  24 + }
  25 + if repository, err := repository.NewTaskRepository(service.transactionContext); err != nil {
  26 + return nil, err
  27 + } else {
  28 + taskRepository = repository
  29 + }
  30 + operator, err := employeeRepository.FindOne(map[string]interface{}{
  31 + "uid": operatorUid,
  32 + })
  33 + if err != nil {
  34 + return nil, err
  35 + }
  36 + if operator == nil {
  37 + return nil, fmt.Errorf("无效的操作者")
  38 + }
  39 + task, err := taskRepository.FindOne(map[string]interface{}{
  40 + "taskId": taskId,
  41 + })
  42 + if err != nil {
  43 + return nil, err
  44 + }
  45 + if task == nil {
  46 + return nil, fmt.Errorf("无效的任务")
  47 + }
  48 + if operator.EmployeeInfo.Uid != task.Sponsor.Uid {
  49 + return nil, fmt.Errorf("无效的任务发布者")
  50 + }
  51 + if err := task.ConfirmTask(plannedCompletionTime); err != nil {
  52 + return nil, err
  53 + }
  54 + if task, err := taskRepository.Save(task); err != nil {
  55 + return nil, err
  56 + } else {
  57 + return task, nil
  58 + }
  59 +}
  60 +
  61 +func NewConfirmRobTaskService(transactionContext *pgTransaction.TransactionContext) (*ConfirmRobTaskService, error) {
  62 + if transactionContext == nil {
  63 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  64 + } else {
  65 + return &ConfirmRobTaskService{
  66 + transactionContext: transactionContext,
  67 + }, nil
  68 + }
  69 +}
  1 +package domain_service
  2 +
  3 +import (
  4 + "fmt"
  5 + coreDomain "github.com/linmadan/egglib-go/core/domain"
  6 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  7 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"
  9 + "time"
  10 +)
  11 +
  12 +type RejectTaskReceiverService struct {
  13 + coreDomain.BaseEventPublisher
  14 + transactionContext *pgTransaction.TransactionContext
  15 +}
  16 +
  17 +func (service *RejectTaskReceiverService) Reject(taskId int64, operatorUid int64, rejectReason string) (*domain.Task, error) {
  18 + var employeeRepository domain.EmployeeRepository
  19 + var taskRepository domain.TaskRepository
  20 + var rejectTaskRecordRepository domain.RejectTaskRecordRepository
  21 + if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil {
  22 + return nil, err
  23 + } else {
  24 + employeeRepository = repository
  25 + }
  26 + if repository, err := repository.NewTaskRepository(service.transactionContext); err != nil {
  27 + return nil, err
  28 + } else {
  29 + taskRepository = repository
  30 + }
  31 + if repository, err := repository.NewRejectTaskRecordRepository(service.transactionContext); err != nil {
  32 + return nil, err
  33 + } else {
  34 + rejectTaskRecordRepository = repository
  35 + }
  36 + operator, err := employeeRepository.FindOne(map[string]interface{}{
  37 + "uid": operatorUid,
  38 + })
  39 + if err != nil {
  40 + return nil, err
  41 + }
  42 + if operator == nil {
  43 + return nil, fmt.Errorf("无效的操作者")
  44 + }
  45 + task, err := taskRepository.FindOne(map[string]interface{}{
  46 + "taskId": taskId,
  47 + })
  48 + if err != nil {
  49 + return nil, err
  50 + }
  51 + if task == nil {
  52 + return nil, fmt.Errorf("无效的任务")
  53 + }
  54 + if operator.EmployeeInfo.Uid != task.Sponsor.Uid {
  55 + return nil, fmt.Errorf("无效的任务发布者")
  56 + }
  57 + if err := task.RejectReceiver(); err != nil {
  58 + return nil, err
  59 + }
  60 + rejectTaskRecord := &domain.RejectTaskRecord{
  61 + Task: task,
  62 + Operator: operator.EmployeeInfo,
  63 + RejectReason: rejectReason,
  64 + CreateTime: time.Now(),
  65 + }
  66 + if _, err := rejectTaskRecordRepository.Save(rejectTaskRecord); err != nil {
  67 + return nil, err
  68 + }
  69 + if task, err := taskRepository.Save(task); err != nil {
  70 + return nil, err
  71 + } else {
  72 + return task, nil
  73 + }
  74 +}
  75 +
  76 +func NewRejectTaskReceiverService(transactionContext *pgTransaction.TransactionContext) (*RejectTaskReceiverService, error) {
  77 + if transactionContext == nil {
  78 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  79 + } else {
  80 + return &RejectTaskReceiverService{
  81 + transactionContext: transactionContext,
  82 + }, nil
  83 + }
  84 +}
@@ -87,7 +87,7 @@ func (service *ReleaseTaskService) Release(taskId int64, operatorUid int64) (*do @@ -87,7 +87,7 @@ func (service *ReleaseTaskService) Release(taskId int64, operatorUid int64) (*do
87 taskReleasedEvent.Sponsor = task.Sponsor 87 taskReleasedEvent.Sponsor = task.Sponsor
88 taskReleasedEvent.TaskStatus = task.TaskStatus 88 taskReleasedEvent.TaskStatus = task.TaskStatus
89 taskReleasedEvent.ReferenceResource = task.ReferenceResource 89 taskReleasedEvent.ReferenceResource = task.ReferenceResource
90 - taskReleasedEvent.CustomerValue = task.CustomerValue 90 + taskReleasedEvent.CustomerValues = task.CustomerValues
91 taskReleasedEvent.TaskNature = task.TaskNature 91 taskReleasedEvent.TaskNature = task.TaskNature
92 taskReleasedEvent.SuMoney = task.SuMoney 92 taskReleasedEvent.SuMoney = task.SuMoney
93 taskReleasedEvent.AcceptanceStandard = task.AcceptanceStandard 93 taskReleasedEvent.AcceptanceStandard = task.AcceptanceStandard
@@ -33,6 +33,7 @@ func init() { @@ -33,6 +33,7 @@ func init() {
33 (*models.CustomerValue)(nil), 33 (*models.CustomerValue)(nil),
34 (*models.TaskNature)(nil), 34 (*models.TaskNature)(nil),
35 (*models.ProjectBelong)(nil), 35 (*models.ProjectBelong)(nil),
  36 + (*models.RejectTaskRecord)(nil),
36 } { 37 } {
37 err := DB.CreateTable(model, &orm.CreateTableOptions{ 38 err := DB.CreateTable(model, &orm.CreateTableOptions{
38 Temp: false, 39 Temp: false,
@@ -16,6 +16,8 @@ type BidInfo struct { @@ -16,6 +16,8 @@ type BidInfo struct {
16 BidStartTime time.Time 16 BidStartTime time.Time
17 // 竞标结束时间 17 // 竞标结束时间
18 BidEndTime time.Time 18 BidEndTime time.Time
  19 + //是否截止时间前一天提醒
  20 + IsRemind bool
19 // 中标时间 21 // 中标时间
20 WinBidTime time.Time 22 WinBidTime time.Time
21 TaskId int64 `pg:",unique"` 23 TaskId int64 `pg:",unique"`
  1 +package models
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  5 + "time"
  6 +)
  7 +
  8 +type RejectTaskRecord struct {
  9 + TableName string `pg:"reject_task_records,alias:reject_task_record"`
  10 + // 驳回任务记录ID
  11 + Id int64 `pg:",pk"`
  12 + // 任务
  13 + TaskId int64
  14 + // 操作人
  15 + Operator *domain.EmployeeInfo
  16 + // 驳回理由
  17 + RejectReason string
  18 + // 创建时间
  19 + CreateTime time.Time
  20 +}
@@ -21,10 +21,12 @@ type Task struct { @@ -21,10 +21,12 @@ type Task struct {
21 TaskStatus int 21 TaskStatus int
22 // 引用资源 22 // 引用资源
23 ReferenceResource *domain.ReferenceResource 23 ReferenceResource *domain.ReferenceResource
  24 + // 项目归属
  25 + ProjectBelong int
24 // 客户价值列表 26 // 客户价值列表
25 - CustomerValue []string `pg:",array"` 27 + CustomerValues []int `pg:",array"`
26 // 任务性质 28 // 任务性质
27 - TaskNature string 29 + TaskNature int
28 // 奖励素币 30 // 奖励素币
29 SuMoney float64 31 SuMoney float64
30 // 验收标准 32 // 验收标准
@@ -43,6 +45,12 @@ type Task struct { @@ -43,6 +45,12 @@ type Task struct {
43 SolveReport string 45 SolveReport string
44 // 解决图片URL列表 46 // 解决图片URL列表
45 SolvePictureUrls []string `pg:",array"` 47 SolvePictureUrls []string `pg:",array"`
  48 + // 指派人员
  49 + AssignedPerson *domain.EmployeeInfo
  50 + // 计划完成时间
  51 + PlannedCompletionTime time.Time
  52 + // 实际完成时间
  53 + ActualCompletionTime time.Time
46 // 抢单任务信息 54 // 抢单任务信息
47 RobInfo *RobInfo 55 RobInfo *RobInfo
48 // 竞标任务信息 56 // 竞标任务信息
@@ -75,6 +75,9 @@ func (repository *CustomerValueRepository) Find(queryOptions map[string]interfac @@ -75,6 +75,9 @@ func (repository *CustomerValueRepository) Find(queryOptions map[string]interfac
75 if customerValueNameMatch, ok := queryOptions["customerValueNameMatch"]; ok && (customerValueNameMatch != "") { 75 if customerValueNameMatch, ok := queryOptions["customerValueNameMatch"]; ok && (customerValueNameMatch != "") {
76 query = query.Where(`customer_value.customer_value_name LIKE ?`, fmt.Sprintf("%%%s%%", customerValueNameMatch.(string))) 76 query = query.Where(`customer_value.customer_value_name LIKE ?`, fmt.Sprintf("%%%s%%", customerValueNameMatch.(string)))
77 } 77 }
  78 + if customerValueIds, ok := queryOptions["customerValueIds"]; ok {
  79 + query = query.Where(`customer_value.id IN (?)`, pg.In(customerValueIds.([]int)))
  80 + }
78 if offset, ok := queryOptions["offset"]; ok { 81 if offset, ok := queryOptions["offset"]; ok {
79 offset := offset.(int) 82 offset := offset.(int)
80 if offset > -1 { 83 if offset > -1 {
  1 +package repository
  2 +
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +
  7 + "github.com/go-pg/pg"
  8 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  9 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
  11 +)
  12 +
  13 +type RejectTaskRecordRepository struct {
  14 + transactionContext *pgTransaction.TransactionContext
  15 +}
  16 +
  17 +func (repository *RejectTaskRecordRepository) Save(rejectTaskRecord *domain.RejectTaskRecord) (*domain.RejectTaskRecord, error) {
  18 + tx := repository.transactionContext.PgTx
  19 + if rejectTaskRecord.Identify() == nil {
  20 + if _, err := tx.QueryOne(
  21 + pg.Scan(&rejectTaskRecord.RejectTaskRecordId, &rejectTaskRecord.Task.TaskId, &rejectTaskRecord.Operator, &rejectTaskRecord.RejectReason, &rejectTaskRecord.CreateTime),
  22 + "INSERT INTO reject_task_records (task_id, operator, reject_reason, create_time) VALUES (?, ?, ?, ?) RETURNING id, task_id, operator, reject_reason, create_time",
  23 + rejectTaskRecord.Task.TaskId, rejectTaskRecord.Operator, rejectTaskRecord.RejectReason, rejectTaskRecord.CreateTime); err != nil {
  24 + return rejectTaskRecord, err
  25 + }
  26 + } else {
  27 + if _, err := tx.QueryOne(
  28 + pg.Scan(&rejectTaskRecord.RejectTaskRecordId, &rejectTaskRecord.Task, &rejectTaskRecord.Operator, &rejectTaskRecord.RejectReason, &rejectTaskRecord.CreateTime),
  29 + "UPDATE reject_task_records SET task_id=?, operator=?, reject_reason=?, create_time=? WHERE id=? RETURNING id, task_id, operator, reject_reason, create_time",
  30 + rejectTaskRecord.Task.TaskId, rejectTaskRecord.Operator, rejectTaskRecord.RejectReason, rejectTaskRecord.CreateTime, rejectTaskRecord.Identify()); err != nil {
  31 + return rejectTaskRecord, err
  32 + }
  33 + }
  34 + return rejectTaskRecord, nil
  35 +}
  36 +func (repository *RejectTaskRecordRepository) Remove(rejectTaskRecord *domain.RejectTaskRecord) (*domain.RejectTaskRecord, error) {
  37 + tx := repository.transactionContext.PgTx
  38 + rejectTaskRecordModel := new(models.RejectTaskRecord)
  39 + rejectTaskRecordModel.Id = rejectTaskRecord.Identify().(int64)
  40 + if _, err := tx.Model(rejectTaskRecordModel).WherePK().Delete(); err != nil {
  41 + return rejectTaskRecord, err
  42 + }
  43 + return rejectTaskRecord, nil
  44 +}
  45 +func (repository *RejectTaskRecordRepository) FindOne(queryOptions map[string]interface{}) (*domain.RejectTaskRecord, error) {
  46 + tx := repository.transactionContext.PgTx
  47 + rejectTaskRecordModel := new(models.RejectTaskRecord)
  48 + query := tx.Model(rejectTaskRecordModel)
  49 + if rejectTaskRecordId, ok := queryOptions["rejectTaskRecordId"]; ok {
  50 + query = query.Where("reject_task_record.id = ?", rejectTaskRecordId)
  51 + }
  52 + if err := query.First(); err != nil {
  53 + if err.Error() == "pg: no rows in result set" {
  54 + return nil, fmt.Errorf("没有此驳回任务记录")
  55 + } else {
  56 + return nil, err
  57 + }
  58 + }
  59 + if rejectTaskRecordModel.Id == 0 {
  60 + return nil, nil
  61 + } else {
  62 + return repository.transformPgModelToDomainModel(rejectTaskRecordModel)
  63 + }
  64 +}
  65 +func (repository *RejectTaskRecordRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.RejectTaskRecord, error) {
  66 + tx := repository.transactionContext.PgTx
  67 + var rejectTaskRecordModels []*models.RejectTaskRecord
  68 + rejectTaskRecords := make([]*domain.RejectTaskRecord, 0)
  69 + query := tx.Model(&rejectTaskRecordModels)
  70 + if taskIds, ok := queryOptions["taskIds"]; ok {
  71 + if len(taskIds.([]int64)) > 0 {
  72 + query = query.Where(`reject_task_record.task_id IN (?)`, pg.In(taskIds.([]int64)))
  73 + } else {
  74 + return int64(0), rejectTaskRecords, nil
  75 + }
  76 + }
  77 + if rejectStartTime, ok := queryOptions["rejectStartTime"]; ok && !rejectStartTime.(time.Time).IsZero() {
  78 + query = query.Where(`reject_task_record.create_time > ?`, rejectStartTime)
  79 + }
  80 + if rejectEndTime, ok := queryOptions["rejectEndTime"]; ok && !rejectEndTime.(time.Time).IsZero() {
  81 + query = query.Where(`reject_task_record.create_time < ?`, rejectEndTime)
  82 + }
  83 + if offset, ok := queryOptions["offset"]; ok {
  84 + offset := offset.(int)
  85 + if offset > -1 {
  86 + query = query.Offset(offset)
  87 + }
  88 + } else {
  89 + query = query.Offset(0)
  90 + }
  91 + if limit, ok := queryOptions["limit"]; ok {
  92 + limit := limit.(int)
  93 + if limit > -1 {
  94 + query = query.Limit(limit)
  95 + }
  96 + } else {
  97 + query = query.Limit(20)
  98 + }
  99 + if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
  100 + return 0, rejectTaskRecords, err
  101 + } else {
  102 + for _, rejectTaskRecordModel := range rejectTaskRecordModels {
  103 + if rejectTaskRecord, err := repository.transformPgModelToDomainModel(rejectTaskRecordModel); err != nil {
  104 + return 0, rejectTaskRecords, err
  105 + } else {
  106 + rejectTaskRecords = append(rejectTaskRecords, rejectTaskRecord)
  107 + }
  108 + }
  109 + return int64(count), rejectTaskRecords, nil
  110 + }
  111 +}
  112 +func (repository *RejectTaskRecordRepository) transformPgModelToDomainModel(rejectTaskRecordModel *models.RejectTaskRecord) (*domain.RejectTaskRecord, error) {
  113 + return &domain.RejectTaskRecord{
  114 + RejectTaskRecordId: rejectTaskRecordModel.Id,
  115 + Task: &domain.Task{
  116 + TaskId: rejectTaskRecordModel.TaskId,
  117 + },
  118 + Operator: rejectTaskRecordModel.Operator,
  119 + RejectReason: rejectTaskRecordModel.RejectReason,
  120 + CreateTime: rejectTaskRecordModel.CreateTime,
  121 + }, nil
  122 +}
  123 +func NewRejectTaskRecordRepository(transactionContext *pgTransaction.TransactionContext) (*RejectTaskRecordRepository, error) {
  124 + if transactionContext == nil {
  125 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  126 + } else {
  127 + return &RejectTaskRecordRepository{
  128 + transactionContext: transactionContext,
  129 + }, nil
  130 + }
  131 +}
@@ -31,9 +31,9 @@ func (repository *TaskRepository) Save(task *domain.Task) (*domain.Task, error) @@ -31,9 +31,9 @@ func (repository *TaskRepository) Save(task *domain.Task) (*domain.Task, error)
31 return task, err 31 return task, err
32 } 32 }
33 if _, err := tx.QueryOne( 33 if _, err := tx.QueryOne(
34 - pg.Scan(&task.TaskId, &task.CompanyId, &task.TaskName, &task.TaskType, &task.Sponsor, &task.TaskStatus, &task.ReferenceResource, pg.Array(&task.CustomerValue), &task.TaskNature, &task.SuMoney, &task.AcceptanceStandard, &task.TaskDescription, pg.Array(&task.TaskPictureUrls), &task.IsRewardTake, &task.CreateTime, &task.ReleaseTime, &task.Participators, &task.TaskPercentage, &task.SolveReport, pg.Array(&task.SolvePictureUrls)),  
35 - "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, create_time, release_time, participators, task_percentage, solve_report, solve_picture_urls) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING 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, create_time, release_time, participators, task_percentage, solve_report, solve_picture_urls",  
36 - takeId, task.CompanyId, task.TaskName, task.TaskType, task.Sponsor, task.TaskStatus, task.ReferenceResource, pg.Array(task.CustomerValue), task.TaskNature, task.SuMoney, task.AcceptanceStandard, task.TaskDescription, pg.Array(task.TaskPictureUrls), task.IsRewardTake, task.CreateTime, task.ReleaseTime, task.Participators, task.TaskPercentage, task.SolveReport, pg.Array(task.SolvePictureUrls)); err != nil { 34 + pg.Scan(&task.TaskId, &task.CompanyId, &task.TaskName, &task.TaskType, &task.Sponsor, &task.TaskStatus, &task.ReferenceResource, &task.ProjectBelong, pg.Array(&task.CustomerValues), &task.TaskNature, &task.SuMoney, &task.AcceptanceStandard, &task.TaskDescription, pg.Array(&task.TaskPictureUrls), &task.IsRewardTake, &task.CreateTime, &task.ReleaseTime, &task.Participators, &task.TaskPercentage, &task.SolveReport, pg.Array(&task.SolvePictureUrls), &task.AssignedPerson, &task.PlannedCompletionTime, &task.ActualCompletionTime),
  35 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, create_time, release_time, participators, task_percentage, solve_report, solve_picture_urls, assigned_person, planned_completion_time, actual_completion_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, create_time, release_time, participators, task_percentage, solve_report, solve_picture_urls, assigned_person, planned_completion_time, actual_completion_time",
  36 + takeId, task.CompanyId, task.TaskName, task.TaskType, task.Sponsor, task.TaskStatus, task.ReferenceResource, task.ProjectBelong, pg.Array(task.CustomerValues), task.TaskNature, task.SuMoney, task.AcceptanceStandard, task.TaskDescription, pg.Array(task.TaskPictureUrls), task.IsRewardTake, task.CreateTime, task.ReleaseTime, task.Participators, task.TaskPercentage, task.SolveReport, pg.Array(task.SolvePictureUrls), task.AssignedPerson, task.PlannedCompletionTime, task.ActualCompletionTime); err != nil {
37 return task, err 37 return task, err
38 } 38 }
39 } else { 39 } else {
@@ -45,9 +45,9 @@ func (repository *TaskRepository) Save(task *domain.Task) (*domain.Task, error) @@ -45,9 +45,9 @@ func (repository *TaskRepository) Save(task *domain.Task) (*domain.Task, error)
45 taskReceiverUid = task.BidInfo.SuccessfulBidder.Uid 45 taskReceiverUid = task.BidInfo.SuccessfulBidder.Uid
46 } 46 }
47 if _, err := tx.QueryOne( 47 if _, err := tx.QueryOne(
48 - pg.Scan(&task.TaskId, &task.CompanyId, &task.TaskName, &task.TaskType, &task.Sponsor, &task.TaskStatus, &task.ReferenceResource, pg.Array(&task.CustomerValue), &task.TaskNature, &task.SuMoney, &task.AcceptanceStandard, &task.TaskDescription, pg.Array(&task.TaskPictureUrls), &task.IsRewardTake, &task.CreateTime, &task.ReleaseTime, &task.Participators, &task.TaskPercentage, &task.SolveReport, pg.Array(&task.SolvePictureUrls), &task.ReceiveTime, &task.CompleteTime, &task.AcceptanceTime),  
49 - "UPDATE tasks SET 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=?, receiver_uid=?, create_time=?, release_time=?, participators=?, task_percentage=?, solve_report=?, solve_picture_urls=?, receive_time=?, complete_time=?, acceptance_time=? WHERE id=? RETURNING 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, create_time, release_time, participators, task_percentage, solve_report, solve_picture_urls, receive_time, complete_time, acceptance_time",  
50 - task.CompanyId, task.TaskName, task.TaskType, task.Sponsor, task.TaskStatus, task.ReferenceResource, pg.Array(task.CustomerValue), task.TaskNature, task.SuMoney, task.AcceptanceStandard, task.TaskDescription, pg.Array(task.TaskPictureUrls), task.IsRewardTake, taskReceiverUid, task.CreateTime, task.ReleaseTime, task.Participators, task.TaskPercentage, task.SolveReport, pg.Array(task.SolvePictureUrls), task.ReceiveTime, task.CompleteTime, task.AcceptanceTime, task.Identify()); err != nil { 48 + pg.Scan(&task.TaskId, &task.CompanyId, &task.TaskName, &task.TaskType, &task.Sponsor, &task.TaskStatus, &task.ReferenceResource, &task.ProjectBelong, pg.Array(&task.CustomerValues), &task.TaskNature, &task.SuMoney, &task.AcceptanceStandard, &task.TaskDescription, pg.Array(&task.TaskPictureUrls), &task.IsRewardTake, &task.CreateTime, &task.ReleaseTime, &task.Participators, &task.TaskPercentage, &task.SolveReport, pg.Array(&task.SolvePictureUrls), &task.AssignedPerson, &task.PlannedCompletionTime, &task.ActualCompletionTime, &task.ReceiveTime, &task.CompleteTime, &task.AcceptanceTime),
  49 + "UPDATE tasks SET company_id=?, task_name=?, task_type=?, sponsor=?, task_status=?, reference_resource=?, project_belong=?, customer_values=?, task_nature=?, su_money=?, acceptance_standard=?, task_description=?, task_picture_urls=?, is_reward_take=?, receiver_uid=?, create_time=?, release_time=?, participators=?, task_percentage=?, solve_report=?, solve_picture_urls=?, assigned_person=?, planned_completion_time=?, actual_completion_time=?, receive_time=?, complete_time=?, acceptance_time=? WHERE id=? RETURNING id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, create_time, release_time, participators, task_percentage, solve_report, solve_picture_urls, assigned_person, planned_completion_time, actual_completion_time, receive_time, complete_time, acceptance_time",
  50 + task.CompanyId, task.TaskName, task.TaskType, task.Sponsor, task.TaskStatus, task.ReferenceResource, task.ProjectBelong, pg.Array(task.CustomerValues), task.TaskNature, task.SuMoney, task.AcceptanceStandard, task.TaskDescription, pg.Array(task.TaskPictureUrls), task.IsRewardTake, taskReceiverUid, task.CreateTime, task.ReleaseTime, task.Participators, task.TaskPercentage, task.SolveReport, pg.Array(task.SolvePictureUrls), task.AssignedPerson, task.PlannedCompletionTime, task.ActualCompletionTime, task.ReceiveTime, task.CompleteTime, task.AcceptanceTime, task.Identify()); err != nil {
51 return task, err 51 return task, err
52 } 52 }
53 } 53 }
@@ -114,25 +114,33 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int @@ -114,25 +114,33 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int
114 if taskType, ok := queryOptions["taskType"]; ok && (taskType != 0) { 114 if taskType, ok := queryOptions["taskType"]; ok && (taskType != 0) {
115 query = query.Where(`task.task_type = ?`, taskType) 115 query = query.Where(`task.task_type = ?`, taskType)
116 } 116 }
117 - if taskNature, ok := queryOptions["taskNature"]; ok && (taskNature != "") {  
118 - query = query.Where(`task.task_nature = ?`, taskNature) 117 + if projectBelongs, ok := queryOptions["projectBelongs"]; ok && len(projectBelongs.([]int)) != 0 {
  118 + query = query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
  119 + for _, value := range projectBelongs.([]int) {
  120 + q = q.WhereOr("task.project_belongs @> ?", pg.Array([]int{value}))
  121 + }
  122 + return q, nil
  123 + })
119 } 124 }
120 - if customerValue, ok := queryOptions["customerValue"]; ok && len(customerValue.([]string)) != 0 { 125 + if taskNatures, ok := queryOptions["taskNatures"]; ok && len(taskNatures.([]int)) != 0 {
121 query = query.WhereGroup(func(q *orm.Query) (*orm.Query, error) { 126 query = query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
122 - for _, value := range customerValue.([]string) {  
123 - q = q.WhereOr("task.customer_value @> ?", pg.Array([]string{value})) 127 + for _, value := range taskNatures.([]int) {
  128 + q = q.WhereOr("task.task_natures @> ?", pg.Array([]int{value}))
124 } 129 }
125 return q, nil 130 return q, nil
126 }) 131 })
127 } 132 }
128 - if taskContentMatch, ok := queryOptions["taskContentMatch"]; ok && (taskContentMatch != "") { 133 + if customerValues, ok := queryOptions["customerValues"]; ok && len(customerValues.([]int)) != 0 {
129 query = query.WhereGroup(func(q *orm.Query) (*orm.Query, error) { 134 query = query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
130 - q = q.WhereOr("task.task_name LIKE ?", fmt.Sprintf("%%%s%%", taskContentMatch.(string))).  
131 - WhereOr("task.task_nature = ?", taskContentMatch.(string)).  
132 - WhereOr("task.customer_value @> ?", pg.Array([]string{taskContentMatch.(string)})) 135 + for _, value := range customerValues.([]int) {
  136 + q = q.WhereOr("task.customer_values @> ?", pg.Array([]int{value}))
  137 + }
133 return q, nil 138 return q, nil
134 }) 139 })
135 } 140 }
  141 + if taskContentMatch, ok := queryOptions["taskContentMatch"]; ok && (taskContentMatch != "") {
  142 + query = query.Where("task.task_name LIKE ?", fmt.Sprintf("%%%s%%", taskContentMatch.(string)))
  143 + }
136 if isRewardTake, ok := queryOptions["isRewardTake"]; ok && (isRewardTake != false) { 144 if isRewardTake, ok := queryOptions["isRewardTake"]; ok && (isRewardTake != false) {
137 query = query.Where(`task.is_reward_take = ?`, isRewardTake) 145 query = query.Where(`task.is_reward_take = ?`, isRewardTake)
138 } 146 }
@@ -154,6 +162,9 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int @@ -154,6 +162,9 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int
154 if participator, ok := queryOptions["participator"]; ok && (participator != int64(0)) { 162 if participator, ok := queryOptions["participator"]; ok && (participator != int64(0)) {
155 query = query.Where(`task.participators @> '[{"uid":?}]'`, participator) 163 query = query.Where(`task.participators @> '[{"uid":?}]'`, participator)
156 } 164 }
  165 + if assignedPerson, ok := queryOptions["assignedPerson"]; ok && (assignedPerson != int64(0)) {
  166 + query = query.Where(`task.assignedPerson @> '{"uid":?}'`, assignedPerson)
  167 + }
157 if taskIds, ok := queryOptions["taskIds"]; ok { 168 if taskIds, ok := queryOptions["taskIds"]; ok {
158 query = query.Where(`task.id IN (?)`, pg.In(taskIds.([]int64))) 169 query = query.Where(`task.id IN (?)`, pg.In(taskIds.([]int64)))
159 } 170 }
@@ -255,6 +266,7 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model @@ -255,6 +266,7 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model
255 BidStartTime: taskModel.BidInfo.BidStartTime, 266 BidStartTime: taskModel.BidInfo.BidStartTime,
256 BidEndTime: taskModel.BidInfo.BidEndTime, 267 BidEndTime: taskModel.BidInfo.BidEndTime,
257 SuccessfulBidder: taskModel.BidInfo.SuccessfulBidder, 268 SuccessfulBidder: taskModel.BidInfo.SuccessfulBidder,
  269 + IsRemind: taskModel.BidInfo.IsRemind,
258 WinBidTime: taskModel.BidInfo.WinBidTime, 270 WinBidTime: taskModel.BidInfo.WinBidTime,
259 } 271 }
260 } 272 }
@@ -278,34 +290,41 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model @@ -278,34 +290,41 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model
278 case domain.TASK_STATUS_CLOSED: 290 case domain.TASK_STATUS_CLOSED:
279 currentStatus = &domain.ClosedStatus{} 291 currentStatus = &domain.ClosedStatus{}
280 break 292 break
  293 + case domain.TASK_STATUS_UNCONFIRMED:
  294 + currentStatus = &domain.UnConfirmedStatus{}
  295 + break
281 } 296 }
282 return &domain.Task{ 297 return &domain.Task{
283 - TaskId: taskModel.Id,  
284 - CompanyId: taskModel.CompanyId,  
285 - TaskName: taskModel.TaskName,  
286 - TaskType: taskModel.TaskType,  
287 - Sponsor: taskModel.Sponsor,  
288 - TaskStatus: taskModel.TaskStatus,  
289 - ReferenceResource: taskModel.ReferenceResource,  
290 - CustomerValue: taskModel.CustomerValue,  
291 - TaskNature: taskModel.TaskNature,  
292 - SuMoney: taskModel.SuMoney,  
293 - AcceptanceStandard: taskModel.AcceptanceStandard,  
294 - TaskDescription: taskModel.TaskDescription,  
295 - TaskPictureUrls: taskModel.TaskPictureUrls,  
296 - IsRewardTake: taskModel.IsRewardTake,  
297 - CreateTime: taskModel.CreateTime,  
298 - ReleaseTime: taskModel.ReleaseTime,  
299 - ReceiveTime: taskModel.ReceiveTime,  
300 - CompleteTime: taskModel.CompleteTime,  
301 - AcceptanceTime: taskModel.AcceptanceTime,  
302 - RobInfo: robInfo,  
303 - BidInfo: bidInfo,  
304 - Participators: taskModel.Participators,  
305 - TaskPercentage: taskModel.TaskPercentage,  
306 - SolveReport: taskModel.SolveReport,  
307 - SolvePictureUrls: taskModel.SolvePictureUrls,  
308 - CurrentStatus: currentStatus, 298 + TaskId: taskModel.Id,
  299 + CompanyId: taskModel.CompanyId,
  300 + TaskName: taskModel.TaskName,
  301 + TaskType: taskModel.TaskType,
  302 + Sponsor: taskModel.Sponsor,
  303 + TaskStatus: taskModel.TaskStatus,
  304 + ReferenceResource: taskModel.ReferenceResource,
  305 + ProjectBelong: taskModel.ProjectBelong,
  306 + CustomerValues: taskModel.CustomerValues,
  307 + TaskNature: taskModel.TaskNature,
  308 + SuMoney: taskModel.SuMoney,
  309 + AcceptanceStandard: taskModel.AcceptanceStandard,
  310 + TaskDescription: taskModel.TaskDescription,
  311 + TaskPictureUrls: taskModel.TaskPictureUrls,
  312 + IsRewardTake: taskModel.IsRewardTake,
  313 + AssignedPerson: taskModel.AssignedPerson,
  314 + PlannedCompletionTime: taskModel.PlannedCompletionTime,
  315 + ActualCompletionTime: taskModel.ActualCompletionTime,
  316 + CreateTime: taskModel.CreateTime,
  317 + ReleaseTime: taskModel.ReleaseTime,
  318 + ReceiveTime: taskModel.ReceiveTime,
  319 + CompleteTime: taskModel.CompleteTime,
  320 + AcceptanceTime: taskModel.AcceptanceTime,
  321 + RobInfo: robInfo,
  322 + BidInfo: bidInfo,
  323 + Participators: taskModel.Participators,
  324 + TaskPercentage: taskModel.TaskPercentage,
  325 + SolveReport: taskModel.SolveReport,
  326 + SolvePictureUrls: taskModel.SolvePictureUrls,
  327 + CurrentStatus: currentStatus,
309 }, nil 328 }, nil
310 } 329 }
311 330
  1 +package controllers
  2 +
  3 +import (
  4 + "encoding/json"
  5 +
  6 + "github.com/astaxie/beego"
  7 + "github.com/linmadan/egglib-go/web/beego/utils"
  8 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/command"
  9 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/query"
  10 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/service"
  11 +)
  12 +
  13 +type RejectTaskRecordController struct {
  14 + beego.Controller
  15 +}
  16 +
  17 +func (controller *RejectTaskRecordController) GetRejectTaskRecord() {
  18 + taskService := service.NewTaskService(nil)
  19 + getRejectTaskRecordQuery := &query.GetRejectTaskRecordQuery{}
  20 + rejectTaskRecordId, _ := controller.GetInt64(":rejectTaskRecordId")
  21 + getRejectTaskRecordQuery.RejectTaskRecordId = rejectTaskRecordId
  22 + data, err := taskService.GetRejectTaskRecord(getRejectTaskRecordQuery)
  23 + var response utils.JsonResponse
  24 + if err != nil {
  25 + response = utils.ResponseError(controller.Ctx, err)
  26 + } else {
  27 + response = utils.ResponseData(controller.Ctx, data)
  28 + }
  29 + controller.Data["json"] = response
  30 + controller.ServeJSON()
  31 +}
  32 +
  33 +func (controller *RejectTaskRecordController) SearchRejectTaskRecord() {
  34 + taskService := service.NewTaskService(nil)
  35 + searchRejectTaskRecordCommand := &command.SearchRejectTaskRecordCommand{}
  36 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), searchRejectTaskRecordCommand)
  37 + data, err := taskService.SearchRejectTaskRecord(searchRejectTaskRecordCommand)
  38 + var response utils.JsonResponse
  39 + if err != nil {
  40 + response = utils.ResponseError(controller.Ctx, err)
  41 + } else {
  42 + response = utils.ResponseData(controller.Ctx, data)
  43 + }
  44 + controller.Data["json"] = response
  45 + controller.ServeJSON()
  46 +}
@@ -13,6 +13,40 @@ type TaskController struct { @@ -13,6 +13,40 @@ type TaskController struct {
13 beego.Controller 13 beego.Controller
14 } 14 }
15 15
  16 +func (controller *TaskController) RejectTaskReceiver() {
  17 + taskService := service.NewTaskService(nil)
  18 + rejectTaskReceiverCommand := &command.RejectTaskReceiverCommand{}
  19 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), rejectTaskReceiverCommand)
  20 + taskId, _ := controller.GetInt64(":taskId")
  21 + rejectTaskReceiverCommand.TaskId = taskId
  22 + data, err := taskService.RejectTaskReceiver(rejectTaskReceiverCommand)
  23 + var response utils.JsonResponse
  24 + if err != nil {
  25 + response = utils.ResponseError(controller.Ctx, err)
  26 + } else {
  27 + response = utils.ResponseData(controller.Ctx, data)
  28 + }
  29 + controller.Data["json"] = response
  30 + controller.ServeJSON()
  31 +}
  32 +
  33 +func (controller *TaskController) ConfirmRobTask() {
  34 + taskService := service.NewTaskService(nil)
  35 + confirmRobTaskCommand := &command.ConfirmRobTaskCommand{}
  36 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), confirmRobTaskCommand)
  37 + taskId, _ := controller.GetInt64(":taskId")
  38 + confirmRobTaskCommand.TaskId = taskId
  39 + data, err := taskService.ConfirmRobTask(confirmRobTaskCommand)
  40 + var response utils.JsonResponse
  41 + if err != nil {
  42 + response = utils.ResponseError(controller.Ctx, err)
  43 + } else {
  44 + response = utils.ResponseData(controller.Ctx, data)
  45 + }
  46 + controller.Data["json"] = response
  47 + controller.ServeJSON()
  48 +}
  49 +
16 func (controller *TaskController) RobTask() { 50 func (controller *TaskController) RobTask() {
17 taskService := service.NewTaskService(nil) 51 taskService := service.NewTaskService(nil)
18 robTaskCommand := &command.RobTaskCommand{} 52 robTaskCommand := &command.RobTaskCommand{}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/astaxie/beego"
  5 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego/controllers"
  6 +)
  7 +
  8 +func init() {
  9 + beego.Router("/reject-task-records/:rejectTaskRecordId", &controllers.RejectTaskRecordController{}, "Get:GetRejectTaskRecord")
  10 + beego.Router("/reject-task-records/search-reject-task-record", &controllers.RejectTaskRecordController{}, "Post:SearchRejectTaskRecord")
  11 +}
@@ -6,6 +6,8 @@ import ( @@ -6,6 +6,8 @@ import (
6 ) 6 )
7 7
8 func init() { 8 func init() {
  9 + beego.Router("/tasks/:taskId/reject-task-receiver", &controllers.TaskController{}, "Post:RejectTaskReceiver")
  10 + beego.Router("/tasks/:taskId/confirm-rob-task", &controllers.TaskController{}, "Post:ConfirmRobTask")
9 beego.Router("/tasks/:taskId/rob", &controllers.TaskController{}, "Post:RobTask") 11 beego.Router("/tasks/:taskId/rob", &controllers.TaskController{}, "Post:RobTask")
10 beego.Router("/tasks/:taskId/bid", &controllers.TaskController{}, "Post:BidTask") 12 beego.Router("/tasks/:taskId/bid", &controllers.TaskController{}, "Post:BidTask")
11 beego.Router("/tasks/:taskId/apply-complete", &controllers.TaskController{}, "Post:ApplyCompleteTask") 13 beego.Router("/tasks/:taskId/apply-complete", &controllers.TaskController{}, "Post:ApplyCompleteTask")
@@ -13,8 +13,38 @@ import ( @@ -13,8 +13,38 @@ import (
13 ) 13 )
14 14
15 var _ = Describe("搜索关闭任务记录", func() { 15 var _ = Describe("搜索关闭任务记录", func() {
  16 + var projectBelongId int
  17 + var taskNatureId int
  18 + var customerValueId1 int
  19 + var customerValueId2 int
  20 + var customerValueId3 int
16 var offTaskRecordId int64 21 var offTaskRecordId int64
17 BeforeEach(func() { 22 BeforeEach(func() {
  23 + _, err8 := pG.DB.QueryOne(
  24 + pg.Scan(&projectBelongId),
  25 + "INSERT INTO project_belongs (project_belong_name, company_id) VALUES (?, ?) RETURNING id",
  26 + "能力展示", 101)
  27 + Expect(err8).NotTo(HaveOccurred())
  28 + _, err9 := pG.DB.QueryOne(
  29 + pg.Scan(&customerValueId1),
  30 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  31 + "口味", 101)
  32 + Expect(err9).NotTo(HaveOccurred())
  33 + _, err10 := pG.DB.QueryOne(
  34 + pg.Scan(&customerValueId2),
  35 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  36 + "口感", 101)
  37 + Expect(err10).NotTo(HaveOccurred())
  38 + _, err11 := pG.DB.QueryOne(
  39 + pg.Scan(&customerValueId3),
  40 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  41 + "性价比", 101)
  42 + Expect(err11).NotTo(HaveOccurred())
  43 + _, err12 := pG.DB.QueryOne(
  44 + pg.Scan(&taskNatureId),
  45 + "INSERT INTO task_natures (task_nature_name, company_id) VALUES (?, ?) RETURNING id",
  46 + "点", 101)
  47 + Expect(err12).NotTo(HaveOccurred())
18 _, err := pG.DB.QueryOne( 48 _, err := pG.DB.QueryOne(
19 pg.Scan(&offTaskRecordId), 49 pg.Scan(&offTaskRecordId),
20 "INSERT INTO off_task_records (id, task_id, operator, off_reason, create_time) VALUES (?, ?, ?, ?, ?) RETURNING id", 50 "INSERT INTO off_task_records (id, task_id, operator, off_reason, create_time) VALUES (?, ?, ?, ?, ?) RETURNING id",
@@ -25,10 +55,10 @@ var _ = Describe("搜索关闭任务记录", func() { @@ -25,10 +55,10 @@ var _ = Describe("搜索关闭任务记录", func() {
25 dayAfter, _ := time.ParseDuration("72h") 55 dayAfter, _ := time.ParseDuration("72h")
26 _, err1 := pG.DB.QueryOne( 56 _, err1 := pG.DB.QueryOne(
27 pg.Scan(), 57 pg.Scan(),
28 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 58 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
29 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 59 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
30 Uid: 2499036607974745088, 60 Uid: 2499036607974745088,
31 - }, 6, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 61 + }, 6, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
32 { 62 {
33 Uid: 2499036607974745077, 63 Uid: 2499036607974745077,
34 }, 64 },
@@ -46,8 +76,9 @@ var _ = Describe("搜索关闭任务记录", func() { @@ -46,8 +76,9 @@ var _ = Describe("搜索关闭任务记录", func() {
46 "companyId": 101, 76 "companyId": 101,
47 "taskContentMatch": "", 77 "taskContentMatch": "",
48 "taskType": 1, 78 "taskType": 1,
49 - "customerValue": "",  
50 - "taskNature": "", 79 + "projectBelongs": make([]int, 0),
  80 + "customerValues": make([]int, 0),
  81 + "taskNatures": make([]int, 0),
51 "offStartTime": time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), 82 "offStartTime": time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()),
52 "offEndTime": time.Time{}, 83 "offEndTime": time.Time{},
53 "offset": 0, 84 "offset": 0,
@@ -72,8 +103,9 @@ var _ = Describe("搜索关闭任务记录", func() { @@ -72,8 +103,9 @@ var _ = Describe("搜索关闭任务记录", func() {
72 "companyId": 102, 103 "companyId": 102,
73 "taskContentMatch": "", 104 "taskContentMatch": "",
74 "taskType": 1, 105 "taskType": 1,
75 - "customerValue": "",  
76 - "taskNature": "", 106 + "projectBelongs": make([]int, 0),
  107 + "customerValues": make([]int, 0),
  108 + "taskNatures": make([]int, 0),
77 "offStartTime": time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), 109 "offStartTime": time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()),
78 "offEndTime": time.Time{}, 110 "offEndTime": time.Time{},
79 "offset": 0, 111 "offset": 0,
@@ -98,8 +130,9 @@ var _ = Describe("搜索关闭任务记录", func() { @@ -98,8 +130,9 @@ var _ = Describe("搜索关闭任务记录", func() {
98 "companyId": 101, 130 "companyId": 101,
99 "taskContentMatch": "", 131 "taskContentMatch": "",
100 "taskType": 1, 132 "taskType": 1,
101 - "customerValue": "",  
102 - "taskNature": "", 133 + "projectBelongs": make([]int, 0),
  134 + "customerValues": make([]int, 0),
  135 + "taskNatures": make([]int, 0),
103 "offStartTime": time.Date(2030, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), 136 "offStartTime": time.Date(2030, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()),
104 "offEndTime": time.Time{}, 137 "offEndTime": time.Time{},
105 "offset": 0, 138 "offset": 0,
@@ -123,5 +156,11 @@ var _ = Describe("搜索关闭任务记录", func() { @@ -123,5 +156,11 @@ var _ = Describe("搜索关闭任务记录", func() {
123 Expect(err).NotTo(HaveOccurred()) 156 Expect(err).NotTo(HaveOccurred())
124 _, err1 := pG.DB.Exec("DELETE FROM tasks WHERE true") 157 _, err1 := pG.DB.Exec("DELETE FROM tasks WHERE true")
125 Expect(err1).NotTo(HaveOccurred()) 158 Expect(err1).NotTo(HaveOccurred())
  159 + _, err3 := pG.DB.Exec("DELETE FROM project_belongs WHERE true")
  160 + Expect(err3).NotTo(HaveOccurred())
  161 + _, err4 := pG.DB.Exec("DELETE FROM task_natures WHERE true")
  162 + Expect(err4).NotTo(HaveOccurred())
  163 + _, err5 := pG.DB.Exec("DELETE FROM customer_values WHERE true")
  164 + Expect(err5).NotTo(HaveOccurred())
126 }) 165 })
127 }) 166 })
  1 +package reject_task_record
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  5 + "net/http"
  6 + "time"
  7 +
  8 + "github.com/gavv/httpexpect"
  9 + "github.com/go-pg/pg"
  10 + . "github.com/onsi/ginkgo"
  11 + . "github.com/onsi/gomega"
  12 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  13 +)
  14 +
  15 +var _ = Describe("返回驳回任务记录", func() {
  16 + BeforeEach(func() {
  17 + _, err := pG.DB.QueryOne(
  18 + pg.Scan(),
  19 + "INSERT INTO reject_task_records (id, task_id, operator, reject_reason, create_time) VALUES (?, ?, ?, ?, ?)",
  20 + 1, 1, &domain.EmployeeInfo{
  21 + Uid: 2499036607974745088,
  22 + }, "testReason", time.Now())
  23 + Expect(err).NotTo(HaveOccurred())
  24 + })
  25 + Describe("返回驳回任务记录", func() {
  26 + Context("", func() {
  27 + It("", func() {
  28 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  29 + httpExpect.GET("/reject-task-records/1").
  30 + Expect().
  31 + Status(http.StatusOK).
  32 + JSON().
  33 + Object().
  34 + ContainsKey("code").ValueEqual("code", 0).
  35 + ContainsKey("msg").ValueEqual("msg", "ok").
  36 + ContainsKey("data").Value("data").Object()
  37 + })
  38 + })
  39 + })
  40 + AfterEach(func() {
  41 + _, err := pG.DB.Exec("DELETE FROM reject_task_records WHERE true")
  42 + Expect(err).NotTo(HaveOccurred())
  43 + })
  44 +})
  1 +package reject_task_record
  2 +
  3 +import (
  4 + "net/http"
  5 + "net/http/httptest"
  6 + "testing"
  7 +
  8 + "github.com/astaxie/beego"
  9 + . "github.com/onsi/ginkgo"
  10 + . "github.com/onsi/gomega"
  11 + _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  12 + _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego"
  13 +)
  14 +
  15 +func TestRejectTaskRecord(t *testing.T) {
  16 + RegisterFailHandler(Fail)
  17 + RunSpecs(t, "Beego Port RejectTaskRecord Correlations Test Case Suite")
  18 +}
  19 +
  20 +var handler http.Handler
  21 +var server *httptest.Server
  22 +
  23 +var _ = BeforeSuite(func() {
  24 + handler = beego.BeeApp.Handlers
  25 + server = httptest.NewServer(handler)
  26 +})
  27 +
  28 +var _ = AfterSuite(func() {
  29 + server.Close()
  30 +})
  1 +package reject_task_record
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  5 + "net/http"
  6 + "time"
  7 +
  8 + "github.com/gavv/httpexpect"
  9 + "github.com/go-pg/pg"
  10 + . "github.com/onsi/ginkgo"
  11 + . "github.com/onsi/gomega"
  12 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  13 +)
  14 +
  15 +var _ = Describe("搜索驳回任务记录", func() {
  16 + var projectBelongId int
  17 + var taskNatureId int
  18 + var customerValueId1 int
  19 + var customerValueId2 int
  20 + var customerValueId3 int
  21 + var rejectTaskRecordId int64
  22 + BeforeEach(func() {
  23 + _, err8 := pG.DB.QueryOne(
  24 + pg.Scan(&projectBelongId),
  25 + "INSERT INTO project_belongs (project_belong_name, company_id) VALUES (?, ?) RETURNING id",
  26 + "能力展示", 101)
  27 + Expect(err8).NotTo(HaveOccurred())
  28 + _, err9 := pG.DB.QueryOne(
  29 + pg.Scan(&customerValueId1),
  30 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  31 + "口味", 101)
  32 + Expect(err9).NotTo(HaveOccurred())
  33 + _, err10 := pG.DB.QueryOne(
  34 + pg.Scan(&customerValueId2),
  35 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  36 + "口感", 101)
  37 + Expect(err10).NotTo(HaveOccurred())
  38 + _, err11 := pG.DB.QueryOne(
  39 + pg.Scan(&customerValueId3),
  40 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  41 + "性价比", 101)
  42 + Expect(err11).NotTo(HaveOccurred())
  43 + _, err12 := pG.DB.QueryOne(
  44 + pg.Scan(&taskNatureId),
  45 + "INSERT INTO task_natures (task_nature_name, company_id) VALUES (?, ?) RETURNING id",
  46 + "点", 101)
  47 + Expect(err12).NotTo(HaveOccurred())
  48 + _, err := pG.DB.QueryOne(
  49 + pg.Scan(&rejectTaskRecordId),
  50 + "INSERT INTO reject_task_records (id, task_id, operator, reject_reason, create_time) VALUES (?, ?, ?, ?, ?) RETURNING id",
  51 + 1, 1, &domain.EmployeeInfo{
  52 + Uid: 2499036607974745088,
  53 + }, "testReason", time.Now())
  54 + Expect(err).NotTo(HaveOccurred())
  55 + dayAfter, _ := time.ParseDuration("72h")
  56 + _, err1 := pG.DB.QueryOne(
  57 + pg.Scan(),
  58 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  59 + 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
  60 + Uid: 2499036607974745088,
  61 + }, 6, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
  62 + {
  63 + Uid: 2499036607974745077,
  64 + },
  65 + {
  66 + Uid: 2499036607974745066,
  67 + },
  68 + }, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
  69 + Expect(err1).NotTo(HaveOccurred())
  70 + })
  71 + Describe("搜索驳回任务记录", func() {
  72 + Context("", func() {
  73 + It("", func() {
  74 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  75 + body := map[string]interface{}{
  76 + "companyId": 101,
  77 + "taskContentMatch": "",
  78 + "taskType": 1,
  79 + "projectBelongs": make([]int, 0),
  80 + "customerValues": make([]int, 0),
  81 + "taskNatures": make([]int, 0),
  82 + "rejectStartTime": time.Date(2020, time.Month(5), 26, 8, 0, 0, 0, time.Now().Location()),
  83 + "rejectEndTime": time.Time{},
  84 + "offset": 0,
  85 + "limit": 20,
  86 + }
  87 + httpExpect.POST("/reject-task-records/search-reject-task-record").
  88 + WithJSON(body).
  89 + Expect().
  90 + Status(http.StatusOK).
  91 + JSON().
  92 + Object().
  93 + ContainsKey("code").ValueEqual("code", 0).
  94 + ContainsKey("msg").ValueEqual("msg", "ok").
  95 + ContainsKey("data").Value("data").Object()
  96 + })
  97 + })
  98 + })
  99 + AfterEach(func() {
  100 + _, err := pG.DB.Exec("DELETE FROM reject_task_records WHERE true")
  101 + Expect(err).NotTo(HaveOccurred())
  102 + _, err1 := pG.DB.Exec("DELETE FROM tasks WHERE true")
  103 + Expect(err1).NotTo(HaveOccurred())
  104 + _, err3 := pG.DB.Exec("DELETE FROM project_belongs WHERE true")
  105 + Expect(err3).NotTo(HaveOccurred())
  106 + _, err4 := pG.DB.Exec("DELETE FROM task_natures WHERE true")
  107 + Expect(err4).NotTo(HaveOccurred())
  108 + _, err5 := pG.DB.Exec("DELETE FROM customer_values WHERE true")
  109 + Expect(err5).NotTo(HaveOccurred())
  110 + })
  111 +})
@@ -19,7 +19,7 @@ var _ = Describe("验收任务", func() { @@ -19,7 +19,7 @@ var _ = Describe("验收任务", func() {
19 dayAfter, _ := time.ParseDuration("72h") 19 dayAfter, _ := time.ParseDuration("72h")
20 _, err := pG.DB.QueryOne( 20 _, err := pG.DB.QueryOne(
21 pg.Scan(), 21 pg.Scan(),
22 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 22 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
23 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 23 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
24 Uid: 2499036607974745088, 24 Uid: 2499036607974745088,
25 }, 4, &domain.ReferenceResource{ 25 }, 4, &domain.ReferenceResource{
@@ -32,7 +32,7 @@ var _ = Describe("验收任务", func() { @@ -32,7 +32,7 @@ var _ = Describe("验收任务", func() {
32 Content: "问题内容1", 32 Content: "问题内容1",
33 }, 33 },
34 }, 34 },
35 - }, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter)) 35 + }, 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
36 Expect(err).NotTo(HaveOccurred()) 36 Expect(err).NotTo(HaveOccurred())
37 _, err1 := pG.DB.QueryOne( 37 _, err1 := pG.DB.QueryOne(
38 pg.Scan(), 38 pg.Scan(),
@@ -19,10 +19,10 @@ var _ = Describe("申请完成任务", func() { @@ -19,10 +19,10 @@ var _ = Describe("申请完成任务", func() {
19 dayAfter, _ := time.ParseDuration("72h") 19 dayAfter, _ := time.ParseDuration("72h")
20 _, err := pG.DB.QueryOne( 20 _, err := pG.DB.QueryOne(
21 pg.Scan(), 21 pg.Scan(),
22 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 22 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
23 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 23 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
24 Uid: 2499036607974745088, 24 Uid: 2499036607974745088,
25 - }, 3, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 25 + }, 3, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
26 { 26 {
27 Uid: 2499036607974745077, 27 Uid: 2499036607974745077,
28 }, 28 },
@@ -19,10 +19,10 @@ var _ = Describe("对任务进行竞标", func() { @@ -19,10 +19,10 @@ var _ = Describe("对任务进行竞标", func() {
19 dayAfter, _ := time.ParseDuration("72h") 19 dayAfter, _ := time.ParseDuration("72h")
20 _, err := pG.DB.QueryOne( 20 _, err := pG.DB.QueryOne(
21 pg.Scan(), 21 pg.Scan(),
22 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 22 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
23 1, 101, "竞标任务1", 2, &domain.EmployeeInfo{ 23 1, 101, "竞标任务1", 2, &domain.EmployeeInfo{
24 Uid: 2499036607974745088, 24 Uid: 2499036607974745088,
25 - }, 2, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 25 + }, 2, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
26 { 26 {
27 Uid: 2499036607974745077, 27 Uid: 2499036607974745077,
28 }, 28 },
@@ -19,10 +19,10 @@ var _ = Describe("选择竞标任务的中标人", func() { @@ -19,10 +19,10 @@ var _ = Describe("选择竞标任务的中标人", func() {
19 dayAfter, _ := time.ParseDuration("72h") 19 dayAfter, _ := time.ParseDuration("72h")
20 _, err := pG.DB.QueryOne( 20 _, err := pG.DB.QueryOne(
21 pg.Scan(), 21 pg.Scan(),
22 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 22 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
23 1, 101, "竞标任务1", 2, &domain.EmployeeInfo{ 23 1, 101, "竞标任务1", 2, &domain.EmployeeInfo{
24 Uid: 2499036607974745088, 24 Uid: 2499036607974745088,
25 - }, 2, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 25 + }, 2, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
26 { 26 {
27 Uid: 2499036607974745077, 27 Uid: 2499036607974745077,
28 }, 28 },
@@ -57,8 +57,9 @@ var _ = Describe("选择竞标任务的中标人", func() { @@ -57,8 +57,9 @@ var _ = Describe("选择竞标任务的中标人", func() {
57 It("选择中标人成功", func() { 57 It("选择中标人成功", func() {
58 httpExpect := httpexpect.New(GinkgoT(), server.URL) 58 httpExpect := httpexpect.New(GinkgoT(), server.URL)
59 body := map[string]interface{}{ 59 body := map[string]interface{}{
60 - "operator": 2499036607974745088,  
61 - "successfulBidder": 2499036607974745099, 60 + "operator": 2499036607974745088,
  61 + "successfulBidder": 2499036607974745099,
  62 + "plannedCompletionTime": time.Now(),
62 } 63 }
63 httpExpect.POST("/tasks/1/choose-successful-bidder"). 64 httpExpect.POST("/tasks/1/choose-successful-bidder").
64 WithJSON(body). 65 WithJSON(body).
  1 +package task
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  5 + "net/http"
  6 + "time"
  7 +
  8 + "github.com/gavv/httpexpect"
  9 + "github.com/go-pg/pg"
  10 + . "github.com/onsi/ginkgo"
  11 + . "github.com/onsi/gomega"
  12 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  13 +)
  14 +
  15 +var _ = Describe("对抢单任务进行确认", func() {
  16 + BeforeEach(func() {
  17 + dayAfter, _ := time.ParseDuration("72h")
  18 + _, err := pG.DB.QueryOne(
  19 + pg.Scan(),
  20 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  21 + 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
  22 + Uid: 2499036607974745088,
  23 + }, 7, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
  24 + {
  25 + Uid: 2499036607974745077,
  26 + },
  27 + {
  28 + Uid: 2499036607974745066,
  29 + },
  30 + }, "null", "", pg.Array([]string{}), 0, time.Now(), time.Now().Add(dayAfter))
  31 + Expect(err).NotTo(HaveOccurred())
  32 + _, err1 := pG.DB.QueryOne(
  33 + pg.Scan(),
  34 + "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
  35 + 1, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0)
  36 + Expect(err1).NotTo(HaveOccurred())
  37 + _, err2 := pG.DB.QueryOne(
  38 + pg.Scan(),
  39 + "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
  40 + 2, 101, 2499036607974745099, "testEmployeeName", "testEmployeeAccount", 0)
  41 + Expect(err2).NotTo(HaveOccurred())
  42 + })
  43 + Describe("对抢单任务进行确认", func() {
  44 + Context("任务发布人对抢单任务进行确认", func() {
  45 + It("确认成功", func() {
  46 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  47 + body := map[string]interface{}{
  48 + "operator": 2499036607974745088,
  49 + "plannedCompletionTime": time.Now(),
  50 + }
  51 + httpExpect.POST("/tasks/1/confirm-rob-task").
  52 + WithJSON(body).
  53 + Expect().
  54 + Status(http.StatusOK).
  55 + JSON().
  56 + Object().
  57 + ContainsKey("code").ValueEqual("code", 0).
  58 + ContainsKey("msg").ValueEqual("msg", "ok").
  59 + ContainsKey("data").Value("data").Object().
  60 + ContainsKey("taskStatus").ValueEqual("taskStatus", 3)
  61 + })
  62 + })
  63 + })
  64 + AfterEach(func() {
  65 + _, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
  66 + Expect(err).NotTo(HaveOccurred())
  67 + _, err1 := pG.DB.Exec("DELETE FROM bid_infos WHERE true")
  68 + Expect(err1).NotTo(HaveOccurred())
  69 + _, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
  70 + Expect(err2).NotTo(HaveOccurred())
  71 + _, err3 := pG.DB.Exec("DELETE FROM employees WHERE true")
  72 + Expect(err3).NotTo(HaveOccurred())
  73 + _, err4 := pG.DB.Exec("DELETE FROM rob_infos WHERE true")
  74 + Expect(err4).NotTo(HaveOccurred())
  75 + })
  76 +})
@@ -21,7 +21,7 @@ var _ = Describe("创建新任务", func() { @@ -21,7 +21,7 @@ var _ = Describe("创建新任务", func() {
21 Expect(err).NotTo(HaveOccurred()) 21 Expect(err).NotTo(HaveOccurred())
22 _, err1 := pG.DB.QueryOne( 22 _, err1 := pG.DB.QueryOne(
23 pg.Scan(), 23 pg.Scan(),
24 - "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 24 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
25 2, 101, "抢单任务2", 1, &domain.EmployeeInfo{ 25 2, 101, "抢单任务2", 1, &domain.EmployeeInfo{
26 Uid: 2499036607974745088, 26 Uid: 2499036607974745088,
27 }, 2, &domain.ReferenceResource{ 27 }, 2, &domain.ReferenceResource{
@@ -31,7 +31,7 @@ var _ = Describe("创建新任务", func() { @@ -31,7 +31,7 @@ var _ = Describe("创建新任务", func() {
31 ReferenceResourceId: 4, 31 ReferenceResourceId: 4,
32 }, 32 },
33 }, 33 },
34 - }, pg.Array([]string{"口感", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now()) 34 + }, 1, pg.Array([]int{1, 2}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now())
35 Expect(err1).NotTo(HaveOccurred()) 35 Expect(err1).NotTo(HaveOccurred())
36 }) 36 })
37 Describe("提交数据创建新任务", func() { 37 Describe("提交数据创建新任务", func() {
@@ -49,12 +49,13 @@ var _ = Describe("创建新任务", func() { @@ -49,12 +49,13 @@ var _ = Describe("创建新任务", func() {
49 {"referenceResourceId": 2, "serialNumber": 2, "title": "问题标题2"}, 49 {"referenceResourceId": 2, "serialNumber": 2, "title": "问题标题2"},
50 {"referenceResourceId": 3, "serialNumber": 3, "title": "问题标题3"}, 50 {"referenceResourceId": 3, "serialNumber": 3, "title": "问题标题3"},
51 }, 51 },
52 - "customerValue": []string{  
53 - "口味",  
54 - "色泽",  
55 - "商务服务", 52 + "projectBelong": 1,
  53 + "customerValues": []int{
  54 + 1,
  55 + 2,
  56 + 3,
56 }, 57 },
57 - "taskNature": "线", 58 + "taskNature": 1,
58 "suMoney": 1000.00, 59 "suMoney": 1000.00,
59 "acceptanceStandard": "验收标准", 60 "acceptanceStandard": "验收标准",
60 "taskDescription": "任务描述", 61 "taskDescription": "任务描述",
@@ -92,12 +93,13 @@ var _ = Describe("创建新任务", func() { @@ -92,12 +93,13 @@ var _ = Describe("创建新任务", func() {
92 {"serialNumber": 2, "title": "机会标题2"}, 93 {"serialNumber": 2, "title": "机会标题2"},
93 {"serialNumber": 3, "title": "机会标题3"}, 94 {"serialNumber": 3, "title": "机会标题3"},
94 }, 95 },
95 - "customerValue": []string{  
96 - "口味",  
97 - "色泽",  
98 - "商务服务", 96 + "projectBelong": 1,
  97 + "customerValues": []int{
  98 + 1,
  99 + 2,
  100 + 3,
99 }, 101 },
100 - "taskNature": "线", 102 + "taskNature": 1,
101 "suMoney": 1000.00, 103 "suMoney": 1000.00,
102 "acceptanceStandard": "验收标准", 104 "acceptanceStandard": "验收标准",
103 "taskDescription": "任务描述", 105 "taskDescription": "任务描述",
@@ -122,6 +124,50 @@ var _ = Describe("创建新任务", func() { @@ -122,6 +124,50 @@ var _ = Describe("创建新任务", func() {
122 ContainsKey("taskId").ValueNotEqual("taskId", BeZero()) 124 ContainsKey("taskId").ValueNotEqual("taskId", BeZero())
123 }) 125 })
124 }) 126 })
  127 + Context("提交正确的指派类型任务数据", func() {
  128 + It("返回指派类型任务数据", func() {
  129 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  130 + body := map[string]interface{}{
  131 + "companyId": 101,
  132 + "taskName": "竞标任务",
  133 + "taskType": 2,
  134 + "sponsor": 2499036607974745088,
  135 + "referenceResourceType": 2,
  136 + "referenceResourceItems": []map[string]interface{}{
  137 + {"serialNumber": 1, "title": "机会标题1"},
  138 + {"serialNumber": 2, "title": "机会标题2"},
  139 + {"serialNumber": 3, "title": "机会标题3"},
  140 + },
  141 + "projectBelong": 1,
  142 + "customerValues": []int{
  143 + 1,
  144 + 2,
  145 + 3,
  146 + },
  147 + "taskNature": 1,
  148 + "suMoney": 1000.00,
  149 + "acceptanceStandard": "验收标准",
  150 + "taskDescription": "任务描述",
  151 + "taskPictureUrls": []string{
  152 + "url-1",
  153 + "url-2",
  154 + "url-3",
  155 + },
  156 + "assignedPerson": 2499036607974745088,
  157 + "plannedCompletionTime": time.Now(),
  158 + }
  159 + httpExpect.POST("/tasks/").
  160 + WithJSON(body).
  161 + Expect().
  162 + Status(http.StatusOK).
  163 + JSON().
  164 + Object().
  165 + ContainsKey("code").ValueEqual("code", 0).
  166 + ContainsKey("msg").ValueEqual("msg", "ok").
  167 + ContainsKey("data").Value("data").Object().
  168 + ContainsKey("taskId").ValueNotEqual("taskId", BeZero())
  169 + })
  170 + })
125 Context("提交已经被引用的问题ID任务数据", func() { 171 Context("提交已经被引用的问题ID任务数据", func() {
126 It("创建失败", func() { 172 It("创建失败", func() {
127 httpExpect := httpexpect.New(GinkgoT(), server.URL) 173 httpExpect := httpexpect.New(GinkgoT(), server.URL)
@@ -134,12 +180,13 @@ var _ = Describe("创建新任务", func() { @@ -134,12 +180,13 @@ var _ = Describe("创建新任务", func() {
134 "referenceResourceItems": []map[string]interface{}{ 180 "referenceResourceItems": []map[string]interface{}{
135 {"referenceResourceId": 4, "serialNumber": 4, "title": "问题标题4"}, 181 {"referenceResourceId": 4, "serialNumber": 4, "title": "问题标题4"},
136 }, 182 },
137 - "customerValue": []string{  
138 - "口味",  
139 - "色泽",  
140 - "商务服务", 183 + "projectBelong": 1,
  184 + "customerValues": []int{
  185 + 1,
  186 + 2,
  187 + 3,
141 }, 188 },
142 - "taskNature": "线", 189 + "taskNature": 1,
143 "suMoney": 1000.00, 190 "suMoney": 1000.00,
144 "acceptanceStandard": "验收标准", 191 "acceptanceStandard": "验收标准",
145 "taskDescription": "任务描述", 192 "taskDescription": "任务描述",
1 package task 1 package task
2 2
3 import ( 3 import (
4 - "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"  
5 - "net/http"  
6 - "time"  
7 -  
8 "github.com/gavv/httpexpect" 4 "github.com/gavv/httpexpect"
9 "github.com/go-pg/pg" 5 "github.com/go-pg/pg"
10 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/ginkgo"
11 . "github.com/onsi/gomega" 7 . "github.com/onsi/gomega"
  8 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
12 pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg" 9 pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  10 + "net/http"
  11 + "time"
13 ) 12 )
14 13
15 var _ = Describe("返回任务", func() { 14 var _ = Describe("返回任务", func() {
  15 + var projectBelongId int
  16 + var taskNatureId int
  17 + var customerValueId1 int
  18 + var customerValueId2 int
  19 + var customerValueId3 int
16 BeforeEach(func() { 20 BeforeEach(func() {
  21 + _, err3 := pG.DB.QueryOne(
  22 + pg.Scan(&projectBelongId),
  23 + "INSERT INTO project_belongs (project_belong_name, company_id) VALUES (?, ?) RETURNING id",
  24 + "能力展示", 101)
  25 + Expect(err3).NotTo(HaveOccurred())
  26 + _, err4 := pG.DB.QueryOne(
  27 + pg.Scan(&customerValueId1),
  28 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  29 + "口味", 101)
  30 + Expect(err4).NotTo(HaveOccurred())
  31 + _, err5 := pG.DB.QueryOne(
  32 + pg.Scan(&customerValueId2),
  33 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  34 + "口感", 101)
  35 + Expect(err5).NotTo(HaveOccurred())
  36 + _, err6 := pG.DB.QueryOne(
  37 + pg.Scan(&customerValueId3),
  38 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  39 + "性价比", 101)
  40 + Expect(err6).NotTo(HaveOccurred())
  41 + _, err7 := pG.DB.QueryOne(
  42 + pg.Scan(&taskNatureId),
  43 + "INSERT INTO task_natures (task_nature_name, company_id) VALUES (?, ?) RETURNING id",
  44 + "点", 101)
  45 + Expect(err7).NotTo(HaveOccurred())
17 dayAfter, _ := time.ParseDuration("72h") 46 dayAfter, _ := time.ParseDuration("72h")
18 _, err := pG.DB.QueryOne( 47 _, err := pG.DB.QueryOne(
19 pg.Scan(), 48 pg.Scan(),
20 - "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 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
21 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 50 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
22 Uid: 2499036607974745088, 51 Uid: 2499036607974745088,
23 - }, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) 52 + }, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
24 Expect(err).NotTo(HaveOccurred()) 53 Expect(err).NotTo(HaveOccurred())
25 _, err1 := pG.DB.QueryOne( 54 _, err1 := pG.DB.QueryOne(
26 pg.Scan(), 55 pg.Scan(),
27 - "INSERT INTO bid_infos (id, task_id) VALUES (?, ?)",  
28 - 1, 1) 56 + "INSERT INTO bid_infos (id, task_id, is_remind) VALUES (?, ?, ?)",
  57 + 1, 1, true)
29 Expect(err1).NotTo(HaveOccurred()) 58 Expect(err1).NotTo(HaveOccurred())
30 _, err2 := pG.DB.QueryOne( 59 _, err2 := pG.DB.QueryOne(
31 pg.Scan(), 60 pg.Scan(),
@@ -55,5 +84,11 @@ var _ = Describe("返回任务", func() { @@ -55,5 +84,11 @@ var _ = Describe("返回任务", func() {
55 Expect(err1).NotTo(HaveOccurred()) 84 Expect(err1).NotTo(HaveOccurred())
56 _, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true") 85 _, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
57 Expect(err2).NotTo(HaveOccurred()) 86 Expect(err2).NotTo(HaveOccurred())
  87 + _, err3 := pG.DB.Exec("DELETE FROM project_belongs WHERE true")
  88 + Expect(err3).NotTo(HaveOccurred())
  89 + _, err4 := pG.DB.Exec("DELETE FROM task_natures WHERE true")
  90 + Expect(err4).NotTo(HaveOccurred())
  91 + _, err5 := pG.DB.Exec("DELETE FROM customer_values WHERE true")
  92 + Expect(err5).NotTo(HaveOccurred())
58 }) 93 })
59 }) 94 })
@@ -13,14 +13,44 @@ import ( @@ -13,14 +13,44 @@ import (
13 ) 13 )
14 14
15 var _ = Describe("返回任务列表", func() { 15 var _ = Describe("返回任务列表", func() {
  16 + var projectBelongId int
  17 + var taskNatureId int
  18 + var customerValueId1 int
  19 + var customerValueId2 int
  20 + var customerValueId3 int
16 BeforeEach(func() { 21 BeforeEach(func() {
  22 + _, err8 := pG.DB.QueryOne(
  23 + pg.Scan(&projectBelongId),
  24 + "INSERT INTO project_belongs (project_belong_name, company_id) VALUES (?, ?) RETURNING id",
  25 + "能力展示", 101)
  26 + Expect(err8).NotTo(HaveOccurred())
  27 + _, err9 := pG.DB.QueryOne(
  28 + pg.Scan(&customerValueId1),
  29 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  30 + "口味", 101)
  31 + Expect(err9).NotTo(HaveOccurred())
  32 + _, err10 := pG.DB.QueryOne(
  33 + pg.Scan(&customerValueId2),
  34 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  35 + "口感", 101)
  36 + Expect(err10).NotTo(HaveOccurred())
  37 + _, err11 := pG.DB.QueryOne(
  38 + pg.Scan(&customerValueId3),
  39 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  40 + "性价比", 101)
  41 + Expect(err11).NotTo(HaveOccurred())
  42 + _, err12 := pG.DB.QueryOne(
  43 + pg.Scan(&taskNatureId),
  44 + "INSERT INTO task_natures (task_nature_name, company_id) VALUES (?, ?) RETURNING id",
  45 + "点", 101)
  46 + Expect(err12).NotTo(HaveOccurred())
17 dayAfter, _ := time.ParseDuration("72h") 47 dayAfter, _ := time.ParseDuration("72h")
18 _, err := pG.DB.QueryOne( 48 _, err := pG.DB.QueryOne(
19 pg.Scan(), 49 pg.Scan(),
20 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 50 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
21 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 51 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
22 Uid: 2499036607974745088, 52 Uid: 2499036607974745088,
23 - }, 1, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 53 + }, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
24 { 54 {
25 Uid: 2499036607974745077, 55 Uid: 2499036607974745077,
26 }, 56 },
@@ -31,30 +61,30 @@ var _ = Describe("返回任务列表", func() { @@ -31,30 +61,30 @@ var _ = Describe("返回任务列表", func() {
31 Expect(err).NotTo(HaveOccurred()) 61 Expect(err).NotTo(HaveOccurred())
32 _, err1 := pG.DB.QueryOne( 62 _, err1 := pG.DB.QueryOne(
33 pg.Scan(), 63 pg.Scan(),
34 - "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 64 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
35 2, 101, "抢单任务2", 1, &domain.EmployeeInfo{ 65 2, 101, "抢单任务2", 1, &domain.EmployeeInfo{
36 Uid: 2499036607974745088, 66 Uid: 2499036607974745088,
37 - }, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) 67 + }, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
38 _, err2 := pG.DB.QueryOne( 68 _, err2 := pG.DB.QueryOne(
39 pg.Scan(), 69 pg.Scan(),
40 - "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 70 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
41 3, 102, "竞标任务1", 2, &domain.EmployeeInfo{ 71 3, 102, "竞标任务1", 2, &domain.EmployeeInfo{
42 Uid: 2499036607974745088, 72 Uid: 2499036607974745088,
43 - }, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) 73 + }, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
44 Expect(err2).NotTo(HaveOccurred()) 74 Expect(err2).NotTo(HaveOccurred())
45 _, err3 := pG.DB.QueryOne( 75 _, err3 := pG.DB.QueryOne(
46 pg.Scan(), 76 pg.Scan(),
47 - "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 77 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, 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 4, 101, "竞标任务1", 2, &domain.EmployeeInfo{ 78 4, 101, "竞标任务1", 2, &domain.EmployeeInfo{
49 Uid: 2499036607974745099, 79 Uid: 2499036607974745099,
50 - }, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) 80 + }, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
51 Expect(err3).NotTo(HaveOccurred()) 81 Expect(err3).NotTo(HaveOccurred())
52 _, err4 := pG.DB.QueryOne( 82 _, err4 := pG.DB.QueryOne(
53 pg.Scan(), 83 pg.Scan(),
54 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 84 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
55 5, 303, "抢单任务1", 1, &domain.EmployeeInfo{ 85 5, 303, "抢单任务1", 1, &domain.EmployeeInfo{
56 Uid: 2499036607974745088, 86 Uid: 2499036607974745088,
57 - }, 6, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 87 + }, 6, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
58 { 88 {
59 Uid: 2499036607974745077, 89 Uid: 2499036607974745077,
60 }, 90 },
@@ -64,11 +94,11 @@ var _ = Describe("返回任务列表", func() { @@ -64,11 +94,11 @@ var _ = Describe("返回任务列表", func() {
64 }, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter)) 94 }, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
65 Expect(err4).NotTo(HaveOccurred()) 95 Expect(err4).NotTo(HaveOccurred())
66 Expect(err1).NotTo(HaveOccurred()) 96 Expect(err1).NotTo(HaveOccurred())
67 - _, err11 := pG.DB.QueryOne( 97 + _, err111 := pG.DB.QueryOne(
68 pg.Scan(), 98 pg.Scan(),
69 "INSERT INTO bid_infos (id, task_id, bid_start_time, bid_end_time) VALUES (?, ?, ?, ?)", 99 "INSERT INTO bid_infos (id, task_id, bid_start_time, bid_end_time) VALUES (?, ?, ?, ?)",
70 1, 4, time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), time.Date(2020, time.Month(4), 10, 8, 0, 0, 0, time.Now().Location())) 100 1, 4, time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), time.Date(2020, time.Month(4), 10, 8, 0, 0, 0, time.Now().Location()))
71 - Expect(err11).NotTo(HaveOccurred()) 101 + Expect(err111).NotTo(HaveOccurred())
72 _, err22 := pG.DB.QueryOne( 102 _, err22 := pG.DB.QueryOne(
73 pg.Scan(), 103 pg.Scan(),
74 "INSERT INTO bidder_infos (id, bid_info_id, task_id) VALUES (?, ?, ?)", 104 "INSERT INTO bidder_infos (id, bid_info_id, task_id) VALUES (?, ?, ?)",
@@ -134,7 +164,7 @@ var _ = Describe("返回任务列表", func() { @@ -134,7 +164,7 @@ var _ = Describe("返回任务列表", func() {
134 httpExpect.GET("/tasks/"). 164 httpExpect.GET("/tasks/").
135 WithQuery("companyId", 101). 165 WithQuery("companyId", 101).
136 WithQuery("sponsor", 2499036607974745088). 166 WithQuery("sponsor", 2499036607974745088).
137 - WithQuery("taskContentMatch", "售后服务"). 167 + WithQuery("taskContentMatch", "任务2").
138 WithQuery("taskType", 1). 168 WithQuery("taskType", 1).
139 WithQuery("offset", 0). 169 WithQuery("offset", 0).
140 WithQuery("limit", 20). 170 WithQuery("limit", 20).
@@ -245,5 +275,11 @@ var _ = Describe("返回任务列表", func() { @@ -245,5 +275,11 @@ var _ = Describe("返回任务列表", func() {
245 Expect(err1).NotTo(HaveOccurred()) 275 Expect(err1).NotTo(HaveOccurred())
246 _, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true") 276 _, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
247 Expect(err2).NotTo(HaveOccurred()) 277 Expect(err2).NotTo(HaveOccurred())
  278 + _, err3 := pG.DB.Exec("DELETE FROM project_belongs WHERE true")
  279 + Expect(err3).NotTo(HaveOccurred())
  280 + _, err4 := pG.DB.Exec("DELETE FROM task_natures WHERE true")
  281 + Expect(err4).NotTo(HaveOccurred())
  282 + _, err5 := pG.DB.Exec("DELETE FROM customer_values WHERE true")
  283 + Expect(err5).NotTo(HaveOccurred())
248 }) 284 })
249 }) 285 })
@@ -19,10 +19,10 @@ var _ = Describe("关闭任务", func() { @@ -19,10 +19,10 @@ var _ = Describe("关闭任务", func() {
19 dayAfter, _ := time.ParseDuration("72h") 19 dayAfter, _ := time.ParseDuration("72h")
20 _, err := pG.DB.QueryOne( 20 _, err := pG.DB.QueryOne(
21 pg.Scan(), 21 pg.Scan(),
22 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 22 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
23 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 23 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
24 Uid: 2499036607974745088, 24 Uid: 2499036607974745088,
25 - }, 3, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 25 + }, 3, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
26 { 26 {
27 Uid: 2499036607974745077, 27 Uid: 2499036607974745077,
28 }, 28 },
@@ -60,10 +60,10 @@ var _ = Describe("关闭任务", func() { @@ -60,10 +60,10 @@ var _ = Describe("关闭任务", func() {
60 dayAfter, _ := time.ParseDuration("72h") 60 dayAfter, _ := time.ParseDuration("72h")
61 _, err := pG.DB.QueryOne( 61 _, err := pG.DB.QueryOne(
62 pg.Scan(), 62 pg.Scan(),
63 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 63 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
64 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 64 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
65 Uid: 2499036607974745088, 65 Uid: 2499036607974745088,
66 - }, 6, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 66 + }, 6, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
67 { 67 {
68 Uid: 2499036607974745077, 68 Uid: 2499036607974745077,
69 }, 69 },
  1 +package task
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  5 + "net/http"
  6 + "time"
  7 +
  8 + "github.com/gavv/httpexpect"
  9 + "github.com/go-pg/pg"
  10 + . "github.com/onsi/ginkgo"
  11 + . "github.com/onsi/gomega"
  12 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  13 +)
  14 +
  15 +var _ = Describe("驳回任务领取人", func() {
  16 + BeforeEach(func() {
  17 + dayAfter, _ := time.ParseDuration("72h")
  18 + _, err := pG.DB.QueryOne(
  19 + pg.Scan(),
  20 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  21 + 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
  22 + Uid: 2499036607974745088,
  23 + }, 3, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
  24 + {
  25 + Uid: 2499036607974745077,
  26 + },
  27 + {
  28 + Uid: 2499036607974745066,
  29 + },
  30 + }, "null", "", pg.Array([]string{}), 0, time.Now(), time.Now().Add(dayAfter))
  31 + Expect(err).NotTo(HaveOccurred())
  32 + _, err1 := pG.DB.QueryOne(
  33 + pg.Scan(),
  34 + "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
  35 + 1, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0)
  36 + Expect(err1).NotTo(HaveOccurred())
  37 + _, err2 := pG.DB.QueryOne(
  38 + pg.Scan(),
  39 + "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
  40 + 2, 101, 2499036607974745099, "testEmployeeName", "testEmployeeAccount", 0)
  41 + Expect(err2).NotTo(HaveOccurred())
  42 + _, err3 := pG.DB.QueryOne(
  43 + pg.Scan(),
  44 + "INSERT INTO rob_infos (id, task_id ,receiver) VALUES (?, ?, ?)",
  45 + 1, 1, &domain.EmployeeInfo{
  46 + Uid: 2499036607974745099,
  47 + })
  48 + Expect(err3).NotTo(HaveOccurred())
  49 + })
  50 + Describe("驳回任务领取人", func() {
  51 + Context("任务发布人驳回任务领取人", func() {
  52 + It("驳回成功", func() {
  53 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  54 + body := map[string]interface{}{
  55 + "operator": 2499036607974745088,
  56 + "rejectReason": "看你不爽",
  57 + }
  58 + httpExpect.POST("/tasks/1/reject-task-receiver").
  59 + WithJSON(body).
  60 + Expect().
  61 + Status(http.StatusOK).
  62 + JSON().
  63 + Object().
  64 + ContainsKey("code").ValueEqual("code", 0).
  65 + ContainsKey("msg").ValueEqual("msg", "ok").
  66 + ContainsKey("data").Value("data").Object().
  67 + ContainsKey("taskStatus").ValueEqual("taskStatus", 2)
  68 + })
  69 + })
  70 + })
  71 + AfterEach(func() {
  72 + _, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
  73 + Expect(err).NotTo(HaveOccurred())
  74 + _, err1 := pG.DB.Exec("DELETE FROM bid_infos WHERE true")
  75 + Expect(err1).NotTo(HaveOccurred())
  76 + _, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
  77 + Expect(err2).NotTo(HaveOccurred())
  78 + _, err3 := pG.DB.Exec("DELETE FROM employees WHERE true")
  79 + Expect(err3).NotTo(HaveOccurred())
  80 + _, err4 := pG.DB.Exec("DELETE FROM rob_infos WHERE true")
  81 + Expect(err4).NotTo(HaveOccurred())
  82 + _, err5 := pG.DB.Exec("DELETE FROM reject_task_records WHERE true")
  83 + Expect(err5).NotTo(HaveOccurred())
  84 + })
  85 +})
@@ -18,7 +18,7 @@ var _ = Describe("发布任务", func() { @@ -18,7 +18,7 @@ var _ = Describe("发布任务", func() {
18 dayAfter, _ := time.ParseDuration("72h") 18 dayAfter, _ := time.ParseDuration("72h")
19 _, err := pG.DB.QueryOne( 19 _, err := pG.DB.QueryOne(
20 pg.Scan(), 20 pg.Scan(),
21 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 21 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
22 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 22 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
23 Uid: 2499036607974745088, 23 Uid: 2499036607974745088,
24 }, 1, &domain.ReferenceResource{ 24 }, 1, &domain.ReferenceResource{
@@ -28,7 +28,7 @@ var _ = Describe("发布任务", func() { @@ -28,7 +28,7 @@ var _ = Describe("发布任务", func() {
28 ReferenceResourceId: 4, 28 ReferenceResourceId: 4,
29 }, 29 },
30 }, 30 },
31 - }, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 31 + }, 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
32 { 32 {
33 Uid: 2499036607974745077, 33 Uid: 2499036607974745077,
34 }, 34 },
@@ -65,10 +65,10 @@ var _ = Describe("发布任务", func() { @@ -65,10 +65,10 @@ var _ = Describe("发布任务", func() {
65 dayAfter, _ := time.ParseDuration("72h") 65 dayAfter, _ := time.ParseDuration("72h")
66 _, err := pG.DB.QueryOne( 66 _, err := pG.DB.QueryOne(
67 pg.Scan(), 67 pg.Scan(),
68 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 68 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
69 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 69 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
70 Uid: 2499036607974745088, 70 Uid: 2499036607974745088,
71 - }, 3, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 71 + }, 3, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
72 { 72 {
73 Uid: 2499036607974745077, 73 Uid: 2499036607974745077,
74 }, 74 },
@@ -103,7 +103,7 @@ var _ = Describe("发布任务", func() { @@ -103,7 +103,7 @@ var _ = Describe("发布任务", func() {
103 dayAfter, _ := time.ParseDuration("72h") 103 dayAfter, _ := time.ParseDuration("72h")
104 _, err := pG.DB.QueryOne( 104 _, err := pG.DB.QueryOne(
105 pg.Scan(), 105 pg.Scan(),
106 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 106 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
107 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 107 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
108 Uid: 2499036607974745088, 108 Uid: 2499036607974745088,
109 }, 2, &domain.ReferenceResource{ 109 }, 2, &domain.ReferenceResource{
@@ -113,7 +113,7 @@ var _ = Describe("发布任务", func() { @@ -113,7 +113,7 @@ var _ = Describe("发布任务", func() {
113 ReferenceResourceId: 4, 113 ReferenceResourceId: 4,
114 }, 114 },
115 }, 115 },
116 - }, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 116 + }, 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
117 { 117 {
118 Uid: 2499036607974745077, 118 Uid: 2499036607974745077,
119 }, 119 },
@@ -129,7 +129,7 @@ var _ = Describe("发布任务", func() { @@ -129,7 +129,7 @@ var _ = Describe("发布任务", func() {
129 Expect(err1).NotTo(HaveOccurred()) 129 Expect(err1).NotTo(HaveOccurred())
130 _, err2 := pG.DB.QueryOne( 130 _, err2 := pG.DB.QueryOne(
131 pg.Scan(), 131 pg.Scan(),
132 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 132 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
133 2, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 133 2, 101, "抢单任务1", 1, &domain.EmployeeInfo{
134 Uid: 2499036607974745088, 134 Uid: 2499036607974745088,
135 }, 2, &domain.ReferenceResource{ 135 }, 2, &domain.ReferenceResource{
@@ -139,7 +139,7 @@ var _ = Describe("发布任务", func() { @@ -139,7 +139,7 @@ var _ = Describe("发布任务", func() {
139 ReferenceResourceId: 4, 139 ReferenceResourceId: 4,
140 }, 140 },
141 }, 141 },
142 - }, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 142 + }, 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
143 { 143 {
144 Uid: 2499036607974745077, 144 Uid: 2499036607974745077,
145 }, 145 },
@@ -164,6 +164,60 @@ var _ = Describe("发布任务", func() { @@ -164,6 +164,60 @@ var _ = Describe("发布任务", func() {
164 ContainsKey("msg").ValueEqual("msg", "内部服务出错:问题资源已经被引用,发布任务失败") 164 ContainsKey("msg").ValueEqual("msg", "内部服务出错:问题资源已经被引用,发布任务失败")
165 }) 165 })
166 }) 166 })
  167 + Context("任务发起者发布待发布的指派任务", func() {
  168 + BeforeEach(func() {
  169 + dayAfter, _ := time.ParseDuration("72h")
  170 + _, err := pG.DB.QueryOne(
  171 + pg.Scan(),
  172 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time, assigned_person, planned_completion_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  173 + 1, 101, "抢单任务1", 3, &domain.EmployeeInfo{
  174 + Uid: 2499036607974745088,
  175 + }, 1, &domain.ReferenceResource{
  176 + ReferenceResourceType: 1,
  177 + ReferenceResourceItems: []*domain.ReferenceResourceItem{
  178 + {
  179 + ReferenceResourceId: 4,
  180 + },
  181 + },
  182 + }, 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
  183 + {
  184 + Uid: 2499036607974745077,
  185 + },
  186 + {
  187 + Uid: 2499036607974745066,
  188 + },
  189 + }, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter), &domain.EmployeeInfo{
  190 + Uid: 2499036607974745099,
  191 + }, time.Now())
  192 + Expect(err).NotTo(HaveOccurred())
  193 + _, err1 := pG.DB.QueryOne(
  194 + pg.Scan(),
  195 + "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
  196 + 1, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0)
  197 + Expect(err1).NotTo(HaveOccurred())
  198 + _, err2 := pG.DB.QueryOne(
  199 + pg.Scan(),
  200 + "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
  201 + 2, 101, 2499036607974745099, "testEmployeeName", "testEmployeeAccount", 0)
  202 + Expect(err2).NotTo(HaveOccurred())
  203 + })
  204 + It("发布任务成功", func() {
  205 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  206 + body := map[string]interface{}{
  207 + "operator": 2499036607974745088,
  208 + }
  209 + httpExpect.POST("/tasks/1/release").
  210 + WithJSON(body).
  211 + Expect().
  212 + Status(http.StatusOK).
  213 + JSON().
  214 + Object().
  215 + ContainsKey("code").ValueEqual("code", 0).
  216 + ContainsKey("msg").ValueEqual("msg", "ok").
  217 + ContainsKey("data").Value("data").Object().
  218 + ContainsKey("taskStatus").ValueEqual("taskStatus", 3)
  219 + })
  220 + })
167 }) 221 })
168 AfterEach(func() { 222 AfterEach(func() {
169 _, err := pG.DB.Exec("DELETE FROM tasks WHERE true") 223 _, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
1 package task 1 package task
2 2
3 import ( 3 import (
  4 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
4 "net/http" 5 "net/http"
  6 + "time"
5 7
6 "github.com/gavv/httpexpect" 8 "github.com/gavv/httpexpect"
7 "github.com/go-pg/pg" 9 "github.com/go-pg/pg"
@@ -12,10 +14,13 @@ import ( @@ -12,10 +14,13 @@ import (
12 14
13 var _ = Describe("移除任务", func() { 15 var _ = Describe("移除任务", func() {
14 BeforeEach(func() { 16 BeforeEach(func() {
  17 + dayAfter, _ := time.ParseDuration("72h")
15 _, err := pG.DB.QueryOne( 18 _, err := pG.DB.QueryOne(
16 pg.Scan(), 19 pg.Scan(),
17 - "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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",  
18 - 1, 101, "testTaskName", 1, "{}", 3, "null", pg.Array([]string{"口感"}), "testTaskNature", 100.00, "testAcceptanceStandard", "testTaskDescription", pg.Array([]string{"url"}), false) 20 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  21 + 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
  22 + Uid: 2499036607974745088,
  23 + }, 1, "null", 1, pg.Array([]int{1, 2, 3}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
19 Expect(err).NotTo(HaveOccurred()) 24 Expect(err).NotTo(HaveOccurred())
20 }) 25 })
21 Describe("根据参数移除任务", func() { 26 Describe("根据参数移除任务", func() {
@@ -19,10 +19,10 @@ var _ = Describe("对任务进行抢单", func() { @@ -19,10 +19,10 @@ var _ = Describe("对任务进行抢单", func() {
19 dayAfter, _ := time.ParseDuration("72h") 19 dayAfter, _ := time.ParseDuration("72h")
20 _, err := pG.DB.QueryOne( 20 _, err := pG.DB.QueryOne(
21 pg.Scan(), 21 pg.Scan(),
22 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 22 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
23 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 23 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
24 Uid: 2499036607974745088, 24 Uid: 2499036607974745088,
25 - }, 2, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 25 + }, 2, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
26 { 26 {
27 Uid: 2499036607974745077, 27 Uid: 2499036607974745077,
28 }, 28 },
@@ -56,7 +56,7 @@ var _ = Describe("对任务进行抢单", func() { @@ -56,7 +56,7 @@ var _ = Describe("对任务进行抢单", func() {
56 ContainsKey("code").ValueEqual("code", 0). 56 ContainsKey("code").ValueEqual("code", 0).
57 ContainsKey("msg").ValueEqual("msg", "ok"). 57 ContainsKey("msg").ValueEqual("msg", "ok").
58 ContainsKey("data").Value("data").Object(). 58 ContainsKey("data").Value("data").Object().
59 - ContainsKey("taskStatus").ValueEqual("taskStatus", 3). 59 + ContainsKey("taskStatus").ValueEqual("taskStatus", 7).
60 ContainsKey("robInfo").Value("robInfo").Object(). 60 ContainsKey("robInfo").Value("robInfo").Object().
61 ContainsKey("receiver").Value("receiver").Object(). 61 ContainsKey("receiver").Value("receiver").Object().
62 ContainsKey("uid").ValueEqual("uid", 2499036607974745099) 62 ContainsKey("uid").ValueEqual("uid", 2499036607974745099)
@@ -67,10 +67,10 @@ var _ = Describe("对任务进行抢单", func() { @@ -67,10 +67,10 @@ var _ = Describe("对任务进行抢单", func() {
67 dayAfter, _ := time.ParseDuration("72h") 67 dayAfter, _ := time.ParseDuration("72h")
68 _, err := pG.DB.QueryOne( 68 _, err := pG.DB.QueryOne(
69 pg.Scan(), 69 pg.Scan(),
70 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 70 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
71 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 71 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
72 Uid: 2499036607974745088, 72 Uid: 2499036607974745088,
73 - }, 2, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 73 + }, 2, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
74 { 74 {
75 Uid: 2499036607974745077, 75 Uid: 2499036607974745077,
76 }, 76 },
@@ -13,14 +13,44 @@ import ( @@ -13,14 +13,44 @@ import (
13 ) 13 )
14 14
15 var _ = Describe("搜索任务", func() { 15 var _ = Describe("搜索任务", func() {
  16 + var projectBelongId int
  17 + var taskNatureId int
  18 + var customerValueId1 int
  19 + var customerValueId2 int
  20 + var customerValueId3 int
16 BeforeEach(func() { 21 BeforeEach(func() {
  22 + _, err8 := pG.DB.QueryOne(
  23 + pg.Scan(&projectBelongId),
  24 + "INSERT INTO project_belongs (project_belong_name, company_id) VALUES (?, ?) RETURNING id",
  25 + "能力展示", 101)
  26 + Expect(err8).NotTo(HaveOccurred())
  27 + _, err9 := pG.DB.QueryOne(
  28 + pg.Scan(&customerValueId1),
  29 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  30 + "口味", 101)
  31 + Expect(err9).NotTo(HaveOccurred())
  32 + _, err10 := pG.DB.QueryOne(
  33 + pg.Scan(&customerValueId2),
  34 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  35 + "口感", 101)
  36 + Expect(err10).NotTo(HaveOccurred())
  37 + _, err11 := pG.DB.QueryOne(
  38 + pg.Scan(&customerValueId3),
  39 + "INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
  40 + "性价比", 101)
  41 + Expect(err11).NotTo(HaveOccurred())
  42 + _, err12 := pG.DB.QueryOne(
  43 + pg.Scan(&taskNatureId),
  44 + "INSERT INTO task_natures (task_nature_name, company_id) VALUES (?, ?) RETURNING id",
  45 + "点", 101)
  46 + Expect(err12).NotTo(HaveOccurred())
17 dayAfter, _ := time.ParseDuration("72h") 47 dayAfter, _ := time.ParseDuration("72h")
18 _, err := pG.DB.QueryOne( 48 _, err := pG.DB.QueryOne(
19 pg.Scan(), 49 pg.Scan(),
20 - "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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 50 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
21 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ 51 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
22 Uid: 2499036607974745088, 52 Uid: 2499036607974745088,
23 - }, 1, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ 53 + }, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
24 { 54 {
25 Uid: 2499036607974745077, 55 Uid: 2499036607974745077,
26 }, 56 },
@@ -31,17 +61,17 @@ var _ = Describe("搜索任务", func() { @@ -31,17 +61,17 @@ var _ = Describe("搜索任务", func() {
31 Expect(err).NotTo(HaveOccurred()) 61 Expect(err).NotTo(HaveOccurred())
32 _, err1 := pG.DB.QueryOne( 62 _, err1 := pG.DB.QueryOne(
33 pg.Scan(), 63 pg.Scan(),
34 - "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 64 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
35 2, 101, "抢单任务2", 1, &domain.EmployeeInfo{ 65 2, 101, "抢单任务2", 1, &domain.EmployeeInfo{
36 Uid: 2499036607974745088, 66 Uid: 2499036607974745088,
37 - }, 1, "null", pg.Array([]string{"口感", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) 67 + }, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
38 Expect(err1).NotTo(HaveOccurred()) 68 Expect(err1).NotTo(HaveOccurred())
39 _, err2 := pG.DB.QueryOne( 69 _, err2 := pG.DB.QueryOne(
40 pg.Scan(), 70 pg.Scan(),
41 - "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 71 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
42 3, 101, "竞标任务1", 2, &domain.EmployeeInfo{ 72 3, 101, "竞标任务1", 2, &domain.EmployeeInfo{
43 Uid: 2499036607974745088, 73 Uid: 2499036607974745088,
44 - }, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) 74 + }, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
45 Expect(err2).NotTo(HaveOccurred()) 75 Expect(err2).NotTo(HaveOccurred())
46 _, err3 := pG.DB.QueryOne( 76 _, err3 := pG.DB.QueryOne(
47 pg.Scan(), 77 pg.Scan(),
@@ -57,10 +87,10 @@ var _ = Describe("搜索任务", func() { @@ -57,10 +87,10 @@ var _ = Describe("搜索任务", func() {
57 Expect(err4).NotTo(HaveOccurred()) 87 Expect(err4).NotTo(HaveOccurred())
58 _, err5 := pG.DB.QueryOne( 88 _, err5 := pG.DB.QueryOne(
59 pg.Scan(), 89 pg.Scan(),
60 - "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 90 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
61 4, 101, "竞标任务1", 2, &domain.EmployeeInfo{ 91 4, 101, "竞标任务1", 2, &domain.EmployeeInfo{
62 Uid: 2499036607974745088, 92 Uid: 2499036607974745088,
63 - }, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) 93 + }, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
64 Expect(err5).NotTo(HaveOccurred()) 94 Expect(err5).NotTo(HaveOccurred())
65 _, err6 := pG.DB.QueryOne( 95 _, err6 := pG.DB.QueryOne(
66 pg.Scan(), 96 pg.Scan(),
@@ -82,10 +112,10 @@ var _ = Describe("搜索任务", func() { @@ -82,10 +112,10 @@ var _ = Describe("搜索任务", func() {
82 body := map[string]interface{}{ 112 body := map[string]interface{}{
83 "companyId": 101, 113 "companyId": 101,
84 "sponsor": 2499036607974745088, 114 "sponsor": 2499036607974745088,
85 - "customerValue": []string{  
86 - "售后服务",  
87 - "口感",  
88 - "品牌", 115 + "customerValues": []int{
  116 + customerValueId1,
  117 + customerValueId2,
  118 + customerValueId3,
89 }, 119 },
90 "offset": 0, 120 "offset": 0,
91 "limit": 20, 121 "limit": 20,
@@ -172,5 +202,11 @@ var _ = Describe("搜索任务", func() { @@ -172,5 +202,11 @@ var _ = Describe("搜索任务", func() {
172 Expect(err1).NotTo(HaveOccurred()) 202 Expect(err1).NotTo(HaveOccurred())
173 _, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true") 203 _, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
174 Expect(err2).NotTo(HaveOccurred()) 204 Expect(err2).NotTo(HaveOccurred())
  205 + _, err3 := pG.DB.Exec("DELETE FROM project_belongs WHERE true")
  206 + Expect(err3).NotTo(HaveOccurred())
  207 + _, err4 := pG.DB.Exec("DELETE FROM task_natures WHERE true")
  208 + Expect(err4).NotTo(HaveOccurred())
  209 + _, err5 := pG.DB.Exec("DELETE FROM customer_values WHERE true")
  210 + Expect(err5).NotTo(HaveOccurred())
175 }) 211 })
176 }) 212 })
@@ -16,8 +16,8 @@ var _ = Describe("更新任务", func() { @@ -16,8 +16,8 @@ var _ = Describe("更新任务", func() {
16 BeforeEach(func() { 16 BeforeEach(func() {
17 _, err := pG.DB.QueryOne( 17 _, err := pG.DB.QueryOne(
18 pg.Scan(), 18 pg.Scan(),
19 - "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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",  
20 - 1, 101, "testTaskName", 1, "{}", 1, "{}", pg.Array([]string{"口感"}), "testTaskNature", 100.00, "testAcceptanceStandard", "testTaskDescription", pg.Array([]string{"url"}), false) 19 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  20 + 1, 101, "testTaskName", 1, "{}", 1, "{}", 1, pg.Array([]int{1}), 1, 100.00, "testAcceptanceStandard", "testTaskDescription", pg.Array([]string{"url"}), false)
21 Expect(err).NotTo(HaveOccurred()) 21 Expect(err).NotTo(HaveOccurred())
22 }) 22 })
23 It("返回更新后的任务数据", func() { 23 It("返回更新后的任务数据", func() {
@@ -32,12 +32,13 @@ var _ = Describe("更新任务", func() { @@ -32,12 +32,13 @@ var _ = Describe("更新任务", func() {
32 {"serialNumber": 2, "title": "问题标题2"}, 32 {"serialNumber": 2, "title": "问题标题2"},
33 {"serialNumber": 3, "title": "问题标题3"}, 33 {"serialNumber": 3, "title": "问题标题3"},
34 }, 34 },
35 - "customerValue": []string{  
36 - "口味",  
37 - "色泽",  
38 - "商务服务", 35 + "projectBelong": 1,
  36 + "customerValues": []int{
  37 + 1,
  38 + 2,
  39 + 3,
39 }, 40 },
40 - "taskNature": "线", 41 + "taskNature": 1,
41 "suMoney": 1000.00, 42 "suMoney": 1000.00,
42 "acceptanceStandard": "验收标准", 43 "acceptanceStandard": "验收标准",
43 "taskDescription": "任务描述", 44 "taskDescription": "任务描述",
@@ -64,8 +65,8 @@ var _ = Describe("更新任务", func() { @@ -64,8 +65,8 @@ var _ = Describe("更新任务", func() {
64 BeforeEach(func() { 65 BeforeEach(func() {
65 _, err := pG.DB.QueryOne( 66 _, err := pG.DB.QueryOne(
66 pg.Scan(), 67 pg.Scan(),
67 - "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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",  
68 - 1, 101, "testTaskName", 1, "{}", 3, "null", pg.Array([]string{"口感"}), "testTaskNature", 100.00, "testAcceptanceStandard", "testTaskDescription", pg.Array([]string{"url"}), false) 68 + "INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, project_belong, customer_values, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  69 + 1, 101, "testTaskName", 1, "{}", 3, "null", 1, pg.Array([]int{1}), 1, 100.00, "testAcceptanceStandard", "testTaskDescription", pg.Array([]string{"url"}), false)
69 Expect(err).NotTo(HaveOccurred()) 70 Expect(err).NotTo(HaveOccurred())
70 }) 71 })
71 It("返回当前状态不能进行编辑操作的提示", func() { 72 It("返回当前状态不能进行编辑操作的提示", func() {
@@ -80,12 +81,13 @@ var _ = Describe("更新任务", func() { @@ -80,12 +81,13 @@ var _ = Describe("更新任务", func() {
80 {"serialNumber": 2, "title": "问题标题2"}, 81 {"serialNumber": 2, "title": "问题标题2"},
81 {"serialNumber": 3, "title": "问题标题3"}, 82 {"serialNumber": 3, "title": "问题标题3"},
82 }, 83 },
83 - "customerValue": []string{  
84 - "口味",  
85 - "色泽",  
86 - "商务服务", 84 + "projectBelong": 1,
  85 + "customerValues": []int{
  86 + 1,
  87 + 2,
  88 + 3,
87 }, 89 },
88 - "taskNature": "线", 90 + "taskNature": 1,
89 "suMoney": 1000.00, 91 "suMoney": 1000.00,
90 "acceptanceStandard": "验收标准", 92 "acceptanceStandard": "验收标准",
91 "taskDescription": "任务描述", 93 "taskDescription": "任务描述",