作者 linmadan

修复驳回任务bug

... ... @@ -686,7 +686,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
}
_, tasks, err := taskRepository.Find(map[string]interface{}{
"companyId": searchRejectTaskRecordCommand.CompanyId,
"taskStatus": domain.TASK_STATUS_CLOSED,
"taskStatus": domain.TASK_STATUS_UNCLAIMED,
"taskContentMatch": searchRejectTaskRecordCommand.TaskContentMatch,
"taskType": searchRejectTaskRecordCommand.TaskType,
"projectBelongs": searchRejectTaskRecordCommand.ProjectBelongs,
... ...
... ... @@ -58,6 +58,15 @@ func (dao *TaskDao) AddRobInfo(taskId int64, receiver *domain.EmployeeInfo) erro
return err
}
func (dao *TaskDao) DeleteRobInfo(taskId int64) error {
tx := dao.transactionContext.PgTx
_, err := tx.QueryOne(
pg.Scan(),
"DELETE FROM rob_infos WHERE task_id=?",
taskId)
return err
}
func (dao *TaskDao) AddBidInfo(taskId int64, bidStartTime time.Time, bidEndTime time.Time, isRemind bool) error {
tx := dao.transactionContext.PgTx
_, err := tx.QueryOne(
... ... @@ -94,6 +103,15 @@ func (dao *TaskDao) SetSuccessfulBidder(taskId int64, successfulBidder *domain.E
return err
}
func (dao *TaskDao) CancelSuccessfulBidder(taskId int64) error {
tx := dao.transactionContext.PgTx
_, err := tx.QueryOne(
pg.Scan(),
"UPDATE bid_infos SET successful_bidder=?, win_bid_time=? WHERE task_id=?",
nil, time.Time{}, taskId)
return err
}
func (dao *TaskDao) CalculateSystemTask(companyId int64) (map[string]interface{}, error) {
var released int64
var underway int64
... ...
... ... @@ -6,6 +6,7 @@ import (
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"
"time"
)
... ... @@ -19,6 +20,7 @@ func (service *RejectTaskReceiverService) Reject(taskId int64, operatorUid int64
var employeeRepository domain.EmployeeRepository
var taskRepository domain.TaskRepository
var rejectTaskRecordRepository domain.RejectTaskRecordRepository
var taskDao *dao.TaskDao
if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil {
return nil, err
} else {
... ... @@ -34,6 +36,11 @@ func (service *RejectTaskReceiverService) Reject(taskId int64, operatorUid int64
} else {
rejectTaskRecordRepository = repository
}
if dao, err := dao.NewTaskDao(service.transactionContext); err != nil {
return nil, err
} else {
taskDao = dao
}
operator, err := employeeRepository.FindOne(map[string]interface{}{
"uid": operatorUid,
})
... ... @@ -64,6 +71,16 @@ func (service *RejectTaskReceiverService) Reject(taskId int64, operatorUid int64
RejectReason: rejectReason,
CreateTime: time.Now(),
}
if task.TaskType == domain.TASK_TYPE_ROB {
if err := taskDao.DeleteRobInfo(taskId); err != nil {
return nil, err
}
}
if task.TaskType == domain.TASK_TYPE_BID {
if err := taskDao.CancelSuccessfulBidder(taskId); err != nil {
return nil, err
}
}
if rejectTaskRecord, err := rejectTaskRecordRepository.Save(newRejectTaskRecord); err != nil {
return nil, err
} else {
... ...
... ... @@ -58,7 +58,7 @@ var _ = Describe("搜索驳回任务记录", func() {
"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{
}, 2, "null", projectBelongId, pg.Array([]int{customerValueId1, customerValueId2, customerValueId3}), taskNatureId, 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
... ...