作者 linmadan

修复消息bug,重构指派任务逻辑

... ... @@ -93,16 +93,9 @@ func (subscriber *NotificationHandleSubscriber) HandleEvent(domainEvent coreDoma
if notification, err := notificationRepository.Save(notification); err != nil {
return err
} else {
var receiver *domain.EmployeeInfo
if taskRejectedEvent.TaskType == domain.TASK_TYPE_ROB {
receiver = taskRejectedEvent.RobInfo.Receiver
}
if taskRejectedEvent.TaskType == domain.TASK_TYPE_BID {
receiver = taskRejectedEvent.BidInfo.SuccessfulBidder
}
sentNotification := &domain.SentNotification{
Notification: notification,
Receiver: receiver,
Receiver: taskRejectedEvent.BeRejectedPerson,
IsRead: false,
ReadTime: time.Time{},
}
... ...
... ... @@ -132,7 +132,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime
} else {
taskDao = value
}
if tasks, err := taskDao.ListNearThePlannedCompletionTimeTask(); err != nil {
if tasks, err := taskDao.ListNearBidEndTimeTask(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, task := range tasks {
... ...
... ... @@ -21,12 +21,10 @@ type TaskRejected struct {
Sponsor *domain.EmployeeInfo `json:"sponsor"`
// 任务状态
TaskStatus int `json:"taskStatus"`
// 抢单任务信息
RobInfo *domain.RobInfo `json:"robInfo"`
// 竞标任务信息
BidInfo *domain.BidInfo `json:"bidInfo"`
//驳回任务记录
RejectTaskRecord *domain.RejectTaskRecord
//被驳回人
BeRejectedPerson *domain.EmployeeInfo `json:"beRejectedPerson"`
}
func (event *TaskRejected) EventType() string {
... ...
... ... @@ -165,8 +165,10 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{})
}
func (status *UnReleasedStatus) Release(task *Task) error {
task.ReleaseTime = time.Now()
currentTime := time.Now()
task.ReleaseTime = currentTime
if task.TaskType == TASK_TYPE_DESIGNATE {
task.ReceiveTime = currentTime
task.TaskStatus = TASK_STATUS_UNDERWAY
task.CurrentStatus = &UnderwayStatus{}
} else {
... ...
... ... @@ -62,9 +62,7 @@ func (service *RejectTaskReceiverService) Reject(taskId int64, operatorUid int64
if operator.EmployeeInfo.Uid != task.Sponsor.Uid {
return nil, fmt.Errorf("无效的任务发布者")
}
if err := task.RejectReceiver(); err != nil {
return nil, err
}
var beRejectedPerson *domain.EmployeeInfo
newRejectTaskRecord := &domain.RejectTaskRecord{
Task: task,
Operator: operator.EmployeeInfo,
... ... @@ -72,11 +70,17 @@ func (service *RejectTaskReceiverService) Reject(taskId int64, operatorUid int64
CreateTime: time.Now(),
}
if task.TaskType == domain.TASK_TYPE_ROB {
if task.RobInfo != nil && task.RobInfo.Receiver != nil{
beRejectedPerson = task.RobInfo.Receiver
}
if err := taskDao.DeleteRobInfo(taskId); err != nil {
return nil, err
}
}
if task.TaskType == domain.TASK_TYPE_BID {
if task.BidInfo != nil && task.BidInfo.SuccessfulBidder != nil{
beRejectedPerson = task.BidInfo.SuccessfulBidder
}
if err := taskDao.CancelSuccessfulBidder(taskId); err != nil {
return nil, err
}
... ... @@ -86,6 +90,9 @@ func (service *RejectTaskReceiverService) Reject(taskId int64, operatorUid int64
} else {
newRejectTaskRecord = rejectTaskRecord
}
if err := task.RejectReceiver(); err != nil {
return nil, err
}
if task, err := taskRepository.Save(task); err != nil {
return nil, err
} else {
... ... @@ -97,8 +104,7 @@ func (service *RejectTaskReceiverService) Reject(taskId int64, operatorUid int64
taskRejectedEvent.TaskType = task.TaskType
taskRejectedEvent.Sponsor = task.Sponsor
taskRejectedEvent.TaskStatus = task.TaskStatus
taskRejectedEvent.RobInfo = task.RobInfo
taskRejectedEvent.BidInfo = task.BidInfo
taskRejectedEvent.BeRejectedPerson = beRejectedPerson
taskRejectedEvent.RejectTaskRecord = newRejectTaskRecord
if err := service.Publish(taskRejectedEvent); err != nil {
return nil, err
... ...