Explorar o código

localLifeAddToList

Xingyu Xian hai 3 meses
pai
achega
73e2b30852

+ 12 - 0
db/s_local_life.go

@@ -51,3 +51,15 @@ func GetFullLocalLifeList(ctx context.Context, pageSize, pageNum int32, conditio
 	}
 	return fullLocals, total, nil
 }
+
+// GetLocalLifeDetail 根据本地生活ID查询本地生活详情
+func GetLocalLifeDetail(ctx context.Context, localLifeId string) (*gorm_model.YounggeeLocalLifeInfo, error) {
+	db := GetReadDB(ctx)
+	var localLifeInfo *gorm_model.YounggeeLocalLifeInfo
+	whereCondition := gorm_model.YounggeeLocalLifeInfo{LocalId: localLifeId}
+	err := db.Model(gorm_model.YounggeeLocalLifeInfo{}).Where(whereCondition).Find(&localLifeInfo).Error
+	if err != nil {
+		return nil, err
+	}
+	return localLifeInfo, nil
+}

+ 1 - 0
handler/full_local_life_list.go

@@ -49,6 +49,7 @@ func (h *FullListHandler) run() {
 	}
 	h.resp.Data = data
 }
+
 func (h *FullListHandler) checkParam() error {
 	return nil
 }

+ 54 - 0
handler/full_s_local_list.go

@@ -0,0 +1,54 @@
+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 WrapFullSLocalListHandler(ctx *gin.Context) {
+	handler := newFullSLocalListHandler(ctx)
+	baseRun(handler)
+}
+
+func newFullSLocalListHandler(ctx *gin.Context) *FullListHandler {
+	return &FullListHandler{
+		req:  http_model.NewFullListRequest(),
+		resp: http_model.NewFullListResponse(),
+		ctx:  ctx,
+	}
+}
+
+type FullSLocalListHandler struct {
+	req  *http_model.FullListRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *FullSLocalListHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *FullSLocalListHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *FullSLocalListHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *FullSLocalListHandler) run() {
+	// enterpriseID := middleware.GetSessionAuth(h.ctx).EnterpriseID
+	condition := pack.HttpFullLocalLifeListRequestToCondition(h.req)
+	data, err := service.LocalLife.GetFullLocalLifeList(h.ctx, h.req.PageSize, h.req.PageNum, 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)
+		return
+	}
+	h.resp.Data = data
+}
+func (h *FullSLocalListHandler) checkParam() error {
+	return nil
+}

+ 64 - 0
handler/s_local_life_detail.go

@@ -0,0 +1,64 @@
+package handler
+
+import (
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	log "github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service"
+	"youngee_b_api/util"
+)
+
+func WrapShowSLocalHandler(ctx *gin.Context) {
+	handler := newShowSLocalHandler(ctx)
+	baseRun(handler)
+}
+
+func newShowSLocalHandler(ctx *gin.Context) *ShowSLocalHandler {
+	return &ShowSLocalHandler{
+		req:  http_model.NewShowProjectRequest(),
+		resp: http_model.NewShowProjectResponse(),
+		ctx:  ctx,
+	}
+}
+
+type ShowSLocalHandler struct {
+	req  *http_model.ShowProjectRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *ShowSLocalHandler) getRequest() interface{} {
+	return h.req
+}
+
+func (h *ShowSLocalHandler) getContext() *gin.Context {
+	return h.ctx
+}
+
+func (h *ShowSLocalHandler) getResponse() interface{} {
+	return h.resp
+}
+
+func (h *ShowSLocalHandler) run() {
+	data := http_model.ShowProjectRequest{}
+	data = *h.req
+	//auth := middleware.GetSessionAuth(h.ctx)
+	//enterpriseID := auth.EnterpriseID
+	fmt.Printf("projectID %+v", data.ProjectID)
+	res, err := service.Project.GetPorjectDetail(h.ctx, data.ProjectID)
+	if err != nil {
+		logrus.Errorf("[ShowProjectHandler] call Show err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		log.Info("ShowProject fail,req:%+v", h.req)
+		return
+	}
+	h.resp.Message = "成功查询项目"
+	h.resp.Data = res
+}
+
+func (h *ShowSLocalHandler) checkParam() error {
+	return nil
+}

+ 1 - 1
model/gorm_model/local_life.go

@@ -17,7 +17,7 @@ type YounggeeLocalLifeInfo struct {
 	PromoteBody         int       `gorm:"column:promote_body"`                              // 推广主体(1门店 2团购)
 	Donate              int       `gorm:"column:donate"`                                    // 赠送达人套餐(1有赠送 2无赠送)
 	LocalName           string    `gorm:"column:local_name"`                                // 任务标题
-	TalentType          string    `gorm:"column:talent_type"`                               // 达人类型(,分隔)
+	TalentType          string    `gorm:"column:talent_type"`                               // 达人类型
 	RecruitDdl          time.Time `gorm:"column:recruit_ddl"`                               // 招募截止时间
 	TaskForm            int       `gorm:"column:task_form"`                                 // 任务形式,1-2分别代表线下探店,素材分发
 	ContentType         int       `gorm:"column:content_type"`                              // 内容形式,1代表图文,2代表视频

+ 19 - 0
model/gorm_model/local_life_brief.go

@@ -0,0 +1,19 @@
+package gorm_model
+
+import (
+	"time"
+)
+
+type LocalLifeBrief struct {
+	LocalBriefId int       `gorm:"column:local_brief_id;primary_key;AUTO_INCREMENT"` // 手卡id
+	FileUrl      string    `gorm:"column:file_url"`                                  // 文件url
+	FileUid      string    `gorm:"column:file_uid"`                                  // 文件uid
+	LocalId      string    `gorm:"column:local_id"`                                  // 所属本地生活id
+	CreatedAt    time.Time `gorm:"column:created_at"`                                // 创建时间
+	FileName     string    `gorm:"column:file_name"`                                 // 文件名称
+	Type         int       `gorm:"column:type;NOT NULL"`                             // 手卡类型(1图片 2文档)
+}
+
+func (m *LocalLifeBrief) TableName() string {
+	return "local_life_brief"
+}

+ 19 - 0
model/gorm_model/local_life_material.go

@@ -0,0 +1,19 @@
+package gorm_model
+
+import (
+	"time"
+)
+
+type LocalLifeMaterial struct {
+	MaterialId int       `gorm:"column:material_id;primary_key;AUTO_INCREMENT"` // 本地生活素材id
+	FileUrl    string    `gorm:"column:file_url"`                               // 文件url
+	FileUid    string    `gorm:"column:file_uid"`                               // 文件uid
+	LocalId    string    `gorm:"column:local_id"`                               // 所属本地生活id
+	CreatedAt  time.Time `gorm:"column:created_at"`                             // 创建时间
+	FileName   string    `gorm:"column:file_name"`                              // 文件名称
+	Type       int       `gorm:"column:type;NOT NULL"`                          // 素材类型(1图片 2视频)
+}
+
+func (m *LocalLifeMaterial) TableName() string {
+	return "local_life_material"
+}

+ 25 - 19
model/gorm_model/s_local_life.go

@@ -5,25 +5,31 @@ import (
 )
 
 type YounggeeSLocalLifeInfo struct {
-	SLocalLifeId        int       `gorm:"column:s_local_life_id;primary_key"` // 主键ID
-	LocalLifeId         string    `gorm:"column:local_life_id"`               // 被加入商单的原本地生活ID
-	EnterpriseId        string    `gorm:"column:enterprise_id"`               // 商家ID
-	SupplierId          int       `gorm:"column:supplier_id"`                 // 服务商ID
-	ApplyNum            int       `gorm:"column:apply_num"`                   // 报名人数
-	RecruitNum          int       `gorm:"column:recruit_num"`                 // 已招募人数
-	SettleNum           int       `gorm:"column:settle_num;default:0"`        // 已结算人数
-	SubAccountId        int       `gorm:"column:sub_account_id"`              // 服务商子账号ID
-	ServiceCharge       string    `gorm:"column:service_charge"`              // 服务商预估可赚服务费
-	ServiceChargeActual string    `gorm:"column:service_charge_actual"`       // 服务商实际可赚服务费
-	OperatorType        int       `gorm:"column:operator_type"`               // 添加商单操作人类型,1为服务商主账号,2为服务商子账号
-	SProjectStatus      string    `gorm:"column:s_project_status"`            // 服务商本地生活任务状态,1待确认,2已确认,3已拒绝
-	StrategyStatus      string    `gorm:"column:strategy_status"`             // 定向本地生活任务是否替换招募策略
-	BOperator           string    `gorm:"column:b_operator"`                  // 商家发起入库邀约人
-	BOperatorType       int       `gorm:"column:b_operator_type"`             // 商家发起入库邀约人类型:1主账号 2子账号
-	CreateTime          time.Time `gorm:"column:create_time"`                 // 创建时间
-	CreateStrategyId    int       `gorm:"column:create_strategy_id"`          // 服务商修改服务费操作人ID
-	CreateStrategyType  string    `gorm:"column:create_strategy_type"`        // 服务商修改服务费操作人类型:1服务商主账号,2子账号
-
+	SLocalId            int       `gorm:"column:s_local_id;primary_key"` // 主键ID
+	LocalId             string    `gorm:"column:local_id"`               // 被加入商单的原本地生活ID
+	EnterpriseId        string    `gorm:"column:enterprise_id"`          // 商家ID
+	SupplierId          int       `gorm:"column:supplier_id"`            // 服务商ID
+	LocalType           int       `gorm:"column:local_type"`             // 任务类型,1为公开,2为定向
+	LocalName           string    `gorm:"column:local_name"`             // 任务名称
+	TaskStatus          int       `gorm:"column:task_status"`            // 任务状态
+	LocalPlatform       int       `gorm:"column:local_platform"`         // 任务平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	TaskForm            int       `gorm:"column:task_form"`              // 任务形式,1-2分别代表线下探店,素材分发
+	ContentType         int       `gorm:"column:content_type"`           // 内容形式,1代表图文,2代表视频
+	ShareCode           string    `gorm:"column:share_code"`             // 分享码URL
+	ApplyNum            int       `gorm:"column:apply_num"`              // 报名人数
+	RecruitNum          int       `gorm:"column:recruit_num"`            // 已招募人数
+	SettleNum           int       `gorm:"column:settle_num;default:0"`   // 已结算人数
+	SubAccountId        int       `gorm:"column:sub_account_id"`         // 服务商子账号ID
+	ServiceCharge       float64   `gorm:"column:service_charge"`         // 服务商预估可赚服务费
+	ServiceChargeActual float64   `gorm:"column:service_charge_actual"`  // 服务商实际可赚服务费
+	OperatorType        int       `gorm:"column:operator_type"`          // 添加商单操作人类型,1为服务商主账号,2为服务商子账号
+	SProjectStatus      string    `gorm:"column:s_project_status"`       // 服务商本地生活任务状态,1待确认,2已确认,3已拒绝
+	StrategyStatus      string    `gorm:"column:strategy_status"`        // 定向本地生活任务是否替换招募策略
+	BOperator           string    `gorm:"column:b_operator"`             // 商家发起入库邀约人
+	BOperatorType       int       `gorm:"column:b_operator_type"`        // 商家发起入库邀约人类型:1主账号 2子账号
+	CreateTime          time.Time `gorm:"column:create_time"`            // 创建时间
+	CreateStrategyId    int       `gorm:"column:create_strategy_id"`     // 服务商修改服务费操作人ID
+	CreateStrategyType  string    `gorm:"column:create_strategy_type"`   // 服务商修改服务费操作人类型:1服务商主账号,2子账号
 }
 
 func (m *YounggeeSLocalLifeInfo) TableName() string {

+ 1 - 1
model/gorm_model/team_buying.go

@@ -9,7 +9,7 @@ type YounggeeTeamBuying struct {
 	StoreId            int       `gorm:"column:store_id;NOT NULL"`                         // 所属门店ID
 	TeamBuyingCategory string    `gorm:"column:team_buying_category;NOT NULL"`             // 团购类目(/分隔)
 	TeamBuyingName     string    `gorm:"column:team_buying_name;NOT NULL"`                 // 团购标题
-	TeamBuyingPrice    string    `gorm:"column:team_buying_price;NOT NULL"`                // 团购售价
+	TeamBuyingPrice    float64   `gorm:"column:team_buying_price;NOT NULL"`                // 团购售价
 	PublicCommission   int       `gorm:"column:public_commission"`                         // 公开佣金%
 	TeamBuyingDetail   string    `gorm:"column:team_buying_detail;NOT NULL"`               // 团购详情
 	TeamBuyingLink     string    `gorm:"column:team_buying_link"`                          // 分销链接

+ 52 - 0
model/http_model/s_local_life_list.go

@@ -0,0 +1,52 @@
+package http_model
+
+type FullSLocalListRequest struct {
+	PageSize        int32  `json:"page_size"`
+	PageNum         int32  `json:"page_num"`
+	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"`         // 本地生活标题
+}
+
+type FullSLocalPreview 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"`    // 本地生活内容形式
+	ServiceCharge       float64 `json:"service_charge"`        // 预估赚
+	ServiceChargeActual float64 `json:"service_charge_actual"` // 实际已赚
+	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"`            // 门店名称
+	StoreId             int     `json:"store_id"`              // 门店ID
+	ApplyNum            int     `json:"apply_num"`             // 报名人数
+	RecruitNum          int     `json:"recruit_num"`           // 已招募人数
+	SettleNum           int     `json:"settle_num"`            // 已结算人数
+	SupplierId          int     `json:"supplier_id"`           // 服务商ID
+	SubAccountId        int     `json:"sub_account_id"`        // 子账号ID
+	OperatorType        int     `json:"operator_type"`         // 添加商单操作人类型,1为服务商主账号,2为服务商子账号
+	CreateTime          string  `json:"create_time"`           // 加入商单时间
+}
+
+type FullSLocalListData struct {
+	FullSLocalPreview []*FullSLocalPreview `json:"full_s_local_preview"`
+	Total             int64                `json:"total"`
+}
+
+func NewFullSLocalListRequest() *FullSLocalListRequest {
+	return new(FullSLocalListRequest)
+}
+func NewFullSLocalListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(FullSLocalListData)
+	return resp
+}

+ 53 - 0
model/http_model/show_s_local_life.go

@@ -0,0 +1,53 @@
+package http_model
+
+import "time"
+
+type ShowSLocalPhoto struct {
+	PhotoUrl string `json:"photo_url"` // 图片url
+	PhotoUid string `json:"photo_uid"`
+	FileName string `json:"name"` //文件名
+}
+
+type ShowSLocalData struct {
+	ProjectName      string                `json:"project_name"`       // 项目名称
+	ProjectStatus    string                `json:"project_status"`     // 项目状态,1-7分别代表创建中、待审核、招募中、待支付、失效、执行中、已结案
+	ProjectType      string                `json:"project_type"`       // 项目类型,1代表全流程项目,2代表专项项目
+	ProjectPlatform  string                `json:"project_platform"`   // 项目平台,1-7分别代表红book、抖音、微博、快手、b站、大众点评、知乎
+	ProjectForm      string                `json:"project_form"`       // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
+	TalentType       string                `json:"talent_type"`        // 达人类型
+	RecruitDdl       time.Time             `json:"recruit_ddl"`        // 招募截止时间
+	ContentType      string                `json:"content_type"`       // 内容形式,1代表图文,2代表视频
+	ProjectDetail    string                `json:"project_detail"`     // 项目详情
+	RecruitStrategys []ShowRecruitStrategy `json:"recruit_strategys"`  // 定价策略
+	ProjectPhotos    []ShowProjectPhoto    `json:"project_photos"`     // 项目图片
+	ProductID        string                `json:"product_id"`         // 关联商品id
+	ProductInfo      string                `json:"product_info"`       // 商品信息
+	ProductPhotoInfo string                `json:"product_photo_info"` // 商品图片
+	EstimatedCost    string                `json:"estimated_cost"`     // 预估成本
+	EnterpriseID     string                `json:"enterprise_id"`      // 企业id
+	Balance          string                `json:"balance"`            // 企业余额
+	AvailableBalance string                `json:"available_balance"`  //可用余额
+	ProjectID        string                `json:"project_id"`         // 项目id
+	FailReason       string                `json:"fail_reason"`        // 失效原因
+	Phone            string                `json:"phone"`              // 联系方式
+	CreateAt         time.Time             `json:"create_at"`          // 创建时间
+	UpdateAt         time.Time             `json:"update_at"`          // 更新时间
+	SubmitAt         time.Time             `json:"submit_at"`          // 更新时间
+	PassAt           time.Time             `json:"pass_at"`            // 审核通过时间
+	FinishAt         time.Time             `json:"finish_at"`          // 结案时间
+	PayAt            time.Time             `json:"pay_at"`             // 支付时间
+	AutoFailAt       time.Time             `json:"auto_fail_at"`       // 自动失效时间
+}
+
+type ShowSLocalRequest struct {
+	ProjectID string `json:"Project_id"` // 项目id
+}
+
+func NewShowSLocalRequest() *ShowSLocalRequest {
+	return new(ShowSLocalRequest)
+}
+func NewShowSLocalResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(ShowSLocalData)
+	return resp
+}

+ 7 - 3
route/init.go

@@ -186,9 +186,13 @@ func InitRoute(r *gin.Engine) {
 	l := r.Group("/youngee/l")
 	{
 		l.Use(middleware.LoginAuthMiddleware)
-		l.POST("/localLife/fullList", handler.WrapFullListHandler)             // 商单广场-公开本地生活任务列表
-		l.POST("/localLife/detail", handler.WrapLocalLifeDetailHandler)        // 本地生活任务详情
-		m.POST("/sLocalLife/addToList", handler.WrapLocalLifeAddToListHandler) // 公开本地生活任务服务商加入商单
+		l.POST("/localLife/fullLocalList", handler.WrapFullListHandler)                    // 商单广场-公开本地生活任务列表
+		l.POST("/localLife/detail", handler.WrapLocalLifeDetailHandler)                    // 本地生活任务详情
+		m.POST("/sLocalLife/addToList", handler.WrapLocalLifeAddToListHandler)             // 公开本地生活任务服务商加入商单
+		l.POST("/sLocalLife/fullSLocalList", handler.WrapFullSLocalListHandler)            // 商单管理-公开本地生活任务列表
+		m.POST("/sLocalLife/showSLocal", handler.WrapShowSLocalHandler)                    // 服务商本地生活任务详情
+		m.POST("/sLocalLife/taskList", handler.WrapProjectTaskListHandler)                 // 任务列表
+		m.POST("/sLocalLife/changeTaskStatus", handler.WrapProjectChangeTaskStatusHandler) // 改变子任务的状态 报名通过,拒绝报名
 	}
 
 	// 财务结算板块

+ 14 - 0
service/s_local_life.go

@@ -2,6 +2,8 @@ package service
 
 import (
 	"context"
+	"youngee_b_api/db"
+	"youngee_b_api/model/gorm_model"
 	"youngee_b_api/model/http_model"
 )
 
@@ -12,9 +14,21 @@ type sLocalLife struct {
 
 // CreateSLocalLife 新建服务商加入商单后的公开本地生活
 func (*sLocalLife) CreateSLocalLife(ctx context.Context, request http_model.LocalLifeAddToListRequest) error {
+	var sLocalLifeInfo *gorm_model.YounggeeSLocalLifeInfo
+	sLocalLifeInfo = &gorm_model.YounggeeSLocalLifeInfo{}
 
 	// 1. 建立SLocalLife信息
 	// 1.1. 根据传入的LocalLifeId去LocalLife表查找信息补全SLocalLife
+	localLifeInfo, localErr := db.GetLocalLifeDetail(ctx, request.LocalLifeId)
+	if localErr != nil {
+		return localErr
+	}
+	if localLifeInfo != nil {
+		sLocalLifeInfo.LocalLifeId = localLifeInfo.LocalId
+		sLocalLifeInfo.SettleNum = 0
+		sLocalLifeInfo.RecruitNum = 0
+		sLocalLifeInfo.ApplyNum = 0
+	}
 
 	return nil
 }

+ 1 - 1
service/s_project.go

@@ -72,7 +72,7 @@ func (*sProject) CreateSProject(ctx context.Context, request http_model.AddToLis
 		currStrategy.RecruitNumber = strategy.RecruitNumber
 		currStrategy.Offer = strategy.Offer
 		currStrategy.TOffer = strategy.TOffer
-		currStrategy.ProjectID = strategy.ProjectID
+		currStrategy.ProjectID = "0"
 		currStrategy.ServiceCharge = strategy.ServiceCharge
 		currStrategy.ServiceRate = strategy.ServiceRate
 		currStrategy.SProjectId = sProjectId