|
@@ -888,13 +888,34 @@ func (s SelectionInfoService) DeleteSelection(selectionId string) (*string, erro
|
|
}
|
|
}
|
|
|
|
|
|
// 结束带货任务
|
|
// 结束带货任务
|
|
-func (s SelectionInfoService) CloseSelection(selectionId string) (*string, error) {
|
|
|
|
- err := dao.SelectionInfoDAO{}.UpdateSelectionInfo(entity.SelectionInfo{
|
|
|
|
- SelectionID: selectionId,
|
|
|
|
- SelectionStatus: 8,
|
|
|
|
- UpdatedAt: time.Now(),
|
|
|
|
- })
|
|
|
|
- return &selectionId, err
|
|
|
|
|
|
+func (s SelectionInfoService) CloseSelection(selectionId string) (string, error) {
|
|
|
|
+ // 任务待办:待审核、待支付、达人未处理 待发货、待签收 未传初稿、未发作品、未传数据
|
|
|
|
+ selectionInfo, err := dao.SelectionInfoDAO{}.GetSelectionInfoById(selectionId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return "0", err
|
|
|
|
+ }
|
|
|
|
+ if selectionInfo == nil {
|
|
|
|
+ return "0", errors.New("任务不存在")
|
|
|
|
+ }
|
|
|
|
+ var needProcess int64
|
|
|
|
+ var logisticsToDo int64
|
|
|
|
+ if selectionInfo.SelectionStatus == 6 {
|
|
|
|
+ // 达人未处理
|
|
|
|
+ _ = dao.Db.Model(&entity.SecTaskInfo{}).Where("selection_id = ? and task_status = ?", selectionId, 1).Count(&needProcess).Error // task_status=1待选
|
|
|
|
+ // 物流待办
|
|
|
|
+ _ = dao.Db.Model(&entity.SecTaskInfo{}).Where("selection_id = ? and logistics_status != ?", selectionId, 3).Count(&logisticsToDo).Error
|
|
|
|
+ }
|
|
|
|
+ if selectionInfo.SelectionStatus == 2 || selectionInfo.SelectionStatus == 4 || (selectionInfo.SelectionStatus == 6 && needProcess+logisticsToDo > 0) {
|
|
|
|
+ // 存在待办不可结束
|
|
|
|
+ return "1", nil
|
|
|
|
+ } else {
|
|
|
|
+ err = dao.SelectionInfoDAO{}.UpdateSelectionInfo(entity.SelectionInfo{
|
|
|
|
+ SelectionID: selectionId,
|
|
|
|
+ SelectionStatus: 8,
|
|
|
|
+ UpdatedAt: time.Now(),
|
|
|
|
+ })
|
|
|
|
+ return "0", err
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// 电商带货选达人角标 未处理、同意合作、拒绝合作
|
|
// 电商带货选达人角标 未处理、同意合作、拒绝合作
|