作者 陈志颖

fix:已过期竞标任务重新编辑发布

@@ -650,3 +650,4 @@ @@ -650,3 +650,4 @@
650 BodyData:{} 650 BodyData:{}
651 2020/11/23 17:18:21.768 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/activity/?companyId=358&offset=0&limit=20&isEnd=true.1606123101682637000 BodyData:{"code":0,"data":{"activities":[],"count":0},"msg":"ok"} 651 2020/11/23 17:18:21.768 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/activity/?companyId=358&offset=0&limit=20&isEnd=true.1606123101682637000 BodyData:{"code":0,"data":{"activities":[],"count":0},"msg":"ok"}
652 2020/11/23 17:18:21.768 [D] [server.go:1925] | 127.0.0.1| 200 | 86.366848ms| match| GET  /cash-pool/activity/ r:/cash-pool/activity/ 652 2020/11/23 17:18:21.768 [D] [server.go:1925] | 127.0.0.1| 200 | 86.366848ms| match| GET  /cash-pool/activity/ r:/cash-pool/activity/
  653 +2020/11/23 17:40:41.529 [I] [???:0] http server Running on http://:8082
@@ -224,9 +224,7 @@ func (status *UnReleasedStatus) RejectReceiver(task *Task) error { @@ -224,9 +224,7 @@ func (status *UnReleasedStatus) RejectReceiver(task *Task) error {
224 224
225 type UnClaimedStatus struct{} 225 type UnClaimedStatus struct{}
226 226
227 -// 待领取任务开放编辑  
228 func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error { 227 func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error {
229 - //return fmt.Errorf("待领取的任务不允许编辑")  
230 if taskName, ok := data["taskName"]; ok { 228 if taskName, ok := data["taskName"]; ok {
231 task.TaskName = taskName.(string) 229 task.TaskName = taskName.(string)
232 } 230 }
@@ -638,15 +636,86 @@ func (status *UnConfirmedStatus) RejectReceiver(task *Task) error { @@ -638,15 +636,86 @@ func (status *UnConfirmedStatus) RejectReceiver(task *Task) error {
638 return nil 636 return nil
639 } 637 }
640 638
641 -// TODO 已过期任务 639 +// TODO 已过期任务支持编辑
642 type ExpiredStatus struct{} 640 type ExpiredStatus struct{}
643 641
644 func (status ExpiredStatus) Update(task *Task, data map[string]interface{}) error { 642 func (status ExpiredStatus) Update(task *Task, data map[string]interface{}) error {
645 - panic("implement me") 643 + if taskName, ok := data["taskName"]; ok {
  644 + task.TaskName = taskName.(string)
  645 + }
  646 + if referenceResourceType, ok := data["referenceResourceType"]; ok {
  647 + task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int)
  648 + }
  649 + if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
  650 + task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
  651 + }
  652 + if projectBelong, ok := data["projectBelong"]; ok {
  653 + task.ProjectBelong = projectBelong.(int)
  654 + }
  655 + if customerValues, ok := data["customerValues"]; ok {
  656 + task.CustomerValues = customerValues.([]int)
  657 + }
  658 + if taskNature, ok := data["taskNature"]; ok {
  659 + task.TaskNature = taskNature.(int)
  660 + }
  661 + if suMoney, ok := data["suMoney"]; ok {
  662 + task.SuMoney = suMoney.(float64)
  663 + }
  664 + if minSuMoney, ok := data["minSuMoney"]; ok {
  665 + task.MinSuMoney = minSuMoney.(float64)
  666 + }
  667 + if maxSuMoney, ok := data["maxSuMoney"]; ok {
  668 + task.MaxSuMoney = maxSuMoney.(float64)
  669 + }
  670 + if task.TaskType == TASK_TYPE_BID {
  671 + if bidStartTime, ok := data["bidStartTime"]; ok {
  672 + task.BidInfo.BidStartTime = bidStartTime.(time.Time)
  673 + }
  674 + if bidEndTime, ok := data["bidEndTime"]; ok {
  675 + task.BidInfo.BidEndTime = bidEndTime.(time.Time)
  676 + }
  677 + if isRemind, ok := data["isRemind"]; ok {
  678 + task.BidInfo.IsRemind = isRemind.(bool)
  679 + }
  680 + }
  681 + if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
  682 + task.AcceptanceStandard = acceptanceStandard.(string)
  683 + }
  684 + if taskDescription, ok := data["taskDescription"]; ok {
  685 + task.TaskDescription = taskDescription.(string)
  686 + }
  687 + if taskPictureUrls, ok := data["taskPictureUrls"]; ok {
  688 + task.TaskPictureUrls = taskPictureUrls.([]string)
  689 + }
  690 + if isRewardTake, ok := data["isRewardTake"]; ok {
  691 + task.IsRewardTake = isRewardTake.(bool)
  692 + }
  693 + if task.TaskType == TASK_TYPE_DESIGNATE {
  694 + if plannedCompletionTime, ok := data["plannedCompletionTime"]; ok {
  695 + task.PlannedCompletionTime = plannedCompletionTime.(time.Time)
  696 + }
  697 + if assignedPerson, ok := data["assignedPerson"]; ok {
  698 + task.AssignedPerson = assignedPerson.(*EmployeeInfo)
  699 + if task.AssignedPerson.Uid == 0 {
  700 + task.AssignedPerson = nil
  701 + }
  702 + }
  703 + }
  704 + return nil
646 } 705 }
647 706
648 func (status ExpiredStatus) Release(task *Task) error { 707 func (status ExpiredStatus) Release(task *Task) error {
649 - panic("implement me") 708 + currentTime := time.Now()
  709 + task.ReleaseTime = currentTime
  710 + if task.TaskType == TASK_TYPE_BID {
  711 + task.ReceiveTime = currentTime
  712 + task.TaskStatus = TASK_STATUS_UNDERWAY
  713 + task.CurrentStatus = &UnderwayStatus{}
  714 + } else {
  715 + task.TaskStatus = TASK_STATUS_UNCLAIMED
  716 + task.CurrentStatus = &UnClaimedStatus{}
  717 + }
  718 + return nil
650 } 719 }
651 720
652 func (status ExpiredStatus) Rob(task *Task, receiver *EmployeeInfo) error { 721 func (status ExpiredStatus) Rob(task *Task, receiver *EmployeeInfo) error {
@@ -150,7 +150,7 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int @@ -150,7 +150,7 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int
150 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint"). 150 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
151 ColumnExpr("sum(su_money_transaction_record.su_money) AS system_exchanged_su_money"). 151 ColumnExpr("sum(su_money_transaction_record.su_money) AS system_exchanged_su_money").
152 Where("e.company_id = ?", companyId). 152 Where("e.company_id = ?", companyId).
153 - Where("e.status = ?", 1). 153 + //Where("e.status = ?", 1).
154 Where(`su_money_transaction_record.record_type = ?`, domain.SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE_CASH). 154 Where(`su_money_transaction_record.record_type = ?`, domain.SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE_CASH).
155 Select(&systemExchangedSuMoney); err != nil { 155 Select(&systemExchangedSuMoney); err != nil {
156 return nil, err 156 return nil, err
@@ -159,7 +159,7 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int @@ -159,7 +159,7 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int
159 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint"). 159 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
160 ColumnExpr("sum(su_money_transaction_record.su_money) AS system_exchanged_su_money"). 160 ColumnExpr("sum(su_money_transaction_record.su_money) AS system_exchanged_su_money").
161 Where("e.company_id = ?", companyId). 161 Where("e.company_id = ?", companyId).
162 - Where("e.status = ?", 1). 162 + //Where("e.status = ?", 1).
163 Where(`su_money_transaction_record.record_type = ?`, domain.SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE_CASH_RESTORE). 163 Where(`su_money_transaction_record.record_type = ?`, domain.SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE_CASH_RESTORE).
164 Select(&systemExchangedSuMoneyRestore); err != nil { 164 Select(&systemExchangedSuMoneyRestore); err != nil {
165 return nil, err 165 return nil, err