|
@@ -4,6 +4,7 @@ import (
|
|
|
"context"
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
+ "fmt"
|
|
|
"reflect"
|
|
|
"time"
|
|
|
"youngee_m_api/db"
|
|
@@ -102,13 +103,13 @@ func (*selection) Update(ctx context.Context, request http_model.UpdateSelection
|
|
|
// b) 选品名称
|
|
|
selectionName := product.BrandName + "-" + product.ProductName
|
|
|
// d) 任务截止时间
|
|
|
+ fmt.Println("taskDdl:", request.TaskDdl)
|
|
|
taskDdl := time.Time{} //赋零值
|
|
|
taskDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", request.TaskDdl, time.Local)
|
|
|
// f) 更新选品状态
|
|
|
if request.SelectionStatus != 2 && request.SelectionStatus != 7 {
|
|
|
request.SelectionStatus = 1
|
|
|
}
|
|
|
-
|
|
|
t := time.Now()
|
|
|
updateSelection := gorm_model.YounggeeSelectionInfo{
|
|
|
SelectionID: request.SelectionID,
|
|
@@ -136,6 +137,9 @@ func (*selection) Update(ctx context.Context, request http_model.UpdateSelection
|
|
|
CreatedAt: selectionInfo.CreatedAt,
|
|
|
UpdatedAt: &t,
|
|
|
}
|
|
|
+ if request.SelectionStatus == 2 {
|
|
|
+ updateSelection.SubmitAt = &t
|
|
|
+ }
|
|
|
// 合并传入参数和数据表中原记录,若传入参数字段值为空,则将字段赋值为原记录中值
|
|
|
result := util.MergeStructValue(&updateSelection, selectionInfo)
|
|
|
// 利用反射机制将interface类型转换为结构体类型
|
|
@@ -325,31 +329,27 @@ func (*selection) Review(ctx context.Context, request http_model.ReviewSelection
|
|
|
|
|
|
// 若审核通过则更新选品阶段为待支付,否则更新为失效并赋值失效原因
|
|
|
t := time.Now()
|
|
|
+ updateSelection := gorm_model.YounggeeSelectionInfo{}
|
|
|
if request.IsPass == 1 {
|
|
|
- updateSelection := gorm_model.YounggeeSelectionInfo{
|
|
|
+ updateSelection = gorm_model.YounggeeSelectionInfo{
|
|
|
SelectionID: request.SelectionId,
|
|
|
SelectionStatus: 4,
|
|
|
PassAt: &t,
|
|
|
EstimatedCost: estimatedCostToString,
|
|
|
}
|
|
|
- err = db.UpdateSelection(ctx, updateSelection)
|
|
|
- if err != nil {
|
|
|
- logrus.WithContext(ctx).Errorf("[selectionDB service] call UpdateSelection error,err:%+v", err)
|
|
|
- return nil, err
|
|
|
- }
|
|
|
} else {
|
|
|
- updateSelection := gorm_model.YounggeeSelectionInfo{
|
|
|
+ updateSelection = gorm_model.YounggeeSelectionInfo{
|
|
|
SelectionID: request.SelectionId,
|
|
|
SelectionStatus: 7,
|
|
|
FailReason: 2,
|
|
|
- PassAt: &t,
|
|
|
+ FinishAt: &t,
|
|
|
EstimatedCost: estimatedCostToString,
|
|
|
}
|
|
|
- err = db.UpdateSelection(ctx, updateSelection)
|
|
|
- if err != nil {
|
|
|
- logrus.WithContext(ctx).Errorf("[selectionDB service] call UpdateSelection error,err:%+v", err)
|
|
|
- return nil, err
|
|
|
- }
|
|
|
+ }
|
|
|
+ err = db.UpdateSelection(ctx, updateSelection)
|
|
|
+ if err != nil {
|
|
|
+ logrus.WithContext(ctx).Errorf("[selectionDB service] call UpdateSelection error,err:%+v", err)
|
|
|
+ return nil, err
|
|
|
}
|
|
|
res := &http_model.ReviewSelectionData{}
|
|
|
return res, nil
|