Xingyu Xian 2 weeks ago
parent
commit
f32ea70c31

+ 7 - 2
db/s_local_life.go

@@ -170,11 +170,16 @@ func GetFullSLocalLifeList(ctx context.Context, pageSize, pageNum int32, conditi
 }
 
 // GetSpecialLocalLifeList 商单广场-定向本地生活列表
-func GetSpecialLocalLifeList(ctx context.Context, pageSize, pageNum int32, condition *common_model.SSpecialLocalLifeCondition) ([]*gorm_model.YounggeeSLocalLifeInfo, int64, error) {
+func GetSpecialLocalLifeList(ctx context.Context, pageSize, pageNum int32, supplierId int, condition *common_model.SSpecialLocalLifeCondition, tag int) ([]*gorm_model.YounggeeSLocalLifeInfo, int64, error) {
 	db := GetReadDB(ctx)
 
 	// 根据带货任务状态过滤
-	db = db.Debug().Model(gorm_model.YounggeeSLocalLifeInfo{}).Where("task_status = 8 and local_type = 2")
+	if tag == 1 {
+		db = db.Debug().Model(gorm_model.YounggeeSLocalLifeInfo{}).Where("task_status = 8 and local_type = 2 and supplier_id = ?", supplierId)
+	} else {
+		db = db.Debug().Model(gorm_model.YounggeeSLocalLifeInfo{}).Where("local_type = 2 and supplier_id = ?", supplierId)
+
+	}
 
 	// 根据Project条件过滤
 	conditionType := reflect.TypeOf(condition).Elem()

+ 6 - 2
db/s_project.go

@@ -73,11 +73,15 @@ func GetSProjectDetail(ctx context.Context, sProjectId int) (*gorm_model.SProjec
 }
 
 // GetSpecialProjectList 根据服务商ID和其他附加条件查询定向种草任务列表
-func GetSpecialProjectList(ctx context.Context, supplierId int, pageSize, pageNum int32, condition *common_model.SpecialSProjectCondition) ([]*gorm_model.SProjectInfo, int64, error) {
+func GetSpecialProjectList(ctx context.Context, supplierId int, pageSize, pageNum int32, condition *common_model.SpecialSProjectCondition, tag int) ([]*gorm_model.SProjectInfo, int64, error) {
 	db := GetReadDB(ctx)
 
 	// 1. 根据服务商id过滤
-	db = db.Debug().Model(gorm_model.SProjectInfo{}).Where("supplier_id = ? and project_status = 8 and project_type = 2", supplierId)
+	if tag == 1 {
+		db = db.Debug().Model(gorm_model.SProjectInfo{}).Where("supplier_id = ? and project_status = 8 and project_type = 2", supplierId)
+	} else {
+		db = db.Debug().Model(gorm_model.SProjectInfo{}).Where("supplier_id = ? and project_type = 2", supplierId)
+	}
 
 	// 2. 根据SProjectCondition条件过滤
 	conditionType := reflect.TypeOf(condition).Elem()

+ 1 - 1
handler/local_strategy.go

@@ -35,7 +35,7 @@ func (h *LocalStrategyHandler) getResponse() interface{} {
 	return h.resp
 }
 func (h *LocalStrategyHandler) run() {
-	recruitStrategys, err := service.Project.GetProjectStrategys(h.ctx, h.req.LocalId)
+	recruitStrategys, err := service.SLocalLife.GetLocalStrategys(h.ctx, h.req)
 	if err != nil {
 		h.resp.Message = err.Error()
 		h.resp.Status = 40000

+ 2 - 3
handler/project_strategy.go

@@ -1,7 +1,6 @@
 package handler
 
 import (
-	"fmt"
 	"github.com/gin-gonic/gin"
 	"youngee_b_api/model/http_model"
 	"youngee_b_api/service"
@@ -36,8 +35,8 @@ func (h *ProjectStrategyHandler) getResponse() interface{} {
 	return h.resp
 }
 func (h *ProjectStrategyHandler) run() {
-	fmt.Println("project_id: ", h.req.ProjectId)
-	recruitStrategys, err := service.Project.GetProjectStrategys(h.ctx, h.req.ProjectId)
+	// fmt.Println("project_id: ", h.req.ProjectId)
+	recruitStrategys, err := service.Project.GetProjectStrategys(h.ctx, h.req)
 	if err != nil {
 		h.resp.Message = err.Error()
 		h.resp.Message = "err"

+ 1 - 1
handler/special_local_list.go

@@ -41,7 +41,7 @@ func (h *SpecialLocalListHandler) getResponse() interface{} {
 func (h *SpecialLocalListHandler) run() {
 	// enterpriseID := middleware.GetSessionAuth(h.ctx).EnterpriseID
 	condition := pack.HttpSpecialLocalLifeListRequestToCondition(h.req)
-	data, err := service.LocalLife.GetSpecialLocalLifeList(h.ctx, h.req.PageSize, h.req.PageNum-1, condition)
+	data, err := service.LocalLife.GetSpecialLocalLifeList(h.ctx, h.req.PageSize, h.req.PageNum-1, h.req.SupplierId, condition)
 	if err != nil {
 		logrus.WithContext(h.ctx).Errorf("[FullListHandler] error GetFullProjectList, err:%+v", err)
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)

+ 59 - 0
handler/special_s_local_list.go

@@ -0,0 +1,59 @@
+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/pack"
+	"youngee_b_api/service"
+	"youngee_b_api/util"
+)
+
+func WrapSpecialSLocalListHandler(ctx *gin.Context) {
+	handler := newSpecialSLocalListHandler(ctx)
+	baseRun(handler)
+}
+
+func newSpecialSLocalListHandler(ctx *gin.Context) *SpecialSLocalListHandler {
+	return &SpecialSLocalListHandler{
+		req:  http_model.NewSpecialLocalListRequest(),
+		resp: http_model.NewSpecialSLocalListResponse(),
+		ctx:  ctx,
+	}
+}
+
+type SpecialSLocalListHandler struct {
+	req  *http_model.SpecialLocalListRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *SpecialSLocalListHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *SpecialSLocalListHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *SpecialSLocalListHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *SpecialSLocalListHandler) run() {
+	// enterpriseID := middleware.GetSessionAuth(h.ctx).EnterpriseID
+	condition := pack.HttpSpecialLocalLifeListRequestToCondition(h.req)
+	data, err := service.LocalLife.GetSpecialSLocalLifeList(h.ctx, h.req.PageSize, h.req.PageNum-1, h.req.SupplierId, condition)
+	if err != nil {
+		logrus.WithContext(h.ctx).Errorf("[FullListHandler] error GetFullProjectList, err:%+v", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
+		h.resp.Message = err.Error()
+		h.resp.Status = 40000
+		return
+	}
+	h.resp.Data = data
+	h.resp.Message = "ok"
+	h.resp.Status = 20000
+}
+
+func (h *SpecialSLocalListHandler) checkParam() error {
+	return nil
+}

+ 2 - 1
model/http_model/local_strategy.go

@@ -3,7 +3,8 @@ package http_model
 import "youngee_b_api/model/gorm_model"
 
 type LocalStrategyRequest struct {
-	LocalId string `json:"local_id"`
+	LocalId  string `json:"local_id"`
+	SLocalId int    `json:"s_local_id"`
 }
 
 type localStrategyData struct {

+ 2 - 1
model/http_model/project_strategy.go

@@ -3,7 +3,8 @@ package http_model
 import "youngee_b_api/model/gorm_model"
 
 type ProjectStrategyRequest struct {
-	ProjectId string `json:"project_id"`
+	ProjectId  string `json:"project_id"`
+	SProjectId int    `json:"s_project_id"`
 }
 
 type ProjectStrategyData struct {

+ 51 - 0
model/http_model/special_s_local_list.go

@@ -0,0 +1,51 @@
+package http_model
+
+type SpecialSLocalListRequest struct {
+	PageSize        int32  `json:"page_size"`
+	PageNum         int32  `json:"page"`
+	SupplierId      int    `json:"supplier_id"`        // 服务商ID
+	LocalPlatform   int    `json:"local_platform"`     // 本地生活平台
+	TaskForm        int    `json:"task_form"`          // 任务形式,1-2分别代表线下探店,素材分发
+	ContentType     int    `json:"content_type"`       // 内容形式,1代表图文,2代表视频
+	AddToListStatus int    `json:"add_to_list_status"` // 加入商单状态,1已加
+	LocalId         string `json:"local_id"`           // 本地生活ID
+	LocalName       string `json:"local_name"`         // 本地生活标题
+	TaskStatus      int    `json:"task_status"`        // 任务状态
+}
+
+type SpecialSLocalPreview struct {
+	LocalId            string                 `json:"local_id"`             // 本地生活ID
+	LocalName          string                 `json:"local_name"`           // 本地生活名称
+	TaskStatus         int                    `json:"task_status"`          // 本地生活状态
+	LocalPlatform      int                    `json:"local_platform"`       // 本地生活平台
+	TaskForm           int                    `json:"task_form"`            // 本地生活形式
+	LocalType          int                    `json:"local_type"`           // 本地生活类型
+	LocalContentType   int                    `json:"local_content_type"`   // 本地生活内容形式
+	RecruitStrategy    []*EasyRecruitStrategy `json:"recruit_strategy"`     // 招募策略
+	EstimatedCost      float64                `json:"estimated_cost"`       // 任务总预算
+	ServiceChargeRate  float64                `json:"service_charge_rate"`  // 服务费率
+	ServiceCharge      float64                `json:"service_charge"`       // 任务总服务费
+	RecruitDdl         string                 `json:"recruit_ddl"`          // 招募截至时间
+	ProductPhotoUrl    string                 `json:"product_photo_url"`    // 门店主图URL
+	ProductPhotoSymbol int64                  `json:"product_photo_symbol"` // 门店标志位
+	ProductPhotoUid    string                 `json:"product_photo_uid"`    // 门店uid
+	StoreName          string                 `json:"store_name"`           // 门店名称
+	ProductPrice       float64                `json:"product_price"`        // 商品售价
+	StoreId            int                    `json:"store_id"`             // 门店ID
+	SLocalStatus       int                    `json:"s_local_status"`       // 服务商本地生活任务状态,1待确认,2已确认,3已拒绝
+	Tools              string                 `json:"tools"`                // 工具选择
+}
+
+type SpecialSLocalListData struct {
+	SpecialSLocalPreview []*SpecialSLocalPreview `json:"special_s_local_pre_view"`
+	Total                int64                   `json:"total"`
+}
+
+func NewSpecialSLocalListRequest() *SpecialSLocalListRequest {
+	return new(SpecialSLocalListRequest)
+}
+func NewSpecialSLocalListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(SpecialSLocalListData)
+	return resp
+}

+ 1 - 0
route/init.go

@@ -133,6 +133,7 @@ func InitRoute(r *gin.Engine) {
 		sLocalLife.POST("/changeTaskStatus", handler.WrapLocalChangeTaskStatusHandler)     // 改变子任务的状态 报名通过,拒绝报名
 		sLocalLife.POST("/teamBuying/find", handler.WrapFindTeamBuyingHandler)             // 查找团购
 		sLocalLife.POST("/store/find", handler.WrapFindStoreHandler)                       // 查找门店
+		sLocalLife.POST("/specialList", handler.WrapSpecialSLocalListHandler)              // 商单管理-定向本地生活任务列表
 		sLocalLife.POST("/specialAddToList", handler.WrapSpecialLocalAddToListHandler)     // 定向本地生活任务同意/拒绝加入商单
 		sLocalLife.POST("/localStrategy", handler.WrapLocalStrategyHandler)                // 招募策略查询
 		sLocalLife.POST("/specialAddStrategy", handler.WrapLocalSpecialAddStrategyHandler) // 定向本地生活任务添加招募策略

+ 84 - 2
service/local_life.go

@@ -106,10 +106,10 @@ func (*localLife) GetFullLocalLifeList(ctx context.Context, pageSize, pageNum in
 }
 
 // GetSpecialLocalLifeList 商单广场-定向本地生活
-func (*localLife) GetSpecialLocalLifeList(ctx context.Context, pageSize, pageNum int32, condition *common_model.SSpecialLocalLifeCondition) (*http_model.SpecialLocalListData, error) {
+func (*localLife) GetSpecialLocalLifeList(ctx context.Context, pageSize, pageNum int32, supplierId int, condition *common_model.SSpecialLocalLifeCondition) (*http_model.SpecialLocalListData, error) {
 
 	// 1. 查询本地生活任务基本信息
-	specialLocals, total, err := db.GetSpecialLocalLifeList(ctx, pageSize, pageNum, condition)
+	specialLocals, total, err := db.GetSpecialLocalLifeList(ctx, pageSize, pageNum, supplierId, condition, 1)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[fullLocals service] call GetFullLocalLifeList error,err:%+v", err)
 		return nil, err
@@ -184,7 +184,89 @@ func (*localLife) GetSpecialLocalLifeList(ctx context.Context, pageSize, pageNum
 		if localInfo != nil {
 			local.Tools = localInfo.Tools
 		}
+	}
+	return specialLocalData, nil
+}
 
+// GetSpecialSLocalLifeList 商单管理-定向本地生活
+func (*localLife) GetSpecialSLocalLifeList(ctx context.Context, pageSize, pageNum int32, supplierId int, condition *common_model.SSpecialLocalLifeCondition) (*http_model.SpecialSLocalListData, error) {
+
+	// 1. 查询本地生活任务基本信息
+	specialLocals, total, err := db.GetSpecialLocalLifeList(ctx, pageSize, pageNum, supplierId, condition, 2)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[fullLocals service] call GetFullLocalLifeList error,err:%+v", err)
+		return nil, err
+	}
+	var specialLocalData *http_model.SpecialSLocalListData
+	specialLocalData = &http_model.SpecialSLocalListData{}
+	specialLocalData.Total = total
+	for _, specialLocal := range specialLocals {
+		var specialLocalPreview *http_model.SpecialSLocalPreview
+		specialLocalPreview = &http_model.SpecialSLocalPreview{}
+		specialLocalPreview.LocalId = specialLocal.LocalId
+		specialLocalPreview.LocalName = specialLocal.LocalName
+		specialLocalPreview.TaskStatus = specialLocal.TaskStatus
+		specialLocalPreview.LocalPlatform = specialLocal.LocalPlatform
+		specialLocalPreview.TaskForm = specialLocal.TaskForm
+		specialLocalPreview.LocalType = specialLocal.LocalType
+		specialLocalPreview.LocalContentType = specialLocal.ContentType
+		specialLocalPreview.SLocalStatus = specialLocal.SLocalStatus
+		specialLocalData.SpecialSLocalPreview = append(specialLocalData.SpecialSLocalPreview, specialLocalPreview)
+	}
+
+	// 2. 查询本地生活补充信息:门店信息,招募策略
+	for _, local := range specialLocalData.SpecialSLocalPreview {
+
+		// 2.1. 门店信息
+		storeInfo, productErr := db.FindStoreById(ctx, local.StoreId)
+		if productErr != nil {
+			return nil, productErr
+		}
+		if storeInfo != nil {
+			local.StoreId = storeInfo.StoreId
+			local.StoreName = storeInfo.StoreName
+		}
+
+		// 2.2. 门店图片信息
+		productPhotoInfo, productPhotoErr := db.GetStorePhotoByStoreID(ctx, local.StoreId)
+		if productPhotoErr != nil {
+			return nil, productPhotoErr
+		}
+		if productPhotoInfo != nil {
+			for _, photo := range productPhotoInfo {
+				fmt.Println(photo)
+				if photo.Symbol == 1 {
+					local.ProductPhotoSymbol = 1
+					local.ProductPhotoUrl = photo.PhotoUrl
+					local.ProductPhotoUid = photo.PhotoUid
+				}
+			}
+		}
+
+		// 2.3. 招募策略信息
+		recruitStrategyInfo, recruitErr := db.GetRecruitStrategyByProjectId(ctx, local.LocalId)
+		if recruitErr != nil {
+			return nil, recruitErr
+		}
+		if recruitStrategyInfo != nil {
+			for _, strategy := range recruitStrategyInfo {
+				var recruitStrategy *http_model.EasyRecruitStrategy
+				recruitStrategy = &http_model.EasyRecruitStrategy{}
+				recruitStrategy.StrategyId = strategy.StrategyID
+				recruitStrategy.FeeForm = strategy.FeeForm
+				recruitStrategy.RecruitNumber = strategy.RecruitNumber
+				local.RecruitStrategy = append(local.RecruitStrategy, recruitStrategy)
+			}
+		}
+
+		// 2.4. 原定向本地生活任务信息
+		localInfo, localErr := db.GetLocalLifeDetail(ctx, local.LocalId)
+		if localErr != nil {
+			return nil, localErr
+		}
+		if localInfo != nil {
+			local.Tools = localInfo.Tools
+		}
 	}
 	return specialLocalData, nil
 }

+ 20 - 5
service/project.go

@@ -860,12 +860,27 @@ func (p *project) ShowTaskProgress(ctx *gin.Context, req http_model.ShowTaskProg
 	*/
 }
 
-func (p *project) GetProjectStrategys(ctx *gin.Context, projectId string) ([]gorm_model.RecruitStrategy, error) {
-	recruitStrategys, getProjectStrategysErr := db.GetRecruitStrategyByProjectId(ctx, projectId)
-	if getProjectStrategysErr != nil {
-		return nil, getProjectStrategysErr
+func (p *project) GetProjectStrategys(ctx *gin.Context, req *http_model.ProjectStrategyRequest) ([]gorm_model.RecruitStrategy, error) {
+	sProjectInfo, sProjectErr := db.GetSProjectDetail(ctx, req.SProjectId)
+	if sProjectErr != nil {
+		return nil, sProjectErr
+	}
+	if sProjectInfo != nil {
+		if sProjectInfo.StrategyStatus == 1 {
+			recruitStrategys, getProjectStrategysErr := db.GetRecruitStrategyBySProjectId(ctx, req.SProjectId)
+			if getProjectStrategysErr != nil {
+				return nil, getProjectStrategysErr
+			}
+			return recruitStrategys, nil
+		} else {
+			recruitStrategys, getProjectStrategysErr := db.GetRecruitStrategyByProjectId(ctx, req.ProjectId)
+			if getProjectStrategysErr != nil {
+				return nil, getProjectStrategysErr
+			}
+			return recruitStrategys, nil
+		}
 	}
-	return recruitStrategys, nil
+	return nil, nil
 }
 
 // GetProjectDetail 查找种草任务详情

+ 25 - 0
service/s_local_life.go

@@ -3,6 +3,7 @@ package service
 import (
 	"context"
 	"fmt"
+	"github.com/gin-gonic/gin"
 	"github.com/issue9/conv"
 	"github.com/sirupsen/logrus"
 	"strconv"
@@ -257,6 +258,7 @@ func (*sLocalLife) GetFullSLocalLifeList(ctx context.Context, pageSize, pageNum
 		fullLocalPreview = &http_model.FullSLocalPreview{}
 		fullLocalPreview.LocalId = fullLocal.LocalId
 		fullLocalPreview.SLocalId = fullLocal.SLocalId
+		fullLocalPreview.LocalName = fullLocal.LocalName
 		fullLocalPreview.StoreId = fullLocal.StoreId
 		fullLocalPreview.TeamBuyingId = fullLocal.TeamBuyingId
 		fullLocalPreview.TaskStatus = fullLocal.TaskStatus
@@ -619,3 +621,26 @@ func (*sLocalLife) CountLocalTask(ctx context.Context, req *http_model.LocalTask
 	counter.Stage7 = stage7
 	return counter, nil
 }
+
+func (p *sLocalLife) GetLocalStrategys(ctx *gin.Context, req *http_model.LocalStrategyRequest) ([]gorm_model.RecruitStrategy, error) {
+	slocalInfo, slocalErr := db.GetSLocalLifeDetail(ctx, req.SLocalId)
+	if slocalErr != nil {
+		return nil, slocalErr
+	}
+	if slocalInfo != nil {
+		if slocalInfo.StrategyStatus == 1 {
+			recruitStrategys, getProjectStrategysErr := db.GetRecruitStrategyBySProjectId(ctx, req.SLocalId)
+			if getProjectStrategysErr != nil {
+				return nil, getProjectStrategysErr
+			}
+			return recruitStrategys, nil
+		} else {
+			recruitStrategys, getProjectStrategysErr := db.GetRecruitStrategyByProjectId(ctx, req.LocalId)
+			if getProjectStrategysErr != nil {
+				return nil, getProjectStrategysErr
+			}
+			return recruitStrategys, nil
+		}
+	}
+	return nil, nil
+}

+ 3 - 2
service/s_project.go

@@ -114,6 +114,7 @@ func (*sProject) GetSProjectList(ctx context.Context, supplierId int, pageSize,
 		currSProject = &http_model.SProjectListReview{}
 		currSProject.SProjectId = sProjectInfo.SProjectId
 		currSProject.ProjectId = sProjectInfo.ProjectId
+		currSProject.ProjectName = sProjectInfo.ProjectName
 		currSProject.ProjectPlatform = sProjectInfo.ProjectPlatform
 		currSProject.ContentType = sProjectInfo.ContentType
 		currSProject.ProjectForm = sProjectInfo.ProjectForm
@@ -352,7 +353,7 @@ func (*sProject) GetSpecialProjectList(ctx context.Context, supplierId int, page
 	specialProjectListData = &http_model.SpecialProjectListData{}
 
 	// 1. 定向种草任务基本信息填入
-	specialProjects, total, err := db.GetSpecialProjectList(ctx, supplierId, pageSize, pageNum, condition)
+	specialProjects, total, err := db.GetSpecialProjectList(ctx, supplierId, pageSize, pageNum, condition, 1)
 	if err != nil {
 		return nil, err
 	}
@@ -433,7 +434,7 @@ func (*sProject) GetSpecialProjectList(ctx context.Context, supplierId int, page
 func (*sProject) GetSpecialSProjectList(ctx context.Context, supplierId int, pageSize, pageNum int32, condition *common_model.SpecialSProjectCondition) (*http_model.SpecialSProjectListData, error) {
 	var specialProjectListData *http_model.SpecialSProjectListData
 	specialProjectListData = &http_model.SpecialSProjectListData{}
-	specialProjects, total, err := db.GetSpecialProjectList(ctx, supplierId, pageSize, pageNum, condition)
+	specialProjects, total, err := db.GetSpecialProjectList(ctx, supplierId, pageSize, pageNum, condition, 2)
 	if err != nil {
 		return nil, err
 	}