|
|
@@ -246,14 +246,54 @@ func (s DeliverOrderProgressService) Start(ctx context.Context, req *work.Delive
|
|
|
"rea_start_date": gtime.Now(),
|
|
|
"remark": req.Remark,
|
|
|
}, "id = ?", req.Id)
|
|
|
- } else {
|
|
|
+ } else if ent.ProgressType == "20" {
|
|
|
_, err = tx.Update("deliver_order_imp_progress", map[string]interface{}{
|
|
|
"progress_status": "20",
|
|
|
"rea_start_date": gtime.Now(),
|
|
|
"remark": req.Remark,
|
|
|
}, "id = ?", req.Id)
|
|
|
+ } else {
|
|
|
+ _, err = tx.Update("deliver_order_imp_progress", map[string]interface{}{
|
|
|
+ "progress_status": "20",
|
|
|
+ "deliver_status": "15",
|
|
|
+ "expect_install_time": req.ExpectInstallTime,
|
|
|
+ "remark": req.Remark,
|
|
|
+ }, "id = ?", req.Id)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
}
|
|
|
+ return nil
|
|
|
+ })
|
|
|
+ if txerr != nil {
|
|
|
+ return txerr
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
|
|
|
+func (s DeliverOrderProgressService) ConfirmInstallInfo(ctx context.Context, req *work.DeliverOrderImpProgressConfirmReq) error {
|
|
|
+ validErr := gvalid.CheckStruct(ctx, req, nil)
|
|
|
+ if validErr != nil {
|
|
|
+ return myerrors.TipsError(validErr.Current().Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ ent, err := s.Dao.Where("id = ?", req.Id).One()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if ent == nil {
|
|
|
+ return myerrors.TipsError(fmt.Sprintf("工单任务不存在: %d", req.Id))
|
|
|
+ }
|
|
|
+
|
|
|
+ txerr := s.Dao.DB.Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
|
|
|
+ _, err = tx.Update("deliver_order_imp_progress", map[string]interface{}{
|
|
|
+ "deliver_status": "20",
|
|
|
+ "rea_start_date": gtime.Now(),
|
|
|
+ "install_begin_time": req.InstallBeginTime,
|
|
|
+ "install_end_time": req.InstallBeginTime,
|
|
|
+ "remark": req.Remark,
|
|
|
+ }, "id = ?", req.Id)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -442,6 +482,7 @@ func (s DeliverOrderProgressService) DeliverGoods(ctx context.Context, req *work
|
|
|
}
|
|
|
|
|
|
if installProgress != nil {
|
|
|
+ // 将产品分配到已存在的安装任务上
|
|
|
_, err = tx.Update("deliver_progress_product", fmt.Sprintf("install_progress_id='%v'", installProgress.Id), fmt.Sprintf("deliver_progress_id='%v'", req.Id))
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -649,3 +690,47 @@ func (s DeliverOrderProgressService) CompleteInstall(ctx context.Context, req *w
|
|
|
|
|
|
return err
|
|
|
}
|
|
|
+
|
|
|
+func (s DeliverOrderProgressService) AuditInstall(ctx context.Context, req *work.DeliverOrderImpProgressAuditReq) error {
|
|
|
+ validErr := gvalid.CheckStruct(ctx, req, nil)
|
|
|
+ if validErr != nil {
|
|
|
+ return myerrors.TipsError(validErr.Current().Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ ent, err := s.Dao.Where("id = ?", req.Id).One()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if ent == nil {
|
|
|
+ return myerrors.TipsError(fmt.Sprintf("工单任务不存在: %d", req.Id))
|
|
|
+ }
|
|
|
+
|
|
|
+ txerr := s.Dao.DB.Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
|
|
|
+ _, err = tx.Update("deliver_order_imp_progress", map[string]interface{}{
|
|
|
+ "deliver_status": "70", // 发货状态(10未开始、15待确认、20进行中、30已发货、40产品已验收、50确认已到货、60安装完成、70安装审批通过)
|
|
|
+ "audit_user_id": s.userInfo.Id,
|
|
|
+ "audit_user": s.userInfo.NickName,
|
|
|
+ "audit_time": gtime.Now(),
|
|
|
+ "audit_desc": req.Remark,
|
|
|
+ }, "id = ?", req.Id)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+ })
|
|
|
+ if txerr != nil {
|
|
|
+ return txerr
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateProgressProductInfo 更新任务单产品明细信息
|
|
|
+func (s DeliverOrderProgressService) UpdateProgressProductInfo(ctx context.Context, req *work.UpdateProductReq) error {
|
|
|
+ data := map[string]interface{}{
|
|
|
+ "pictures": req.Pictures,
|
|
|
+ "desc": req.Desc,
|
|
|
+ }
|
|
|
+ where := fmt.Sprintf("id='%v'", req.Id)
|
|
|
+ _, err := s.ProductDao.Update(data, where)
|
|
|
+ return err
|
|
|
+}
|