瀏覽代碼

选品接口1

Ohio-HYF 1 年之前
父節點
當前提交
a02a1c25bb

+ 2 - 10
db/message.go

@@ -46,15 +46,8 @@ func CreateMessageByTaskId(ctx context.Context, messageId int, messageType int,
 }
 
 // 插入新消息
-func CreateMessage(ctx context.Context, messageId int, messageType int, talentId string, projectId string) error {
+func CreateMessage(ctx context.Context, messageId int, messageType int, talentId string, projectName string) error {
 	db := GetReadDB(ctx)
-	var projectName string
-	err := db.Model(gorm_model.ProjectInfo{}).Select("project_name").Where("project_id = ?", projectId).Find(&projectName).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error read mysql, err:%+v", err)
-		return err
-	}
-
 	messageInfo := gorm_model.YounggeeMessageInfo{
 		MessageID:   messageId,
 		MessageType: messageType,
@@ -64,8 +57,7 @@ func CreateMessage(ctx context.Context, messageId int, messageType int, talentId
 		IsReaded:    0,
 		IsDeleted:   0,
 	}
-	db1 := GetReadDB(ctx)
-	err = db1.Model(gorm_model.YounggeeMessageInfo{}).Create(&messageInfo).Error
+	err := db.Model(gorm_model.YounggeeMessageInfo{}).Create(&messageInfo).Error
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[CreateMessageByTask] error create mysql, err:%+v", err)
 		return err

+ 35 - 0
db/product.go

@@ -2,6 +2,7 @@ package db
 
 import (
 	"context"
+	"github.com/sirupsen/logrus"
 	"youngee_b_api/model/gorm_model"
 
 	"gorm.io/gorm"
@@ -62,3 +63,37 @@ func GetProductIDByName(ctx context.Context, brandName string, productName strin
 	}
 	return &product.ProductID, nil
 }
+
+func GetProductInfoBySelectionId(ctx context.Context, selectionId string) (*gorm_model.YounggeeProduct, error) {
+	db := GetReadDB(ctx)
+	productId := 0
+	err := db.Model(gorm_model.YounggeeSelectionInfo{}).Select("product_id").Where("selection_id = ?", selectionId).Find(&productId).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProductInfo] error query mysql, err:%+v", err)
+		return nil, err
+	}
+	productInfo := gorm_model.YounggeeProduct{}
+	err = db.Model(gorm_model.YounggeeProduct{}).Where("product_id = ?", productId).Find(&productInfo).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProductInfo] error query mysql, err:%+v", err)
+		return nil, err
+	}
+	return &productInfo, nil
+}
+
+func GetProductPhotoInfoBySelectionId(ctx context.Context, selectionId string) ([]*gorm_model.YounggeeProductPhoto, error) {
+	db := GetReadDB(ctx)
+	productId := 0
+	err := db.Model(gorm_model.YounggeeSelectionInfo{}).Select("product_id").Where("selection_id = ?", selectionId).Find(&productId).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProductInfo] error query mysql, err:%+v", err)
+		return nil, err
+	}
+	var productPhotoInfo []*gorm_model.YounggeeProductPhoto
+	err = db.Model(gorm_model.YounggeeProductPhoto{}).Where("product_id = ?", productId).Find(&productPhotoInfo).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProductInfo] error query mysql, err:%+v", err)
+		return nil, err
+	}
+	return productPhotoInfo, nil
+}

+ 176 - 0
db/sectask.go

@@ -0,0 +1,176 @@
+package db
+
+import (
+	"context"
+	"errors"
+	"github.com/sirupsen/logrus"
+	"gorm.io/gorm"
+	"strings"
+	"time"
+	"youngee_b_api/model/gorm_model"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/pack"
+)
+
+func GetSecTaskList(ctx context.Context, selectionId string, taskStatus int, searchValue string, pageSize, pageNum int64) ([]*http_model.SecTaskInfo, int64, error) {
+	db := GetReadDB(ctx)
+	whereCondition := gorm_model.YounggeeSecTaskInfo{
+		SelectionID: selectionId,
+		TaskStatus:  taskStatus,
+	}
+	db = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where(whereCondition)
+
+	// 查询总数
+	var total int64
+	var secTaskInfoList []*gorm_model.YounggeeSecTaskInfo
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetSelectionList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	// 查询该页数据
+	limit := pageSize
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("create_date desc").Limit(int(limit)).Offset(int(offset)).Find(&secTaskInfoList).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetSelectionList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+
+	newSecTaskInfoList := pack.GormSecTaskListToHttpSecTaskList(secTaskInfoList)
+	var resSecTaskInfoList []*http_model.SecTaskInfo
+	if searchValue != "" {
+		for _, v := range newSecTaskInfoList {
+			if strings.Contains(v.SelectionId, searchValue) {
+				resSecTaskInfoList = append(resSecTaskInfoList, v)
+			} else if strings.Contains(v.PlatformNickname, searchValue) {
+				resSecTaskInfoList = append(resSecTaskInfoList, v)
+			} else {
+				total--
+			}
+		}
+	} else {
+		resSecTaskInfoList = newSecTaskInfoList
+	}
+	return resSecTaskInfoList, total, nil
+}
+
+func PassSecTaskCoop(ctx context.Context, selectionId string, taskIds []string) (bool, error) {
+	db := GetWriteDB(ctx)
+	// 1. 校验
+	var count int64
+	err := db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND task_stage = 3", taskIds).Count(&count).Error
+	if err != nil {
+		return false, err
+	}
+	if int64(len(taskIds)) == 0 || count != int64(len(taskIds)) {
+		return false, errors.New("任务id有误")
+	}
+
+	// 2. 查询任务对应达人id(用于生成达人消息)
+	var talentIds []string
+	err = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ?", taskIds).Select("talent_id").Find(talentIds).Error
+	if err != nil {
+		return false, err
+	}
+	// 3. 查询任务对应选品名称(用于生成达人消息)
+	var selection gorm_model.YounggeeSelectionInfo
+	err = db.Model(gorm_model.YounggeeSelectionInfo{}).Where("selection_id = ?", selectionId).Find(selection).Error
+	if err != nil {
+		return false, err
+	}
+
+	err = db.Transaction(func(tx *gorm.DB) error {
+		// 2. 修改任务状态和任务阶段
+		// 若选品不提供样品,则直接跳转执行阶段,否则进入发货阶段
+		if selection.SampleMode == 3 {
+			updateData := gorm_model.YounggeeSecTaskInfo{
+				TaskStatus:      2,
+				TaskStage:       6,
+				SelectDate:      time.Now(),
+				LogisticsStatus: 1,
+			}
+			err = tx.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND task_stage = 3", taskIds).Updates(updateData).Error
+			if err != nil {
+				return err
+			}
+		} else {
+			updateData := gorm_model.YounggeeSecTaskInfo{
+				TaskStatus:       2,
+				TaskStage:        8,
+				SelectDate:       time.Now(),
+				LogisticsStatus:  3,
+				AssignmentStatus: 1,
+			}
+			err = tx.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND task_stage = 3", taskIds).Updates(updateData).Error
+			if err != nil {
+				return err
+			}
+		}
+		// 3. 生成达人消息
+		for _, talendId := range talentIds {
+			err = CreateMessage(ctx, 1, 1, talendId, selection.SelectionName)
+			if err != nil {
+				return err
+			}
+		}
+		// 返回 nil 提交事务
+		return nil
+	})
+	if err != nil {
+		return false, err
+	}
+	return true, nil
+}
+
+func RefuseSecTaskCoop(ctx context.Context, taskIds []string) (bool, error) {
+	db := GetWriteDB(ctx)
+	// 1. 校验
+	var count int64
+	err := db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND task_stage = 3", taskIds).Count(&count).Error
+	if err != nil {
+		return false, err
+	}
+	if count != int64(len(taskIds)) {
+		return false, errors.New("任务id有误")
+	}
+
+	// 查询任务对应达人id
+	var talentIds []string
+	err = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ?", taskIds).Select("talent_id").Find(talentIds).Error
+	if err != nil {
+		return false, err
+	}
+
+	err = db.Transaction(func(tx *gorm.DB) error {
+		// 2. 修改任务状态和任务阶段
+		updateData := gorm_model.YounggeeSecTaskInfo{
+			TaskStatus:     3,
+			TaskStage:      5,
+			CompleteDate:   time.Now(),
+			CompleteStatus: 3,
+		}
+		err = tx.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND task_stage = 3", taskIds).Updates(updateData).Error
+		if err != nil {
+			return err
+		}
+
+		// 返回 nil 提交事务
+		return nil
+	})
+	if err != nil {
+		return false, err
+	}
+	return true, nil
+}
+
+func UpdateSecTask(ctx context.Context, updateData gorm_model.YounggeeSecTaskInfo) (bool, error) {
+	db := GetWriteDB(ctx)
+	whereCondition := gorm_model.YounggeeSecTaskInfo{
+		TaskID: updateData.TaskID,
+	}
+	err := db.Where(whereCondition).Updates(&updateData).Error
+	if err != nil {
+		return false, err
+	}
+	return true, nil
+}

+ 29 - 0
db/sectask_logistics.go

@@ -0,0 +1,29 @@
+package db
+
+import (
+	"context"
+	"youngee_b_api/model/gorm_model"
+)
+
+func CreateSecTaskLogistics(ctx context.Context, logistics gorm_model.YoungeeTaskLogistics) (*int64, error) {
+	db := GetWriteDB(ctx)
+	err := db.Create(&logistics).Error
+	if err != nil {
+		return nil, err
+	}
+
+	return &logistics.LogisticsID, nil
+}
+
+func UpdateSecTaskLogistics(ctx context.Context, updateData gorm_model.YoungeeTaskLogistics) (*int64, error) {
+	db := GetWriteDB(ctx)
+	whereCondition := gorm_model.YoungeeTaskLogistics{
+		LogisticsID: updateData.LogisticsID,
+	}
+	err := db.Where(whereCondition).Updates(&updateData).Error
+	if err != nil {
+		return nil, err
+	}
+
+	return &updateData.LogisticsID, nil
+}

+ 76 - 40
db/selection.go

@@ -2,8 +2,10 @@ package db
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	"github.com/sirupsen/logrus"
+	"gorm.io/gorm"
 	"reflect"
 	"strings"
 	"youngee_b_api/model/common_model"
@@ -11,6 +13,25 @@ import (
 	"youngee_b_api/util"
 )
 
+func CreateSelection(ctx context.Context, selectionInfo gorm_model.YounggeeSelectionInfo) error {
+	db := GetWriteDB(ctx)
+	err := db.Create(&selectionInfo).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func UpdateSelection(ctx context.Context, selectionInfo gorm_model.YounggeeSelectionInfo) error {
+	db := GetWriteDB(ctx)
+	whereCondition := gorm_model.YounggeeSelectionInfo{SelectionID: selectionInfo.SelectionID}
+	err := db.Model(&gorm_model.YounggeeSelectionInfo{}).Where(whereCondition).Updates(selectionInfo).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
 func DeleteSelection(ctx context.Context, SelectionId string) error {
 	db := GetReadDB(ctx)
 	err := db.Where("selection_id = ?", SelectionId).Delete(&gorm_model.YounggeeSelectionInfo{}).Error
@@ -20,6 +41,36 @@ func DeleteSelection(ctx context.Context, SelectionId string) error {
 	return nil
 }
 
+func GetSelectionById(ctx context.Context, selectionId string) (*gorm_model.YounggeeSelectionInfo, error) {
+	db := GetWriteDB(ctx)
+	selectionInfo := gorm_model.YounggeeSelectionInfo{}
+	whereCondition := gorm_model.YounggeeSelectionInfo{SelectionID: selectionId}
+	result := db.Where(&whereCondition).First(&selectionInfo)
+	if result.Error != nil {
+		if errors.Is(result.Error, gorm.ErrRecordNotFound) {
+			return nil, nil
+		} else {
+			return nil, result.Error
+		}
+	}
+	return &selectionInfo, nil
+}
+
+func GetSelectionByEnterpiseIdAndProductId(ctx context.Context, enterpriseId string, productId int) (*gorm_model.YounggeeSelectionInfo, error) {
+	db := GetWriteDB(ctx)
+	selectionInfo := gorm_model.YounggeeSelectionInfo{}
+	whereCondition := gorm_model.YounggeeSelectionInfo{EnterpriseID: enterpriseId, ProductID: productId}
+	result := db.Where(&whereCondition).First(&selectionInfo)
+	if result.Error != nil {
+		if errors.Is(result.Error, gorm.ErrRecordNotFound) {
+			return nil, nil
+		} else {
+			return nil, result.Error
+		}
+	}
+	return &selectionInfo, nil
+}
+
 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)
@@ -81,17 +132,6 @@ func GetSelectionList(ctx context.Context, enterpriseID string, pageSize, pageNu
 	return newSelectionInfos, total, nil
 }
 
-func GetSelectionInfo(ctx context.Context, selectionId string) (*gorm_model.YounggeeSelectionInfo, error) {
-	db := GetReadDB(ctx)
-	selectionInfo := gorm_model.YounggeeSelectionInfo{}
-	err := db.Model(gorm_model.YounggeeSelectionInfo{}).Where("selection_id = ?", selectionId).Find(&selectionInfo).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetSelectionList] error query mysql total, err:%+v", err)
-		return nil, err
-	}
-	return &selectionInfo, nil
-}
-
 func GetSelectionBriefInfo(ctx context.Context, selectionId string) ([]*gorm_model.YounggeeSecBrief, error) {
 	db := GetReadDB(ctx)
 	var selectionBriefInfos []*gorm_model.YounggeeSecBrief
@@ -114,36 +154,32 @@ func GetSelectionExampleInfo(ctx context.Context, selectionId string) ([]*gorm_m
 	return selectionExampleInfos, nil
 }
 
-func GetProductInfo(ctx context.Context, selectionId string) (*gorm_model.YounggeeProduct, error) {
-	db := GetReadDB(ctx)
-	productId := 0
-	err := db.Model(gorm_model.YounggeeSelectionInfo{}).Select("product_id").Where("selection_id = ?", selectionId).Find(&productId).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetProductInfo] error query mysql, err:%+v", err)
-		return nil, err
-	}
-	productInfo := gorm_model.YounggeeProduct{}
-	err = db.Model(gorm_model.YounggeeProduct{}).Where("product_id = ?", productId).Find(&productInfo).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetProductInfo] error query mysql, err:%+v", err)
-		return nil, err
-	}
-	return &productInfo, nil
-}
+func PaySelection(ctx context.Context, enterpriseId string, payMoney float64, selectionId string) error {
+	db := GetWriteDB(ctx)
+	err := db.Transaction(func(tx *gorm.DB) error {
+		// 1. 冻结账户余额
+		whereCondition := gorm_model.Enterprise{
+			EnterpriseID: enterpriseId,
+		}
+		updateData := map[string]interface{}{
+			"frozen_balance":    gorm.Expr("frozen_balance + ?", payMoney),
+			"available_balance": gorm.Expr("available_balance - ?", payMoney)}
+		if err := tx.Model(gorm_model.Enterprise{}).Where(whereCondition).Updates(updateData).Error; err != nil {
+			return err
+		}
 
-func GetProductPhotoInfo(ctx context.Context, selectionId string) ([]*gorm_model.YounggeeProductPhoto, error) {
-	db := GetReadDB(ctx)
-	productId := 0
-	err := db.Model(gorm_model.YounggeeSelectionInfo{}).Select("product_id").Where("selection_id = ?", selectionId).Find(&productId).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetProductInfo] error query mysql, err:%+v", err)
-		return nil, err
-	}
-	var productPhotoInfo []*gorm_model.YounggeeProductPhoto
-	err = db.Model(gorm_model.YounggeeProductPhoto{}).Where("product_id = ?", productId).Find(&productPhotoInfo).Error
+		// 2. 更新选品项目状态
+		whereCondition1 := gorm_model.YounggeeSelectionInfo{SelectionID: selectionId, SelectionStatus: 4}
+		updateData1 := gorm_model.YounggeeSelectionInfo{SelectionStatus: 6}
+		if err := tx.Model(gorm_model.YounggeeSelectionInfo{}).Where(whereCondition1).Updates(updateData1).Error; err != nil {
+			return err
+		}
+
+		// 返回 nil 提交事务
+		return nil
+	})
 	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetProductInfo] error query mysql, err:%+v", err)
-		return nil, err
+		return err
 	}
-	return productPhotoInfo, nil
+	return nil
 }

+ 1 - 0
go.mod

@@ -9,6 +9,7 @@ require (
 )
 
 require (
+	github.com/caixw/lib.go v0.0.0-20141220110639-1781da9139e0
 	github.com/go-openapi/swag v0.21.1 // indirect
 	github.com/go-playground/validator/v10 v10.10.1 // indirect
 	github.com/go-redis/redis/v8 v8.11.5

+ 2 - 0
go.sum

@@ -11,6 +11,8 @@ github.com/agiledragon/gomonkey v2.0.2+incompatible h1:eXKi9/piiC3cjJD1658mEE2o3
 github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw=
 github.com/agiledragon/gomonkey/v2 v2.3.1 h1:k+UnUY0EMNYUFUAQVETGY9uUTxjMdnUkP0ARyJS1zzs=
 github.com/agiledragon/gomonkey/v2 v2.3.1/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY=
+github.com/caixw/lib.go v0.0.0-20141220110639-1781da9139e0 h1:MnIURgMAFAMyxAHu8h2TbnjxMMd7SKVCPyTZz5EfwNA=
+github.com/caixw/lib.go v0.0.0-20141220110639-1781da9139e0/go.mod h1:hQL8hyiiVE/BSo7gh13njx+DpvoPh/yE8/BkKKc62RA=
 github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
 github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=

+ 60 - 0
handler/CreateSecTaskLogistics.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"youngee_b_api/consts"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service/sectask_service"
+	"youngee_b_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+)
+
+func WrapCreateSecTaskLogisticsHandler(ctx *gin.Context) {
+	handler := newCreateSecTaskLogisticsHandler(ctx)
+	baseRun(handler)
+}
+
+type CreateSecTaskLogistics struct {
+	ctx  *gin.Context
+	req  *http_model.CreateSecTaskLogisticsRequest
+	resp *http_model.CommonResponse
+}
+
+func (c CreateSecTaskLogistics) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c CreateSecTaskLogistics) getResponse() interface{} {
+	return c.resp
+}
+
+func (c CreateSecTaskLogistics) getRequest() interface{} {
+	return c.req
+}
+
+func (c CreateSecTaskLogistics) run() {
+	data := http_model.CreateSecTaskLogisticsRequest{}
+	data = *c.req
+	res, err := sectask_service.Logistics.Create(c.ctx, data)
+	if err != nil {
+		logrus.Errorf("[CreateSecTaskLogistics] call CreateSecTaskLogistics err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("CreateSecTaskLogistics fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功添加发货信息"
+	c.resp.Data = res
+}
+
+func (c CreateSecTaskLogistics) checkParam() error {
+	return nil
+}
+
+func newCreateSecTaskLogisticsHandler(ctx *gin.Context) *CreateSecTaskLogistics {
+	return &CreateSecTaskLogistics{
+		ctx:  ctx,
+		req:  http_model.NewCreateSecTaskLogisticsRequest(),
+		resp: http_model.NewCreateSecTaskLogisticsResponse(),
+	}
+}

+ 62 - 0
handler/CreateSelection.go

@@ -0,0 +1,62 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/middleware"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service/selection_service"
+	"youngee_b_api/util"
+)
+
+func WrapCreateSelectionHandler(ctx *gin.Context) {
+	handler := newCreateSelectionHandler(ctx)
+	baseRun(handler)
+}
+
+type CreateSelection struct {
+	ctx  *gin.Context
+	req  *http_model.CreateSelectionRequest
+	resp *http_model.CommonResponse
+}
+
+func (c CreateSelection) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c CreateSelection) getResponse() interface{} {
+	return c.resp
+}
+
+func (c CreateSelection) getRequest() interface{} {
+	return c.req
+}
+
+func (c CreateSelection) run() {
+	data := http_model.CreateSelectionRequest{}
+	data = *c.req
+	auth := middleware.GetSessionAuth(c.ctx)
+	enterpriseID := auth.EnterpriseID
+	res, err := selection_service.Selection.Create(c.ctx, data, enterpriseID)
+	if err != nil {
+		logrus.Errorf("[CreateSelection] call CreateSelection err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("CreateSelection fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功创建选品"
+	c.resp.Data = res
+}
+
+func (c CreateSelection) checkParam() error {
+	return nil
+}
+
+func newCreateSelectionHandler(ctx *gin.Context) *CreateSelection {
+	return &CreateSelection{
+		ctx:  ctx,
+		req:  http_model.NewCreateSelectionRequest(),
+		resp: http_model.NewCreateSelectionResponse(),
+	}
+}

+ 61 - 0
handler/GetSecTaskList.go

@@ -0,0 +1,61 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service/sectask_service"
+	"youngee_b_api/util"
+)
+
+func WrapGetSecTaskListHandler(ctx *gin.Context) {
+	handler := newGetSecTaskListHandler(ctx)
+	baseRun(handler)
+}
+
+type GetSecTaskList struct {
+	ctx  *gin.Context
+	req  *http_model.GetSecTaskListRequest
+	resp *http_model.CommonResponse
+}
+
+func (c GetSecTaskList) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c GetSecTaskList) getResponse() interface{} {
+	return c.resp
+}
+
+func (c GetSecTaskList) getRequest() interface{} {
+	return c.req
+}
+
+func (c GetSecTaskList) run() {
+	data := http_model.GetSecTaskListRequest{}
+	data = *c.req
+	//auth := middleware.GetSessionAuth(c.ctx)
+	//enterpriseID := auth.EnterpriseID
+	res, err := sectask_service.SelectionTask.GetList(c.ctx, data)
+	if err != nil {
+		logrus.Errorf("[GetSecTaskList] call GetSecTaskList err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("GetSecTaskList fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功查询选品任务"
+	c.resp.Data = res
+}
+
+func (c GetSecTaskList) checkParam() error {
+	return nil
+}
+
+func newGetSecTaskListHandler(ctx *gin.Context) *GetSecTaskList {
+	return &GetSecTaskList{
+		ctx:  ctx,
+		req:  http_model.NewGetSecTaskListRequest(),
+		resp: http_model.NewGetSecTaskListResponse(),
+	}
+}

+ 61 - 0
handler/PassSecTaskCoop.go

@@ -0,0 +1,61 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service/sectask_service"
+	"youngee_b_api/util"
+)
+
+func WrapPassSecTaskCoopHandler(ctx *gin.Context) {
+	handler := newPassSecTaskCoopHandler(ctx)
+	baseRun(handler)
+}
+
+type PassSecTaskCoop struct {
+	ctx  *gin.Context
+	req  *http_model.PassSecTaskCoopRequest
+	resp *http_model.CommonResponse
+}
+
+func (c PassSecTaskCoop) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c PassSecTaskCoop) getResponse() interface{} {
+	return c.resp
+}
+
+func (c PassSecTaskCoop) getRequest() interface{} {
+	return c.req
+}
+
+func (c PassSecTaskCoop) run() {
+	data := http_model.PassSecTaskCoopRequest{}
+	data = *c.req
+	//auth := middleware.GetSessionAuth(c.ctx)
+	//enterpriseID := auth.EnterpriseID
+	res, err := sectask_service.SelectionTask.PassCoop(c.ctx, data)
+	if err != nil {
+		logrus.Errorf("[PassSecTaskCoop] call PassSecTaskCoop err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("PassSecTaskCoop fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功合作选品任务"
+	c.resp.Data = res
+}
+
+func (c PassSecTaskCoop) checkParam() error {
+	return nil
+}
+
+func newPassSecTaskCoopHandler(ctx *gin.Context) *PassSecTaskCoop {
+	return &PassSecTaskCoop{
+		ctx:  ctx,
+		req:  http_model.NewPassSecTaskCoopRequest(),
+		resp: http_model.NewPassSecTaskCoopResponse(),
+	}
+}

+ 62 - 0
handler/PaySelection.go

@@ -0,0 +1,62 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/middleware"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service/selection_service"
+	"youngee_b_api/util"
+)
+
+func WrapPaySelectionHandler(ctx *gin.Context) {
+	handler := newPaySelectionHandler(ctx)
+	baseRun(handler)
+}
+
+type PaySelection struct {
+	ctx  *gin.Context
+	req  *http_model.PaySelectionRequest
+	resp *http_model.CommonResponse
+}
+
+func (c PaySelection) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c PaySelection) getResponse() interface{} {
+	return c.resp
+}
+
+func (c PaySelection) getRequest() interface{} {
+	return c.req
+}
+
+func (c PaySelection) run() {
+	data := http_model.PaySelectionRequest{}
+	data = *c.req
+	auth := middleware.GetSessionAuth(c.ctx)
+	enterpriseID := auth.EnterpriseID
+	res, err := selection_service.Selection.Pay(c.ctx, data, enterpriseID)
+	if err != nil {
+		logrus.Errorf("[PaySelection] call PaySelection err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("PaySelection fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "支付成功"
+	c.resp.Data = res
+}
+
+func (c PaySelection) checkParam() error {
+	return nil
+}
+
+func newPaySelectionHandler(ctx *gin.Context) *PaySelection {
+	return &PaySelection{
+		ctx:  ctx,
+		req:  http_model.NewPaySelectionRequest(),
+		resp: http_model.NewPaySelectionResponse(),
+	}
+}

+ 61 - 0
handler/RefuseSecTaskCoop.go

@@ -0,0 +1,61 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service/sectask_service"
+	"youngee_b_api/util"
+)
+
+func WrapRefuseSecTaskCoopHandler(ctx *gin.Context) {
+	handler := newRefuseSecTaskCoopHandler(ctx)
+	baseRun(handler)
+}
+
+type RefuseSecTaskCoop struct {
+	ctx  *gin.Context
+	req  *http_model.RefuseSecTaskCoopRequest
+	resp *http_model.CommonResponse
+}
+
+func (c RefuseSecTaskCoop) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c RefuseSecTaskCoop) getResponse() interface{} {
+	return c.resp
+}
+
+func (c RefuseSecTaskCoop) getRequest() interface{} {
+	return c.req
+}
+
+func (c RefuseSecTaskCoop) run() {
+	data := http_model.RefuseSecTaskCoopRequest{}
+	data = *c.req
+	//auth := middleware.GetSessionAuth(c.ctx)
+	//enterpriseID := auth.EnterpriseID
+	res, err := sectask_service.SelectionTask.RefuseCoop(c.ctx, data)
+	if err != nil {
+		logrus.Errorf("[RefuseSecTaskCoop] call RefuseSecTaskCoop err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("RefuseSecTaskCoop fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功拒绝选品任务"
+	c.resp.Data = res
+}
+
+func (c RefuseSecTaskCoop) checkParam() error {
+	return nil
+}
+
+func newRefuseSecTaskCoopHandler(ctx *gin.Context) *RefuseSecTaskCoop {
+	return &RefuseSecTaskCoop{
+		ctx:  ctx,
+		req:  http_model.NewRefuseSecTaskCoopRequest(),
+		resp: http_model.NewRefuseSecTaskCoopResponse(),
+	}
+}

+ 60 - 0
handler/UpdateSecTaskLogistics.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"youngee_b_api/consts"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service/sectask_service"
+	"youngee_b_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+)
+
+func WrapUpdateSecTaskLogisticsHandler(ctx *gin.Context) {
+	handler := newUpdateSecTaskLogisticsHandler(ctx)
+	baseRun(handler)
+}
+
+type UpdateSecTaskLogistics struct {
+	ctx  *gin.Context
+	req  *http_model.UpdateSecTaskLogisticsRequest
+	resp *http_model.CommonResponse
+}
+
+func (c UpdateSecTaskLogistics) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c UpdateSecTaskLogistics) getResponse() interface{} {
+	return c.resp
+}
+
+func (c UpdateSecTaskLogistics) getRequest() interface{} {
+	return c.req
+}
+
+func (c UpdateSecTaskLogistics) run() {
+	data := http_model.UpdateSecTaskLogisticsRequest{}
+	data = *c.req
+	res, err := sectask_service.Logistics.Update(c.ctx, data)
+	if err != nil {
+		logrus.Errorf("[UpdateSecTaskLogistics] call UpdateSecTaskLogistics err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("UpdateSecTaskLogistics fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功添加发货信息"
+	c.resp.Data = res
+}
+
+func (c UpdateSecTaskLogistics) checkParam() error {
+	return nil
+}
+
+func newUpdateSecTaskLogisticsHandler(ctx *gin.Context) *UpdateSecTaskLogistics {
+	return &UpdateSecTaskLogistics{
+		ctx:  ctx,
+		req:  http_model.NewUpdateSecTaskLogisticsRequest(),
+		resp: http_model.NewUpdateSecTaskLogisticsResponse(),
+	}
+}

+ 62 - 0
handler/UpdateSelection.go

@@ -0,0 +1,62 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/middleware"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service/selection_service"
+	"youngee_b_api/util"
+)
+
+func WrapUpdateSelectionHandler(ctx *gin.Context) {
+	handler := newUpdateSelectionHandler(ctx)
+	baseRun(handler)
+}
+
+type UpdateSelection struct {
+	ctx  *gin.Context
+	req  *http_model.UpdateSelectionRequest
+	resp *http_model.CommonResponse
+}
+
+func (c UpdateSelection) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c UpdateSelection) getResponse() interface{} {
+	return c.resp
+}
+
+func (c UpdateSelection) getRequest() interface{} {
+	return c.req
+}
+
+func (c UpdateSelection) run() {
+	data := http_model.UpdateSelectionRequest{}
+	data = *c.req
+	auth := middleware.GetSessionAuth(c.ctx)
+	enterpriseID := auth.EnterpriseID
+	res, err := selection_service.Selection.Update(c.ctx, data, enterpriseID)
+	if err != nil {
+		logrus.Errorf("[UpdateSelection] call UpdateSelection err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("UpdateSelection fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功创建选品"
+	c.resp.Data = res
+}
+
+func (c UpdateSelection) checkParam() error {
+	return nil
+}
+
+func newUpdateSelectionHandler(ctx *gin.Context) *UpdateSelection {
+	return &UpdateSelection{
+		ctx:  ctx,
+		req:  http_model.NewUpdateSelectionRequest(),
+		resp: http_model.NewUpdateSelectionResponse(),
+	}
+}

+ 2 - 2
handler/selection_detail.go

@@ -6,7 +6,7 @@ import (
 	"youngee_b_api/consts"
 	"youngee_b_api/middleware"
 	"youngee_b_api/model/http_model"
-	"youngee_b_api/service"
+	"youngee_b_api/service/selection_service"
 	"youngee_b_api/util"
 )
 
@@ -35,7 +35,7 @@ func (s SelectionDetailHandler) getRequest() interface{} {
 
 func (s SelectionDetailHandler) run() {
 	enterpriseID := middleware.GetSessionAuth(s.ctx).EnterpriseID
-	res, err := service.Selection.GetSelectionDetail(s.ctx, s.req.SelectionId, enterpriseID)
+	res, err := selection_service.Selection.GetSelectionDetail(s.ctx, s.req.SelectionId, enterpriseID)
 	if err != nil {
 		logrus.Errorf("[GetSelectionDetail] call Show err:%+v\n", err)
 		util.HandlerPackErrorResp(s.resp, consts.ErrorInternal, "")

+ 2 - 2
handler/selection_find_all.go

@@ -9,7 +9,7 @@ import (
 	"youngee_b_api/middleware"
 	"youngee_b_api/model/http_model"
 	"youngee_b_api/pack"
-	"youngee_b_api/service"
+	"youngee_b_api/service/selection_service"
 	"youngee_b_api/util"
 )
 
@@ -39,7 +39,7 @@ 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, enterpriseID, f.req.PageSize, f.req.PageNum, condition)
+	data, err := selection_service.Selection.GetAllSelection(f.ctx, enterpriseID, f.req.PageSize, f.req.PageNum, condition)
 	if err != nil {
 		logrus.WithContext(f.ctx).Errorf("[FindAllSelectionHandler] error GetAllSelection, err:%+v", err)
 		util.HandlerPackErrorResp(f.resp, consts.ErrorInternal, consts.DefaultToast)

+ 24 - 0
model/http_model/CreateSecTaskLogistics.go

@@ -0,0 +1,24 @@
+package http_model
+
+type CreateSecTaskLogisticsRequest struct {
+	TaskID                string `json:"task_id"`                // 任务id
+	CompanyName           string `json:"company_name"`           // 实物商品-物流公司名称
+	LogisticsNumber       string `json:"logistics_number"`       // 实物商品-物流单号
+	ExplorestoreStarttime string `json:"explorestore_starttime"` // 线下探店-探店开始时间
+	ExplorestoreEndtime   string `json:"explorestore_endtime"`   // 线下探店-探店结束时间
+	ExplorestorePeriod    string `json:"explorestore_period"`    // 线下探店-探店持续时间
+	ThingsType            int    `json:"things_type"`            // 产品类型 1:实物, 3:线下探店
+}
+
+type CreateSecTaskLogisticsData struct {
+}
+
+func NewCreateSecTaskLogisticsRequest() *CreateSecTaskLogisticsRequest {
+	return new(CreateSecTaskLogisticsRequest)
+}
+
+func NewCreateSecTaskLogisticsResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(CreateSecTaskLogisticsData)
+	return resp
+}

+ 20 - 0
model/http_model/CreateSelection.go

@@ -0,0 +1,20 @@
+package http_model
+
+type CreateSelectionRequest struct {
+	Platform  string `json:"platform"`
+	ProductId string `json:"product_id"`
+}
+
+type CreateSelectionData struct {
+	SelectionId string `json:"selection_id"`
+}
+
+func NewCreateSelectionRequest() *CreateSelectionRequest {
+	return new(CreateSelectionRequest)
+}
+
+func NewCreateSelectionResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(CreateSelectionData)
+	return resp
+}

+ 38 - 0
model/http_model/GetSecTaskList.go

@@ -0,0 +1,38 @@
+package http_model
+
+import (
+	"time"
+)
+
+type GetSecTaskListRequest struct {
+	PageSize      int64  `json:"page_size"`
+	PageNum       int64  `json:"page_num"`
+	SelectionId   string `json:"selection_id"`
+	SecTaskStatus int    `json:"sec_task_status"`
+	SearchValue   string `json:"search_value"`
+}
+
+type GetSecTaskListData struct {
+	SecTaskList []*SecTaskInfo `json:"sec_task_list"`
+	Total       string         `json:"total"`
+}
+
+type SecTaskInfo struct {
+	SelectionId        string    `json:"selection_id"`
+	PlatformNickname   string    `json:"platform_nickname"`                            // 帐号昵称
+	FansCount          string    `json:"fans_count"`                                   // 粉丝数
+	HomePageCaptureUrl string    `json:"home_page_capture_url"`                        // 主页截图链接
+	HomePageUrl        string    `json:"home_page_url"`                                // 主页链接
+	CreateDate         time.Time `json:"column:create_date;default:CURRENT_TIMESTAMP"` // 创建时间
+	SelectDate         time.Time `json:"column:select_date"`                           // 反选时间
+}
+
+func NewGetSecTaskListRequest() *GetSecTaskListRequest {
+	return new(GetSecTaskListRequest)
+}
+
+func NewGetSecTaskListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(GetSecTaskListData)
+	return resp
+}

+ 19 - 0
model/http_model/PassSecTaskCoop.go

@@ -0,0 +1,19 @@
+package http_model
+
+type PassSecTaskCoopRequest struct {
+	SelectionId string   `json:"selection_id"`
+	TaskIds     []string `json:"task_ids"`
+}
+
+type PassSecTaskCoopData struct {
+}
+
+func NewPassSecTaskCoopRequest() *PassSecTaskCoopRequest {
+	return new(PassSecTaskCoopRequest)
+}
+
+func NewPassSecTaskCoopResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(PassSecTaskCoopData)
+	return resp
+}

+ 20 - 0
model/http_model/PaySelection.go

@@ -0,0 +1,20 @@
+package http_model
+
+type PaySelectionRequest struct {
+	PayMoney    float64 `json:"pay_money"`
+	SelectionId string  `json:"selection_id"`
+}
+
+type PaySelectionData struct {
+	SelectionId string `json:"selection_id"`
+}
+
+func NewPaySelectionRequest() *PaySelectionRequest {
+	return new(PaySelectionRequest)
+}
+
+func NewPaySelectionResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(PaySelectionData)
+	return resp
+}

+ 18 - 0
model/http_model/RefuseSecTaskCoop.go

@@ -0,0 +1,18 @@
+package http_model
+
+type RefuseSecTaskCoopRequest struct {
+	TaskIds []string `json:"task_ids"`
+}
+
+type RefuseSecTaskCoopData struct {
+}
+
+func NewRefuseSecTaskCoopRequest() *RefuseSecTaskCoopRequest {
+	return new(RefuseSecTaskCoopRequest)
+}
+
+func NewRefuseSecTaskCoopResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(RefuseSecTaskCoopData)
+	return resp
+}

+ 25 - 0
model/http_model/UpdateSecTaskLogistics.go

@@ -0,0 +1,25 @@
+package http_model
+
+type UpdateSecTaskLogisticsRequest struct {
+	TaskID                string `json:"task_id"`                // 任务id
+	LogisticsId           int64  `json:"logistics_id"`           // 物流信息id
+	CompanyName           string `json:"company_name"`           // 实物商品-物流公司名称
+	LogisticsNumber       string `json:"logistics_number"`       // 实物商品-物流单号
+	ExplorestoreStarttime string `json:"explorestore_starttime"` // 线下探店-探店开始时间
+	ExplorestoreEndtime   string `json:"explorestore_endtime"`   // 线下探店-探店结束时间
+	ExplorestorePeriod    string `json:"explorestore_period"`    // 线下探店-探店持续时间
+	ThingsType            int    `json:"things_type"`            // 产品类型 1:实物, 3:线下探店
+}
+
+type UpdateSecTaskLogisticsData struct {
+}
+
+func NewUpdateSecTaskLogisticsRequest() *UpdateSecTaskLogisticsRequest {
+	return new(UpdateSecTaskLogisticsRequest)
+}
+
+func NewUpdateSecTaskLogisticsResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(UpdateSecTaskLogisticsData)
+	return resp
+}

+ 47 - 0
model/http_model/UpdateSelection.go

@@ -0,0 +1,47 @@
+package http_model
+
+type UpdateSelectionRequest struct {
+	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"`
+}
+
+type SecBriefInfo struct {
+	FileUrl  string `json:"file_url"`
+	FileUid  string `json:"file_uid"`
+	FileName string `json:"file_name"`
+}
+
+type SecExampleInfo struct {
+	FileUrl  string `json:"file_url"`
+	FileUid  string `json:"file_uid"`
+	FileName string `json:"file_name"`
+}
+
+type UpdateSelectionData struct {
+	SelectionId string `json:"selection_id"`
+}
+
+func NewUpdateSelectionRequest() *UpdateSelectionRequest {
+	return new(UpdateSelectionRequest)
+}
+
+func NewUpdateSelectionResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(UpdateSelectionData)
+	return resp
+}

+ 10 - 10
model/http_model/logistics_create.go

@@ -1,18 +1,18 @@
 package http_model
 
 type CreateLogisticsRequest struct {
-	StrategyID            int64     `json:"strategy_id"`             //招募策略id
-	LogisticsID           int64     `json:"logistics_id"`            // 货物-id
-	CompanyName           string    `json:"company_name"`            // 实物商品-物流公司名称
-	LogisticsNumber       string    `json:"logistics_number"`        // 实物商品-物流单号
+	StrategyID            int64  `json:"strategy_id"`             //招募策略id
+	LogisticsID           int64  `json:"logistics_id"`            // 货物-id
+	CompanyName           string `json:"company_name"`            // 实物商品-物流公司名称
+	LogisticsNumber       string `json:"logistics_number"`        // 实物商品-物流单号
 	ExplorestoreStarttime string `json:"explorestore_starttime"`  // 线下探店-探店开始时间
 	ExplorestoreEndtime   string `json:"explorestore_endtime"`    // 线下探店-探店结束时间
-	ExplorestorePeriod    string    `json:"explorestore_period"`     // 线下探店-探店持续时间
-	CouponCodeInformation string    `json:"coupon_code_information"` // 虚拟产品-券码信息
-	TaskID                string    `json:"task_id"`                 // 任务id
-	DeliveryTime          string    `json:"delivery_time"`           // 发货时间
-	ThingsType            int       `json:"things_type"`             //产品类型 1:实物, 2:虚拟产品,3:线下探店
-	IsUpdate              int       `json:"is_update"`               //更新标志位 0:不更新 1:更新
+	ExplorestorePeriod    string `json:"explorestore_period"`     // 线下探店-探店持续时间
+	CouponCodeInformation string `json:"coupon_code_information"` // 虚拟产品-券码信息
+	TaskID                string `json:"task_id"`                 // 任务id
+	DeliveryTime          string `json:"delivery_time"`           // 发货时间
+	ThingsType            int    `json:"things_type"`             //产品类型 1:实物, 2:虚拟产品,3:线下探店
+	IsUpdate              int    `json:"is_update"`               //更新标志位 0:不更新 1:更新
 }
 
 type CreateLogisticsData struct {

+ 30 - 0
pack/sec_task_list.go

@@ -0,0 +1,30 @@
+package pack
+
+import (
+	"github.com/tidwall/gjson"
+	"youngee_b_api/model/gorm_model"
+	"youngee_b_api/model/http_model"
+
+	"github.com/caixw/lib.go/conv"
+)
+
+func GormSecTaskListToHttpSecTaskList(secTaskList []*gorm_model.YounggeeSecTaskInfo) []*http_model.SecTaskInfo {
+	var resTaskTaskList []*http_model.SecTaskInfo
+	for _, secTask := range secTaskList {
+		secTaskH := GormSecTaskToHttpSecTask(secTask)
+		resTaskTaskList = append(resTaskTaskList, secTaskH)
+	}
+	return resTaskTaskList
+}
+
+func GormSecTaskToHttpSecTask(secTask *gorm_model.YounggeeSecTaskInfo) *http_model.SecTaskInfo {
+	TalentPlatformInfoSnap := secTask.TalentPlatformInfoSnap
+	return &http_model.SecTaskInfo{
+		PlatformNickname:   conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname"), ""),
+		FansCount:          conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count"), ""),
+		HomePageCaptureUrl: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "home_page_capture_url"), ""),
+		HomePageUrl:        conv.MustString(gjson.Get(TalentPlatformInfoSnap, "home_page_url"), ""),
+		CreateDate:         secTask.CreateDate,
+		SelectDate:         secTask.SelectDate,
+	}
+}

+ 12 - 3
route/init.go

@@ -132,14 +132,23 @@ func InitRoute(r *gin.Engine) {
 		m.POST("/project/recruit/getservicecharge", handler.WrapGetServiceChargeHandler)         // 获取产品置换服务费
 		m.POST("/product/deletePhotoUrl", handler.WrapDeletePhotoUrlHandler)                     // 在数据库中删除图片url
 		m.POST("/qrcode/getwxqrcode", handler.WrapGetWxQRCodeHandler)                            // 获取微信二维码
+
 	}
 
 	// 选品广场相关接口
 	s := r.Group("/youngee/s")
 	{
 		s.Use(middleware.LoginAuthMiddleware)
-		s.POST("/selection/delete", handler.WrapDeleteSelectionHandler)   //删除选品
-		s.POST("/selection/findAll", handler.WrapFindAllSelectionHandler) //选品列表
-		s.POST("/selection/detail", handler.WrapSelectionDetailHandler)   //选品详情
+		s.POST("/selectionDB/delete", handler.WrapDeleteSelectionHandler)                       //删除选品
+		s.POST("/selectionDB/findAll", handler.WrapFindAllSelectionHandler)                     //选品列表
+		s.POST("/selectionDB/detail", handler.WrapSelectionDetailHandler)                       //选品详情
+		s.POST("/selectionDB/create", handler.WrapCreateSelectionHandler)                       // 创建选品
+		s.POST("/selectionDB/update", handler.WrapUpdateSelectionHandler)                       // 更新选品
+		s.POST("/selectionDB/pay", handler.WrapPaySelectionHandler)                             // 支付选品项目
+		s.POST("/selectionDB/task/list", handler.WrapGetSecTaskListHandler)                     // 查询选品的任务列表
+		s.POST("/selectionDB/task/coop/pass", handler.WrapPassSecTaskCoopHandler)               // 同意任务合作
+		s.POST("/selectionDB/task/coop/refuse", handler.WrapRefuseSecTaskCoopHandler)           // 拒绝任务合作
+		s.POST("/selectionDB/task/logistics/create", handler.WrapCreateSecTaskLogisticsHandler) // 上传物流信息
+		s.POST("/selectionDB/task/logistics/update", handler.WrapUpdateSecTaskLogisticsHandler) // 修改物流信息
 	}
 }

+ 106 - 0
service/sectask_service/logistics.go

@@ -0,0 +1,106 @@
+package sectask_service
+
+import (
+	"context"
+	"github.com/sirupsen/logrus"
+	"time"
+	"youngee_b_api/db"
+	"youngee_b_api/model/gorm_model"
+	"youngee_b_api/model/http_model"
+)
+
+var Logistics *logistics
+
+type logistics struct {
+}
+
+func (*logistics) Create(ctx context.Context, request http_model.CreateSecTaskLogisticsRequest) (*http_model.CreateSecTaskLogisticsData, error) {
+	ThingsType := request.ThingsType
+	newLogistics := gorm_model.YoungeeTaskLogistics{
+		TaskID:                request.TaskID,
+		ThingsType:            int64(ThingsType),
+		ExplorestoreStarttime: time.Now(),
+		ExplorestoreEndtime:   time.Now(),
+		DeliveryTime:          time.Now(),
+	}
+	//实物
+	if ThingsType == 1 {
+		newLogistics.CompanyName = request.CompanyName
+		newLogistics.LogisticsNumber = request.LogisticsNumber
+		newLogistics.DeliveryTime = time.Now()
+	} else if ThingsType == 3 {
+		ExplorestoreStarttime, _ := time.ParseInLocation("2006-01-02 15:04:05", request.ExplorestoreStarttime, time.Local)
+		ExplorestoreEndtime, _ := time.ParseInLocation("2006-01-02 15:04:05", request.ExplorestoreEndtime, time.Local)
+		newLogistics.ExplorestoreStarttime = ExplorestoreStarttime
+		newLogistics.ExplorestoreEndtime = ExplorestoreEndtime
+	}
+
+	_, err := db.CreateSecTaskLogistics(ctx, newLogistics)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[newLogistics service] call CreatenewLogistics error,err:%+v", err)
+		return nil, err
+	}
+
+	// 修改task_info中发货时间、任务阶段
+	updatdSecTask := gorm_model.YounggeeSecTaskInfo{
+		TaskID:          request.TaskID,
+		LogisticsStatus: 2,
+		TaskStage:       7,
+		DeliveryDate:    time.Now(),
+	}
+	_, err = db.UpdateSecTask(ctx, updatdSecTask)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[sectask logistics service] call UpdateSecTask error,err:%+v", err)
+		return nil, err
+	}
+
+	// 记录任务日志-发货
+	err = db.CreateTaskLog(ctx, newLogistics.TaskID, "发货时间")
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[newLogistics service] call CreateTaskLog error,err:%+v", err)
+		return nil, err
+	}
+
+	err = db.CreateMessageByTaskId(ctx, 8, 2, newLogistics.TaskID)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[newLogistics service] call CreateMessageByTaskId error,err:%+v", err)
+		return nil, err
+	}
+
+	data := http_model.CreateSecTaskLogisticsData{}
+
+	return &data, nil
+}
+
+func (*logistics) Update(ctx context.Context, request http_model.UpdateSecTaskLogisticsRequest) (*http_model.UpdateSecTaskLogisticsData, error) {
+	ThingsType := request.ThingsType
+	newLogistics := gorm_model.YoungeeTaskLogistics{
+		LogisticsID:           request.LogisticsId,
+		TaskID:                request.TaskID,
+		ThingsType:            int64(ThingsType),
+		ExplorestoreStarttime: time.Now(),
+		ExplorestoreEndtime:   time.Now(),
+		DeliveryTime:          time.Now(),
+	}
+	//实物
+	if ThingsType == 1 {
+		newLogistics.CompanyName = request.CompanyName
+		newLogistics.LogisticsNumber = request.LogisticsNumber
+		newLogistics.DeliveryTime = time.Now()
+	} else if ThingsType == 3 {
+		ExplorestoreStarttime, _ := time.ParseInLocation("2006-01-02 15:04:05", request.ExplorestoreStarttime, time.Local)
+		ExplorestoreEndtime, _ := time.ParseInLocation("2006-01-02 15:04:05", request.ExplorestoreEndtime, time.Local)
+		newLogistics.ExplorestoreStarttime = ExplorestoreStarttime
+		newLogistics.ExplorestoreEndtime = ExplorestoreEndtime
+	}
+
+	_, err := db.UpdateSecTaskLogistics(ctx, newLogistics)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[newLogistics service] call UpdatenewLogistics error,err:%+v", err)
+		return nil, err
+	}
+
+	data := http_model.UpdateSecTaskLogisticsData{}
+
+	return &data, nil
+}

+ 1 - 0
service/sectask_service/recruit.go

@@ -0,0 +1 @@
+package sectask_service

+ 55 - 0
service/sectask_service/sectask.go

@@ -0,0 +1,55 @@
+package sectask_service
+
+import (
+	"context"
+	"github.com/issue9/conv"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/db"
+	"youngee_b_api/model/http_model"
+)
+
+var SelectionTask *selectionTask
+
+type selectionTask struct {
+}
+
+func (*selectionTask) GetList(ctx context.Context, request http_model.GetSecTaskListRequest) (*http_model.GetSecTaskListData, error) {
+	secTaskList, total, err := db.GetSecTaskList(ctx, request.SelectionId, request.SecTaskStatus, request.SearchValue, request.PageSize, request.PageNum)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[sectask_service service] call GetAllSelection error,err:%+v", err)
+		return nil, err
+	}
+
+	selectionListData := http_model.GetSecTaskListData{
+		Total:       conv.MustString(total, ""),
+		SecTaskList: secTaskList,
+	}
+
+	return &selectionListData, nil
+}
+
+func (*selectionTask) PassCoop(ctx context.Context, request http_model.PassSecTaskCoopRequest) (*http_model.PassSecTaskCoopData, error) {
+
+	_, err := db.PassSecTaskCoop(ctx, request.SelectionId, request.TaskIds)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[sectask_service service] call PassCoop error,err:%+v", err)
+		return nil, err
+	}
+
+	selectionListData := http_model.PassSecTaskCoopData{}
+
+	return &selectionListData, nil
+}
+
+func (*selectionTask) RefuseCoop(ctx context.Context, request http_model.RefuseSecTaskCoopRequest) (*http_model.RefuseSecTaskCoopData, error) {
+
+	_, err := db.RefuseSecTaskCoop(ctx, request.TaskIds)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[sectask_service service] call RefuseCoop error,err:%+v", err)
+		return nil, err
+	}
+
+	selectionListData := http_model.RefuseSecTaskCoopData{}
+
+	return &selectionListData, nil
+}

+ 1 - 0
service/sectask_service/settle.go

@@ -0,0 +1 @@
+package sectask_service

+ 0 - 64
service/selection.go

@@ -1,64 +0,0 @@
-package service
-
-import (
-	"context"
-	"github.com/gin-gonic/gin"
-	"github.com/issue9/conv"
-	"github.com/sirupsen/logrus"
-	"youngee_b_api/db"
-	"youngee_b_api/model/common_model"
-	"youngee_b_api/model/http_model"
-	"youngee_b_api/pack"
-)
-
-var Selection *selection
-
-type selection struct {
-}
-
-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 {
-		logrus.WithContext(ctx).Errorf("[selection service] call GetAllSelection error,err:%+v", err)
-		return nil, err
-	}
-	SelectionListData := new(http_model.SelectionData)
-	SelectionListData.SelectionInfo = pack.MGormSelectionToHttpSelectionPreview(SelectionList)
-	SelectionListData.Total = conv.MustString(total)
-	return SelectionListData, nil
-}
-
-func (s *selection) GetSelectionDetail(ctx *gin.Context, selectionId, enterpriseID string) (*http_model.SelectionDetail, error) {
-	selectionDetail := http_model.SelectionDetail{}
-	selectionInfo, err := db.GetSelectionInfo(ctx, selectionId)
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[selection service] call GetSelectionInfo error,err:%+v", err)
-		return nil, err
-	}
-	selectionBriefInfo, err := db.GetSelectionBriefInfo(ctx, selectionId)
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[selection service] call GetSelectionBriefInfo error,err:%+v", err)
-		return nil, err
-	}
-	selectionExampleInfo, err := db.GetSelectionExampleInfo(ctx, selectionId)
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[selection service] call GetSelectionExampleInfo error,err:%+v", err)
-		return nil, err
-	}
-	productInfo, err := db.GetProductInfo(ctx, selectionId)
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[selection service] call GetProductInfo error,err:%+v", err)
-		return nil, err
-	}
-	productPhotoInfo, err := db.GetProductPhotoInfo(ctx, selectionId)
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[selection service] call GetProductPhotoInfo error,err:%+v", err)
-		return nil, err
-	}
-	selectionDetail.SelectionBrief = selectionBriefInfo
-	selectionDetail.SelectionInfo = selectionInfo
-	selectionDetail.SelectionExample = selectionExampleInfo
-	selectionDetail.ProductInfo = productInfo
-	selectionDetail.ProductPhotoInfo = productPhotoInfo
-	return &selectionDetail, nil
-}

+ 230 - 0
service/selection_service/selection.go

@@ -0,0 +1,230 @@
+package selection_service
+
+import (
+	"context"
+	"encoding/json"
+	"errors"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"reflect"
+	"time"
+	"youngee_b_api/db"
+	"youngee_b_api/model/common_model"
+	"youngee_b_api/model/gorm_model"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/pack"
+	"youngee_b_api/util"
+
+	"github.com/caixw/lib.go/conv"
+)
+
+var Selection *selection
+
+type selection struct {
+}
+
+func (*selection) Create(ctx context.Context, request http_model.CreateSelectionRequest, enterpriseId string) (*http_model.CreateSelectionData, error) {
+	// 1. 检查该企业id和商品id有无选品
+	selectionInfo, err := db.GetSelectionByEnterpiseIdAndProductId(ctx, enterpriseId, conv.MustInt(request.ProductId, 0))
+	if err != nil {
+		return nil, err
+	}
+	if selectionInfo != nil {
+		return nil, errors.New("该商品下选品已存在")
+	}
+
+	// 2. 数据准备
+	// a) 生成选品id
+	selectionId := util.GetSelectionID()
+	// b) 查找关联商品信息
+	product, err := db.GetProductByID(ctx, conv.MustInt64(request.ProductId, 0))
+	if err != nil {
+		return nil, err
+	}
+	productPhotos, err := db.GetProductPhotoByProductID(ctx, conv.MustInt64(request.ProductId, 0))
+	productInfoToJson, _ := json.Marshal(product)
+	productPhotosToJson, _ := json.Marshal(productPhotos)
+	// c) 选品名称
+	selectionName := product.BrandName + "-" + product.ProductName
+
+	// 3. 创建选品
+	newSelection := gorm_model.YounggeeSelectionInfo{
+		SelectionID:      selectionId,
+		SelectionName:    selectionName,
+		ProductID:        conv.MustInt(request.ProductId, 0),
+		EnterpriseID:     enterpriseId,
+		Platform:         conv.MustInt(request.Platform, 0),
+		ProductSnap:      string(productInfoToJson),
+		ProductPhotoSnap: string(productPhotosToJson),
+		CreatedAt:        time.Now(),
+	}
+	err = db.CreateSelection(ctx, newSelection)
+	if err != nil {
+		return nil, err
+	}
+
+	res := &http_model.CreateSelectionData{
+		SelectionId: selectionId,
+	}
+	return res, nil
+}
+
+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))
+	if err != nil {
+		return nil, err
+	}
+	if selectionInfo == nil {
+		return nil, errors.New("选品不存在")
+	}
+
+	// 2. 数据准备
+	// a) 查找关联商品信息
+	product, err := db.GetProductByID(ctx, conv.MustInt64(request.ProductId, 0))
+	if err != nil {
+		return nil, err
+	}
+	productPhotos, err := db.GetProductPhotoByProductID(ctx, conv.MustInt64(request.ProductId, 0))
+	productInfoToJson, _ := json.Marshal(product)
+	productPhotosToJson, _ := json.Marshal(productPhotos)
+	// b) 选品名称
+	selectionName := product.BrandName + "-" + product.ProductName
+	// c) 计算预估成本(如果有)
+	var estimatedCost float64
+	if conv.MustInt(request.TaskMode, 0) == 1 {
+		estimatedCost = conv.MustFloat64(request.TaskReward, 0) * conv.MustFloat64(request.SampleNum, 0)
+	}
+	estimatedCostToString, _ := conv.String(estimatedCost)
+	// d) 任务截止时间
+	taskDdl := time.Time{} //赋零值
+	if request.TaskDdl != "" {
+		taskDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", request.TaskDdl, time.Local)
+	}
+
+	updateSelection := gorm_model.YounggeeSelectionInfo{
+		SelectionID:      request.SelectionID,
+		SelectionName:    selectionName,
+		EnterpriseID:     enterpriseId,
+		ProductID:        conv.MustInt(request.ProductId, 0),
+		ContentType:      conv.MustInt(request.ContentType, 0),
+		SelectionStatus:  1,
+		TaskMode:         conv.MustInt(request.TaskMode, 0),
+		Platform:         conv.MustInt(request.Platform, 0),
+		SampleMode:       conv.MustInt(request.SampleMode, 0),
+		ProductUrl:       request.ProductUrl,
+		SampleNum:        conv.MustInt(request.SampleNum, 0),
+		RemainNum:        conv.MustInt(request.SampleNum, 0),
+		CommissionRate:   conv.MustInt(request.CommissionRate, 0),
+		EstimatedCost:    estimatedCostToString,
+		SampleCondition:  request.SampleCondition,
+		RewardCondition:  request.RewardCondition,
+		TaskDdl:          taskDdl,
+		Detail:           request.Detail,
+		ProductSnap:      string(productInfoToJson),
+		ProductPhotoSnap: string(productPhotosToJson),
+		CreatedAt:        selectionInfo.CreatedAt,
+		UpdatedAt:        time.Now(),
+		SubmitAt:         time.Now(),
+	}
+	// 合并传入参数和数据表中原记录,若传入参数字段值为空,则将字段赋值为原记录中值
+	result := util.MergeStructValue(&updateSelection, &selectionInfo)
+	// 利用反射机制将interface类型转换为结构体类型
+	v := reflect.ValueOf(result).Elem()
+	if v.Kind() == reflect.Struct {
+		updateSelection = v.Interface().(gorm_model.YounggeeSelectionInfo)
+		//fmt.Println(p)
+	}
+
+	// 3. 更新选品
+	err = db.UpdateSelection(ctx, updateSelection)
+	if err != nil {
+		return nil, err
+	}
+
+	res := &http_model.UpdateSelectionData{
+		SelectionId: updateSelection.SelectionID,
+	}
+	return res, nil
+}
+
+func (*selection) Pay(ctx context.Context, request http_model.PaySelectionRequest, enterpriseId string) (*http_model.PaySelectionData, error) {
+	// 校验
+	// 1. 账户余额是否足够
+	enterprise, err := db.GetEnterpriseByEnterpriseID(ctx, enterpriseId)
+	if err != nil {
+		return nil, err
+	}
+	if enterprise.AvailableBalance < request.PayMoney {
+		return nil, errors.New("账户余额不足")
+	}
+	// 2. 选品项目状态是否正确
+	selectionInfo, err := db.GetSelectionById(ctx, request.SelectionId)
+	if err != nil {
+		return nil, err
+	}
+	if selectionInfo == nil {
+		return nil, errors.New("选品不存在")
+	}
+	if selectionInfo.SelectionStatus != 4 {
+		return nil, errors.New("选品状态有误")
+	}
+
+	// 支付
+	err = db.PaySelection(ctx, enterpriseId, request.PayMoney, request.SelectionId)
+	if err != nil {
+		return nil, err
+	}
+
+	res := &http_model.PaySelectionData{
+		SelectionId: request.SelectionId,
+	}
+	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 {
+		logrus.WithContext(ctx).Errorf("[selectionDB service] call GetAllSelection error,err:%+v", err)
+		return nil, err
+	}
+	SelectionListData := new(http_model.SelectionData)
+	SelectionListData.SelectionInfo = pack.MGormSelectionToHttpSelectionPreview(SelectionList)
+	SelectionListData.Total = conv.MustString(total, "")
+	return SelectionListData, nil
+}
+
+func (s *selection) GetSelectionDetail(ctx *gin.Context, selectionId, enterpriseID string) (*http_model.SelectionDetail, error) {
+	selectionDetail := http_model.SelectionDetail{}
+	selectionInfo, err := db.GetSelectionById(ctx, selectionId)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[selectionDB service] call GetSelectionInfo error,err:%+v", err)
+		return nil, err
+	}
+	selectionBriefInfo, err := db.GetSelectionBriefInfo(ctx, selectionId)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[selectionDB service] call GetSelectionBriefInfo error,err:%+v", err)
+		return nil, err
+	}
+	selectionExampleInfo, err := db.GetSelectionExampleInfo(ctx, selectionId)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[selectionDB service] call GetSelectionExampleInfo error,err:%+v", err)
+		return nil, err
+	}
+	productInfo, err := db.GetProductInfoBySelectionId(ctx, selectionId)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[selectionDB service] call GetProductInfo error,err:%+v", err)
+		return nil, err
+	}
+	productPhotoInfo, err := db.GetProductPhotoInfoBySelectionId(ctx, selectionId)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[selectionDB service] call GetProductPhotoInfo error,err:%+v", err)
+		return nil, err
+	}
+	selectionDetail.SelectionBrief = selectionBriefInfo
+	selectionDetail.SelectionInfo = selectionInfo
+	selectionDetail.SelectionExample = selectionExampleInfo
+	selectionDetail.ProductInfo = productInfo
+	selectionDetail.ProductPhotoInfo = productPhotoInfo
+	return &selectionDetail, nil
+}

+ 22 - 0
util/structFunc.go

@@ -0,0 +1,22 @@
+package util
+
+import "reflect"
+
+/*
+	合并两个结构体的值,遍历结构体s1,若s1中某字段值为空,则将s2该字段的值赋给s1,否则不变
+	参数:interface{} -> &struct, 结构体指针
+	返回值:interface{} -> &struct, 结构体指针
+*/
+func MergeStructValue(s1 interface{}, s2 interface{}) interface{} {
+	v1 := reflect.ValueOf(s1).Elem()
+	v2 := reflect.ValueOf(s2).Elem()
+	for i := 0; i < v1.NumField(); i++ {
+		field := v1.Field(i)
+		name := v1.Type().Field(i).Name
+		if field.Interface() == reflect.Zero(field.Type()).Interface() {
+			v1.FieldByName(name).Set(v2.FieldByName(name))
+		}
+	}
+
+	return new
+}

+ 16 - 0
util/uuid.go

@@ -3,6 +3,9 @@ package util
 import (
 	"github.com/GUAIK-ORG/go-snowflake/snowflake"
 	"github.com/google/uuid"
+	"github.com/issue9/conv"
+	"math/rand"
+	"time"
 )
 
 var snowflakeInstance *snowflake.Snowflake
@@ -20,3 +23,16 @@ func GetUUID() string {
 func GetSnowflakeID() int64 {
 	return snowflakeInstance.NextVal()
 }
+
+func GetSelectionID() string {
+	rand.Seed(time.Now().UnixNano())
+	td := conv.MustString(time.Now().Day())
+	for {
+		if len(td) == 3 {
+			break
+		}
+		td = "0" + td
+	}
+	selectionId := conv.MustString(time.Now().Year())[2:] + td + conv.MustString(rand.Intn(100000-10000)+10000)
+	return selectionId
+}