Xingyu Xian 2 ماه پیش
والد
کامیت
2afb8d41a0

+ 52 - 0
handler/local_special_add_strategy.go

@@ -0,0 +1,52 @@
+package handler
+
+import (
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service"
+)
+
+func WrapLocalSpecialAddStrategyHandler(ctx *gin.Context) {
+	handler := newLocalSpecialAddStrategyHandler(ctx)
+	baseRun(handler)
+}
+
+func newLocalSpecialAddStrategyHandler(ctx *gin.Context) *LocalSpecialAddStrategyHandler {
+	return &LocalSpecialAddStrategyHandler{
+		req:  http_model.NewLocalSpecialAddStrategyRequest(),
+		resp: http_model.NewLocalSpecialAddStrategyResponse(),
+		ctx:  ctx,
+	}
+}
+
+type LocalSpecialAddStrategyHandler struct {
+	req  *http_model.LocalSpecialAddStrategyRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (p *LocalSpecialAddStrategyHandler) getContext() *gin.Context {
+	return p.ctx
+}
+
+func (p *LocalSpecialAddStrategyHandler) getResponse() interface{} {
+	return p.resp
+}
+
+func (p *LocalSpecialAddStrategyHandler) getRequest() interface{} {
+	return p.req
+}
+
+func (p *LocalSpecialAddStrategyHandler) run() {
+	fmt.Println(p.req.RecruitStrategys)
+	err := service.SLocalLife.CreateSpecialStrategy(p.ctx, p.req)
+	if err != nil {
+		p.resp.Message = err.Error()
+	}
+	p.resp.Message = "成功添加招募策略"
+}
+
+func (p *LocalSpecialAddStrategyHandler) checkParam() error {
+	return nil
+}

+ 47 - 0
handler/local_strategy.go

@@ -0,0 +1,47 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service"
+)
+
+func WrapLocalStrategyHandler(ctx *gin.Context) {
+	handler := newLocalStrategyHandler(ctx)
+	baseRun(handler)
+}
+
+func newLocalStrategyHandler(ctx *gin.Context) *LocalStrategyHandler {
+	return &LocalStrategyHandler{
+		req:  http_model.NewLocalStrategyRequest(),
+		resp: http_model.NewlocalStrategyResponse(),
+		ctx:  ctx,
+	}
+}
+
+type LocalStrategyHandler struct {
+	req  *http_model.LocalStrategyRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *LocalStrategyHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *LocalStrategyHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *LocalStrategyHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *LocalStrategyHandler) run() {
+	recruitStrategys, err := service.Project.GetProjectStrategys(h.ctx, h.req.LocalId)
+	if err != nil {
+		h.resp.Message = err.Error()
+	}
+	h.resp.Message = "成功查询招募策略"
+	h.resp.Data = recruitStrategys
+}
+func (h *LocalStrategyHandler) checkParam() error {
+	return nil
+}

+ 1 - 1
model/gorm_model/s_local_life.go

@@ -31,7 +31,7 @@ type YounggeeSLocalLifeInfo struct {
 	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子账号
+	CreateStrategyType  int       `gorm:"column:create_strategy_type"`   // 服务商修改服务费操作人类型:1服务商主账号,2子账号
 }
 
 func (m *YounggeeSLocalLifeInfo) TableName() string {

+ 1 - 1
model/gorm_model/s_project.go

@@ -25,7 +25,7 @@ type SProjectInfo struct {
 	ServiceChargeSettle float64    `gorm:"column:service_charge_settle"`                   // 服务商已结算服务费
 	OperatorType        int        `gorm:"column:operator_type"`                           // 添加商单操作人类型,1为服务商主账号,2为服务商子账号
 	SProjectStatus      int        `gorm:"column:s_project_status"`                        // 服务商种草任务状态,1待确认,2已确认,3已拒绝
-	StrategyStatus      int        `gorm:"column:strategy_status"`                         // 定向种草任务是否替换招募策略
+	StrategyStatus      int        `gorm:"column:strategy_status"`                         // 定向种草任务是否替换招募策略,0无,1有
 	CreateStrategyId    int        `gorm:"column:create_strategy_id"`                      // 服务商修改服务费操作人ID
 	CreateStrategyType  int        `gorm:"column:create_strategy_type"`                    // 服务商修改服务费操作人类型:1服务商主账号,2子账号
 	CreateTime          *time.Time `gorm:"column:create_time"`                             // 创建时间

+ 19 - 0
model/http_model/local_special_add_strategy.go

@@ -0,0 +1,19 @@
+package http_model
+
+import "youngee_b_api/model/gorm_model"
+
+type LocalSpecialAddStrategyRequest struct {
+	SLocalId           int                          `json:"s_local_id"`           // 服务商本地生活任务ID
+	RecruitStrategys   []gorm_model.RecruitStrategy `json:"recruit_strategys"`    // 招募策略
+	CreateStrategyId   int                          `json:"create_strategy_id"`   // 替换招募策略操作人ID
+	CreateStrategyType int                          `json:"create_strategy_type"` // 服务商修改服务费操作人类型:1服务商主账号,2子账号
+}
+
+func NewLocalSpecialAddStrategyRequest() *LocalSpecialAddStrategyRequest {
+	return new(LocalSpecialAddStrategyRequest)
+}
+
+func NewLocalSpecialAddStrategyResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 20 - 0
model/http_model/local_strategy.go

@@ -0,0 +1,20 @@
+package http_model
+
+import "youngee_b_api/model/gorm_model"
+
+type LocalStrategyRequest struct {
+	LocalId string `json:"local_id"`
+}
+
+type localStrategyData struct {
+	RecruitStrategys []gorm_model.RecruitStrategy `json:"recruit_strategys"`
+}
+
+func NewLocalStrategyRequest() *LocalStrategyRequest {
+	return new(LocalStrategyRequest)
+}
+func NewlocalStrategyResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(localStrategyData)
+	return resp
+}

+ 4 - 2
route/init.go

@@ -195,8 +195,10 @@ func InitRoute(r *gin.Engine) {
 		l.POST("/sLocalLife/taskList", handler.WrapLocalTaskListHandler)                 // 子任务列表
 		l.POST("/sLocalLife/changeTaskStatus", handler.WrapLocalChangeTaskStatusHandler) // 改变子任务的状态 报名通过,拒绝报名
 
-		l.POST("/localLife/specialLocalList", handler.WrapSpecialLocalListHandler)       // 商单广场-定向本地生活任务列表
-		l.POST("/sLocalLife/specialAddToList", handler.WrapSpecialLocalAddToListHandler) // 定向本地生活任务同意/拒绝加入商单
+		l.POST("/localLife/specialLocalList", handler.WrapSpecialLocalListHandler)           // 商单广场-定向本地生活任务列表
+		l.POST("/sLocalLife/specialAddToList", handler.WrapSpecialLocalAddToListHandler)     // 定向本地生活任务同意/拒绝加入商单
+		l.POST("/sLocalLife/localStrategy", handler.WrapLocalStrategyHandler)                // 招募策略查询
+		l.POST("/sLocalLife/specialAddStrategy", handler.WrapLocalSpecialAddStrategyHandler) // 定向本地生活任务添加招募策略
 	}
 
 	// 财务结算板块

+ 31 - 0
service/s_local_life.go

@@ -361,3 +361,34 @@ func (*sLocalLife) ChangeSupplierStatus(ctx context.Context, req *http_model.Spe
 	}
 	return nil
 }
+
+// CreateSpecialStrategy 定向本地生活替换服务费率
+func (*sLocalLife) CreateSpecialStrategy(ctx context.Context, request *http_model.LocalSpecialAddStrategyRequest) error {
+	// 1. 添加服务商招募策略
+	// 1.1. 整理数据
+	for _, strategy := range request.RecruitStrategys {
+		// 一口价需要计算服务费率和达人所见报价
+		strategy.ServiceRate = int(strategy.ServiceCharge / strategy.Offer)
+		strategy.TOffer = strategy.Offer - strategy.ServiceCharge
+		strategy.ProjectID = "0"
+		strategy.SLocalId = request.SLocalId
+		strategy.QuoteRecruitStrategyId = int(strategy.RecruitStrategyID)
+	}
+	createErr := db.CreateSpecialStrategy(ctx, request.RecruitStrategys)
+	if createErr != nil {
+		return createErr
+	}
+
+	// 2. 修改sProject中的字段
+	var sLocalInfo *gorm_model.YounggeeSLocalLifeInfo
+	sLocalInfo = &gorm_model.YounggeeSLocalLifeInfo{}
+	sLocalInfo.SLocalId = request.SLocalId
+	sLocalInfo.StrategyStatus = 1
+	sLocalInfo.CreateStrategyId = request.CreateStrategyId
+	sLocalInfo.CreateStrategyType = request.CreateStrategyType
+	updateErr := db.UpdateSLocal(ctx, sLocalInfo)
+	if updateErr != nil {
+		return updateErr
+	}
+	return nil
+}

+ 3 - 0
service/s_project.go

@@ -475,6 +475,9 @@ func (*sProject) CreateSpecialStrategy(ctx context.Context, request *http_model.
 		// 一口价需要计算服务费率和达人所见报价
 		strategy.ServiceRate = int(strategy.ServiceCharge / strategy.Offer)
 		strategy.TOffer = strategy.Offer - strategy.ServiceCharge
+		strategy.ProjectID = "0"
+		strategy.SProjectId = request.SProjectId
+		strategy.QuoteRecruitStrategyId = int(strategy.RecruitStrategyID)
 	}
 	createErr := db.CreateSpecialStrategy(ctx, request.RecruitStrategys)
 	if createErr != nil {