Răsfoiți Sursa

新增选品提交审核

Ohio-HYF 1 an în urmă
părinte
comite
ae27f528a5

+ 7 - 2
db/selection.go

@@ -125,7 +125,8 @@ func GetSelectionByEnterpiseIdAndProductId(ctx context.Context, enterpriseId str
 
 func GetSelectionList(ctx context.Context, enterpriseID string, pageSize, pageNum int64, conditions *common_model.SelectionConditions) ([]*gorm_model.YounggeeSelectionInfo, int64, error) {
 	db := GetReadDB(ctx)
-	db = db.Debug().Model(gorm_model.YounggeeSelectionInfo{}).Where("enterprise_id = ?", enterpriseID)
+	//db = db.Debug().Model(gorm_model.YounggeeSelectionInfo{}).Where("enterprise_id = ?", enterpriseID)
+	db = db.Debug().Model(gorm_model.YounggeeSelectionInfo{})
 	conditionType := reflect.TypeOf(conditions).Elem()
 	conditionValue := reflect.ValueOf(conditions).Elem()
 	selectionStatus := ""
@@ -135,7 +136,11 @@ func GetSelectionList(ctx context.Context, enterpriseID string, pageSize, pageNu
 		tag := field.Tag.Get("condition")
 		value := conditionValue.FieldByName(field.Name)
 		if tag == "selection_status" {
-			selectionStatus = fmt.Sprintf("%v", value.Interface())
+			selectionStatus = fmt.Sprintf("%v", conv.MustInt(value.Interface(), 0))
+			if selectionStatus != "0" {
+				db = db.Where("selection_status = ?", selectionStatus)
+			}
+
 		} else if tag == "search_value" {
 			searchValue = fmt.Sprintf("%v", value.Interface())
 		} else if tag == "submit_at" && value.Interface() != "" {

+ 61 - 0
handler/SubmitSelection.go

@@ -0,0 +1,61 @@
+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"
+)
+
+func WrapSubmitSelectionHandler(ctx *gin.Context) {
+	handler := newSubmitSelectionHandler(ctx)
+	BaseRun(handler)
+}
+
+type SubmitSelection struct {
+	ctx  *gin.Context
+	req  *http_model.SubmitSelectionRequest
+	resp *http_model.CommonResponse
+}
+
+func (c SubmitSelection) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c SubmitSelection) getResponse() interface{} {
+	return c.resp
+}
+
+func (c SubmitSelection) getRequest() interface{} {
+	return c.req
+}
+
+func (c SubmitSelection) run() {
+	data := http_model.SubmitSelectionRequest{}
+	data = *c.req
+	//auth := middleware.GetSessionAuth(c.ctx)
+	//enterpriseID := auth.EnterpriseID
+	res, err := service.Selection.Submit(c.ctx, data)
+	if err != nil {
+		logrus.Errorf("[SubmitSelection] call SubmitSelection err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("SubmitSelection fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "项目已提交审核"
+	c.resp.Data = res
+}
+
+func (c SubmitSelection) checkParam() error {
+	return nil
+}
+
+func newSubmitSelectionHandler(ctx *gin.Context) *SubmitSelection {
+	return &SubmitSelection{
+		ctx:  ctx,
+		req:  http_model.NewSubmitSelectionRequest(),
+		resp: http_model.NewSubmitSelectionResponse(),
+	}
+}

+ 0 - 1
handler/selection_find_all.go

@@ -36,7 +36,6 @@ func (f FindAllSelectionHandler) getRequest() interface{} {
 }
 
 func (f FindAllSelectionHandler) run() {
-	//enterpriseID := middleware.GetSessionAuth(f.ctx).EnterpriseID
 	condition := pack.HttpFindAllSelectionRequestToCondition(f.req)
 	data, err := service.Selection.GetAllSelection(f.ctx, f.req.EnterpriseId, f.req.PageSize, f.req.PageNum, condition)
 	if err != nil {

+ 18 - 0
model/http_model/SubmitSelection.go

@@ -0,0 +1,18 @@
+package http_model
+
+type SubmitSelectionRequest struct {
+	SelectionId     string `json:"selection_id"` // 选品id
+	SelectionStatus int    `json:"selection_status"`
+}
+
+type SubmitSelectionData struct{}
+
+func NewSubmitSelectionRequest() *SubmitSelectionRequest {
+	return new(SubmitSelectionRequest)
+}
+
+func NewSubmitSelectionResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(SubmitSelectionData)
+	return resp
+}

+ 19 - 18
model/http_model/UpdateSelectionRequest.go

@@ -1,24 +1,25 @@
 package http_model
 
 type UpdateSelectionRequest struct {
-	EnterpriseId    string            `json:"enterprise_id"`
-	SelectionID     string            `json:"selection_id"` // 选品项目id
-	Platform        string            `json:"platform"`
-	ProductId       int               `json:"product_id"`
-	ContentType     int               `json:"content_type"`
-	TaskMode        int               `json:"task_mode"`
-	SampleNum       int               `json:"sample_num"`  // 样品数量
-	RemainNum       int               `json:"remain_num"`  // 剩余数量
-	TaskReward      float64           `json:"task_reward"` // 任务悬赏
-	TaskDdl         string            `json:"task_ddl"`
-	SampleMode      int               `json:"sample_mode"`
-	CommissionRate  int               `json:"commission_rate"`
-	ProductUrl      string            `json:"product_url"`
-	SampleCondition string            `json:"sample_condition"`
-	RewardCondition string            `json:"reward_condition"` // 返现悬赏条件
-	SecBrief        []*SecBriefInfo   `json:"sec_brief"`
-	SecExample      []*SecExampleInfo `json:"sec_example"`
-	Detail          string            `json:"detail"`
+	EnterpriseId     string            `json:"enterprise_id"`
+	SelectionID      string            `json:"selection_id"` // 选品项目id
+	Platform         string            `json:"platform"`
+	ProductId        string            `json:"product_id"`
+	ContentType      int               `json:"content_type"`
+	TaskMode         int               `json:"task_mode"`
+	SampleNum        int               `json:"sample_num"`  // 样品数量
+	RemainNum        int               `json:"remain_num"`  // 剩余数量
+	TaskReward       float64           `json:"task_reward"` // 任务悬赏
+	TaskDdl          string            `json:"task_ddl"`
+	SampleMode       int               `json:"sample_mode"`
+	CommissionRate   int               `json:"commission_rate"`
+	ProductUrl       string            `json:"product_url"`
+	SampleCondition  string            `json:"sample_condition"`
+	RewardCondition  string            `json:"reward_condition"` // 返现悬赏条件
+	SecBrief         []*SecBriefInfo   `json:"sec_brief"`
+	SecExample       []*SecExampleInfo `json:"sec_example"`
+	Detail           string            `json:"detail"`
+	SettlementAmount float64           `json:"settlement_amount"`
 }
 
 type SecBriefInfo struct {

+ 1 - 0
pack/selection.go

@@ -56,5 +56,6 @@ func GormSelectionToHttpSelectionPreview(selectionInfo *gorm_model.YounggeeSelec
 		PayAt:            selectionInfo.PayAt,
 		FinishAt:         selectionInfo.FinishAt,
 		IsRead:           selectionInfo.IsRead,
+		TaskMode:         selectionInfo.TaskMode,
 	}
 }

+ 4 - 3
route/init.go

@@ -190,14 +190,15 @@ 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)                       //删除选品
 		s.POST("/findAll", handler.WrapFindAllSelectionHandler)                     //选品列表
 		s.POST("/detail", handler.WrapSelectionDetailHandler)                       //选品详情
 		s.POST("/create", handler.WrapCreateSelectionHandler)                       // 创建选品
-		s.POST("/update", handler.WrapUpdateSelectionHandler)                       // 更新选品
-		s.POST("/update", handler.WrapReviewSelectionHandler)                       // 选品审核通过
+		s.POST("/update", handler.WrapUpdateSelectionHandler)                       // 更新选品(提交项目审核)
+		s.POST("/submit", handler.WrapSubmitSelectionHandler)                       // 提交项目审核
+		s.POST("/review", handler.WrapReviewSelectionHandler)                       // 选品审核通过
 		s.POST("/pay", handler.WrapPaySelectionHandler)                             // 支付选品项目
 		s.POST("/task/list", handler.WrapGetSecTaskListHandler)                     // 查询选品的任务列表
 		s.POST("/task/coop/pass", handler.WrapPassSecTaskCoopHandler)               // 同意任务合作

+ 20 - 2
service/selection.go

@@ -127,6 +127,8 @@ func (*selection) Update(ctx context.Context, request http_model.UpdateSelection
 		SampleNum:        conv.MustInt(request.SampleNum, 0),
 		RemainNum:        conv.MustInt(request.SampleNum, 0),
 		CommissionRate:   conv.MustInt(request.CommissionRate, 0),
+		TaskReward:       conv.MustString(request.TaskReward, "0"),
+		SettlementAmount: conv.MustString(request.SettlementAmount, "0"),
 		EstimatedCost:    estimatedCostToString,
 		SampleCondition:  request.SampleCondition,
 		RewardCondition:  request.RewardCondition,
@@ -139,9 +141,9 @@ func (*selection) Update(ctx context.Context, request http_model.UpdateSelection
 		SubmitAt:         time.Now(),
 	}
 	// 合并传入参数和数据表中原记录,若传入参数字段值为空,则将字段赋值为原记录中值
-	result := util.MergeStructValue(&updateSelection, &selectionInfo)
+	result := util.MergeStructValue(&updateSelection, selectionInfo)
 	// 利用反射机制将interface类型转换为结构体类型
-	v := reflect.ValueOf(result).Elem()
+	v := reflect.ValueOf(&result).Elem()
 	if v.Kind() == reflect.Struct {
 		updateSelection = v.Interface().(gorm_model.YounggeeSelectionInfo)
 		//fmt.Println(p)
@@ -193,6 +195,22 @@ func (*selection) Pay(ctx context.Context, request http_model.PaySelectionReques
 	return res, nil
 }
 
+func (*selection) Submit(ctx context.Context, request http_model.SubmitSelectionRequest) (*http_model.SubmitSelectionData, error) {
+	updateSelection := gorm_model.YounggeeSelectionInfo{
+		SelectionID:     request.SelectionId,
+		SelectionStatus: request.SelectionStatus,
+		SubmitAt:        time.Now(),
+	}
+
+	err := db.UpdateSelection(ctx, updateSelection)
+	if err != nil {
+		return nil, err
+	}
+
+	res := &http_model.SubmitSelectionData{}
+	return res, nil
+}
+
 func (s *selection) GetAllSelection(ctx context.Context, enterpriseID string, pageSize, pageNum int64, conditions *common_model.SelectionConditions) (*http_model.SelectionData, error) {
 	SelectionList, total, err := db.GetSelectionList(ctx, enterpriseID, pageSize, pageNum, conditions)
 	if err != nil {