作者 linmadan

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

正在显示 60 个修改的文件 包含 2248 行增加203 行删除
... ... @@ -6,6 +6,22 @@ import (
domainService "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/domain_service"
)
func CreateRejectTaskReceiverService(options map[string]interface{}) (service.RejectTaskReceiverService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewRejectTaskReceiverService(transactionContext)
}
func CreateConfirmRobTaskService(options map[string]interface{}) (service.ConfirmRobTaskService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewConfirmRobTaskService(transactionContext)
}
func CreateReleaseTaskService(options map[string]interface{}) (service.ReleaseTaskService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
... ...
... ... @@ -61,3 +61,11 @@ func CreateProjectBelongRepository(options map[string]interface{}) (domain.Proje
}
return repository.NewProjectBelongRepository(transactionContext)
}
func CreateRejectTaskRecordRepository(options map[string]interface{}) (domain.RejectTaskRecordRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewRejectTaskRecordRepository(transactionContext)
}
... ...
... ... @@ -3,6 +3,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
"github.com/astaxie/beego/validation"
)
... ... @@ -22,6 +23,8 @@ type AcceptanceTaskCommand struct {
SolveReport string `json:"solveReport,omitempty"`
// 解决图片URL列表
SolvePictureUrls []string `json:"solvePictureUrls,omitempty"`
// 实际完成时间
ActualCompletionTime time.Time `json:"actualCompletionTime"`
}
//func (acceptanceTaskCommand *AcceptanceTaskCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"time"
"github.com/astaxie/beego/validation"
)
... ... @@ -13,12 +14,10 @@ type ChooseSuccessfulBidderCommand struct {
Operator int64 `json:"operator" valid:"Required"`
// 中标者uid
SuccessfulBidder int64 `json:"successfulBidder" valid:"Required"`
// 计划完成时间
PlannedCompletionTime time.Time `json:"plannedCompletionTime" valid:"Required"`
}
//func (chooseSuccessfulBidderCommand *ChooseSuccessfulBidderCommand) Valid(validation *validation.Validation) {
// validation.SetError("CustomValid", "未实现的自定义认证")
//}
func (chooseSuccessfulBidderCommand *ChooseSuccessfulBidderCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(chooseSuccessfulBidderCommand)
... ...
package command
import (
"fmt"
"time"
"github.com/astaxie/beego/validation"
)
type ConfirmRobTaskCommand struct {
// 任务ID
TaskId int64 `json:"taskId" valid:"Required"`
// 操作人uid
Operator int64 `json:"operator" valid:"Required"`
// 计划完成时间
PlannedCompletionTime time.Time `json:"plannedCompletionTime" valid:"Required"`
}
func (confirmRobTaskCommand *ConfirmRobTaskCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(confirmRobTaskCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -14,17 +14,19 @@ type CreateTaskCommand struct {
// 任务名称
TaskName string `json:"taskName" valid:"Required"`
// 任务类型
TaskType int `json:"taskType" valid:"Required"`
TaskType int `json:"taskType,omitempty"`
// 任务发起者uid
Sponsor int64 `json:"sponsor" valid:"Required"`
// 引用类型
ReferenceResourceType int `json:"referenceResourceType,omitempty"`
// 引用资源项列表
ReferenceResourceItems []*domain.ReferenceResourceItem `json:"referenceResourceItems,omitempty"`
// 项目归属
ProjectBelong int `json:"projectBelong,omitempty"`
// 客户价值列表
CustomerValue []string `json:"customerValue,omitempty"`
CustomerValues []int `json:"customerValues,omitempty"`
// 任务性质
TaskNature string `json:"taskNature,omitempty"`
TaskNature int `json:"taskNature,omitempty"`
// 奖励素币
SuMoney float64 `json:"suMoney,omitempty"`
// 验收标准
... ... @@ -39,12 +41,14 @@ type CreateTaskCommand struct {
BidStartTime time.Time `json:"bidStartTime,omitempty"`
// 竞标结束时间
BidEndTime time.Time `json:"bidEndTime,omitempty"`
// 是否截止时间前一天提醒
IsRemind bool `json:"isRemind,omitempty"`
// 计划完成时间
PlannedCompletionTime time.Time `json:"plannedCompletionTime,omitempty"`
// 指派人员uid
AssignedPerson int64 `json:"assignedPerson,omitempty"`
}
//func (createTaskCommand *CreateTaskCommand) Valid(validation *validation.Validation) {
// validation.SetError("CustomValid", "未实现的自定义认证")
//}
func (createTaskCommand *CreateTaskCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createTaskCommand)
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type RejectTaskReceiverCommand struct {
// 任务ID
TaskId int64 `json:"taskId" valid:"Required"`
// 操作人uid
Operator int64 `json:"operator" valid:"Required"`
// 驳回理由
RejectReason string `json:"rejectReason" valid:"Required"`
}
func (rejectTaskReceiverCommand *RejectTaskReceiverCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(rejectTaskReceiverCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -14,10 +14,12 @@ type SearchOffTaskRecordCommand struct {
TaskContentMatch string `json:"taskContentMatch,omitempty"`
// 任务类型
TaskType int `json:"taskType,omitempty"`
// 项目归属
ProjectBelongs []int `json:"projectBelongs,omitempty"`
// 客户价值
CustomerValue []string `json:"customerValue,omitempty"`
CustomerValues []int `json:"customerValues,omitempty"`
// 任务性质
TaskNature string `json:"taskNature,omitempty"`
TaskNatures []int `json:"taskNatures,omitempty"`
// 关闭任务时间区间-开始时间
OffStartTime time.Time `json:"offStartTime,omitempty"`
// 关闭任务时间区间-截止时间
... ...
package command
import (
"fmt"
"time"
"github.com/astaxie/beego/validation"
)
type SearchRejectTaskRecordCommand struct {
// 公司ID
CompanyId int64 `json:"companyId" valid:"Required"`
// 任务内容匹配
TaskContentMatch string `json:"taskContentMatch,omitempty"`
// 任务类型
TaskType int `json:"taskType,omitempty"`
// 项目归属
ProjectBelongs []int `json:"projectBelongs,omitempty"`
// 客户价值
CustomerValues []int `json:"customerValues,omitempty"`
// 任务性质
TaskNatures []int `json:"taskNatures,omitempty"`
// 驳回任务时间区间-开始时间
RejectStartTime time.Time `json:"rejectStartTime,omitempty"`
// 驳回任务时间区间-截止时间
RejectEndTime time.Time `json:"rejectEndTime,omitempty"`
// 查询偏离量
Offset int `json:"offset,omitempty"`
// 查询限制
Limit int `json:"limit,omitempty"`
}
func (searchRejectTaskRecordCommand *SearchRejectTaskRecordCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(searchRejectTaskRecordCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -9,7 +9,7 @@ import (
type SearchTaskCommand struct {
// 公司ID
CompanyId int64 `json:"companyId" valid:"Required"`
// 任务发起者
// 任务发起者UID
Sponsor int64 `json:"sponsor,omitempty"`
// 任务内容匹配
TaskContentMatch string `json:"taskContentMatch,omitempty"`
... ... @@ -17,36 +17,38 @@ type SearchTaskCommand struct {
TaskType int `json:"taskType,omitempty"`
// 任务状态
TaskStatus int `json:"taskStatus,omitempty"`
// 项目归属
ProjectBelongs []int `json:"projectBelongs,omitempty"`
// 客户价值
CustomerValue []string `json:"customerValue,omitempty"`
CustomerValues []int `json:"customerValues,omitempty"`
// 任务性质
TaskNature string `json:"taskNature,omitempty"`
TaskNatures []int `json:"taskNatures,omitempty"`
// 是否悬赏任务
IsRewardTake bool `json:"isRewardTake,omitempty"`
// 竞标参与者UID
Bidder int64 `json:"bidder,omitempty"`
// 竞标时间(1全部,2已截止,3未截止)
BidTimeMatch int `json:"bidTimeMatch,omitempty"`
// 任务领取人
// 任务领取人UID
Receiver int64 `json:"receiver,omitempty"`
// 任务参与者
// 任务参与者UID
Participator int64 `json:"participator,omitempty"`
//是否过滤关闭状态任务
// 指派人员UID
AssignedPerson int64 `json:"assignedPerson,omitempty"`
// 是否过滤关闭状态任务
IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"`
//是否过滤待发布状态任务
// 是否过滤待发布状态任务
IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"`
//按创建任务时间排序(ASC,DESC)
// 按创建任务时间排序(ASC,DESC)
SortByCreateTime string `json:"sortByCreateTime,omitempty"`
//按发布任务时间排序(ASC,DESC)
// 按发布任务时间排序(ASC,DESC)
SortByReleaseTime string `json:"sortByReleaseTime,omitempty"`
//按领取任务时间排序(ASC,DESC)
// 按领取任务时间排序(ASC,DESC)
SortByReceiveTime string `json:"sortByReceiveTime,omitempty"`
//按完成任务操作时间排序(ASC,DESC)
// 按完成任务操作时间排序(ASC,DESC)
SortByCompleteTime string `json:"sortByCompleteTime,omitempty"`
//按验收方验收时间排序(ASC,DESC)
// 按验收方验收时间排序(ASC,DESC)
SortByAcceptanceTime string `json:"sortByAcceptanceTime,omitempty"`
//按参与竞标时间排序(ASC,DESC)
SortByBidTime string `json:"sortByBidTime,omitempty"`
// 查询偏离量
Offset int `json:"offset,omitempty"`
// 查询限制
... ...
... ... @@ -17,10 +17,12 @@ type UpdateTaskCommand struct {
ReferenceResourceType int `json:"referenceResourceType,omitempty"`
// 引用资源项列表
ReferenceResourceItems []*domain.ReferenceResourceItem `json:"referenceResourceItems,omitempty"`
// 项目归属
ProjectBelong int `json:"projectBelong,omitempty"`
// 客户价值列表
CustomerValue []string `json:"customerValue,omitempty"`
CustomerValues []int `json:"customerValues,omitempty"`
// 任务性质
TaskNature string `json:"taskNature,omitempty"`
TaskNature int `json:"taskNature,omitempty"`
// 奖励素币
SuMoney float64 `json:"suMoney,omitempty"`
// 验收标准
... ... @@ -35,12 +37,14 @@ type UpdateTaskCommand struct {
BidStartTime time.Time `json:"bidStartTime,omitempty"`
// 竞标结束时间
BidEndTime time.Time `json:"bidEndTime,omitempty"`
// 是否截止时间前一天提醒
IsRemind bool `json:"isRemind,omitempty"`
// 计划完成时间
PlannedCompletionTime time.Time `json:"plannedCompletionTime,omitempty"`
// 指派人员uid
AssignedPerson int64 `json:"assignedPerson,omitempty"`
}
//func (updateTaskCommand *UpdateTaskCommand) Valid(validation *validation.Validation) {
// validation.SetError("CustomValid", "未实现的自定义认证")
//}
func (updateTaskCommand *UpdateTaskCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateTaskCommand)
... ...
package dto
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type OffTaskRecordDto struct {
// 关闭任务记录ID
OffTaskRecordId int64 `json:"offTaskRecordId"`
// 任务
Task *TaskDto `json:"task"`
// 操作人
Operator *domain.EmployeeInfo `json:"operator"`
// 关闭理由
OffReason string `json:"offReason"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
func (dto *OffTaskRecordDto) LoadDto(offTaskRecord *domain.OffTaskRecord, projectBelongMap map[int]*domain.ProjectBelong, customerValueMap map[int]*domain.CustomerValue, taskNatureMap map[int]*domain.TaskNature) error {
dto.OffTaskRecordId = offTaskRecord.OffTaskRecordId
taskDto := &TaskDto{}
if err := taskDto.LoadDto(offTaskRecord.Task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
return err
}
dto.Task = taskDto
dto.Operator = offTaskRecord.Operator
dto.OffReason = offTaskRecord.OffReason
dto.CreateTime = offTaskRecord.CreateTime
return nil
}
... ...
package dto
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type RejectTaskRecordDto struct {
// 关闭任务记录ID
RejectTaskRecordId int64 `json:"rejectTaskRecordId"`
// 任务
Task *TaskDto `json:"task"`
// 操作人
Operator *domain.EmployeeInfo `json:"operator"`
// 关闭理由
RejectReason string `json:"rejectReason"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
func (dto *RejectTaskRecordDto) LoadDto(rejectTaskRecord *domain.RejectTaskRecord, projectBelongMap map[int]*domain.ProjectBelong, customerValueMap map[int]*domain.CustomerValue, taskNatureMap map[int]*domain.TaskNature) error {
dto.RejectTaskRecordId = rejectTaskRecord.RejectTaskRecordId
taskDto := &TaskDto{}
if err := taskDto.LoadDto(rejectTaskRecord.Task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
return err
}
dto.Task = taskDto
dto.Operator = rejectTaskRecord.Operator
dto.RejectReason = rejectTaskRecord.RejectReason
dto.CreateTime = rejectTaskRecord.CreateTime
return nil
}
... ...
package dto
import (
"fmt"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type TaskDto struct {
// 任务ID
TaskId int64 `json:"taskId"`
// 公司ID
CompanyId int64 `json:"companyId"`
// 任务名称
TaskName string `json:"taskName"`
// 任务类型Type
TaskType int `json:"taskType"`
// 任务发起者
Sponsor *domain.EmployeeInfo `json:"sponsor"`
// 任务状态
TaskStatus int `json:"taskStatus"`
// 引用资源
ReferenceResource *domain.ReferenceResource `json:"referenceResource"`
// 项目归属
ProjectBelong *domain.ProjectBelong `json:"projectBelong"`
// 客户价值列表
CustomerValues []*domain.CustomerValue `json:"customerValues"`
// 任务性质
TaskNature *domain.TaskNature `json:"taskNature"`
// 奖励素币
SuMoney float64 `json:"suMoney"`
// 验收标准
AcceptanceStandard string `json:"acceptanceStandard"`
// 任务描述
TaskDescription string `json:"taskDescription"`
// 任务图片URL列表
TaskPictureUrls []string `json:"taskPictureUrls"`
// 是否悬赏任务
IsRewardTake bool `json:"isRewardTake"`
// 抢单任务信息
RobInfo *domain.RobInfo `json:"robInfo"`
// 竞标任务信息
BidInfo *domain.BidInfo `json:"bidInfo"`
// 任务参与者列表
Participators []*domain.EmployeeInfo `json:"participators"`
// 任务贡献占比
TaskPercentage []*domain.TaskPercentageItem `json:"taskPercentage"`
// 解决报告
SolveReport string `json:"solveReport"`
// 解决图片URL列表
SolvePictureUrls []string `json:"solvePictureUrls"`
// 指派人员
AssignedPerson *domain.EmployeeInfo `json:"assignedPerson"`
// 计划完成时间
PlannedCompletionTime time.Time `json:"plannedCompletionTime"`
// 实际完成时间
ActualCompletionTime time.Time `json:"actualCompletionTime"`
// 创建时间
CreateTime time.Time `json:"createTime"`
// 发布任务时间
ReleaseTime time.Time `json:"releaseTime"`
// 领取任务时间
ReceiveTime time.Time `json:"receiveTime"`
// 完成任务操作时间
CompleteTime time.Time `json:"completeTime"`
// 验收方验收时间
AcceptanceTime time.Time `json:"acceptanceTime"`
}
func (dto *TaskDto) LoadDto(task *domain.Task, projectBelongMap map[int]*domain.ProjectBelong, customerValueMap map[int]*domain.CustomerValue, taskNatureMap map[int]*domain.TaskNature) error {
dto.TaskId = task.TaskId
dto.CompanyId = task.CompanyId
dto.TaskName = task.TaskName
dto.TaskType = task.TaskType
dto.Sponsor = task.Sponsor
dto.TaskStatus = task.TaskStatus
dto.ReferenceResource = task.ReferenceResource
if task.ProjectBelong != 0 {
if projectBelong, ok := projectBelongMap[task.ProjectBelong]; ok {
dto.ProjectBelong = projectBelong
} else {
return fmt.Errorf("无效的项目归属")
}
}
if len(task.CustomerValues) > 0 {
for _, customerValueId := range task.CustomerValues {
if customerValue, ok := customerValueMap[customerValueId]; ok {
dto.CustomerValues = append(dto.CustomerValues, customerValue)
} else {
return fmt.Errorf("无效的客户价值")
}
}
}
if task.TaskNature != 0 {
if taskNature, ok := taskNatureMap[task.TaskNature]; ok {
dto.TaskNature = taskNature
} else {
return fmt.Errorf("无效的任务性质")
}
}
dto.SuMoney = task.SuMoney
dto.AcceptanceStandard = task.AcceptanceStandard
dto.TaskDescription = task.TaskDescription
dto.TaskPictureUrls = task.TaskPictureUrls
dto.IsRewardTake = task.IsRewardTake
dto.RobInfo = task.RobInfo
dto.BidInfo = task.BidInfo
dto.Participators = task.Participators
dto.TaskPercentage = task.TaskPercentage
dto.SolveReport = task.SolveReport
dto.SolvePictureUrls = task.SolvePictureUrls
dto.AssignedPerson = task.AssignedPerson
dto.PlannedCompletionTime = task.PlannedCompletionTime
dto.ActualCompletionTime = task.ActualCompletionTime
dto.CreateTime = task.CreateTime
dto.ReleaseTime = task.ReleaseTime
dto.ReceiveTime = task.ReceiveTime
dto.CompleteTime = task.CompleteTime
dto.AcceptanceTime = task.AcceptanceTime
return nil
}
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type GetRejectTaskRecordQuery struct {
// 驳回任务记录ID
RejectTaskRecordId int64 `json:"rejectTaskRecordId" valid:"Required"`
}
func (getRejectTaskRecordQuery *GetRejectTaskRecordQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getRejectTaskRecordQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -7,6 +7,7 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/event/subscriber"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/dto"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
... ... @@ -18,6 +19,74 @@ import (
type TaskService struct {
}
// 对抢单任务进行确认
func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.ConfirmRobTaskCommand) (interface{}, error) {
if err := confirmRobTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var confirmRobTaskService service.ConfirmRobTaskService
if value, err := factory.CreateConfirmRobTaskService(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
confirmRobTaskService = value
//confirmRobTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
}
if task, err := confirmRobTaskService.Confirm(confirmRobTaskCommand.TaskId, confirmRobTaskCommand.Operator, confirmRobTaskCommand.PlannedCompletionTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return task, nil
}
}
// 驳回任务领取人
func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *command.RejectTaskReceiverCommand) (interface{}, error) {
if err := rejectTaskReceiverCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var rejectTaskReceiverService service.RejectTaskReceiverService
if value, err := factory.CreateRejectTaskReceiverService(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rejectTaskReceiverService = value
//rejectTaskReceiverService.Subscribe(&subscriber.AbilityServiceSubscriber{})
}
if task, err := rejectTaskReceiverService.Reject(rejectTaskReceiverCommand.TaskId, rejectTaskReceiverCommand.Operator, rejectTaskReceiverCommand.RejectReason); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return task, nil
}
}
// 对任务进行抢单
func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand) (interface{}, error) {
if err := robTaskCommand.ValidateCommand(); err != nil {
... ... @@ -109,7 +178,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom
chooseSuccessfulBidderService = value
chooseSuccessfulBidderService.Subscribe(&subscriber.AbilityServiceSubscriber{})
}
if task, err := chooseSuccessfulBidderService.Choose(chooseSuccessfulBidderCommand.TaskId, chooseSuccessfulBidderCommand.SuccessfulBidder, chooseSuccessfulBidderCommand.Operator); err != nil {
if task, err := chooseSuccessfulBidderService.Choose(chooseSuccessfulBidderCommand.TaskId, chooseSuccessfulBidderCommand.SuccessfulBidder, chooseSuccessfulBidderCommand.Operator, chooseSuccessfulBidderCommand.PlannedCompletionTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -244,7 +313,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
acceptanceTaskService = value
acceptanceTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
}
if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls); err != nil {
if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls, acceptanceTaskCommand.ActualCompletionTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -277,15 +346,77 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
} else {
taskRepository = value
}
var projectBelongRepository domain.ProjectBelongRepository
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
projectBelongRepository = value
}
projectBelongMap := make(map[int]*domain.ProjectBelong)
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
"companyId": searchTaskCommand.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, projectBelong := range projectBelongs {
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
}
}
var customerValueRepository domain.CustomerValueRepository
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
customerValueRepository = value
}
customerValueMap := make(map[int]*domain.CustomerValue)
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
"companyId": searchTaskCommand.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, customerValue := range customerValues {
customerValueMap[customerValue.CustomerValueId] = customerValue
}
}
var taskNatureRepository domain.TaskNatureRepository
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
taskNatureRepository = value
}
taskNatureMap := make(map[int]*domain.TaskNature)
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
"companyId": searchTaskCommand.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, taskNature := range taskNatures {
taskNatureMap[taskNature.TaskNatureId] = taskNature
}
}
if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(searchTaskCommand)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var taskDtos []*dto.TaskDto
for _, task := range tasks {
taskDto := &dto.TaskDto{}
if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
taskDtos = append(taskDtos, taskDto)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"count": count,
"tasks": tasks,
"tasks": taskDtos,
}, nil
}
}
... ... @@ -305,6 +436,60 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
defer func() {
transactionContext.RollbackTransaction()
}()
var projectBelongRepository domain.ProjectBelongRepository
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
projectBelongRepository = value
}
projectBelongMap := make(map[int]*domain.ProjectBelong)
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
"companyId": searchOffTaskRecordCommand.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, projectBelong := range projectBelongs {
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
}
}
var customerValueRepository domain.CustomerValueRepository
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
customerValueRepository = value
}
customerValueMap := make(map[int]*domain.CustomerValue)
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
"companyId": searchOffTaskRecordCommand.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, customerValue := range customerValues {
customerValueMap[customerValue.CustomerValueId] = customerValue
}
}
var taskNatureRepository domain.TaskNatureRepository
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
taskNatureRepository = value
}
taskNatureMap := make(map[int]*domain.TaskNature)
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
"companyId": searchOffTaskRecordCommand.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, taskNature := range taskNatures {
taskNatureMap[taskNature.TaskNatureId] = taskNature
}
}
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -326,8 +511,9 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
"taskStatus": domain.TASK_STATUS_CLOSED,
"taskContentMatch": searchOffTaskRecordCommand.TaskContentMatch,
"taskType": searchOffTaskRecordCommand.TaskType,
"customerValue": searchOffTaskRecordCommand.CustomerValue,
"taskNature": searchOffTaskRecordCommand.TaskNature,
"projectBelongs": searchOffTaskRecordCommand.ProjectBelongs,
"customerValues": searchOffTaskRecordCommand.CustomerValues,
"taskNatures": searchOffTaskRecordCommand.TaskNatures,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -345,19 +531,25 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var offTaskRecordDtos []*dto.OffTaskRecordDto
for _, offTaskRecord := range offTaskRecords {
for _, task := range tasks {
if offTaskRecord.Task.TaskId == task.TaskId {
offTaskRecord.Task = task
}
}
offTaskRecordDto := &dto.OffTaskRecordDto{}
if err := offTaskRecordDto.LoadDto(offTaskRecord, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
offTaskRecordDtos = append(offTaskRecordDtos, offTaskRecordDto)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"count": count,
"offTaskRecords": offTaskRecords,
"offTaskRecords": offTaskRecordDtos,
}, nil
}
}
... ... @@ -399,6 +591,176 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge
}
}
// 搜索驳回任务记录
func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCommand *command.SearchRejectTaskRecordCommand) (interface{}, error) {
if err := searchRejectTaskRecordCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var projectBelongRepository domain.ProjectBelongRepository
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
projectBelongRepository = value
}
projectBelongMap := make(map[int]*domain.ProjectBelong)
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
"companyId": searchRejectTaskRecordCommand.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, projectBelong := range projectBelongs {
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
}
}
var customerValueRepository domain.CustomerValueRepository
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
customerValueRepository = value
}
customerValueMap := make(map[int]*domain.CustomerValue)
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
"companyId": searchRejectTaskRecordCommand.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, customerValue := range customerValues {
customerValueMap[customerValue.CustomerValueId] = customerValue
}
}
var taskNatureRepository domain.TaskNatureRepository
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
taskNatureRepository = value
}
taskNatureMap := make(map[int]*domain.TaskNature)
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
"companyId": searchRejectTaskRecordCommand.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, taskNature := range taskNatures {
taskNatureMap[taskNature.TaskNatureId] = taskNature
}
}
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
taskRepository = value
}
var rejectTaskRecordRepository domain.RejectTaskRecordRepository
if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rejectTaskRecordRepository = value
}
_, tasks, err := taskRepository.Find(map[string]interface{}{
"companyId": searchRejectTaskRecordCommand.CompanyId,
"taskStatus": domain.TASK_STATUS_CLOSED,
"taskContentMatch": searchRejectTaskRecordCommand.TaskContentMatch,
"taskType": searchRejectTaskRecordCommand.TaskType,
"projectBelongs": searchRejectTaskRecordCommand.ProjectBelongs,
"customerValues": searchRejectTaskRecordCommand.CustomerValues,
"taskNatures": searchRejectTaskRecordCommand.TaskNatures,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var taskIds []int64
for _, task := range tasks {
taskIds = append(taskIds, task.TaskId)
}
if count, rejectTaskRecords, err := rejectTaskRecordRepository.Find(map[string]interface{}{
"taskIds": taskIds,
"rejectStartTime": searchRejectTaskRecordCommand.RejectStartTime,
"rejectEndTime": searchRejectTaskRecordCommand.RejectEndTime,
"offset": searchRejectTaskRecordCommand.Offset,
"limit": searchRejectTaskRecordCommand.Limit,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var rejectTaskRecordDtos []*dto.RejectTaskRecordDto
for _, rejectTaskRecord := range rejectTaskRecords {
for _, task := range tasks {
if rejectTaskRecord.Task.TaskId == task.TaskId {
rejectTaskRecord.Task = task
}
}
rejectTaskRecordDto := &dto.RejectTaskRecordDto{}
if err := rejectTaskRecordDto.LoadDto(rejectTaskRecord, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
rejectTaskRecordDtos = append(rejectTaskRecordDtos, rejectTaskRecordDto)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"count": count,
"offTaskRecords": rejectTaskRecordDtos,
}, nil
}
}
// 返回驳回任务记录
func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *query.GetRejectTaskRecordQuery) (interface{}, error) {
if err := getRejectTaskRecordQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var rejectTaskRecordRepository domain.RejectTaskRecordRepository
if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rejectTaskRecordRepository = value
}
rejectTaskRecord, err := rejectTaskRecordRepository.FindOne(map[string]interface{}{"rejectTaskRecordId": getRejectTaskRecordQuery.RejectTaskRecordId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if rejectTaskRecord == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getRejectTaskRecordQuery.RejectTaskRecordId)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return rejectTaskRecord, nil
}
}
// 创建新任务
func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTaskCommand) (interface{}, error) {
if err := createTaskCommand.ValidateCommand(); err != nil {
... ... @@ -439,6 +801,19 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
if sponsor == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者")
}
var assignedPerson *domain.EmployeeInfo
if createTaskCommand.AssignedPerson != 0 {
employee, err := employeeRepository.FindOne(map[string]interface{}{
"uid": createTaskCommand.AssignedPerson,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if employee == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
}
assignedPerson = employee.EmployeeInfo
}
newTask := &domain.Task{
TaskStatus: domain.TASK_STATUS_UNRELEASED,
CompanyId: createTaskCommand.CompanyId,
... ... @@ -449,13 +824,16 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
ReferenceResourceType: createTaskCommand.ReferenceResourceType,
ReferenceResourceItems: createTaskCommand.ReferenceResourceItems,
},
CustomerValue: createTaskCommand.CustomerValue,
ProjectBelong: createTaskCommand.ProjectBelong,
CustomerValues: createTaskCommand.CustomerValues,
TaskNature: createTaskCommand.TaskNature,
SuMoney: createTaskCommand.SuMoney,
AcceptanceStandard: createTaskCommand.AcceptanceStandard,
TaskDescription: createTaskCommand.TaskDescription,
TaskPictureUrls: createTaskCommand.TaskPictureUrls,
IsRewardTake: createTaskCommand.IsRewardTake,
AssignedPerson: assignedPerson,
PlannedCompletionTime: createTaskCommand.PlannedCompletionTime,
CreateTime: time.Now(),
}
var taskRepository domain.TaskRepository
... ... @@ -487,7 +865,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if createTaskCommand.TaskType == domain.TASK_TYPE_BID {
if err := taskDao.AddBidInfo(task.TaskId, createTaskCommand.BidStartTime, createTaskCommand.BidEndTime); err != nil {
if err := taskDao.AddBidInfo(task.TaskId, createTaskCommand.BidStartTime, createTaskCommand.BidEndTime, createTaskCommand.IsRemind); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
... ... @@ -545,10 +923,68 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
if task == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getTaskQuery.TaskId)))
} else {
var projectBelongRepository domain.ProjectBelongRepository
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
projectBelongRepository = value
}
projectBelongMap := make(map[int]*domain.ProjectBelong)
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
"companyId": task.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, projectBelong := range projectBelongs {
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
}
}
var customerValueRepository domain.CustomerValueRepository
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
customerValueRepository = value
}
customerValueMap := make(map[int]*domain.CustomerValue)
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
"companyId": task.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, customerValue := range customerValues {
customerValueMap[customerValue.CustomerValueId] = customerValue
}
}
var taskNatureRepository domain.TaskNatureRepository
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
taskNatureRepository = value
}
taskNatureMap := make(map[int]*domain.TaskNature)
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
"companyId": task.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, taskNature := range taskNatures {
taskNatureMap[taskNature.TaskNatureId] = taskNature
}
}
taskDto := &dto.TaskDto{}
if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return task, nil
return taskDto, nil
}
}
... ... @@ -619,7 +1055,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if task.TaskType == domain.TASK_TYPE_BID {
if err := taskDao.UpdateBidInfo(updateTaskCommand.TaskId, updateTaskCommand.BidStartTime, updateTaskCommand.BidEndTime); err != nil {
if err := taskDao.UpdateBidInfo(updateTaskCommand.TaskId, updateTaskCommand.BidStartTime, updateTaskCommand.BidEndTime, updateTaskCommand.IsRemind); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
... ...
... ... @@ -12,6 +12,8 @@ type BidInfo struct {
BidStartTime time.Time `json:"bidStartTime"`
// 竞标结束时间
BidEndTime time.Time `json:"bidEndTime"`
//是否截止时间前一天提醒
IsRemind bool `json:"isRemind"`
// 中标时间
WinBidTime time.Time `json:"winBidTime"`
}
... ...
... ... @@ -23,10 +23,12 @@ type TaskReleased struct {
TaskStatus int `json:"taskStatus"`
// 引用资源
ReferenceResource *domain.ReferenceResource `json:"referenceResource"`
// 项目归属
ProjectBelong int `json:"projectBelong"`
// 客户价值列表
CustomerValue []string `json:"customerValue"`
CustomerValues []int `json:"customerValues"`
// 任务性质
TaskNature string `json:"taskNature"`
TaskNature int `json:"taskNature"`
// 奖励素币
SuMoney float64 `json:"suMoney"`
// 验收标准
... ...
package domain
import "time"
// 驳回任务记录
type RejectTaskRecord struct {
// 驳回任务记录ID
RejectTaskRecordId int64 `json:"rejectTaskRecordId"`
// 任务
Task *Task `json:"task"`
// 操作人
Operator *EmployeeInfo `json:"operator"`
// 驳回理由
RejectReason string `json:"rejectReason"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
type RejectTaskRecordRepository interface {
Save(rejectTaskRecord *RejectTaskRecord) (*RejectTaskRecord, error)
Remove(rejectTaskRecord *RejectTaskRecord) (*RejectTaskRecord, error)
FindOne(queryOptions map[string]interface{}) (*RejectTaskRecord, error)
Find(queryOptions map[string]interface{}) (int64, []*RejectTaskRecord, error)
}
func (rejectTaskRecord *RejectTaskRecord) Identify() interface{} {
if rejectTaskRecord.RejectTaskRecordId == 0 {
return nil
}
return rejectTaskRecord.RejectTaskRecordId
}
func (rejectTaskRecord *RejectTaskRecord) Update(data map[string]interface{}) error {
if rejectReason, ok := data["rejectReason"]; ok && rejectReason != "" {
rejectTaskRecord.RejectReason = rejectReason.(string)
}
return nil
}
... ...
... ... @@ -3,9 +3,10 @@ package service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type AcceptanceTaskService interface {
coreDomain.DomainEventPublisher
Acceptance(taskId int64, operatorUid int64, participators []int64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string) (*domain.Task, error)
Acceptance(taskId int64, operatorUid int64, participators []int64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) (*domain.Task, error)
}
... ...
... ... @@ -3,9 +3,10 @@ package service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type ChooseSuccessfulBidderService interface {
coreDomain.DomainEventPublisher
Choose(taskId int64, successfulBidderUid int64, operatorUid int64) (*domain.Task, error)
Choose(taskId int64, successfulBidderUid int64, operatorUid int64, plannedCompletionTime time.Time) (*domain.Task, error)
}
... ...
package service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type ConfirmRobTaskService interface {
coreDomain.DomainEventPublisher
Confirm(taskId int64, operatorUid int64, plannedCompletionTime time.Time) (*domain.Task, error)
}
... ...
package service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type RejectTaskReceiverService interface {
coreDomain.DomainEventPublisher
Reject(taskId int64, operatorUid int64, rejectReason string) (*domain.Task, error)
}
... ...
... ... @@ -42,10 +42,12 @@ type Task struct {
TaskStatus int `json:"taskStatus"`
// 引用资源
ReferenceResource *ReferenceResource `json:"referenceResource"`
// 项目归属
ProjectBelong int `json:"projectBelong"`
// 客户价值列表
CustomerValue []string `json:"customerValue"`
CustomerValues []int `json:"customerValues"`
// 任务性质
TaskNature string `json:"taskNature"`
TaskNature int `json:"taskNature"`
// 奖励素币
SuMoney float64 `json:"suMoney"`
// 验收标准
... ... @@ -68,6 +70,12 @@ type Task struct {
SolveReport string `json:"solveReport"`
// 解决图片URL列表
SolvePictureUrls []string `json:"solvePictureUrls"`
// 指派人员
AssignedPerson *EmployeeInfo `json:"assignedPerson"`
// 计划完成时间
PlannedCompletionTime time.Time `json:"plannedCompletionTime"`
// 实际完成时间
ActualCompletionTime time.Time `json:"actualCompletionTime"`
// 创建时间
CreateTime time.Time `json:"createTime"`
// 发布任务时间
... ... @@ -87,10 +95,12 @@ type TaskStatus interface {
Release(task *Task) error
Rob(task *Task, receiver *EmployeeInfo) error
Bib(task *Task, bidder *EmployeeInfo) error
ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error
ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error
ApplyComplete(task *Task) error
Off(task *Task) error
Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error
Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error
ConfirmTask(task *Task, plannedCompletionTime time.Time) error
RejectReceiver(task *Task) error
}
type UnReleasedStatus struct{}
... ... @@ -105,11 +115,14 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{})
if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
}
if customerValue, ok := data["customerValue"]; ok {
task.CustomerValue = customerValue.([]string)
if projectBelong, ok := data["projectBelong"]; ok {
task.ProjectBelong = projectBelong.(int)
}
if customerValues, ok := data["customerValues"]; ok {
task.CustomerValues = customerValues.([]int)
}
if taskNature, ok := data["taskNature"]; ok {
task.TaskNature = taskNature.(string)
task.TaskNature = taskNature.(int)
}
if suMoney, ok := data["suMoney"]; ok {
task.SuMoney = suMoney.(float64)
... ... @@ -121,6 +134,9 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{})
if bidEndTime, ok := data["bidEndTime"]; ok {
task.BidInfo.BidEndTime = bidEndTime.(time.Time)
}
if isRemind, ok := data["isRemind"]; ok {
task.BidInfo.IsRemind = isRemind.(bool)
}
}
if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
task.AcceptanceStandard = acceptanceStandard.(string)
... ... @@ -134,13 +150,26 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{})
if isRewardTake, ok := data["isRewardTake"]; ok {
task.IsRewardTake = isRewardTake.(bool)
}
if task.TaskType == TASK_TYPE_DESIGNATE {
if plannedCompletionTime, ok := data["plannedCompletionTime"]; ok {
task.PlannedCompletionTime = plannedCompletionTime.(time.Time)
}
if assignedPerson, ok := data["assignedPerson"]; ok {
task.AssignedPerson = assignedPerson.(*EmployeeInfo)
}
}
return nil
}
func (status *UnReleasedStatus) Release(task *Task) error {
task.ReleaseTime = time.Now()
if task.TaskType == TASK_TYPE_DESIGNATE {
task.TaskStatus = TASK_STATUS_UNDERWAY
task.CurrentStatus = &UnderwayStatus{}
} else {
task.TaskStatus = TASK_STATUS_UNCLAIMED
task.CurrentStatus = &UnClaimedStatus{}
}
return nil
}
... ... @@ -152,7 +181,7 @@ func (status *UnReleasedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("待发布的任务不允许竞标")
}
func (status *UnReleasedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error {
func (status *UnReleasedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("待发布的任务不允许选择竞标任务的中标人")
}
... ... @@ -164,10 +193,18 @@ func (status *UnReleasedStatus) Off(task *Task) error {
return fmt.Errorf("待发布的任务不允许关闭")
}
func (status *UnReleasedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error {
func (status *UnReleasedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("待发布的任务不允许验收")
}
func (status *UnReleasedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("待发布的任务不允许确认任务领取人")
}
func (status *UnReleasedStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("待发布的任务不允许驳回任务领取人")
}
type UnClaimedStatus struct{}
func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error {
... ... @@ -188,8 +225,8 @@ func (status *UnClaimedStatus) Rob(task *Task, receiver *EmployeeInfo) error {
ReceiveTime: currentTime,
}
task.ReceiveTime = currentTime
task.TaskStatus = TASK_STATUS_UNDERWAY
task.CurrentStatus = &UnderwayStatus{}
task.TaskStatus = TASK_STATUS_UNCONFIRMED
task.CurrentStatus = &UnConfirmedStatus{}
return nil
}
... ... @@ -216,7 +253,7 @@ func (status *UnClaimedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
}
}
func (status *UnClaimedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error {
func (status *UnClaimedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
if task.TaskType != TASK_TYPE_BID {
return fmt.Errorf("类型不符合的任务不允许选择竞中标人")
}
... ... @@ -228,6 +265,7 @@ func (status *UnClaimedStatus) ChooseSuccessfulBidder(task *Task, successfulBidd
task.BidInfo.WinBidTime = winBidTime
task.ReceiveTime = winBidTime
task.TaskStatus = TASK_STATUS_UNDERWAY
task.PlannedCompletionTime = plannedCompletionTime
task.CurrentStatus = &UnderwayStatus{}
return nil
}
... ... @@ -243,10 +281,18 @@ func (status *UnClaimedStatus) Off(task *Task) error {
return nil
}
func (status *UnClaimedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error {
func (status *UnClaimedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("待领取的任务不允许验收")
}
func (status *UnClaimedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("待领取的任务不允许确认任务领取人")
}
func (status *UnClaimedStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("待领取的任务不允许驳回任务领取人")
}
type UnderwayStatus struct{}
func (status *UnderwayStatus) Update(task *Task, data map[string]interface{}) error {
... ... @@ -265,7 +311,7 @@ func (status *UnderwayStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("进行中的任务不允许竞标")
}
func (status *UnderwayStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error {
func (status *UnderwayStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("进行中的任务不允许选择竞标任务的中标人")
}
... ... @@ -282,10 +328,32 @@ func (status *UnderwayStatus) Off(task *Task) error {
return nil
}
func (status *UnderwayStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error {
func (status *UnderwayStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("进行中的任务不允许验收")
}
func (status *UnderwayStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("进行中的任务不允许确认任务领取人")
}
func (status *UnderwayStatus) RejectReceiver(task *Task) error {
if task.TaskType == TASK_TYPE_DESIGNATE {
return fmt.Errorf("类型不符合的任务不允许驳回领取人")
}
if task.TaskType == TASK_TYPE_ROB {
task.RobInfo.Receiver = nil
task.RobInfo.ReceiveTime = time.Time{}
}
if task.TaskType == TASK_TYPE_BID {
task.BidInfo.SuccessfulBidder = nil
task.BidInfo.WinBidTime = time.Time{}
}
task.ReceiveTime = time.Time{}
task.TaskStatus = TASK_STATUS_UNCLAIMED
task.CurrentStatus = &UnClaimedStatus{}
return nil
}
type UnAcceptanceStatus struct{}
func (status *UnAcceptanceStatus) Update(task *Task, data map[string]interface{}) error {
... ... @@ -304,7 +372,7 @@ func (status *UnAcceptanceStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("待验收的任务不允许竞标")
}
func (status *UnAcceptanceStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error {
func (status *UnAcceptanceStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("待验收的任务不允许选择竞标任务的中标人")
}
... ... @@ -318,7 +386,7 @@ func (status *UnAcceptanceStatus) Off(task *Task) error {
return nil
}
func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error {
func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
task.Participators = participators
task.TaskPercentage = taskPercentage
task.SolveReport = solveReport
... ... @@ -333,12 +401,21 @@ func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*Employ
}
}
}
task.ActualCompletionTime = actualCompletionTime
task.TaskStatus = TASK_STATUS_COMPLETED
task.AcceptanceTime = time.Now()
task.CurrentStatus = &CompletedStatus{}
return nil
}
func (status *UnAcceptanceStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("待验收的任务不允许确认任务领取人")
}
func (status *UnAcceptanceStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("待验收的任务不允许驳回任务领取人")
}
type CompletedStatus struct{}
func (status *CompletedStatus) Update(task *Task, data map[string]interface{}) error {
... ... @@ -357,7 +434,7 @@ func (status *CompletedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("已完成的任务不允许竞标")
}
func (status *CompletedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error {
func (status *CompletedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("已完成的任务不允许选择竞标任务的中标人")
}
... ... @@ -369,10 +446,18 @@ func (status *CompletedStatus) Off(task *Task) error {
return fmt.Errorf("已完成的任务不允许申请完成任务")
}
func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error {
func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("已完成的任务不允许验收")
}
func (status *CompletedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("已完成的任务不允许确认任务领取人")
}
func (status *CompletedStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("已完成的任务不允许驳回任务领取人")
}
type ClosedStatus struct{}
func (status *ClosedStatus) Update(task *Task, data map[string]interface{}) error {
... ... @@ -391,7 +476,7 @@ func (status *ClosedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("已关闭的任务不允许竞标")
}
func (status *ClosedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo) error {
func (status *ClosedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("已关闭的任务不允许选择竞标任务的中标人")
}
... ... @@ -403,10 +488,73 @@ func (status *ClosedStatus) Off(task *Task) error {
return fmt.Errorf("已关闭的任务不允许关闭")
}
func (status *ClosedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error {
func (status *ClosedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("已关闭的任务不允许验收")
}
func (status *ClosedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("已关闭的任务不允许确认任务领取人")
}
func (status *ClosedStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("已关闭的任务不允许驳回任务领取人")
}
type UnConfirmedStatus struct{}
func (status *UnConfirmedStatus) Update(task *Task, data map[string]interface{}) error {
return fmt.Errorf("待确认的任务不允许编辑")
}
func (status *UnConfirmedStatus) Release(task *Task) error {
return fmt.Errorf("待确认的任务不允许重新发布")
}
func (status *UnConfirmedStatus) Rob(task *Task, receiver *EmployeeInfo) error {
return fmt.Errorf("待确认的任务不允许抢单")
}
func (status *UnConfirmedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("待确认的任务不允许竞标")
}
func (status *UnConfirmedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("待确认的任务不允许选择竞标任务的中标人")
}
func (status *UnConfirmedStatus) ApplyComplete(task *Task) error {
return fmt.Errorf("待确认的任务不允许申请完成任务")
}
func (status *UnConfirmedStatus) Off(task *Task) error {
task.TaskStatus = TASK_STATUS_CLOSED
task.CurrentStatus = &ClosedStatus{}
return nil
}
func (status *UnConfirmedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("待确认的任务不允许验收")
}
func (status *UnConfirmedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
task.PlannedCompletionTime = plannedCompletionTime
task.TaskStatus = TASK_STATUS_UNDERWAY
task.CurrentStatus = &UnderwayStatus{}
return nil
}
func (status *UnConfirmedStatus) RejectReceiver(task *Task) error {
if task.TaskType != TASK_TYPE_ROB {
return fmt.Errorf("类型不符合的任务不允许在待确认状态下驳回领取人")
}
task.RobInfo.Receiver = nil
task.RobInfo.ReceiveTime = time.Time{}
task.ReceiveTime = time.Time{}
task.TaskStatus = TASK_STATUS_UNCLAIMED
task.CurrentStatus = &UnClaimedStatus{}
return nil
}
type TaskRepository interface {
Save(task *Task) (*Task, error)
Remove(task *Task) (*Task, error)
... ... @@ -437,8 +585,8 @@ func (task *Task) Bib(bidder *EmployeeInfo) error {
return task.CurrentStatus.Bib(task, bidder)
}
func (task *Task) ChooseSuccessfulBidder(successfulBidder *EmployeeInfo) error {
return task.CurrentStatus.ChooseSuccessfulBidder(task, successfulBidder)
func (task *Task) ChooseSuccessfulBidder(successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return task.CurrentStatus.ChooseSuccessfulBidder(task, successfulBidder, plannedCompletionTime)
}
func (task *Task) ApplyComplete() error {
... ... @@ -449,6 +597,14 @@ func (task *Task) Off() error {
return task.CurrentStatus.Off(task)
}
func (task *Task) Acceptance(participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error {
return task.CurrentStatus.Acceptance(task, participators, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls)
func (task *Task) Acceptance(participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return task.CurrentStatus.Acceptance(task, participators, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls, actualCompletionTime)
}
func (task *Task) ConfirmTask(plannedCompletionTime time.Time) error {
return task.CurrentStatus.ConfirmTask(task, plannedCompletionTime)
}
func (task *Task) RejectReceiver() error {
return task.CurrentStatus.RejectReceiver(task)
}
... ...
... ... @@ -23,21 +23,21 @@ func (dao *TaskDao) AddRobInfo(taskId int64, receiver *domain.EmployeeInfo) erro
return err
}
func (dao *TaskDao) AddBidInfo(taskId int64, bidStartTime time.Time, bidEndTime time.Time) error {
func (dao *TaskDao) AddBidInfo(taskId int64, bidStartTime time.Time, bidEndTime time.Time, isRemind bool) error {
tx := dao.transactionContext.PgTx
_, err := tx.QueryOne(
pg.Scan(),
"INSERT INTO bid_infos (task_id, bid_start_time, bid_end_time) VALUES (?, ?, ?)",
taskId, bidStartTime, bidEndTime)
"INSERT INTO bid_infos (task_id, bid_start_time, bid_end_time, is_remind) VALUES (?, ?, ?, ?)",
taskId, bidStartTime, bidEndTime, isRemind)
return err
}
func (dao *TaskDao) UpdateBidInfo(taskId int64, bidStartTime time.Time, bidEndTime time.Time) error {
func (dao *TaskDao) UpdateBidInfo(taskId int64, bidStartTime time.Time, bidEndTime time.Time, isRemind bool) error {
tx := dao.transactionContext.PgTx
_, err := tx.QueryOne(
pg.Scan(),
"UPDATE bid_infos SET bid_start_time=?, bid_end_time=? WHERE task_id=?",
bidStartTime, bidEndTime, taskId)
"UPDATE bid_infos SET bid_start_time=?, bid_end_time=?, is_remind=? WHERE task_id=?",
bidStartTime, bidEndTime, isRemind, taskId)
return err
}
... ...
... ... @@ -16,7 +16,7 @@ type AcceptanceTaskService struct {
transactionContext *pgTransaction.TransactionContext
}
func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64, participators []int64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string) (*domain.Task, error) {
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) {
var employeeRepository domain.EmployeeRepository
var taskRepository domain.TaskRepository
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
... ... @@ -72,7 +72,7 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
participatorInfos = append(participatorInfos, participator.EmployeeInfo)
}
}
if err := task.Acceptance(participatorInfos, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls); err != nil {
if err := task.Acceptance(participatorInfos, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls, actualCompletionTime); err != nil {
return nil, err
}
for _, taskPercentageItem := range taskPercentage {
... ...
... ... @@ -16,7 +16,7 @@ type ChooseSuccessfulBidderService struct {
transactionContext *pgTransaction.TransactionContext
}
func (service *ChooseSuccessfulBidderService) Choose(taskId int64, successfulBidderUid int64, operatorUid int64) (*domain.Task, error) {
func (service *ChooseSuccessfulBidderService) Choose(taskId int64, successfulBidderUid int64, operatorUid int64, plannedCompletionTime time.Time) (*domain.Task, error) {
var employeeRepository domain.EmployeeRepository
var taskRepository domain.TaskRepository
var taskDao *dao.TaskDao
... ... @@ -65,7 +65,7 @@ func (service *ChooseSuccessfulBidderService) Choose(taskId int64, successfulBid
if successfulBidder == nil {
return nil, fmt.Errorf("无效的中标人")
}
if err := task.ChooseSuccessfulBidder(successfulBidder.EmployeeInfo); err != nil {
if err := task.ChooseSuccessfulBidder(successfulBidder.EmployeeInfo, plannedCompletionTime); err != nil {
return nil, err
}
if err := taskDao.SetSuccessfulBidder(taskId, task.BidInfo.SuccessfulBidder, task.BidInfo.WinBidTime); err != nil {
... ...
package domain_service
import (
"fmt"
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"
"time"
)
type ConfirmRobTaskService struct {
coreDomain.BaseEventPublisher
transactionContext *pgTransaction.TransactionContext
}
func (service *ConfirmRobTaskService) Confirm(taskId int64, operatorUid int64, plannedCompletionTime time.Time) (*domain.Task, error) {
var employeeRepository domain.EmployeeRepository
var taskRepository domain.TaskRepository
if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil {
return nil, err
} else {
employeeRepository = repository
}
if repository, err := repository.NewTaskRepository(service.transactionContext); err != nil {
return nil, err
} else {
taskRepository = repository
}
operator, err := employeeRepository.FindOne(map[string]interface{}{
"uid": operatorUid,
})
if err != nil {
return nil, err
}
if operator == nil {
return nil, fmt.Errorf("无效的操作者")
}
task, err := taskRepository.FindOne(map[string]interface{}{
"taskId": taskId,
})
if err != nil {
return nil, err
}
if task == nil {
return nil, fmt.Errorf("无效的任务")
}
if operator.EmployeeInfo.Uid != task.Sponsor.Uid {
return nil, fmt.Errorf("无效的任务发布者")
}
if err := task.ConfirmTask(plannedCompletionTime); err != nil {
return nil, err
}
if task, err := taskRepository.Save(task); err != nil {
return nil, err
} else {
return task, nil
}
}
func NewConfirmRobTaskService(transactionContext *pgTransaction.TransactionContext) (*ConfirmRobTaskService, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &ConfirmRobTaskService{
transactionContext: transactionContext,
}, nil
}
}
... ...
package domain_service
import (
"fmt"
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"
"time"
)
type RejectTaskReceiverService struct {
coreDomain.BaseEventPublisher
transactionContext *pgTransaction.TransactionContext
}
func (service *RejectTaskReceiverService) Reject(taskId int64, operatorUid int64, rejectReason string) (*domain.Task, error) {
var employeeRepository domain.EmployeeRepository
var taskRepository domain.TaskRepository
var rejectTaskRecordRepository domain.RejectTaskRecordRepository
if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil {
return nil, err
} else {
employeeRepository = repository
}
if repository, err := repository.NewTaskRepository(service.transactionContext); err != nil {
return nil, err
} else {
taskRepository = repository
}
if repository, err := repository.NewRejectTaskRecordRepository(service.transactionContext); err != nil {
return nil, err
} else {
rejectTaskRecordRepository = repository
}
operator, err := employeeRepository.FindOne(map[string]interface{}{
"uid": operatorUid,
})
if err != nil {
return nil, err
}
if operator == nil {
return nil, fmt.Errorf("无效的操作者")
}
task, err := taskRepository.FindOne(map[string]interface{}{
"taskId": taskId,
})
if err != nil {
return nil, err
}
if task == nil {
return nil, fmt.Errorf("无效的任务")
}
if operator.EmployeeInfo.Uid != task.Sponsor.Uid {
return nil, fmt.Errorf("无效的任务发布者")
}
if err := task.RejectReceiver(); err != nil {
return nil, err
}
rejectTaskRecord := &domain.RejectTaskRecord{
Task: task,
Operator: operator.EmployeeInfo,
RejectReason: rejectReason,
CreateTime: time.Now(),
}
if _, err := rejectTaskRecordRepository.Save(rejectTaskRecord); err != nil {
return nil, err
}
if task, err := taskRepository.Save(task); err != nil {
return nil, err
} else {
return task, nil
}
}
func NewRejectTaskReceiverService(transactionContext *pgTransaction.TransactionContext) (*RejectTaskReceiverService, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &RejectTaskReceiverService{
transactionContext: transactionContext,
}, nil
}
}
... ...
... ... @@ -87,7 +87,7 @@ func (service *ReleaseTaskService) Release(taskId int64, operatorUid int64) (*do
taskReleasedEvent.Sponsor = task.Sponsor
taskReleasedEvent.TaskStatus = task.TaskStatus
taskReleasedEvent.ReferenceResource = task.ReferenceResource
taskReleasedEvent.CustomerValue = task.CustomerValue
taskReleasedEvent.CustomerValues = task.CustomerValues
taskReleasedEvent.TaskNature = task.TaskNature
taskReleasedEvent.SuMoney = task.SuMoney
taskReleasedEvent.AcceptanceStandard = task.AcceptanceStandard
... ...
... ... @@ -33,6 +33,7 @@ func init() {
(*models.CustomerValue)(nil),
(*models.TaskNature)(nil),
(*models.ProjectBelong)(nil),
(*models.RejectTaskRecord)(nil),
} {
err := DB.CreateTable(model, &orm.CreateTableOptions{
Temp: false,
... ...
... ... @@ -16,6 +16,8 @@ type BidInfo struct {
BidStartTime time.Time
// 竞标结束时间
BidEndTime time.Time
//是否截止时间前一天提醒
IsRemind bool
// 中标时间
WinBidTime time.Time
TaskId int64 `pg:",unique"`
... ...
package models
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type RejectTaskRecord struct {
TableName string `pg:"reject_task_records,alias:reject_task_record"`
// 驳回任务记录ID
Id int64 `pg:",pk"`
// 任务
TaskId int64
// 操作人
Operator *domain.EmployeeInfo
// 驳回理由
RejectReason string
// 创建时间
CreateTime time.Time
}
... ...
... ... @@ -21,10 +21,12 @@ type Task struct {
TaskStatus int
// 引用资源
ReferenceResource *domain.ReferenceResource
// 项目归属
ProjectBelong int
// 客户价值列表
CustomerValue []string `pg:",array"`
CustomerValues []int `pg:",array"`
// 任务性质
TaskNature string
TaskNature int
// 奖励素币
SuMoney float64
// 验收标准
... ... @@ -43,6 +45,12 @@ type Task struct {
SolveReport string
// 解决图片URL列表
SolvePictureUrls []string `pg:",array"`
// 指派人员
AssignedPerson *domain.EmployeeInfo
// 计划完成时间
PlannedCompletionTime time.Time
// 实际完成时间
ActualCompletionTime time.Time
// 抢单任务信息
RobInfo *RobInfo
// 竞标任务信息
... ...
... ... @@ -75,6 +75,9 @@ func (repository *CustomerValueRepository) Find(queryOptions map[string]interfac
if customerValueNameMatch, ok := queryOptions["customerValueNameMatch"]; ok && (customerValueNameMatch != "") {
query = query.Where(`customer_value.customer_value_name LIKE ?`, fmt.Sprintf("%%%s%%", customerValueNameMatch.(string)))
}
if customerValueIds, ok := queryOptions["customerValueIds"]; ok {
query = query.Where(`customer_value.id IN (?)`, pg.In(customerValueIds.([]int)))
}
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
if offset > -1 {
... ...
package repository
import (
"fmt"
"time"
"github.com/go-pg/pg"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
)
type RejectTaskRecordRepository struct {
transactionContext *pgTransaction.TransactionContext
}
func (repository *RejectTaskRecordRepository) Save(rejectTaskRecord *domain.RejectTaskRecord) (*domain.RejectTaskRecord, error) {
tx := repository.transactionContext.PgTx
if rejectTaskRecord.Identify() == nil {
if _, err := tx.QueryOne(
pg.Scan(&rejectTaskRecord.RejectTaskRecordId, &rejectTaskRecord.Task.TaskId, &rejectTaskRecord.Operator, &rejectTaskRecord.RejectReason, &rejectTaskRecord.CreateTime),
"INSERT INTO reject_task_records (task_id, operator, reject_reason, create_time) VALUES (?, ?, ?, ?) RETURNING id, task_id, operator, reject_reason, create_time",
rejectTaskRecord.Task.TaskId, rejectTaskRecord.Operator, rejectTaskRecord.RejectReason, rejectTaskRecord.CreateTime); err != nil {
return rejectTaskRecord, err
}
} else {
if _, err := tx.QueryOne(
pg.Scan(&rejectTaskRecord.RejectTaskRecordId, &rejectTaskRecord.Task, &rejectTaskRecord.Operator, &rejectTaskRecord.RejectReason, &rejectTaskRecord.CreateTime),
"UPDATE reject_task_records SET task_id=?, operator=?, reject_reason=?, create_time=? WHERE id=? RETURNING id, task_id, operator, reject_reason, create_time",
rejectTaskRecord.Task.TaskId, rejectTaskRecord.Operator, rejectTaskRecord.RejectReason, rejectTaskRecord.CreateTime, rejectTaskRecord.Identify()); err != nil {
return rejectTaskRecord, err
}
}
return rejectTaskRecord, nil
}
func (repository *RejectTaskRecordRepository) Remove(rejectTaskRecord *domain.RejectTaskRecord) (*domain.RejectTaskRecord, error) {
tx := repository.transactionContext.PgTx
rejectTaskRecordModel := new(models.RejectTaskRecord)
rejectTaskRecordModel.Id = rejectTaskRecord.Identify().(int64)
if _, err := tx.Model(rejectTaskRecordModel).WherePK().Delete(); err != nil {
return rejectTaskRecord, err
}
return rejectTaskRecord, nil
}
func (repository *RejectTaskRecordRepository) FindOne(queryOptions map[string]interface{}) (*domain.RejectTaskRecord, error) {
tx := repository.transactionContext.PgTx
rejectTaskRecordModel := new(models.RejectTaskRecord)
query := tx.Model(rejectTaskRecordModel)
if rejectTaskRecordId, ok := queryOptions["rejectTaskRecordId"]; ok {
query = query.Where("reject_task_record.id = ?", rejectTaskRecordId)
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此驳回任务记录")
} else {
return nil, err
}
}
if rejectTaskRecordModel.Id == 0 {
return nil, nil
} else {
return repository.transformPgModelToDomainModel(rejectTaskRecordModel)
}
}
func (repository *RejectTaskRecordRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.RejectTaskRecord, error) {
tx := repository.transactionContext.PgTx
var rejectTaskRecordModels []*models.RejectTaskRecord
rejectTaskRecords := make([]*domain.RejectTaskRecord, 0)
query := tx.Model(&rejectTaskRecordModels)
if taskIds, ok := queryOptions["taskIds"]; ok {
if len(taskIds.([]int64)) > 0 {
query = query.Where(`reject_task_record.task_id IN (?)`, pg.In(taskIds.([]int64)))
} else {
return int64(0), rejectTaskRecords, nil
}
}
if rejectStartTime, ok := queryOptions["rejectStartTime"]; ok && !rejectStartTime.(time.Time).IsZero() {
query = query.Where(`reject_task_record.create_time > ?`, rejectStartTime)
}
if rejectEndTime, ok := queryOptions["rejectEndTime"]; ok && !rejectEndTime.(time.Time).IsZero() {
query = query.Where(`reject_task_record.create_time < ?`, rejectEndTime)
}
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
if offset > -1 {
query = query.Offset(offset)
}
} else {
query = query.Offset(0)
}
if limit, ok := queryOptions["limit"]; ok {
limit := limit.(int)
if limit > -1 {
query = query.Limit(limit)
}
} else {
query = query.Limit(20)
}
if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
return 0, rejectTaskRecords, err
} else {
for _, rejectTaskRecordModel := range rejectTaskRecordModels {
if rejectTaskRecord, err := repository.transformPgModelToDomainModel(rejectTaskRecordModel); err != nil {
return 0, rejectTaskRecords, err
} else {
rejectTaskRecords = append(rejectTaskRecords, rejectTaskRecord)
}
}
return int64(count), rejectTaskRecords, nil
}
}
func (repository *RejectTaskRecordRepository) transformPgModelToDomainModel(rejectTaskRecordModel *models.RejectTaskRecord) (*domain.RejectTaskRecord, error) {
return &domain.RejectTaskRecord{
RejectTaskRecordId: rejectTaskRecordModel.Id,
Task: &domain.Task{
TaskId: rejectTaskRecordModel.TaskId,
},
Operator: rejectTaskRecordModel.Operator,
RejectReason: rejectTaskRecordModel.RejectReason,
CreateTime: rejectTaskRecordModel.CreateTime,
}, nil
}
func NewRejectTaskRecordRepository(transactionContext *pgTransaction.TransactionContext) (*RejectTaskRecordRepository, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &RejectTaskRecordRepository{
transactionContext: transactionContext,
}, nil
}
}
... ...
... ... @@ -31,9 +31,9 @@ func (repository *TaskRepository) Save(task *domain.Task) (*domain.Task, error)
return task, err
}
if _, err := tx.QueryOne(
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)),
"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",
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 {
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),
"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",
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 {
return task, err
}
} else {
... ... @@ -45,9 +45,9 @@ func (repository *TaskRepository) Save(task *domain.Task) (*domain.Task, error)
taskReceiverUid = task.BidInfo.SuccessfulBidder.Uid
}
if _, err := tx.QueryOne(
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),
"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",
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 {
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),
"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",
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 {
return task, err
}
}
... ... @@ -114,25 +114,33 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int
if taskType, ok := queryOptions["taskType"]; ok && (taskType != 0) {
query = query.Where(`task.task_type = ?`, taskType)
}
if taskNature, ok := queryOptions["taskNature"]; ok && (taskNature != "") {
query = query.Where(`task.task_nature = ?`, taskNature)
if projectBelongs, ok := queryOptions["projectBelongs"]; ok && len(projectBelongs.([]int)) != 0 {
query = query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
for _, value := range projectBelongs.([]int) {
q = q.WhereOr("task.project_belongs @> ?", pg.Array([]int{value}))
}
if customerValue, ok := queryOptions["customerValue"]; ok && len(customerValue.([]string)) != 0 {
return q, nil
})
}
if taskNatures, ok := queryOptions["taskNatures"]; ok && len(taskNatures.([]int)) != 0 {
query = query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
for _, value := range customerValue.([]string) {
q = q.WhereOr("task.customer_value @> ?", pg.Array([]string{value}))
for _, value := range taskNatures.([]int) {
q = q.WhereOr("task.task_natures @> ?", pg.Array([]int{value}))
}
return q, nil
})
}
if taskContentMatch, ok := queryOptions["taskContentMatch"]; ok && (taskContentMatch != "") {
if customerValues, ok := queryOptions["customerValues"]; ok && len(customerValues.([]int)) != 0 {
query = query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
q = q.WhereOr("task.task_name LIKE ?", fmt.Sprintf("%%%s%%", taskContentMatch.(string))).
WhereOr("task.task_nature = ?", taskContentMatch.(string)).
WhereOr("task.customer_value @> ?", pg.Array([]string{taskContentMatch.(string)}))
for _, value := range customerValues.([]int) {
q = q.WhereOr("task.customer_values @> ?", pg.Array([]int{value}))
}
return q, nil
})
}
if taskContentMatch, ok := queryOptions["taskContentMatch"]; ok && (taskContentMatch != "") {
query = query.Where("task.task_name LIKE ?", fmt.Sprintf("%%%s%%", taskContentMatch.(string)))
}
if isRewardTake, ok := queryOptions["isRewardTake"]; ok && (isRewardTake != false) {
query = query.Where(`task.is_reward_take = ?`, isRewardTake)
}
... ... @@ -154,6 +162,9 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int
if participator, ok := queryOptions["participator"]; ok && (participator != int64(0)) {
query = query.Where(`task.participators @> '[{"uid":?}]'`, participator)
}
if assignedPerson, ok := queryOptions["assignedPerson"]; ok && (assignedPerson != int64(0)) {
query = query.Where(`task.assignedPerson @> '{"uid":?}'`, assignedPerson)
}
if taskIds, ok := queryOptions["taskIds"]; ok {
query = query.Where(`task.id IN (?)`, pg.In(taskIds.([]int64)))
}
... ... @@ -255,6 +266,7 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model
BidStartTime: taskModel.BidInfo.BidStartTime,
BidEndTime: taskModel.BidInfo.BidEndTime,
SuccessfulBidder: taskModel.BidInfo.SuccessfulBidder,
IsRemind: taskModel.BidInfo.IsRemind,
WinBidTime: taskModel.BidInfo.WinBidTime,
}
}
... ... @@ -278,6 +290,9 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model
case domain.TASK_STATUS_CLOSED:
currentStatus = &domain.ClosedStatus{}
break
case domain.TASK_STATUS_UNCONFIRMED:
currentStatus = &domain.UnConfirmedStatus{}
break
}
return &domain.Task{
TaskId: taskModel.Id,
... ... @@ -287,13 +302,17 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model
Sponsor: taskModel.Sponsor,
TaskStatus: taskModel.TaskStatus,
ReferenceResource: taskModel.ReferenceResource,
CustomerValue: taskModel.CustomerValue,
ProjectBelong: taskModel.ProjectBelong,
CustomerValues: taskModel.CustomerValues,
TaskNature: taskModel.TaskNature,
SuMoney: taskModel.SuMoney,
AcceptanceStandard: taskModel.AcceptanceStandard,
TaskDescription: taskModel.TaskDescription,
TaskPictureUrls: taskModel.TaskPictureUrls,
IsRewardTake: taskModel.IsRewardTake,
AssignedPerson: taskModel.AssignedPerson,
PlannedCompletionTime: taskModel.PlannedCompletionTime,
ActualCompletionTime: taskModel.ActualCompletionTime,
CreateTime: taskModel.CreateTime,
ReleaseTime: taskModel.ReleaseTime,
ReceiveTime: taskModel.ReceiveTime,
... ...
package controllers
import (
"encoding/json"
"github.com/astaxie/beego"
"github.com/linmadan/egglib-go/web/beego/utils"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/service"
)
type RejectTaskRecordController struct {
beego.Controller
}
func (controller *RejectTaskRecordController) GetRejectTaskRecord() {
taskService := service.NewTaskService(nil)
getRejectTaskRecordQuery := &query.GetRejectTaskRecordQuery{}
rejectTaskRecordId, _ := controller.GetInt64(":rejectTaskRecordId")
getRejectTaskRecordQuery.RejectTaskRecordId = rejectTaskRecordId
data, err := taskService.GetRejectTaskRecord(getRejectTaskRecordQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
func (controller *RejectTaskRecordController) SearchRejectTaskRecord() {
taskService := service.NewTaskService(nil)
searchRejectTaskRecordCommand := &command.SearchRejectTaskRecordCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), searchRejectTaskRecordCommand)
data, err := taskService.SearchRejectTaskRecord(searchRejectTaskRecordCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ...
... ... @@ -13,6 +13,40 @@ type TaskController struct {
beego.Controller
}
func (controller *TaskController) RejectTaskReceiver() {
taskService := service.NewTaskService(nil)
rejectTaskReceiverCommand := &command.RejectTaskReceiverCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), rejectTaskReceiverCommand)
taskId, _ := controller.GetInt64(":taskId")
rejectTaskReceiverCommand.TaskId = taskId
data, err := taskService.RejectTaskReceiver(rejectTaskReceiverCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
func (controller *TaskController) ConfirmRobTask() {
taskService := service.NewTaskService(nil)
confirmRobTaskCommand := &command.ConfirmRobTaskCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), confirmRobTaskCommand)
taskId, _ := controller.GetInt64(":taskId")
confirmRobTaskCommand.TaskId = taskId
data, err := taskService.ConfirmRobTask(confirmRobTaskCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
func (controller *TaskController) RobTask() {
taskService := service.NewTaskService(nil)
robTaskCommand := &command.RobTaskCommand{}
... ...
package routers
import (
"github.com/astaxie/beego"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego/controllers"
)
func init() {
beego.Router("/reject-task-records/:rejectTaskRecordId", &controllers.RejectTaskRecordController{}, "Get:GetRejectTaskRecord")
beego.Router("/reject-task-records/search-reject-task-record", &controllers.RejectTaskRecordController{}, "Post:SearchRejectTaskRecord")
}
... ...
... ... @@ -6,6 +6,8 @@ import (
)
func init() {
beego.Router("/tasks/:taskId/reject-task-receiver", &controllers.TaskController{}, "Post:RejectTaskReceiver")
beego.Router("/tasks/:taskId/confirm-rob-task", &controllers.TaskController{}, "Post:ConfirmRobTask")
beego.Router("/tasks/:taskId/rob", &controllers.TaskController{}, "Post:RobTask")
beego.Router("/tasks/:taskId/bid", &controllers.TaskController{}, "Post:BidTask")
beego.Router("/tasks/:taskId/apply-complete", &controllers.TaskController{}, "Post:ApplyCompleteTask")
... ...
... ... @@ -13,8 +13,38 @@ import (
)
var _ = Describe("搜索关闭任务记录", func() {
var projectBelongId int
var taskNatureId int
var customerValueId1 int
var customerValueId2 int
var customerValueId3 int
var offTaskRecordId int64
BeforeEach(func() {
_, err8 := pG.DB.QueryOne(
pg.Scan(&projectBelongId),
"INSERT INTO project_belongs (project_belong_name, company_id) VALUES (?, ?) RETURNING id",
"能力展示", 101)
Expect(err8).NotTo(HaveOccurred())
_, err9 := pG.DB.QueryOne(
pg.Scan(&customerValueId1),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"口味", 101)
Expect(err9).NotTo(HaveOccurred())
_, err10 := pG.DB.QueryOne(
pg.Scan(&customerValueId2),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"口感", 101)
Expect(err10).NotTo(HaveOccurred())
_, err11 := pG.DB.QueryOne(
pg.Scan(&customerValueId3),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"性价比", 101)
Expect(err11).NotTo(HaveOccurred())
_, err12 := pG.DB.QueryOne(
pg.Scan(&taskNatureId),
"INSERT INTO task_natures (task_nature_name, company_id) VALUES (?, ?) RETURNING id",
"点", 101)
Expect(err12).NotTo(HaveOccurred())
_, err := pG.DB.QueryOne(
pg.Scan(&offTaskRecordId),
"INSERT INTO off_task_records (id, task_id, operator, off_reason, create_time) VALUES (?, ?, ?, ?, ?) RETURNING id",
... ... @@ -25,10 +55,10 @@ var _ = Describe("搜索关闭任务记录", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err1 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 6, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 6, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -46,8 +76,9 @@ var _ = Describe("搜索关闭任务记录", func() {
"companyId": 101,
"taskContentMatch": "",
"taskType": 1,
"customerValue": "",
"taskNature": "",
"projectBelongs": make([]int, 0),
"customerValues": make([]int, 0),
"taskNatures": make([]int, 0),
"offStartTime": time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()),
"offEndTime": time.Time{},
"offset": 0,
... ... @@ -72,8 +103,9 @@ var _ = Describe("搜索关闭任务记录", func() {
"companyId": 102,
"taskContentMatch": "",
"taskType": 1,
"customerValue": "",
"taskNature": "",
"projectBelongs": make([]int, 0),
"customerValues": make([]int, 0),
"taskNatures": make([]int, 0),
"offStartTime": time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()),
"offEndTime": time.Time{},
"offset": 0,
... ... @@ -98,8 +130,9 @@ var _ = Describe("搜索关闭任务记录", func() {
"companyId": 101,
"taskContentMatch": "",
"taskType": 1,
"customerValue": "",
"taskNature": "",
"projectBelongs": make([]int, 0),
"customerValues": make([]int, 0),
"taskNatures": make([]int, 0),
"offStartTime": time.Date(2030, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()),
"offEndTime": time.Time{},
"offset": 0,
... ... @@ -123,5 +156,11 @@ var _ = Describe("搜索关闭任务记录", func() {
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.Exec("DELETE FROM tasks WHERE true")
Expect(err1).NotTo(HaveOccurred())
_, err3 := pG.DB.Exec("DELETE FROM project_belongs WHERE true")
Expect(err3).NotTo(HaveOccurred())
_, err4 := pG.DB.Exec("DELETE FROM task_natures WHERE true")
Expect(err4).NotTo(HaveOccurred())
_, err5 := pG.DB.Exec("DELETE FROM customer_values WHERE true")
Expect(err5).NotTo(HaveOccurred())
})
})
... ...
package reject_task_record
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"net/http"
"time"
"github.com/gavv/httpexpect"
"github.com/go-pg/pg"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
)
var _ = Describe("返回驳回任务记录", func() {
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO reject_task_records (id, task_id, operator, reject_reason, create_time) VALUES (?, ?, ?, ?, ?)",
1, 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, "testReason", time.Now())
Expect(err).NotTo(HaveOccurred())
})
Describe("返回驳回任务记录", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/reject-task-records/1").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM reject_task_records WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package reject_task_record
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/astaxie/beego"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego"
)
func TestRejectTaskRecord(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Beego Port RejectTaskRecord Correlations Test Case Suite")
}
var handler http.Handler
var server *httptest.Server
var _ = BeforeSuite(func() {
handler = beego.BeeApp.Handlers
server = httptest.NewServer(handler)
})
var _ = AfterSuite(func() {
server.Close()
})
... ...
package reject_task_record
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"net/http"
"time"
"github.com/gavv/httpexpect"
"github.com/go-pg/pg"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
)
var _ = Describe("搜索驳回任务记录", func() {
var projectBelongId int
var taskNatureId int
var customerValueId1 int
var customerValueId2 int
var customerValueId3 int
var rejectTaskRecordId int64
BeforeEach(func() {
_, err8 := pG.DB.QueryOne(
pg.Scan(&projectBelongId),
"INSERT INTO project_belongs (project_belong_name, company_id) VALUES (?, ?) RETURNING id",
"能力展示", 101)
Expect(err8).NotTo(HaveOccurred())
_, err9 := pG.DB.QueryOne(
pg.Scan(&customerValueId1),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"口味", 101)
Expect(err9).NotTo(HaveOccurred())
_, err10 := pG.DB.QueryOne(
pg.Scan(&customerValueId2),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"口感", 101)
Expect(err10).NotTo(HaveOccurred())
_, err11 := pG.DB.QueryOne(
pg.Scan(&customerValueId3),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"性价比", 101)
Expect(err11).NotTo(HaveOccurred())
_, err12 := pG.DB.QueryOne(
pg.Scan(&taskNatureId),
"INSERT INTO task_natures (task_nature_name, company_id) VALUES (?, ?) RETURNING id",
"点", 101)
Expect(err12).NotTo(HaveOccurred())
_, err := pG.DB.QueryOne(
pg.Scan(&rejectTaskRecordId),
"INSERT INTO reject_task_records (id, task_id, operator, reject_reason, create_time) VALUES (?, ?, ?, ?, ?) RETURNING id",
1, 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, "testReason", time.Now())
Expect(err).NotTo(HaveOccurred())
dayAfter, _ := time.ParseDuration("72h")
_, err1 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 6, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
{
Uid: 2499036607974745066,
},
}, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
Expect(err1).NotTo(HaveOccurred())
})
Describe("搜索驳回任务记录", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"companyId": 101,
"taskContentMatch": "",
"taskType": 1,
"projectBelongs": make([]int, 0),
"customerValues": make([]int, 0),
"taskNatures": make([]int, 0),
"rejectStartTime": time.Date(2020, time.Month(5), 26, 8, 0, 0, 0, time.Now().Location()),
"rejectEndTime": time.Time{},
"offset": 0,
"limit": 20,
}
httpExpect.POST("/reject-task-records/search-reject-task-record").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM reject_task_records WHERE true")
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.Exec("DELETE FROM tasks WHERE true")
Expect(err1).NotTo(HaveOccurred())
_, err3 := pG.DB.Exec("DELETE FROM project_belongs WHERE true")
Expect(err3).NotTo(HaveOccurred())
_, err4 := pG.DB.Exec("DELETE FROM task_natures WHERE true")
Expect(err4).NotTo(HaveOccurred())
_, err5 := pG.DB.Exec("DELETE FROM customer_values WHERE true")
Expect(err5).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -19,7 +19,7 @@ var _ = Describe("验收任务", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 4, &domain.ReferenceResource{
... ... @@ -32,7 +32,7 @@ var _ = Describe("验收任务", func() {
Content: "问题内容1",
},
},
}, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
}, 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))
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.QueryOne(
pg.Scan(),
... ...
... ... @@ -19,10 +19,10 @@ var _ = Describe("申请完成任务", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 3, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 3, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ...
... ... @@ -19,10 +19,10 @@ var _ = Describe("对任务进行竞标", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "竞标任务1", 2, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 2, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 2, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ...
... ... @@ -19,10 +19,10 @@ var _ = Describe("选择竞标任务的中标人", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "竞标任务1", 2, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 2, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 2, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -59,6 +59,7 @@ var _ = Describe("选择竞标任务的中标人", func() {
body := map[string]interface{}{
"operator": 2499036607974745088,
"successfulBidder": 2499036607974745099,
"plannedCompletionTime": time.Now(),
}
httpExpect.POST("/tasks/1/choose-successful-bidder").
WithJSON(body).
... ...
package task
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"net/http"
"time"
"github.com/gavv/httpexpect"
"github.com/go-pg/pg"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
)
var _ = Describe("对抢单任务进行确认", func() {
BeforeEach(func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 7, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
{
Uid: 2499036607974745066,
},
}, "null", "", pg.Array([]string{}), 0, time.Now(), time.Now().Add(dayAfter))
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
1, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0)
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
2, 101, 2499036607974745099, "testEmployeeName", "testEmployeeAccount", 0)
Expect(err2).NotTo(HaveOccurred())
})
Describe("对抢单任务进行确认", func() {
Context("任务发布人对抢单任务进行确认", func() {
It("确认成功", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"operator": 2499036607974745088,
"plannedCompletionTime": time.Now(),
}
httpExpect.POST("/tasks/1/confirm-rob-task").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("taskStatus").ValueEqual("taskStatus", 3)
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.Exec("DELETE FROM bid_infos WHERE true")
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
Expect(err2).NotTo(HaveOccurred())
_, err3 := pG.DB.Exec("DELETE FROM employees WHERE true")
Expect(err3).NotTo(HaveOccurred())
_, err4 := pG.DB.Exec("DELETE FROM rob_infos WHERE true")
Expect(err4).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -21,7 +21,7 @@ var _ = Describe("创建新任务", func() {
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
2, 101, "抢单任务2", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 2, &domain.ReferenceResource{
... ... @@ -31,7 +31,7 @@ var _ = Describe("创建新任务", func() {
ReferenceResourceId: 4,
},
},
}, pg.Array([]string{"口感", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now())
}, 1, pg.Array([]int{1, 2}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now())
Expect(err1).NotTo(HaveOccurred())
})
Describe("提交数据创建新任务", func() {
... ... @@ -49,12 +49,13 @@ var _ = Describe("创建新任务", func() {
{"referenceResourceId": 2, "serialNumber": 2, "title": "问题标题2"},
{"referenceResourceId": 3, "serialNumber": 3, "title": "问题标题3"},
},
"customerValue": []string{
"口味",
"色泽",
"商务服务",
"projectBelong": 1,
"customerValues": []int{
1,
2,
3,
},
"taskNature": "线",
"taskNature": 1,
"suMoney": 1000.00,
"acceptanceStandard": "验收标准",
"taskDescription": "任务描述",
... ... @@ -92,12 +93,13 @@ var _ = Describe("创建新任务", func() {
{"serialNumber": 2, "title": "机会标题2"},
{"serialNumber": 3, "title": "机会标题3"},
},
"customerValue": []string{
"口味",
"色泽",
"商务服务",
"projectBelong": 1,
"customerValues": []int{
1,
2,
3,
},
"taskNature": "线",
"taskNature": 1,
"suMoney": 1000.00,
"acceptanceStandard": "验收标准",
"taskDescription": "任务描述",
... ... @@ -122,6 +124,50 @@ var _ = Describe("创建新任务", func() {
ContainsKey("taskId").ValueNotEqual("taskId", BeZero())
})
})
Context("提交正确的指派类型任务数据", func() {
It("返回指派类型任务数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"companyId": 101,
"taskName": "竞标任务",
"taskType": 2,
"sponsor": 2499036607974745088,
"referenceResourceType": 2,
"referenceResourceItems": []map[string]interface{}{
{"serialNumber": 1, "title": "机会标题1"},
{"serialNumber": 2, "title": "机会标题2"},
{"serialNumber": 3, "title": "机会标题3"},
},
"projectBelong": 1,
"customerValues": []int{
1,
2,
3,
},
"taskNature": 1,
"suMoney": 1000.00,
"acceptanceStandard": "验收标准",
"taskDescription": "任务描述",
"taskPictureUrls": []string{
"url-1",
"url-2",
"url-3",
},
"assignedPerson": 2499036607974745088,
"plannedCompletionTime": time.Now(),
}
httpExpect.POST("/tasks/").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("taskId").ValueNotEqual("taskId", BeZero())
})
})
Context("提交已经被引用的问题ID任务数据", func() {
It("创建失败", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
... ... @@ -134,12 +180,13 @@ var _ = Describe("创建新任务", func() {
"referenceResourceItems": []map[string]interface{}{
{"referenceResourceId": 4, "serialNumber": 4, "title": "问题标题4"},
},
"customerValue": []string{
"口味",
"色泽",
"商务服务",
"projectBelong": 1,
"customerValues": []int{
1,
2,
3,
},
"taskNature": "线",
"taskNature": 1,
"suMoney": 1000.00,
"acceptanceStandard": "验收标准",
"taskDescription": "任务描述",
... ...
package task
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"net/http"
"time"
"github.com/gavv/httpexpect"
"github.com/go-pg/pg"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
"net/http"
"time"
)
var _ = Describe("返回任务", func() {
var projectBelongId int
var taskNatureId int
var customerValueId1 int
var customerValueId2 int
var customerValueId3 int
BeforeEach(func() {
_, err3 := pG.DB.QueryOne(
pg.Scan(&projectBelongId),
"INSERT INTO project_belongs (project_belong_name, company_id) VALUES (?, ?) RETURNING id",
"能力展示", 101)
Expect(err3).NotTo(HaveOccurred())
_, err4 := pG.DB.QueryOne(
pg.Scan(&customerValueId1),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"口味", 101)
Expect(err4).NotTo(HaveOccurred())
_, err5 := pG.DB.QueryOne(
pg.Scan(&customerValueId2),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"口感", 101)
Expect(err5).NotTo(HaveOccurred())
_, err6 := pG.DB.QueryOne(
pg.Scan(&customerValueId3),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"性价比", 101)
Expect(err6).NotTo(HaveOccurred())
_, err7 := pG.DB.QueryOne(
pg.Scan(&taskNatureId),
"INSERT INTO task_natures (task_nature_name, company_id) VALUES (?, ?) RETURNING id",
"点", 101)
Expect(err7).NotTo(HaveOccurred())
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
}, 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))
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO bid_infos (id, task_id) VALUES (?, ?)",
1, 1)
"INSERT INTO bid_infos (id, task_id, is_remind) VALUES (?, ?, ?)",
1, 1, true)
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.QueryOne(
pg.Scan(),
... ... @@ -55,5 +84,11 @@ var _ = Describe("返回任务", func() {
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
Expect(err2).NotTo(HaveOccurred())
_, err3 := pG.DB.Exec("DELETE FROM project_belongs WHERE true")
Expect(err3).NotTo(HaveOccurred())
_, err4 := pG.DB.Exec("DELETE FROM task_natures WHERE true")
Expect(err4).NotTo(HaveOccurred())
_, err5 := pG.DB.Exec("DELETE FROM customer_values WHERE true")
Expect(err5).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -13,14 +13,44 @@ import (
)
var _ = Describe("返回任务列表", func() {
var projectBelongId int
var taskNatureId int
var customerValueId1 int
var customerValueId2 int
var customerValueId3 int
BeforeEach(func() {
_, err8 := pG.DB.QueryOne(
pg.Scan(&projectBelongId),
"INSERT INTO project_belongs (project_belong_name, company_id) VALUES (?, ?) RETURNING id",
"能力展示", 101)
Expect(err8).NotTo(HaveOccurred())
_, err9 := pG.DB.QueryOne(
pg.Scan(&customerValueId1),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"口味", 101)
Expect(err9).NotTo(HaveOccurred())
_, err10 := pG.DB.QueryOne(
pg.Scan(&customerValueId2),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"口感", 101)
Expect(err10).NotTo(HaveOccurred())
_, err11 := pG.DB.QueryOne(
pg.Scan(&customerValueId3),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"性价比", 101)
Expect(err11).NotTo(HaveOccurred())
_, err12 := pG.DB.QueryOne(
pg.Scan(&taskNatureId),
"INSERT INTO task_natures (task_nature_name, company_id) VALUES (?, ?) RETURNING id",
"点", 101)
Expect(err12).NotTo(HaveOccurred())
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -31,30 +61,30 @@ var _ = Describe("返回任务列表", func() {
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
2, 101, "抢单任务2", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
}, 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))
_, err2 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
3, 102, "竞标任务1", 2, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
}, 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))
Expect(err2).NotTo(HaveOccurred())
_, err3 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
4, 101, "竞标任务1", 2, &domain.EmployeeInfo{
Uid: 2499036607974745099,
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
}, 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))
Expect(err3).NotTo(HaveOccurred())
_, err4 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
5, 303, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 6, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 6, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -64,11 +94,11 @@ var _ = Describe("返回任务列表", func() {
}, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
Expect(err4).NotTo(HaveOccurred())
Expect(err1).NotTo(HaveOccurred())
_, err11 := pG.DB.QueryOne(
_, err111 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO bid_infos (id, task_id, bid_start_time, bid_end_time) VALUES (?, ?, ?, ?)",
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()))
Expect(err11).NotTo(HaveOccurred())
Expect(err111).NotTo(HaveOccurred())
_, err22 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO bidder_infos (id, bid_info_id, task_id) VALUES (?, ?, ?)",
... ... @@ -134,7 +164,7 @@ var _ = Describe("返回任务列表", func() {
httpExpect.GET("/tasks/").
WithQuery("companyId", 101).
WithQuery("sponsor", 2499036607974745088).
WithQuery("taskContentMatch", "售后服务").
WithQuery("taskContentMatch", "任务2").
WithQuery("taskType", 1).
WithQuery("offset", 0).
WithQuery("limit", 20).
... ... @@ -245,5 +275,11 @@ var _ = Describe("返回任务列表", func() {
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
Expect(err2).NotTo(HaveOccurred())
_, err3 := pG.DB.Exec("DELETE FROM project_belongs WHERE true")
Expect(err3).NotTo(HaveOccurred())
_, err4 := pG.DB.Exec("DELETE FROM task_natures WHERE true")
Expect(err4).NotTo(HaveOccurred())
_, err5 := pG.DB.Exec("DELETE FROM customer_values WHERE true")
Expect(err5).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -19,10 +19,10 @@ var _ = Describe("关闭任务", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 3, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 3, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -60,10 +60,10 @@ var _ = Describe("关闭任务", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 6, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 6, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ...
package task
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"net/http"
"time"
"github.com/gavv/httpexpect"
"github.com/go-pg/pg"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
)
var _ = Describe("驳回任务领取人", func() {
BeforeEach(func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 3, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
{
Uid: 2499036607974745066,
},
}, "null", "", pg.Array([]string{}), 0, time.Now(), time.Now().Add(dayAfter))
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
1, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0)
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
2, 101, 2499036607974745099, "testEmployeeName", "testEmployeeAccount", 0)
Expect(err2).NotTo(HaveOccurred())
_, err3 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO rob_infos (id, task_id ,receiver) VALUES (?, ?, ?)",
1, 1, &domain.EmployeeInfo{
Uid: 2499036607974745099,
})
Expect(err3).NotTo(HaveOccurred())
})
Describe("驳回任务领取人", func() {
Context("任务发布人驳回任务领取人", func() {
It("驳回成功", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"operator": 2499036607974745088,
"rejectReason": "看你不爽",
}
httpExpect.POST("/tasks/1/reject-task-receiver").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("taskStatus").ValueEqual("taskStatus", 2)
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.Exec("DELETE FROM bid_infos WHERE true")
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
Expect(err2).NotTo(HaveOccurred())
_, err3 := pG.DB.Exec("DELETE FROM employees WHERE true")
Expect(err3).NotTo(HaveOccurred())
_, err4 := pG.DB.Exec("DELETE FROM rob_infos WHERE true")
Expect(err4).NotTo(HaveOccurred())
_, err5 := pG.DB.Exec("DELETE FROM reject_task_records WHERE true")
Expect(err5).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -18,7 +18,7 @@ var _ = Describe("发布任务", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1, &domain.ReferenceResource{
... ... @@ -28,7 +28,7 @@ var _ = Describe("发布任务", func() {
ReferenceResourceId: 4,
},
},
}, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -65,10 +65,10 @@ var _ = Describe("发布任务", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 3, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 3, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -103,7 +103,7 @@ var _ = Describe("发布任务", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 2, &domain.ReferenceResource{
... ... @@ -113,7 +113,7 @@ var _ = Describe("发布任务", func() {
ReferenceResourceId: 4,
},
},
}, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -129,7 +129,7 @@ var _ = Describe("发布任务", func() {
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
2, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 2, &domain.ReferenceResource{
... ... @@ -139,7 +139,7 @@ var _ = Describe("发布任务", func() {
ReferenceResourceId: 4,
},
},
}, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -164,6 +164,60 @@ var _ = Describe("发布任务", func() {
ContainsKey("msg").ValueEqual("msg", "内部服务出错:问题资源已经被引用,发布任务失败")
})
})
Context("任务发起者发布待发布的指派任务", func() {
BeforeEach(func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 3, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1, &domain.ReferenceResource{
ReferenceResourceType: 1,
ReferenceResourceItems: []*domain.ReferenceResourceItem{
{
ReferenceResourceId: 4,
},
},
}, 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
{
Uid: 2499036607974745066,
},
}, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter), &domain.EmployeeInfo{
Uid: 2499036607974745099,
}, time.Now())
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
1, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0)
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
2, 101, 2499036607974745099, "testEmployeeName", "testEmployeeAccount", 0)
Expect(err2).NotTo(HaveOccurred())
})
It("发布任务成功", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"operator": 2499036607974745088,
}
httpExpect.POST("/tasks/1/release").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("taskStatus").ValueEqual("taskStatus", 3)
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
... ...
package task
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"net/http"
"time"
"github.com/gavv/httpexpect"
"github.com/go-pg/pg"
... ... @@ -12,10 +14,13 @@ import (
var _ = Describe("移除任务", func() {
BeforeEach(func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "testTaskName", 1, "{}", 3, "null", pg.Array([]string{"口感"}), "testTaskNature", 100.00, "testAcceptanceStandard", "testTaskDescription", pg.Array([]string{"url"}), false)
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 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))
Expect(err).NotTo(HaveOccurred())
})
Describe("根据参数移除任务", func() {
... ...
... ... @@ -19,10 +19,10 @@ var _ = Describe("对任务进行抢单", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 2, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 2, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -56,7 +56,7 @@ var _ = Describe("对任务进行抢单", func() {
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("taskStatus").ValueEqual("taskStatus", 3).
ContainsKey("taskStatus").ValueEqual("taskStatus", 7).
ContainsKey("robInfo").Value("robInfo").Object().
ContainsKey("receiver").Value("receiver").Object().
ContainsKey("uid").ValueEqual("uid", 2499036607974745099)
... ... @@ -67,10 +67,10 @@ var _ = Describe("对任务进行抢单", func() {
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 2, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 2, "null", 1, pg.Array([]int{1, 2, 3, 4}), 1, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ...
... ... @@ -13,14 +13,44 @@ import (
)
var _ = Describe("搜索任务", func() {
var projectBelongId int
var taskNatureId int
var customerValueId1 int
var customerValueId2 int
var customerValueId3 int
BeforeEach(func() {
_, err8 := pG.DB.QueryOne(
pg.Scan(&projectBelongId),
"INSERT INTO project_belongs (project_belong_name, company_id) VALUES (?, ?) RETURNING id",
"能力展示", 101)
Expect(err8).NotTo(HaveOccurred())
_, err9 := pG.DB.QueryOne(
pg.Scan(&customerValueId1),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"口味", 101)
Expect(err9).NotTo(HaveOccurred())
_, err10 := pG.DB.QueryOne(
pg.Scan(&customerValueId2),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"口感", 101)
Expect(err10).NotTo(HaveOccurred())
_, err11 := pG.DB.QueryOne(
pg.Scan(&customerValueId3),
"INSERT INTO customer_values (customer_value_name, company_id) VALUES (?, ?) RETURNING id",
"性价比", 101)
Expect(err11).NotTo(HaveOccurred())
_, err12 := pG.DB.QueryOne(
pg.Scan(&taskNatureId),
"INSERT INTO task_natures (task_nature_name, company_id) VALUES (?, ?) RETURNING id",
"点", 101)
Expect(err12).NotTo(HaveOccurred())
dayAfter, _ := time.ParseDuration("72h")
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
}, 1, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ... @@ -31,17 +61,17 @@ var _ = Describe("搜索任务", func() {
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
2, 101, "抢单任务2", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1, "null", pg.Array([]string{"口感", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
}, 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))
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
3, 101, "竞标任务1", 2, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
}, 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))
Expect(err2).NotTo(HaveOccurred())
_, err3 := pG.DB.QueryOne(
pg.Scan(),
... ... @@ -57,10 +87,10 @@ var _ = Describe("搜索任务", func() {
Expect(err4).NotTo(HaveOccurred())
_, err5 := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
4, 101, "竞标任务1", 2, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
}, 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))
Expect(err5).NotTo(HaveOccurred())
_, err6 := pG.DB.QueryOne(
pg.Scan(),
... ... @@ -82,10 +112,10 @@ var _ = Describe("搜索任务", func() {
body := map[string]interface{}{
"companyId": 101,
"sponsor": 2499036607974745088,
"customerValue": []string{
"售后服务",
"口感",
"品牌",
"customerValues": []int{
customerValueId1,
customerValueId2,
customerValueId3,
},
"offset": 0,
"limit": 20,
... ... @@ -172,5 +202,11 @@ var _ = Describe("搜索任务", func() {
Expect(err1).NotTo(HaveOccurred())
_, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
Expect(err2).NotTo(HaveOccurred())
_, err3 := pG.DB.Exec("DELETE FROM project_belongs WHERE true")
Expect(err3).NotTo(HaveOccurred())
_, err4 := pG.DB.Exec("DELETE FROM task_natures WHERE true")
Expect(err4).NotTo(HaveOccurred())
_, err5 := pG.DB.Exec("DELETE FROM customer_values WHERE true")
Expect(err5).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -16,8 +16,8 @@ var _ = Describe("更新任务", func() {
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "testTaskName", 1, "{}", 1, "{}", pg.Array([]string{"口感"}), "testTaskNature", 100.00, "testAcceptanceStandard", "testTaskDescription", pg.Array([]string{"url"}), false)
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "testTaskName", 1, "{}", 1, "{}", 1, pg.Array([]int{1}), 1, 100.00, "testAcceptanceStandard", "testTaskDescription", pg.Array([]string{"url"}), false)
Expect(err).NotTo(HaveOccurred())
})
It("返回更新后的任务数据", func() {
... ... @@ -32,12 +32,13 @@ var _ = Describe("更新任务", func() {
{"serialNumber": 2, "title": "问题标题2"},
{"serialNumber": 3, "title": "问题标题3"},
},
"customerValue": []string{
"口味",
"色泽",
"商务服务",
"projectBelong": 1,
"customerValues": []int{
1,
2,
3,
},
"taskNature": "线",
"taskNature": 1,
"suMoney": 1000.00,
"acceptanceStandard": "验收标准",
"taskDescription": "任务描述",
... ... @@ -64,8 +65,8 @@ var _ = Describe("更新任务", func() {
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(),
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "testTaskName", 1, "{}", 3, "null", pg.Array([]string{"口感"}), "testTaskNature", 100.00, "testAcceptanceStandard", "testTaskDescription", pg.Array([]string{"url"}), false)
"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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1, 101, "testTaskName", 1, "{}", 3, "null", 1, pg.Array([]int{1}), 1, 100.00, "testAcceptanceStandard", "testTaskDescription", pg.Array([]string{"url"}), false)
Expect(err).NotTo(HaveOccurred())
})
It("返回当前状态不能进行编辑操作的提示", func() {
... ... @@ -80,12 +81,13 @@ var _ = Describe("更新任务", func() {
{"serialNumber": 2, "title": "问题标题2"},
{"serialNumber": 3, "title": "问题标题3"},
},
"customerValue": []string{
"口味",
"色泽",
"商务服务",
"projectBelong": 1,
"customerValues": []int{
1,
2,
3,
},
"taskNature": "线",
"taskNature": 1,
"suMoney": 1000.00,
"acceptanceStandard": "验收标准",
"taskDescription": "任务描述",
... ...