Browse Source

Merge branch 'feature/经销商培训申请' into develop

yanglingling 1 year ago
parent
commit
0ea7144662

+ 48 - 39
opms_parent/app/dao/train/internal/train_sale_apply_summary.go

@@ -26,19 +26,22 @@ type TrainSaleApplySummaryDao struct {
 
 // TrainSaleApplySummaryColumns defines and stores column names for table train_sale_apply_summary.
 type trainSaleApplySummaryColumns struct {
-	Id              string // 主键
-	ApplyId         string // 申请ID
-	ExplainDuration string // 讲解时长
-	QuestionRecord  string // 提问记录
-	TrainSummary    string // 培训效果总结
-	NextStep        string // 下一步工作计划
-	CreatedBy       string // 创建人
-	CreatedName     string // 创建人
-	CreatedTime     string // 创建时间
-	UpdatedBy       string // 更新人
-	UpdatedName     string // 更新人
-	UpdatedTime     string // 更新时间
-	DeletedTime     string // 删除时间
+	Id                     string // 主键
+	ApplyId                string // 申请ID
+	WorkOrderId            string // 关联工单ID
+	FeedbackSupportContent string // 本次支持反馈内容
+	FeedbackSupportTime    string // 支持反馈-反馈时间
+	ExplainDuration        string // 讲解时长
+	QuestionRecord         string // 提问记录
+	TrainSummary           string // 培训效果总结
+	NextStep               string // 下一步工作计划
+	CreatedBy              string // 创建人
+	CreatedName            string // 创建人
+	CreatedTime            string // 创建时间
+	UpdatedBy              string // 更新人
+	UpdatedName            string // 更新人
+	UpdatedTime            string // 更新时间
+	DeletedTime            string // 删除时间
 }
 
 var (
@@ -48,19 +51,22 @@ var (
 		DB:    g.DB("default"),
 		Table: "train_sale_apply_summary",
 		C: trainSaleApplySummaryColumns{
-			Id:              "id",
-			ApplyId:         "apply_id",
-			ExplainDuration: "explain_duration",
-			QuestionRecord:  "question_record",
-			TrainSummary:    "train_summary",
-			NextStep:        "next_step",
-			CreatedBy:       "created_by",
-			CreatedName:     "created_name",
-			CreatedTime:     "created_time",
-			UpdatedBy:       "updated_by",
-			UpdatedName:     "updated_name",
-			UpdatedTime:     "updated_time",
-			DeletedTime:     "deleted_time",
+			Id:                     "id",
+			ApplyId:                "apply_id",
+			WorkOrderId:            "work_order_id",
+			FeedbackSupportContent: "feedback_support_content",
+			FeedbackSupportTime:    "feedback_support_time",
+			ExplainDuration:        "explain_duration",
+			QuestionRecord:         "question_record",
+			TrainSummary:           "train_summary",
+			NextStep:               "next_step",
+			CreatedBy:              "created_by",
+			CreatedName:            "created_name",
+			CreatedTime:            "created_time",
+			UpdatedBy:              "updated_by",
+			UpdatedName:            "updated_name",
+			UpdatedTime:            "updated_time",
+			DeletedTime:            "deleted_time",
 		},
 	}
 )
@@ -72,19 +78,22 @@ func NewTrainSaleApplySummaryDao(tenant string) TrainSaleApplySummaryDao {
 		DB:    g.DB(tenant),
 		Table: "train_sale_apply_summary",
 		C: trainSaleApplySummaryColumns{
-			Id:              "id",
-			ApplyId:         "apply_id",
-			ExplainDuration: "explain_duration",
-			QuestionRecord:  "question_record",
-			TrainSummary:    "train_summary",
-			NextStep:        "next_step",
-			CreatedBy:       "created_by",
-			CreatedName:     "created_name",
-			CreatedTime:     "created_time",
-			UpdatedBy:       "updated_by",
-			UpdatedName:     "updated_name",
-			UpdatedTime:     "updated_time",
-			DeletedTime:     "deleted_time",
+			Id:                     "id",
+			ApplyId:                "apply_id",
+			WorkOrderId:            "work_order_id",
+			FeedbackSupportContent: "feedback_support_content",
+			FeedbackSupportTime:    "feedback_support_time",
+			ExplainDuration:        "explain_duration",
+			QuestionRecord:         "question_record",
+			TrainSummary:           "train_summary",
+			NextStep:               "next_step",
+			CreatedBy:              "created_by",
+			CreatedName:            "created_name",
+			CreatedTime:            "created_time",
+			UpdatedBy:              "updated_by",
+			UpdatedName:            "updated_name",
+			UpdatedTime:            "updated_time",
+			DeletedTime:            "deleted_time",
 		},
 	}
 	return dao

+ 16 - 13
opms_parent/app/model/train/internal/train_sale_apply_summary.go

@@ -10,17 +10,20 @@ import (
 
 // TrainSaleApplySummary is the golang structure for table train_sale_apply_summary.
 type TrainSaleApplySummary struct {
-    Id              int         `orm:"id,primary"       json:"id"`              // 主键            
-    ApplyId         int         `orm:"apply_id"         json:"applyId"`         // 申请ID          
-    ExplainDuration string      `orm:"explain_duration" json:"explainDuration"` // 讲解时长        
-    QuestionRecord  string      `orm:"question_record"  json:"questionRecord"`  // 提问记录        
-    TrainSummary    string      `orm:"train_summary"    json:"trainSummary"`    // 培训效果总结    
-    NextStep        string      `orm:"next_step"        json:"nextStep"`        // 下一步工作计划  
-    CreatedBy       int         `orm:"created_by"       json:"createdBy"`       // 创建人          
-    CreatedName     string      `orm:"created_name"     json:"createdName"`     // 创建人          
-    CreatedTime     *gtime.Time `orm:"created_time"     json:"createdTime"`     // 创建时间        
-    UpdatedBy       int         `orm:"updated_by"       json:"updatedBy"`       // 更新人          
-    UpdatedName     string      `orm:"updated_name"     json:"updatedName"`     // 更新人          
-    UpdatedTime     *gtime.Time `orm:"updated_time"     json:"updatedTime"`     // 更新时间        
-    DeletedTime     *gtime.Time `orm:"deleted_time"     json:"deletedTime"`     // 删除时间        
+    Id                     int         `orm:"id,primary"               json:"id"`                     // 主键               
+    ApplyId                int         `orm:"apply_id"                 json:"applyId"`                // 申请ID             
+    WorkOrderId            int         `orm:"work_order_id"            json:"workOrderId"`            // 关联工单ID         
+    FeedbackSupportContent string      `orm:"feedback_support_content" json:"feedbackSupportContent"` // 本次支持反馈内容   
+    FeedbackSupportTime    *gtime.Time `orm:"feedback_support_time"    json:"feedbackSupportTime"`    // 支持反馈-反馈时间  
+    ExplainDuration        string      `orm:"explain_duration"         json:"explainDuration"`        // 讲解时长           
+    QuestionRecord         string      `orm:"question_record"          json:"questionRecord"`         // 提问记录           
+    TrainSummary           string      `orm:"train_summary"            json:"trainSummary"`           // 培训效果总结       
+    NextStep               string      `orm:"next_step"                json:"nextStep"`               // 下一步工作计划     
+    CreatedBy              int         `orm:"created_by"               json:"createdBy"`              // 创建人             
+    CreatedName            string      `orm:"created_name"             json:"createdName"`            // 创建人             
+    CreatedTime            *gtime.Time `orm:"created_time"             json:"createdTime"`            // 创建时间           
+    UpdatedBy              int         `orm:"updated_by"               json:"updatedBy"`              // 更新人             
+    UpdatedName            string      `orm:"updated_name"             json:"updatedName"`            // 更新人             
+    UpdatedTime            *gtime.Time `orm:"updated_time"             json:"updatedTime"`            // 更新时间           
+    DeletedTime            *gtime.Time `orm:"deleted_time"             json:"deletedTime"`            // 删除时间           
 }

+ 26 - 12
opms_parent/app/model/train/train_sale_apply_summary.go

@@ -6,6 +6,7 @@ package model
 
 import (
 	"dashoo.cn/micro/app/model/train/internal"
+	"github.com/gogf/gf/os/gtime"
 )
 
 // TrainSaleApplySummary is the golang structure for table train_sale_apply_summary.
@@ -18,12 +19,22 @@ type TraSaleApplySummarySearchReq struct {
 }
 
 type TraSaleApplySummaryRes struct {
-	Id              int    `json:"id"`              // 主键
-	ApplyId         int    `json:"applyId"`         // 申请ID
-	ExplainDuration string `json:"explainDuration"` // 讲解时长
-	QuestionRecord  string `json:"questionRecord"`  // 提问记录
-	TrainSummary    string `json:"trainSummary"`    // 培训效果总结
-	NextStep        string `json:"nextStep"`        // 下一步工作计划
+	Id                     int         `json:"id"`                     // 主键
+	ApplyId                int         `json:"applyId"`                // 申请ID
+	WorkOrderId            int         `json:"workOrderId"`            // 关联工单ID
+	FeedbackSupportContent string      `json:"feedbackSupportContent"` // 本次支持反馈内容
+	FeedbackSupportTime    *gtime.Time `json:"feedbackSupportTime"`    // 支持反馈-反馈时间
+	ExplainDuration        string      `json:"explainDuration"`        // 讲解时长
+	QuestionRecord         string      `json:"questionRecord"`         // 提问记录
+	TrainSummary           string      `json:"trainSummary"`           // 培训效果总结
+	NextStep               string      `json:"nextStep"`               // 下一步工作计划
+}
+
+type TraSaleSupportReq struct {
+	ApplyId                int         `json:"applyId" v:"required|min:1#|申请ID不能为空"`           // 申请ID
+	WorkOrderId            int         `json:"workOrderId" v:"required|min:1#|关联工单ID不能为空"`     // 关联工单ID
+	FeedbackSupportContent string      `json:"feedbackSupportContent" v:"required#本次支持反馈内容为空"` // 本次支持反馈内容
+	FeedbackSupportTime    *gtime.Time `json:"feedbackSupportTime"`                            // 支持反馈-反馈时间
 }
 
 type TraSaleApplySummaryCreateReq struct {
@@ -35,10 +46,13 @@ type TraSaleApplySummaryCreateReq struct {
 }
 
 type TraSaleApplySummaryUpdateReq struct {
-	Id              int    `json:"id" v:"required|min:1#|主ID不能为空"`       // 主键
-	ApplyId         int    `json:"applyId" v:"required|min:1#|申请ID不能为空"` // 申请ID
-	ExplainDuration string `json:"explainDuration" v:"required#讲解时长为空"`  // 讲解时长
-	QuestionRecord  string `json:"questionRecord" v:"required#提问记录为空"`   // 提问记录
-	TrainSummary    string `json:"trainSummary" v:"required#培训效果总结为空"`   // 培训效果总结
-	NextStep        string `json:"nextStep" v:"required#下一步工作计划为空"`      // 下一步工作计划
+	Id                     int         `json:"id" v:"required|min:1#|主ID不能为空"`                 // 主键
+	ApplyId                int         `json:"applyId" v:"required|min:1#|申请ID不能为空"`           // 申请ID
+	WorkOrderId            int         `json:"workOrderId" v:"required|min:1#|关联工单ID不能为空"`     // 关联工单ID
+	FeedbackSupportContent string      `json:"feedbackSupportContent" v:"required#本次支持反馈内容为空"` // 本次支持反馈内容
+	FeedbackSupportTime    *gtime.Time `json:"feedbackSupportTime"`                            // 支持反馈-反馈时间
+	ExplainDuration        string      `json:"explainDuration" v:"required#讲解时长为空"`            // 讲解时长
+	QuestionRecord         string      `json:"questionRecord" v:"required#提问记录为空"`             // 提问记录
+	TrainSummary           string      `json:"trainSummary" v:"required#培训效果总结为空"`             // 培训效果总结
+	NextStep               string      `json:"nextStep" v:"required#下一步工作计划为空"`                // 下一步工作计划
 }

+ 66 - 6
opms_parent/app/service/train/sale_apply_summary.go

@@ -48,6 +48,49 @@ func (s *SaleApplySummaryService) GetEntityById(ctx context.Context, id int64) (
 	return
 }
 
+// CreateSupport
+// Create 支持人员反馈创建
+func (s *SaleApplySummaryService) CreateSupport(ctx context.Context, req *model.TraSaleSupportReq) (lastId int64, err error) {
+	DistributorData := new(model.TrainSaleApplySummary)
+	if err = gconv.Struct(req, DistributorData); err != nil {
+		return 0, err
+	}
+	service.SetCreatedInfo(DistributorData, s.GetCxtUserId(), s.GetCxtUserName())
+	svc, _ := NewSaleApplyService(ctx)
+	txerr := s.Dao.DB.Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
+		count, e := s.Dao.Ctx(ctx).TX(tx).Where(s.Dao.C.ApplyId, req.ApplyId).Count()
+		if e != nil {
+			return e
+		}
+		if count == 0 {
+			lastId, e = tx.InsertAndGetId("train_sale_apply_summary", DistributorData)
+			if e != nil {
+				return e
+			}
+			_, e = svc.Dao.Ctx(ctx).TX(tx).WherePri(req.ApplyId).Data(g.Map{svc.Dao.C.ApplyType: "25"}).Update()
+			if e != nil {
+				return e
+			}
+		} else {
+			_, e = s.Dao.Ctx(ctx).TX(tx).FieldsEx(s.Dao.C.Id, s.Dao.C.CreatedName, s.Dao.C.CreatedBy, s.Dao.C.CreatedTime).
+				Where(s.Dao.C.ApplyId, req.ApplyId).
+				Data(g.Map{s.Dao.C.ApplyId: req.ApplyId, s.Dao.C.WorkOrderId: req.WorkOrderId, s.Dao.C.FeedbackSupportTime: req.FeedbackSupportTime, s.Dao.C.FeedbackSupportContent: req.FeedbackSupportContent}).Update()
+			if e != nil {
+				return e
+			}
+			_, e = svc.Dao.Ctx(ctx).TX(tx).WherePri(req.ApplyId).Data(g.Map{svc.Dao.C.ApplyType: "40"}).Update()
+			if e != nil {
+				return e
+			}
+		}
+		return e
+	})
+	if txerr != nil {
+		return 0, txerr
+	}
+	return lastId, nil
+}
+
 // Create 销售申请总结创建
 func (s *SaleApplySummaryService) Create(ctx context.Context, req *model.TraSaleApplySummaryCreateReq) (lastId int64, err error) {
 	DistributorData := new(model.TrainSaleApplySummary)
@@ -57,13 +100,30 @@ func (s *SaleApplySummaryService) Create(ctx context.Context, req *model.TraSale
 	service.SetCreatedInfo(DistributorData, s.GetCxtUserId(), s.GetCxtUserName())
 	svc, _ := NewSaleApplyService(ctx)
 	txerr := s.Dao.DB.Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
-		lastId, err = tx.InsertAndGetId("train_sale_apply_summary", DistributorData)
-		if err != nil {
-			return err
+		count, e := s.Dao.Ctx(ctx).TX(tx).Where(s.Dao.C.ApplyId, req.ApplyId).Count()
+		if e != nil {
+			return e
 		}
-		_, err = svc.Dao.Ctx(ctx).TX(tx).WherePri(req.ApplyId).Data(g.Map{svc.Dao.C.ApplyType: "30"}).Update()
-		if err != nil {
-			return err
+		if count == 0 {
+			lastId, e = tx.InsertAndGetId("train_sale_apply_summary", DistributorData)
+			if e != nil {
+				return e
+			}
+			_, e = svc.Dao.Ctx(ctx).TX(tx).WherePri(req.ApplyId).Data(g.Map{svc.Dao.C.ApplyType: "25"}).Update()
+			if e != nil {
+				return e
+			}
+		} else {
+			_, e = s.Dao.Ctx(ctx).TX(tx).FieldsEx(s.Dao.C.Id, s.Dao.C.CreatedName, s.Dao.C.CreatedBy, s.Dao.C.CreatedTime).
+				Where(s.Dao.C.ApplyId, req.ApplyId).
+				Data(g.Map{s.Dao.C.ApplyId: req.ApplyId, s.Dao.C.ExplainDuration: req.ExplainDuration, s.Dao.C.QuestionRecord: req.QuestionRecord, s.Dao.C.TrainSummary: req.TrainSummary, s.Dao.C.NextStep: req.NextStep}).Update()
+			if e != nil {
+				return e
+			}
+			_, e = svc.Dao.Ctx(ctx).TX(tx).WherePri(req.ApplyId).Data(g.Map{svc.Dao.C.ApplyType: "40"}).Update()
+			if e != nil {
+				return e
+			}
 		}
 		return err
 	})