Explorar o código

选品查询 选品列表 删除选品

yuliang1112 hai 1 ano
pai
achega
5267aa933a

+ 149 - 0
db/selection.go

@@ -0,0 +1,149 @@
+package db
+
+import (
+	"context"
+	"fmt"
+	"github.com/sirupsen/logrus"
+	"reflect"
+	"strings"
+	"youngee_b_api/model/common_model"
+	"youngee_b_api/model/gorm_model"
+	"youngee_b_api/util"
+)
+
+func DeleteSelection(ctx context.Context, SelectionId string) error {
+	db := GetReadDB(ctx)
+	err := db.Where("selection_id = ?", SelectionId).Delete(&gorm_model.YounggeeSelectionInfo{}).Error
+	if err != nil {
+		return err
+	}
+	return 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)
+	conditionType := reflect.TypeOf(conditions).Elem()
+	conditionValue := reflect.ValueOf(conditions).Elem()
+	selectionStatus := ""
+	searchValue := ""
+	for i := 0; i < conditionType.NumField(); i++ {
+		field := conditionType.Field(i)
+		tag := field.Tag.Get("condition")
+		value := conditionValue.FieldByName(field.Name)
+		if tag == "selection_status" {
+			selectionStatus = fmt.Sprintf("%v", value.Interface())
+		} else if tag == "search_value" {
+			searchValue = fmt.Sprintf("%v", value.Interface())
+		} else if tag == "submit_at" && value.Interface() != "" {
+			db = db.Where(fmt.Sprintf("submit_at like '%s%%'", value.Interface()))
+		} else if tag == "task_ddl" && value.Interface() != "" {
+			db = db.Where(fmt.Sprintf("task_ddl like '%s%%'", value.Interface()))
+		} else if !util.IsBlank(value) && tag != "task_ddl" && tag != "submit_at" && tag != "search_value" {
+			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		}
+	}
+	// 查询总数
+	var total int64
+	var selectionInfos []*gorm_model.YounggeeSelectionInfo
+	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
+	if selectionStatus == "1" {
+		err := db.Order("submit_at desc").Limit(int(limit)).Offset(int(offset)).Find(&selectionInfos).Error
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[GetSelectionList] error query mysql total, err:%+v", err)
+			return nil, 0, err
+		}
+	} else {
+		err := db.Order("task_ddl desc").Limit(int(limit)).Offset(int(offset)).Find(&selectionInfos).Error
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[GetSelectionList] error query mysql total, err:%+v", err)
+			return nil, 0, err
+		}
+	}
+	var newSelectionInfos []*gorm_model.YounggeeSelectionInfo
+	for _, v := range selectionInfos {
+		if searchValue == "" {
+			newSelectionInfos = append(newSelectionInfos, v)
+		} else if strings.Contains(v.SelectionID, searchValue) {
+			newSelectionInfos = append(newSelectionInfos, v)
+		} else if strings.Contains(v.SelectionName, searchValue) {
+			newSelectionInfos = append(newSelectionInfos, v)
+		} else {
+			total--
+		}
+	}
+	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
+	err := db.Model(gorm_model.YounggeeSecBrief{}).Where("selection_id = ?", selectionId).Find(&selectionBriefInfos).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetSelectionBriefInfo] error query mysql, err:%+v", err)
+		return nil, err
+	}
+	return selectionBriefInfos, nil
+}
+
+func GetSelectionExampleInfo(ctx context.Context, selectionId string) ([]*gorm_model.YounggeeSecExample, error) {
+	db := GetReadDB(ctx)
+	var selectionExampleInfos []*gorm_model.YounggeeSecExample
+	err := db.Model(gorm_model.YounggeeSecExample{}).Where("selection_id = ?", selectionId).Find(&selectionExampleInfos).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetSelectionExampleInfo] error query, err:%+v", err)
+		return nil, err
+	}
+	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 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
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProductInfo] error query mysql, err:%+v", err)
+		return nil, err
+	}
+	return productPhotoInfo, nil
+}

+ 55 - 0
handler/selection_delete.go

@@ -0,0 +1,55 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/db"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/util"
+)
+
+func WrapDeleteSelectionHandler(ctx *gin.Context) {
+	handler := NewDeleteSelection(ctx)
+	baseRun(handler)
+}
+
+type DeleteSelectionHandler struct {
+	ctx  *gin.Context
+	req  *http_model.DeleteSelectionRequest
+	resp *http_model.CommonResponse
+}
+
+func (d DeleteSelectionHandler) getContext() *gin.Context {
+	return d.ctx
+}
+
+func (d DeleteSelectionHandler) getResponse() interface{} {
+	return d.resp
+}
+
+func (d DeleteSelectionHandler) getRequest() interface{} {
+	return d.req
+}
+
+func (d DeleteSelectionHandler) run() {
+	err := db.DeleteSelection(d.ctx, d.req.SelectionId)
+	if err != nil {
+		logrus.WithContext(d.ctx).Errorf("[DeleteSelectionHandler] error DeleteSelection, err:%+v", err)
+		util.HandlerPackErrorResp(d.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	d.resp.Message = "选品删除成功"
+}
+
+func (d DeleteSelectionHandler) checkParam() error {
+	return nil
+}
+
+func NewDeleteSelection(ctx *gin.Context) *DeleteSelectionHandler {
+	return &DeleteSelectionHandler{
+		ctx:  ctx,
+		req:  http_model.NewDeleteSelectionRequest(),
+		resp: http_model.NewDeleteSelectionResponse(),
+	}
+}

+ 59 - 0
handler/selection_detail.go

@@ -0,0 +1,59 @@
+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"
+	"youngee_b_api/util"
+)
+
+func WrapSelectionDetailHandler(ctx *gin.Context) {
+	handler := newSelectionDetail(ctx)
+	baseRun(handler)
+}
+
+type SelectionDetailHandler struct {
+	ctx  *gin.Context
+	req  *http_model.SelectionDetailRequest
+	resp *http_model.CommonResponse
+}
+
+func (s SelectionDetailHandler) getContext() *gin.Context {
+	return s.ctx
+}
+
+func (s SelectionDetailHandler) getResponse() interface{} {
+	return s.resp
+}
+
+func (s SelectionDetailHandler) getRequest() interface{} {
+	return s.req
+}
+
+func (s SelectionDetailHandler) run() {
+	enterpriseID := middleware.GetSessionAuth(s.ctx).EnterpriseID
+	res, err := 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, "")
+		logrus.Info("GetSelectionDetail fail,req:%+v", s.req)
+		return
+	}
+	s.resp.Message = "成功查询项目"
+	s.resp.Data = res
+}
+
+func (s SelectionDetailHandler) checkParam() error {
+	return nil
+}
+
+func newSelectionDetail(ctx *gin.Context) *SelectionDetailHandler {
+	return &SelectionDetailHandler{
+		ctx:  ctx,
+		req:  http_model.NewSelectionDetailRequest(),
+		resp: http_model.NewSelectionDetailResponse(),
+	}
+}

+ 69 - 0
handler/selection_find_all.go

@@ -0,0 +1,69 @@
+package handler
+
+import (
+	"errors"
+	"fmt"
+	"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/pack"
+	"youngee_b_api/service"
+	"youngee_b_api/util"
+)
+
+func WrapFindAllSelectionHandler(ctx *gin.Context) {
+	handler := newFindAllSelection(ctx)
+	baseRun(handler)
+}
+
+type FindAllSelectionHandler struct {
+	ctx  *gin.Context
+	req  *http_model.FindAllSelectionRequest
+	resp *http_model.CommonResponse
+}
+
+func (f FindAllSelectionHandler) getContext() *gin.Context {
+	return f.ctx
+}
+
+func (f FindAllSelectionHandler) getResponse() interface{} {
+	return f.resp
+}
+
+func (f FindAllSelectionHandler) getRequest() interface{} {
+	return f.req
+}
+
+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)
+	if err != nil {
+		logrus.WithContext(f.ctx).Errorf("[FindAllSelectionHandler] error GetAllSelection, err:%+v", err)
+		util.HandlerPackErrorResp(f.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	f.resp.Data = data
+}
+
+func (f FindAllSelectionHandler) checkParam() error {
+	var errs []error
+	if f.req.PageNum < 0 || f.req.PageSize <= 0 {
+		errs = append(errs, errors.New("page param error"))
+	}
+	f.req.PageNum--
+	if len(errs) != 0 {
+		return fmt.Errorf("check param errs:%+v", errs)
+	}
+	return nil
+}
+
+func newFindAllSelection(ctx *gin.Context) *FindAllSelectionHandler {
+	return &FindAllSelectionHandler{
+		ctx:  ctx,
+		req:  http_model.NewFindAllSelectionRequest(),
+		resp: http_model.NewFindAllSelectionResponse(),
+	}
+}

+ 12 - 0
model/common_model/selection_conditions.go

@@ -0,0 +1,12 @@
+package common_model
+
+type SelectionConditions struct {
+	SelectionStatus int8   `condition:"selection_status"` // 选品阶段
+	Platform        int8   `condition:"platform"`         // 社媒平台
+	SampleMode      int8   `condition:"sample_mode"`      // 领样形式
+	ContentType     int8   `condition:"content_type"`     // 内容形式
+	TaskMode        int8   `condition:"task_mode"`        // 任务形式
+	SearchValue     string `condition:"search_value"`     // 项目id或项目名称
+	SubmitAt        string `condition:"submit_at"`        // 提交审核时间
+	TaskDdl         string `condition:"task_ddl"`         // 任务截止时间
+}

+ 20 - 0
model/gorm_model/selection_brief_info.go

@@ -0,0 +1,20 @@
+package gorm_model
+
+// Code generated by sql2gorm. DO NOT EDIT.
+
+import (
+	"time"
+)
+
+type YounggeeSecBrief struct {
+	SectionBriefID int       `gorm:"column:section_brief_id;primary_key;AUTO_INCREMENT"` // brief的Id
+	FileUrl        string    `gorm:"column:file_url"`                                    // 文件url
+	FileUid        string    `gorm:"column:file_uid"`                                    // 文件uid
+	SelectionID    string    `gorm:"column:selection_id"`                                // 所属选品id
+	CreatedAt      time.Time `gorm:"column:created_at"`                                  // 创建时间
+	FileName       string    `gorm:"column:file_name"`                                   // 文件名称
+}
+
+func (m *YounggeeSecBrief) TableName() string {
+	return "younggee_sec_brief"
+}

+ 20 - 0
model/gorm_model/selection_example_info.go

@@ -0,0 +1,20 @@
+package gorm_model
+
+// Code generated by sql2gorm. DO NOT EDIT.
+
+import (
+	"time"
+)
+
+type YounggeeSecExample struct {
+	ExampleID   int       `gorm:"column:example_id;primary_key;AUTO_INCREMENT"` // 选品示例图id
+	FileUrl     string    `gorm:"column:file_url"`                              // 文件url
+	FileUid     string    `gorm:"column:file_uid"`                              // 文件uid
+	SelectionID string    `gorm:"column:selection_id"`                          // 所属项目id
+	CreatedAt   time.Time `gorm:"column:created_at"`                            // 创建时间
+	FileName    string    `gorm:"column:file_name"`                             // 文件名称
+}
+
+func (m *YounggeeSecExample) TableName() string {
+	return "younggee_sec_example"
+}

+ 44 - 0
model/gorm_model/selection_info.go

@@ -0,0 +1,44 @@
+package gorm_model
+
+// Code generated by sql2gorm. DO NOT EDIT.
+
+import (
+	"time"
+)
+
+type YounggeeSelectionInfo struct {
+	SelectionID      string    `gorm:"column:selection_id;primary_key"` // 选品项目id
+	SelectionName    string    `gorm:"column:selection_name"`           // 选品项目名称
+	EnterpriseID     string    `gorm:"column:enterprise_id"`            // 所属企业id
+	ProductID        int       `gorm:"column:product_id"`               // 关联商品id
+	ContentType      int       `gorm:"column:content_type"`             // 内容形式,1代表图文,2代表视频
+	SelectionStatus  int       `gorm:"column:selection_status"`         // 选品项目状态,1-8分别代表创建中、待审核、审核通过、待支付、已支付、执行中、失效、已结案
+	TaskMode         int       `gorm:"column:task_mode"`                // 任务形式,1、2分别表示悬赏任务、纯佣带货
+	Platform         int       `gorm:"column:platform"`                 // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	SampleMode       int       `gorm:"column:sample_mode"`              // 领样形式,1、2分别表示免费领样、垫付领样
+	ProductUrl       string    `gorm:"column:product_url"`              // 带货链接
+	SampleNum        int       `gorm:"column:sample_num"`               // 样品数量
+	RemainNum        int       `gorm:"column:remain_num"`               // 剩余数量
+	CommissionRate   int       `gorm:"column:commission_rate"`          // 佣金比例
+	EstimatedCost    string    `gorm:"column:estimated_cost"`           // 预估成本
+	TaskReward       string    `gorm:"column:task_reward"`              // 任务悬赏
+	SampleCondition  string    `gorm:"column:sample_condition"`         // 领样条件
+	RewardCondition  string    `gorm:"column:reward_condition"`         // 返现悬赏条件
+	SettlementAmount string    `gorm:"column:settlement_amount"`        // 结算金额
+	TaskDdl          time.Time `gorm:"column:task_ddl"`                 // 招募截止时间
+	Detail           string    `gorm:"column:detail"`                   // 卖点总结
+	ProductSnap      string    `gorm:"column:product_snap"`             // 商品信息快照
+	ProductPhotoSnap string    `gorm:"column:product_photo_snap"`       // 商品图片快照
+	CreatedAt        time.Time `gorm:"column:created_at"`               // 创建时间
+	UpdatedAt        time.Time `gorm:"column:updated_at"`               // 修改时间
+	SubmitAt         time.Time `gorm:"column:submit_at"`                // 提交审核时间
+	PassAt           time.Time `gorm:"column:pass_at"`                  // 审核通过时间
+	FailReason       int       `gorm:"column:fail_reason"`              // 失效原因,1、2分别表示逾期未支付、项目存在风险
+	PayAt            time.Time `gorm:"column:pay_at"`                   // 支付时间
+	FinishAt         time.Time `gorm:"column:finish_at"`                // 结案时间
+	IsRead           int       `gorm:"column:is_read"`                  // 是否已读
+}
+
+func (m *YounggeeSelectionInfo) TableName() string {
+	return "younggee_selection_info"
+}

+ 44 - 0
model/gorm_model/selection_task_info.go

@@ -0,0 +1,44 @@
+package gorm_model
+
+// Code generated by sql2gorm. DO NOT EDIT.
+
+import (
+	"time"
+)
+
+type YounggeeSecTaskInfo struct {
+	ID                     int       `gorm:"column:id;primary_key"`                        // 递增id
+	TaskID                 string    `gorm:"column:task_id"`                               // 选品任务id
+	SelectionID            string    `gorm:"column:selection_id"`                          // 选品id
+	TalentID               string    `gorm:"column:talent_id"`                             // 达人id
+	AccountID              int       `gorm:"column:account_id"`                            // 账号id
+	TalentPlatformInfoSnap string    `gorm:"column:talent_platform_info_snap"`             // 达人平台信息快照
+	TalentPersonalInfoSnap string    `gorm:"column:talent_personal_info_snap"`             // 达人个人信息快照
+	TalentPostAddrSnap     string    `gorm:"column:talent_post_addr_snap"`                 // 收货地址快照
+	TaskReward             string    `gorm:"column:task_reward"`                           //  达人赏金
+	TalentPayment          string    `gorm:"column:talent_payment"`                        // 达人垫付金额
+	IsPayPayment           int       `gorm:"column:is_pay_payment"`                        // 企业是否返样品钱
+	IsPayReward            int       `gorm:"column:is_pay_reward"`                         // 企业是否结算悬赏
+	TaskMode               int       `gorm:"column:task_mode"`                             // 任务形式,1、2分别表示纯佣带货、悬赏任务
+	SampleMode             int       `gorm:"column:sample_mode"`                           // 领样形式,1-3分别表示免费领样、垫付买样、不提供样品
+	TaskStatus             int       `gorm:"column:task_status;default:1"`                 // 任务状态 1待选 2已选 3落选
+	TaskStage              int       `gorm:"column:task_stage"`                            // 任务阶段,详情见info_sec_task_stage表
+	CreateDate             time.Time `gorm:"column:create_date;default:CURRENT_TIMESTAMP"` // 创建时间
+	SelectDate             time.Time `gorm:"column:select_date"`                           // 反选时间
+	DeliveryDate           time.Time `gorm:"column:delivery_date"`                         // 发货时间
+	CompleteDate           time.Time `gorm:"column:complete_date"`                         // 结束时间
+	WithdrawDate           time.Time `gorm:"column:withdraw_date"`                         // 提现时间
+	CompleteStatus         int       `gorm:"column:complete_status;default:1"`             // 结束方式 1未结束 2正常结束 3反选失败
+	LogisticsStatus        int       `gorm:"column:logistics_status;default:1"`            // 发货状态 1 待发货 2已发货 3 已签收
+	AssignmentStatus       uint      `gorm:"column:assignment_status;default:1"`           // 作业上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
+	UpdateAt               time.Time `gorm:"column:update_at"`                             // 更新时间
+	WithdrawStatus         int       `gorm:"column:withdraw_status;default:1"`             // 提现状态,1-4分别代表不可提现、可提现、提现中、已提现
+	LeadTeamID             string    `gorm:"column:lead_team_id"`                          // 作为团长的young之团id,对应younggee_talent_team中的team_id字段
+	TeamID                 string    `gorm:"column:team_id"`                               // 作为团员的young之团id,对应younggee_talent_team中的team_id字段
+	TeamIncome             int       `gorm:"column:team_income"`                           // young之团团长现金收益
+	TeamPoint              int       `gorm:"column:team_point"`                            // young之团团长积分收益
+}
+
+func (m *YounggeeSecTaskInfo) TableName() string {
+	return "younggee_sec_task_info"
+}

+ 13 - 0
model/http_model/DeleteSelectionRequest.go

@@ -0,0 +1,13 @@
+package http_model
+
+type DeleteSelectionRequest struct {
+	SelectionId string `json:"selection_id"`
+}
+
+func NewDeleteSelectionRequest() *DeleteSelectionRequest {
+	return new(DeleteSelectionRequest)
+}
+
+func NewDeleteSelectionResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 31 - 0
model/http_model/FindAllSelectionRequest.go

@@ -0,0 +1,31 @@
+package http_model
+
+import "youngee_b_api/model/gorm_model"
+
+type FindAllSelectionRequest struct {
+	PageSize        int64  `json:"page_size"`
+	PageNum         int64  `json:"page_num"`
+	SelectionStatus int8   `json:"selection_status"` // 选品阶段
+	Platform        int8   `json:"platform"`         // 社媒平台
+	SampleMode      int8   `json:"sample_mode"`      // 领样形式
+	ContentType     int8   `json:"content_type"`     // 内容形式
+	TaskMode        int8   `json:"task_mode"`        // 任务形式
+	SearchValue     string `json:"search_value"`     // 项目id或项目名称
+	SubmitAt        string `json:"submit_at"`        // 提交审核时间
+	TaskDdl         string `json:"task_ddl"`         // 提交审核时间
+}
+
+type SelectionData struct {
+	SelectionInfo []*gorm_model.YounggeeSelectionInfo `json:"selection_info"`
+	Total         string                              `json:"total"`
+}
+
+func NewFindAllSelectionRequest() *FindAllSelectionRequest {
+	return new(FindAllSelectionRequest)
+}
+
+func NewFindAllSelectionResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(SelectionData)
+	return resp
+}

+ 25 - 0
model/http_model/SelectionDetailRequest.go

@@ -0,0 +1,25 @@
+package http_model
+
+import "youngee_b_api/model/gorm_model"
+
+type SelectionDetailRequest struct {
+	SelectionId string `json:"selection_id"` // 选品id
+}
+
+type SelectionDetail struct {
+	SelectionInfo    *gorm_model.YounggeeSelectionInfo  // 选品详情
+	SelectionBrief   []*gorm_model.YounggeeSecBrief     // 选品brief列表
+	SelectionExample []*gorm_model.YounggeeSecExample   // 选品示例列表
+	ProductInfo      *gorm_model.YounggeeProduct        // 商品详情
+	ProductPhotoInfo []*gorm_model.YounggeeProductPhoto // 商品图片列表
+}
+
+func NewSelectionDetailRequest() *SelectionDetailRequest {
+	return new(SelectionDetailRequest)
+}
+
+func NewSelectionDetailResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(SelectionDetail)
+	return resp
+}

+ 60 - 0
pack/selection.go

@@ -0,0 +1,60 @@
+package pack
+
+import (
+	"youngee_b_api/model/common_model"
+	"youngee_b_api/model/gorm_model"
+	"youngee_b_api/model/http_model"
+)
+
+func HttpFindAllSelectionRequestToCondition(req *http_model.FindAllSelectionRequest) *common_model.SelectionConditions {
+	return &common_model.SelectionConditions{
+		SelectionStatus: req.SelectionStatus,
+		Platform:        req.Platform,
+		SampleMode:      req.SampleMode,
+		ContentType:     req.ContentType,
+		TaskMode:        req.TaskMode,
+		SearchValue:     req.SearchValue,
+		SubmitAt:        req.SubmitAt,
+		TaskDdl:         req.TaskDdl,
+	}
+}
+
+func MGormSelectionToHttpSelectionPreview(gormSelectionInfos []*gorm_model.YounggeeSelectionInfo) []*gorm_model.YounggeeSelectionInfo {
+	var httpSelectionPreviews []*gorm_model.YounggeeSelectionInfo
+	for _, gormSelectionInfo := range gormSelectionInfos {
+		gormSelectionInfo := GormSelectionToHttpSelectionPreview(gormSelectionInfo)
+		httpSelectionPreviews = append(httpSelectionPreviews, gormSelectionInfo)
+	}
+	return httpSelectionPreviews
+}
+
+func GormSelectionToHttpSelectionPreview(selectionInfo *gorm_model.YounggeeSelectionInfo) *gorm_model.YounggeeSelectionInfo {
+	return &gorm_model.YounggeeSelectionInfo{
+		SelectionID:      selectionInfo.SelectionID,
+		SelectionName:    selectionInfo.SelectionName,
+		EnterpriseID:     selectionInfo.EnterpriseID,
+		ProductID:        selectionInfo.ProductID,
+		ContentType:      selectionInfo.ContentType,
+		SelectionStatus:  selectionInfo.SelectionStatus,
+		Platform:         selectionInfo.Platform,
+		ProductUrl:       selectionInfo.ProductUrl,
+		RemainNum:        selectionInfo.RemainNum,
+		EstimatedCost:    selectionInfo.EstimatedCost,
+		TaskReward:       selectionInfo.TaskReward,
+		SampleCondition:  selectionInfo.SampleCondition,
+		RewardCondition:  selectionInfo.RewardCondition,
+		SettlementAmount: selectionInfo.SettlementAmount,
+		TaskDdl:          selectionInfo.TaskDdl,
+		Detail:           selectionInfo.Detail,
+		ProductSnap:      selectionInfo.ProductSnap,
+		ProductPhotoSnap: selectionInfo.ProductPhotoSnap,
+		CreatedAt:        selectionInfo.CreatedAt,
+		UpdatedAt:        selectionInfo.UpdatedAt,
+		SubmitAt:         selectionInfo.SubmitAt,
+		PassAt:           selectionInfo.PassAt,
+		FailReason:       selectionInfo.FailReason,
+		PayAt:            selectionInfo.PayAt,
+		FinishAt:         selectionInfo.FinishAt,
+		IsRead:           selectionInfo.IsRead,
+	}
+}

+ 9 - 0
route/init.go

@@ -133,4 +133,13 @@ func InitRoute(r *gin.Engine) {
 		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)   //选品详情
+	}
 }

+ 64 - 0
service/selection.go

@@ -0,0 +1,64 @@
+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
+}