Kaynağa Gözat

818会议修改

“liushuai” 1 yıl önce
ebeveyn
işleme
99816bbf7c

+ 46 - 1
.idea/workspace.xml

@@ -6,13 +6,19 @@
   <component name="ChangeListManager">
     <list default="true" id="8dde75a1-d1c1-4fc1-81a0-4db9a43a6250" name="更改" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+<<<<<<< HEAD
+=======
+      <change beforePath="$PROJECT_DIR$/db/selection.go" beforeDir="false" afterPath="$PROJECT_DIR$/db/selection.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/model/http_model/UpdateSelectionRequest.go" beforeDir="false" afterPath="$PROJECT_DIR$/model/http_model/UpdateSelectionRequest.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/service/selection.go" beforeDir="false" afterPath="$PROJECT_DIR$/service/selection.go" afterDir="false" />
+>>>>>>> new
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
     <option name="LAST_RESOLUTION" value="IGNORE" />
   </component>
-  <component name="GOROOT" url="file://$PROJECT_DIR$/../../../Application/Go" />
+  <component name="GOROOT" url="file://$PROJECT_DIR$/../../../develop_tools/Go" />
   <component name="Git.Settings">
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
   </component>
@@ -21,6 +27,7 @@
     <option name="hideEmptyMiddlePackages" value="true" />
     <option name="showLibraryContents" value="true" />
   </component>
+<<<<<<< HEAD
   <component name="PropertiesComponent">{
   &quot;keyToString&quot;: {
     &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
@@ -36,6 +43,44 @@
     &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;
   }
 }</component>
+=======
+  <component name="PropertiesComponent"><![CDATA[{
+  "keyToString": {
+    "RunOnceActivity.OpenProjectViewOnStart": "true",
+    "RunOnceActivity.ShowReadmeOnStart": "true",
+    "RunOnceActivity.go.formatter.settings.were.checked": "true",
+    "RunOnceActivity.go.migrated.go.modules.settings": "true",
+    "RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
+    "WebServerToolWindowFactoryState": "false",
+    "go.import.settings.migrated": "true",
+    "go.sdk.automatically.set": "true",
+    "last_opened_file_path": "C:/Users/24678",
+    "node.js.detected.package.eslint": "true",
+    "node.js.selected.package.eslint": "(autodetect)"
+  }
+}]]></component>
+  <component name="RunManager">
+    <configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
+      <module name="youngee_m_api" />
+      <working_directory value="$PROJECT_DIR$" />
+      <go_parameters value="-i" />
+      <kind value="FILE" />
+      <directory value="$PROJECT_DIR$" />
+      <filePath value="$PROJECT_DIR$" />
+      <method v="2" />
+    </configuration>
+    <configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
+      <module name="youngee_m_api" />
+      <working_directory value="$PROJECT_DIR$" />
+      <go_parameters value="-i" />
+      <kind value="DIRECTORY" />
+      <directory value="$PROJECT_DIR$" />
+      <filePath value="$PROJECT_DIR$" />
+      <framework value="gotest" />
+      <method v="2" />
+    </configuration>
+  </component>
+>>>>>>> new
   <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
   <component name="TypeScriptGeneratedFilesManager">
     <option name="version" value="3" />

+ 42 - 0
db/selection.go

@@ -240,3 +240,45 @@ func PaySelection(ctx context.Context, enterpriseId string, payMoney float64, se
 	}
 	return nil
 }
+
+func CreateSecBrief(ctx context.Context, briefInfo gorm_model.YounggeeSecBrief) error {
+	db := GetWriteDB(ctx)
+	err := db.Create(&briefInfo).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func DeleteSecBriefBySelectionId(ctx context.Context, selectionId string) error {
+	db := GetWriteDB(ctx)
+	deleteCondition := gorm_model.YounggeeSecBrief{
+		SelectionID: selectionId,
+	}
+	err := db.Where(deleteCondition).Delete(gorm_model.YounggeeSecBrief{}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func CreateSecExample(ctx context.Context, ExampleInfo gorm_model.YounggeeSecExample) error {
+	db := GetWriteDB(ctx)
+	err := db.Create(&ExampleInfo).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func DeleteSecExampleBySelectionId(ctx context.Context, selectionId string) error {
+	db := GetWriteDB(ctx)
+	deleteCondition := gorm_model.YounggeeSecExample{
+		SelectionID: selectionId,
+	}
+	err := db.Where(deleteCondition).Delete(gorm_model.YounggeeSecExample{}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 6 - 3
handler/selection_review.go

@@ -1,12 +1,13 @@
 package handler
 
 import (
-	"github.com/gin-gonic/gin"
-	"github.com/sirupsen/logrus"
 	"youngee_m_api/consts"
 	"youngee_m_api/model/http_model"
 	"youngee_m_api/service"
 	"youngee_m_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
 )
 
 func WrapReviewSelectionHandler(ctx *gin.Context) {
@@ -42,7 +43,9 @@ func (c ReviewSelection) run() {
 		logrus.Info("ReviewSelection fail,req:%+v", c.req)
 		return
 	}
-	c.resp.Message = "成功创建选品"
+	if data.IsPass == 1 {
+		c.resp.Message = "审核成功"
+	}
 	c.resp.Data = res
 }
 

+ 4 - 3
handler/selection_update.go

@@ -1,12 +1,13 @@
 package handler
 
 import (
-	"github.com/gin-gonic/gin"
-	"github.com/sirupsen/logrus"
 	"youngee_m_api/consts"
 	"youngee_m_api/model/http_model"
 	"youngee_m_api/service"
 	"youngee_m_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
 )
 
 func WrapUpdateSelectionHandler(ctx *gin.Context) {
@@ -42,7 +43,7 @@ func (c UpdateSelection) run() {
 		logrus.Info("UpdateSelection fail,req:%+v", c.req)
 		return
 	}
-	c.resp.Message = "成功创建选品"
+	c.resp.Message = "更新选品成功"
 	c.resp.Data = res
 }
 

+ 1 - 1
model/http_model/UpdateSelectionRequest.go

@@ -3,7 +3,7 @@ package http_model
 type UpdateSelectionRequest struct {
 	EnterpriseId     string            `json:"enterprise_id"`
 	SelectionID      string            `json:"selection_id"` // 选品项目id
-	SelectionStatus  string            `json:"selection_status"`
+	SelectionStatus  int               `json:"selection_status"`
 	Platform         int               `json:"platform"`
 	ProductId        string            `json:"product_id"`
 	ContentType      int               `json:"content_type"`

+ 1 - 0
route/init.go

@@ -190,6 +190,7 @@ func InitRoute(r *gin.Engine) {
 	// 选品广场相关接口
 	s := r.Group("/youngee/m/selection")
 	{
+		//s.Use(middleware.LoginAuthMiddleware)
 		//s.Use(middleware.LoginAuthMiddleware)
 		s.GET("/reviewnumber", handler.WrapSelectionReviewNumberHandler)            //查询选品待审核的数量
 		s.POST("/delete", handler.WrapDeleteSelectionHandler)                       //删除选品

+ 52 - 7
service/selection.go

@@ -84,7 +84,7 @@ func (*selection) Create(ctx context.Context, request http_model.CreateSelection
 
 func (*selection) Update(ctx context.Context, request http_model.UpdateSelectionRequest, enterpriseId string) (*http_model.UpdateSelectionData, error) {
 	// 1. 检查该企业id和商品id有无选品
-	selectionInfo, err := db.GetSelectionByEnterpiseIdAndProductId(ctx, enterpriseId, conv.MustInt(request.ProductId, 0))
+	selectionInfo, err := db.GetSelectionById(ctx, request.SelectionID)
 	if err != nil {
 		return nil, err
 	}
@@ -106,18 +106,18 @@ func (*selection) Update(ctx context.Context, request http_model.UpdateSelection
 	// d) 任务截止时间
 	taskDdl := time.Time{} //赋零值
 	taskDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", request.TaskDdl, time.Local)
-
-	if request.SelectionStatus != "2" && request.SelectionStatus != "7" {
-		request.SelectionStatus = "1"
+	// f) 更新选品状态
+	if request.SelectionStatus != 2 && request.SelectionStatus != 7 {
+		request.SelectionStatus = 1
 	}
 
 	updateSelection := gorm_model.YounggeeSelectionInfo{
 		SelectionID:      request.SelectionID,
+		SelectionStatus:  request.SelectionStatus,
 		SelectionName:    selectionName,
 		EnterpriseID:     enterpriseId,
 		ProductID:        conv.MustInt(request.ProductId, 0),
 		ContentType:      conv.MustInt(request.ContentType, 0),
-		SelectionStatus:  selectionInfo.SelectionStatus,
 		TaskMode:         conv.MustInt(request.TaskMode, 0),
 		Platform:         conv.MustInt(request.Platform, 0),
 		SampleMode:       conv.MustInt(request.SampleMode, 0),
@@ -148,8 +148,8 @@ func (*selection) Update(ctx context.Context, request http_model.UpdateSelection
 	}
 	// c) 计算预估成本(如果有)
 	var estimatedCost float64
-	if conv.MustInt(request.TaskMode, 0) == 1 {
-		estimatedCost = conv.MustFloat64(request.TaskReward, 0) * conv.MustFloat64(request.SampleNum, 0)
+	if conv.MustInt(updateSelection.TaskMode, 0) == 1 {
+		estimatedCost = conv.MustFloat64(updateSelection.TaskReward, 0) * conv.MustFloat64(updateSelection.SampleNum, 0)
 	}
 	estimatedCostToString, _ := conv.String(estimatedCost)
 	updateSelection.EstimatedCost = estimatedCostToString
@@ -160,6 +160,51 @@ func (*selection) Update(ctx context.Context, request http_model.UpdateSelection
 		return nil, err
 	}
 
+	// 4. 更新选品brief和示例
+	if request.SecBrief != nil {
+		// 删除已有brief
+		err = db.DeleteSecBriefBySelectionId(ctx, selectionInfo.SelectionID)
+		if err != nil {
+			return nil, err
+		}
+		// 插入新的brief
+		for _, v := range request.SecBrief {
+			brief := gorm_model.YounggeeSecBrief{
+				SelectionID: selectionInfo.SelectionID,
+				FileUid:     v.PhotoUid,
+				FileName:    v.Name,
+				FileUrl:     v.PhotoUrl,
+				CreatedAt:   time.Now(),
+			}
+			err = db.CreateSecBrief(ctx, brief)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+
+	if request.SecExample != nil {
+		// 删除已有示例
+		err = db.DeleteSecExampleBySelectionId(ctx, selectionInfo.SelectionID)
+		if err != nil {
+			return nil, err
+		}
+		// 插入新的示例
+		for _, v := range request.SecExample {
+			Example := gorm_model.YounggeeSecExample{
+				SelectionID: selectionInfo.SelectionID,
+				FileUid:     v.PhotoUid,
+				FileName:    v.Name,
+				FileUrl:     v.PhotoUrl,
+				CreatedAt:   time.Now(),
+			}
+			err = db.CreateSecExample(ctx, Example)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+
 	res := &http_model.UpdateSelectionData{
 		SelectionId: updateSelection.SelectionID,
 	}