作者 linmadan

修复竞标任务更新bug

... ... @@ -538,6 +538,14 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
} else {
taskRepository = value
}
var taskDao *dao.TaskDao
if value, err := factory.CreateTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
taskDao = value
}
task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -551,6 +559,11 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
if task, err := taskRepository.Save(task); err != nil {
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 {
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())
}
... ...
... ... @@ -32,6 +32,15 @@ func (dao *TaskDao) AddBidInfo(taskId int64, bidStartTime time.Time, bidEndTime
return err
}
func (dao *TaskDao) UpdateBidInfo(taskId int64, bidStartTime time.Time, bidEndTime time.Time) 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)
return err
}
func (dao *TaskDao) AddBidderInfo(taskId int64, bidder *domain.EmployeeInfo) error {
tx := dao.transactionContext.PgTx
_, err := tx.QueryOne(
... ...
... ... @@ -76,12 +76,19 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
return nil, err
}
for _, taskPercentageItem := range taskPercentage {
var taskTypeName string
if task.TaskType == domain.TASK_TYPE_BID {
taskTypeName = "竞标任务"
}
if task.TaskType == domain.TASK_TYPE_ROB {
taskTypeName = "抢单任务"
}
suMoneyTransactionRecord := &domain.SuMoneyTransactionRecord{
RecordType: domain.SU_MONEY_TRANSACTION_RECORD_TYPE_AWARD,
Employee: taskPercentageItem.Contributor,
SuMoney: taskPercentageItem.SuMoney,
Operator: operator.EmployeeInfo,
RecordDescription: fmt.Sprintf("完成[%s]任务奖励", task.TaskName),
RecordDescription: fmt.Sprintf("%s-%s", taskTypeName, task.TaskName),
CreateTime: time.Now(),
}
if _, err := suMoneyTransactionRecordRepository.Save(suMoneyTransactionRecord); err != nil {
... ...