Browse Source

specialLocalLife

Xingyu Xian 2 tháng trước cách đây
mục cha
commit
6911ee08aa

+ 31 - 0
db/local_life_task.go

@@ -68,3 +68,34 @@ func GetLocalTaskList(ctx context.Context, pageSize, pageNum int32, conditions *
 	}
 	return newTaskDatas, totalTask, nil
 }
+
+// ChangeLocalTaskStatus 修改服务商本地生活子任务报名状态
+func ChangeLocalTaskStatus(ctx context.Context, taskIds []string, supplierStatus int) ([]int64, error) {
+	db := GetReadDB(ctx)
+	taskSta := supplierStatus
+
+	if err := db.Debug().Model(&gorm_model.YoungeeLocalTaskInfo{}).Where("task_id IN ?", taskIds).
+		Updates(gorm_model.YoungeeLocalTaskInfo{SupplierStatus: taskSta}).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[ChangeTaskStatus]2 error query mysql total, err:%+v", err)
+		return nil, err
+	}
+
+	var taskInfos []gorm_model.YoungeeLocalTaskInfo
+	err := db.Debug().Model(&gorm_model.YoungeeLocalTaskInfo{}).Where("task_id IN ?", taskIds).Find(&taskInfos).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[ChangeTaskStatus]3 error query mysql total, err:%+v", err)
+		return nil, err
+	}
+
+	var recruitStrategysIDs []int64
+	recruitStrategys := gorm_model.RecruitStrategy{}
+	for _, taskInfo := range taskInfos {
+		err2 := db.Debug().Model(gorm_model.RecruitStrategy{}).Where("s_local_id=? AND strategy_id=?", taskInfo.SLocalID, taskInfo.StrategyID).Scan(&recruitStrategys).Error
+		if err2 != nil {
+			logrus.WithContext(ctx).Errorf("[ChangeTaskStatus]4 error query mysql total, err:%+v", err2)
+			return nil, err2
+		}
+		recruitStrategysIDs = append(recruitStrategysIDs, recruitStrategys.RecruitStrategyID)
+	}
+	return recruitStrategysIDs, nil
+}

+ 74 - 9
db/s_local_life.go

@@ -10,12 +10,12 @@ import (
 	"youngee_b_api/util"
 )
 
-// GetFullLocalLifeList 查看所有本地生活列表
+// GetFullLocalLifeList 商单广场-公开本地生活列表
 func GetFullLocalLifeList(ctx context.Context, pageSize, pageNum int32, condition *common_model.SLocalLifeCondition) ([]*gorm_model.YounggeeLocalLifeInfo, int64, error) {
 	db := GetReadDB(ctx)
 
 	// 根据带货任务状态过滤
-	db = db.Debug().Model(gorm_model.YounggeeLocalLifeInfo{}).Where("task_status = 4")
+	db = db.Debug().Model(gorm_model.YounggeeLocalLifeInfo{}).Where("task_status = 4 and local_type = 1")
 
 	// 根据Project条件过滤
 	conditionType := reflect.TypeOf(condition).Elem()
@@ -64,14 +64,26 @@ func GetLocalLifeDetail(ctx context.Context, localLifeId string) (*gorm_model.Yo
 	return localLifeInfo, nil
 }
 
+// GetSLocalLifeDetail 服务商本地生活查询
+func GetSLocalLifeDetail(ctx context.Context, sLocalLifeId int) (*gorm_model.YounggeeSLocalLifeInfo, error) {
+	db := GetReadDB(ctx)
+	var sLocalLifeInfo *gorm_model.YounggeeSLocalLifeInfo
+	whereCondition := gorm_model.YounggeeSLocalLifeInfo{SLocalId: sLocalLifeId}
+	err := db.Model(gorm_model.YounggeeSLocalLifeInfo{}).Where(whereCondition).Find(&sLocalLifeInfo).Error
+	if err != nil {
+		return nil, err
+	}
+	return sLocalLifeInfo, nil
+}
+
 // CreateSLocalLife 创建服务商加入商单后的本地生活详情
-func CreateSLocalLife(ctx context.Context, newSLocal *gorm_model.YounggeeSLocalLifeInfo) error {
+func CreateSLocalLife(ctx context.Context, newSLocal *gorm_model.YounggeeSLocalLifeInfo) (int, error) {
 	db := GetWriteDB(ctx)
 	err := db.Create(&newSLocal).Error
 	if err != nil {
-		return err
+		return 0, err
 	}
-	return nil
+	return newSLocal.SLocalId, nil
 }
 
 // FindBriefByLocalId 根据localId查找Brief
@@ -100,7 +112,7 @@ func FindMaterialByLocalId(ctx context.Context, localId string) ([]gorm_model.Lo
 	return sProjectInfo, nil
 }
 
-// FindSLocalByLocalIdAndSupplierId 根据LocalId和SupplierId查找SLocal
+// FindSLocalByLocalIdAndSupplierId 根据LocalId和SupplierId查找SLocal数量
 func FindSLocalByLocalIdAndSupplierId(ctx context.Context, localId string, supplierId int) (int64, error) {
 	db := GetWriteDB(ctx)
 	whereCondition := gorm_model.YounggeeSLocalLifeInfo{
@@ -115,12 +127,54 @@ func FindSLocalByLocalIdAndSupplierId(ctx context.Context, localId string, suppl
 	return total, nil
 }
 
-// GetFullSLocalLifeList 查看加入商单后的本地生活列表
+// GetFullSLocalLifeList 商单管理-公开本地生活列表
 func GetFullSLocalLifeList(ctx context.Context, pageSize, pageNum int32, condition *common_model.SLocalLifeCondition) ([]*gorm_model.YounggeeSLocalLifeInfo, int64, error) {
 	db := GetReadDB(ctx)
 
 	// 根据带货任务状态过滤
-	db = db.Debug().Model(gorm_model.YounggeeSLocalLifeInfo{}).Where("task_status = 4")
+	db = db.Debug().Model(gorm_model.YounggeeSLocalLifeInfo{}).Where("task_status = 4 and local_type = 1")
+
+	// 根据条件过滤
+	conditionType := reflect.TypeOf(condition).Elem()
+	conditionValue := reflect.ValueOf(condition).Elem()
+	for i := 0; i < conditionType.NumField(); i++ {
+		field := conditionType.Field(i)
+		tag := field.Tag.Get("condition")
+		value := conditionValue.FieldByName(field.Name)
+		if (tag == "local_id" || tag == "local_name") && !util.IsBlank(value) {
+			db = db.Where(fmt.Sprintf("local_id like '%%%v%%' or local_name like '%%%v%%'", value.Interface(), value.Interface()))
+		} else if tag == "updated_at" && value.Interface() != "0" {
+			db = db.Where(fmt.Sprintf("updated_at like '%s%%'", value.Interface()))
+		} else if !util.IsBlank(value) && tag != "updated_at" {
+			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		}
+	}
+
+	// 查询总数
+	var total int64
+	var fullLocals []*gorm_model.YounggeeSLocalLifeInfo
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetFullProjectList] 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_time desc").Limit(int(limit)).Offset(int(offset)).Find(&fullLocals).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetFullProjectList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	return fullLocals, total, nil
+}
+
+// GetSpecialLocalLifeList 商单广场-定向本地生活列表
+func GetSpecialLocalLifeList(ctx context.Context, pageSize, pageNum int32, condition *common_model.SSpecialLocalLifeCondition) ([]*gorm_model.YounggeeSLocalLifeInfo, int64, error) {
+	db := GetReadDB(ctx)
+
+	// 根据带货任务状态过滤
+	db = db.Debug().Model(gorm_model.YounggeeSLocalLifeInfo{}).Where("task_status = 4 and local_type = 2")
 
 	// 根据Project条件过滤
 	conditionType := reflect.TypeOf(condition).Elem()
@@ -149,10 +203,21 @@ func GetFullSLocalLifeList(ctx context.Context, pageSize, pageNum int32, conditi
 	// 查询该页数据
 	limit := pageSize
 	offset := pageSize * pageNum // assert pageNum start with 0
-	err := db.Order("updated_at desc").Limit(int(limit)).Offset(int(offset)).Find(&fullLocals).Error
+	err := db.Order("create_time desc").Limit(int(limit)).Offset(int(offset)).Find(&fullLocals).Error
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[GetFullProjectList] error query mysql total, err:%+v", err)
 		return nil, 0, err
 	}
 	return fullLocals, total, nil
 }
+
+// UpdateSLocal 更新SLocal
+func UpdateSLocal(ctx context.Context, sLocalInfo *gorm_model.YounggeeSLocalLifeInfo) error {
+	db := GetWriteDB(ctx)
+	whereCondition := gorm_model.YounggeeSLocalLifeInfo{SLocalId: sLocalInfo.SLocalId}
+	err := db.Model(&gorm_model.YounggeeSLocalLifeInfo{}).Where(whereCondition).Updates(sLocalInfo).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 1 - 1
handler/full_s_local_list.go

@@ -41,7 +41,7 @@ func (h *FullSLocalListHandler) getResponse() interface{} {
 func (h *FullSLocalListHandler) run() {
 	// enterpriseID := middleware.GetSessionAuth(h.ctx).EnterpriseID
 	condition := pack.HttpFullSLocalLifeListRequestToCondition(h.req)
-	data, err := service.SLcoalLife.GetFullSLocalLifeList(h.ctx, h.req.PageSize, h.req.PageNum, h.req.SupplierId, condition)
+	data, err := service.SLocalLife.GetFullSLocalLifeList(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)

+ 45 - 0
handler/local_change_supplier_status.go

@@ -0,0 +1,45 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"youngee_b_api/model/http_model"
+)
+
+func WrapLocalChangeTaskStatusHandler(ctx *gin.Context) {
+	handler := newLocalChangeTaskStatusHandler(ctx)
+	baseRun(handler)
+}
+
+func newLocalChangeTaskStatusHandler(ctx *gin.Context) *LocalChangeTaskStatusHandler {
+	return &LocalChangeTaskStatusHandler{
+		req:  http_model.NewLocalChangeSupplierStatusRequst(),
+		resp: http_model.NewLocalChangeSupplierStatusResponse(),
+		ctx:  ctx,
+	}
+}
+
+type LocalChangeTaskStatusHandler struct {
+	req  *http_model.LocalChangeSupplierStatusRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (p *LocalChangeTaskStatusHandler) getContext() *gin.Context {
+	return p.ctx
+}
+
+func (p *LocalChangeTaskStatusHandler) getResponse() interface{} {
+	return p.resp
+}
+
+func (p *LocalChangeTaskStatusHandler) getRequest() interface{} {
+	return p.req
+}
+
+func (p *LocalChangeTaskStatusHandler) run() {
+	p.resp.Message = "任务状态更换成功"
+}
+
+func (p *LocalChangeTaskStatusHandler) checkParam() error {
+	return nil
+}

+ 1 - 1
handler/local_life_add_to_list.go

@@ -36,7 +36,7 @@ func (h *LocalLifeAddToListHandler) getResponse() interface{} {
 }
 func (h *LocalLifeAddToListHandler) run() {
 	// 1. 加入商单
-	createErr := service.SLcoalLife.CreateSLocalLife(h.ctx, h.req)
+	createErr := service.SLocalLife.CreateSLocalLife(h.ctx, h.req)
 	if createErr != nil {
 		h.resp.Status = 50000
 		h.resp.Message = "加入商单失败"

+ 3 - 1
handler/local_task_list.go

@@ -46,7 +46,9 @@ func (h *LocalTaskListHandler) run() {
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
 		return
 	}
-	// h.resp.Data = data
+	h.resp.Status = 20000
+	h.resp.Message = "ok"
+	h.resp.Data = data
 }
 func (h *LocalTaskListHandler) checkParam() error {
 	return nil

+ 1 - 1
handler/s_local_life_detail.go

@@ -42,7 +42,7 @@ func (h *ShowSLocalHandler) getResponse() interface{} {
 }
 
 func (h *ShowSLocalHandler) run() {
-	res, err := service.SLcoalLife.ShowSLocalLife(h.ctx, h.req)
+	res, err := service.SLocalLife.ShowSLocalLife(h.ctx, h.req)
 	if err != nil {
 		logrus.Errorf("[ShowProjectHandler] call Show err:%+v\n", err)
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")

+ 51 - 0
handler/special_local_add_to_list.go

@@ -0,0 +1,51 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service"
+)
+
+func WrapSpecialLocalAddToListHandler(ctx *gin.Context) {
+	handler := newLocalLifeAddToListHandler(ctx)
+	baseRun(handler)
+}
+
+func newSpecialLocalAddToListHandler(ctx *gin.Context) *SpecialLocalAddToListHandler {
+	return &SpecialLocalAddToListHandler{
+		req:  http_model.NewSpecialLocalAddToListRequest(),
+		resp: http_model.NewSpecialLocalAddToListResponse(),
+		ctx:  ctx,
+	}
+}
+
+type SpecialLocalAddToListHandler struct {
+	req  *http_model.SpecialLocalAddToListRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *SpecialLocalAddToListHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *SpecialLocalAddToListHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *SpecialLocalAddToListHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *SpecialLocalAddToListHandler) run() {
+	// 1. 加入商单
+	createErr := service.SLocalLife.ChangeSupplierStatus(h.ctx, h.req)
+	if createErr != nil {
+		h.resp.Status = 50000
+		h.resp.Message = "加入商单失败"
+		return
+	}
+	h.resp.Status = 20000
+	h.resp.Message = "加入商单成功"
+}
+
+func (h *SpecialLocalAddToListHandler) checkParam() error {
+	return nil
+}

+ 55 - 0
handler/special_local_list.go

@@ -0,0 +1,55 @@
+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 WrapSpecialLocalListHandler(ctx *gin.Context) {
+	handler := newSpecialLocalListHandler(ctx)
+	baseRun(handler)
+}
+
+func newSpecialLocalListHandler(ctx *gin.Context) *SpecialLocalListHandler {
+	return &SpecialLocalListHandler{
+		req:  http_model.NewSpecialLocalListRequest(),
+		resp: http_model.NewSpecialLocalListResponse(),
+		ctx:  ctx,
+	}
+}
+
+type SpecialLocalListHandler struct {
+	req  *http_model.SpecialLocalListRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *SpecialLocalListHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *SpecialLocalListHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *SpecialLocalListHandler) getResponse() interface{} {
+	return h.resp
+}
+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, 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 *SpecialLocalListHandler) checkParam() error {
+	return nil
+}

+ 7 - 0
model/common_model/full_local_life_condition.go

@@ -11,4 +11,11 @@ type SLocalLifeCondition struct {
 }
 
 type SSpecialLocalLifeCondition struct {
+	LocalPlatform   int    `condition:"local_platform"`     // 本地生活平台
+	TaskForm        int    `condition:"task_form"`          // 任务形式,1-2分别代表线下探店,素材分发
+	ContentType     int    `condition:"content_type"`       // 内容形式
+	AddToListStatus int    `condition:"add_to_list_status"` // 加入商单状态,1已加入,2未加入
+	LocalId         string `condition:"local_id"`           // 本地生活ID
+	TaskStatus      int    `condition:"task_status"`        // 任务状态
+	LocalName       string `condition:"local_name"`         // 本地生活标题
 }

+ 1 - 1
model/gorm_model/local_life_task_info.go

@@ -60,7 +60,7 @@ type YoungeeLocalTaskInfo struct {
 	SOperator              int       `gorm:"column:s_operator;default:0"`                           // 服务商提报达人操作人ID
 	SOperatorType          int       `gorm:"column:s_operator_type;default:0"`                      // 服务商操作人类型,1服务商主账号,2服务商子账号,3管理后台
 	OpenID                 string    `gorm:"column:open_id"`                                        // 达人报名的快手唯一标识
-	SLocalLifeID           int       `gorm:"column:s_local_life_id"`                                // 服务商本地生活任务ID
+	SLocalID               int       `gorm:"column:s_local_id"`                                     // 服务商本地生活任务ID
 	SupportFee             float64   `gorm:"column:support_fee"`                                    // 提报价格(达人自报价经过计算后,)
 	SketchMissingTime      time.Time `gorm:"column:sketch_missing_time"`                            // 未传初稿违约时间
 	SketchMissingStatus    int       `gorm:"column:sketch_missing_status;default:0"`                // 未传初稿违约状态,0无违约,1有违约

+ 1 - 0
model/gorm_model/s_local_life.go

@@ -10,6 +10,7 @@ type YounggeeSLocalLifeInfo struct {
 	EnterpriseId        string    `gorm:"column:enterprise_id"`          // 商家ID
 	SupplierId          int       `gorm:"column:supplier_id"`            // 服务商ID
 	StoreId             int       `gorm:"column:store_id"`               // 门店ID
+	LocalName           string    `gorm:"column:local_name"`             // 本地生活名称
 	TeamBuyingId        int       `gorm:"column:team_buying_id"`         // 团购ID
 	LocalType           int       `gorm:"column:local_type"`             // 任务类型,1为公开,2为定向
 	TaskStatus          int       `gorm:"column:task_status"`            // 任务状态

+ 18 - 0
model/http_model/local_change_supplier_status.go

@@ -0,0 +1,18 @@
+package http_model
+
+type LocalChangeSupplierStatusRequest struct {
+	TaskIds        []string `json:"task_ids"`
+	TaskStatus     string   `json:"task_status"`
+	TaskStage      string   `json:"task_stage"`
+	LocalId        string   `json:"local_id"`
+	SupplierStatus int      `json:"supplier_status"` // 服务商任务状态 0表示达人来源非服务商 1待选 2已选 3落选
+}
+
+func NewLocalChangeSupplierStatusRequst() *LocalChangeSupplierStatusRequest {
+	return new(LocalChangeSupplierStatusRequest)
+}
+
+func NewLocalChangeSupplierStatusResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 1 - 1
model/http_model/local_life_add_to_list.go

@@ -1,7 +1,7 @@
 package http_model
 
 type LocalLifeAddToListRequest struct {
-	LocalLifeId  string `json:"local_life_id"`  // 待加入商单的本地生活ID
+	LocalId      string `json:"local_id"`       // 待加入商单的本地生活ID
 	EnterpriseId string `json:"enterprise_id"`  // 商家ID
 	SupplierId   int    `json:"supplier_id"`    // 服务商ID
 	SubAccountId int    `json:"sub_account_id"` // 子账号ID

+ 17 - 0
model/http_model/special_local_add_to_list.go

@@ -0,0 +1,17 @@
+package http_model
+
+type SpecialLocalAddToListRequest struct {
+	SLocalId     int `json:"sLocalId"`       //
+	SupplierId   int `json:"supplier_id"`    // 服务商ID
+	SubAccountId int `json:"sub_account_id"` // 子账号ID
+	OperatorType int `json:"operator_type"`  // 账号类型,1为主账号,2为子账号
+	SLocalStatus int `json:"s_local_status"` // 服务商本地生活任务状态,1待确认,2已确认,3已拒绝
+}
+
+func NewSpecialLocalAddToListRequest() *SpecialLocalAddToListRequest {
+	return new(SpecialLocalAddToListRequest)
+}
+func NewSpecialLocalAddToListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 51 - 0
model/http_model/special_local_list.go

@@ -0,0 +1,51 @@
+package http_model
+
+type SpecialLocalListRequest 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"`         // 本地生活标题
+	TaskStatus      int    `json:"task_status"`        // 任务状态
+}
+
+type SpecialLocalPreview 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 SpecialLocalListData struct {
+	SpecialLocalPreview []*SpecialLocalPreview `json:"special_local_pre_view"`
+	Total               int64                  `json:"total"`
+}
+
+func NewSpecialLocalListRequest() *SpecialLocalListRequest {
+	return new(SpecialLocalListRequest)
+}
+func NewSpecialLocalListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(SpecialLocalListData)
+	return resp
+}

+ 2 - 0
pack/full_local_life_list.go

@@ -5,6 +5,7 @@ import (
 	"youngee_b_api/model/http_model"
 )
 
+// HttpFullLocalLifeListRequestToCondition 商单广场
 func HttpFullLocalLifeListRequestToCondition(req *http_model.FullListRequest) *common_model.SLocalLifeCondition {
 	return &common_model.SLocalLifeCondition{
 		TaskStatus:      req.TaskStatus,      // 任务状态
@@ -17,6 +18,7 @@ func HttpFullLocalLifeListRequestToCondition(req *http_model.FullListRequest) *c
 	}
 }
 
+// HttpFullSLocalLifeListRequestToCondition 商单管理
 func HttpFullSLocalLifeListRequestToCondition(req *http_model.FullSLocalListRequest) *common_model.SLocalLifeCondition {
 	return &common_model.SLocalLifeCondition{
 		TaskStatus:      req.TaskStatus,      // 任务状态

+ 32 - 0
pack/special_local_list.go

@@ -0,0 +1,32 @@
+package pack
+
+import (
+	"youngee_b_api/model/common_model"
+	"youngee_b_api/model/http_model"
+)
+
+// HttpSpecialLocalLifeListRequestToCondition 商单广场
+func HttpSpecialLocalLifeListRequestToCondition(req *http_model.SpecialLocalListRequest) *common_model.SSpecialLocalLifeCondition {
+	return &common_model.SSpecialLocalLifeCondition{
+		TaskStatus:      req.TaskStatus,      // 任务状态
+		LocalPlatform:   req.LocalPlatform,   // 本地生活平台
+		TaskForm:        req.TaskForm,        // 任务形式,1-2分别代表线下探店,素材分发
+		ContentType:     req.ContentType,     // 内容形式
+		AddToListStatus: req.AddToListStatus, // 加入商单状态,1已加入,2未加入
+		LocalId:         req.LocalId,         // 本地生活ID
+		LocalName:       req.LocalName,       // 本地生活标题
+	}
+}
+
+// HttpSpecialSLocalLifeListRequestToCondition 商单管理
+func HttpSpecialSLocalLifeListRequestToCondition(req *http_model.FullSLocalListRequest) *common_model.SLocalLifeCondition {
+	return &common_model.SLocalLifeCondition{
+		TaskStatus:      req.TaskStatus,      // 任务状态
+		LocalPlatform:   req.LocalPlatform,   // 本地生活平台
+		TaskForm:        req.TaskForm,        // 任务形式,1-2分别代表线下探店,素材分发
+		ContentType:     req.ContentType,     // 内容形式
+		AddToListStatus: req.AddToListStatus, // 加入商单状态,1已加入,2未加入
+		LocalId:         req.LocalId,         // 本地生活ID
+		LocalName:       req.LocalName,       // 本地生活标题
+	}
+}

+ 10 - 9
route/init.go

@@ -40,6 +40,7 @@ func InitRoute(r *gin.Engine) {
 	//	c.JSON(200, resp)
 	//	// 注意这里只是debug用的 接口要写成handler形式
 	//})
+
 	m := r.Group("/youngee/m")
 	{
 		m.Use(middleware.LoginAuthMiddleware)
@@ -186,16 +187,16 @@ func InitRoute(r *gin.Engine) {
 	l := r.Group("/youngee/l")
 	{
 		l.Use(middleware.LoginAuthMiddleware)
-		l.POST("/localLife/fullLocalList", handler.WrapFullListHandler)                    // 商单广场-公开本地生活任务列表
-		l.POST("/localLife/detail", handler.WrapLocalLifeDetailHandler)                    // 本地生活任务详情
-		l.POST("/sLocalLife/addToList", handler.WrapLocalLifeAddToListHandler)             // 公开本地生活任务服务商加入商单
-		l.POST("/sLocalLife/fullSLocalList", handler.WrapFullSLocalListHandler)            // 商单管理-公开本地生活任务列表
-		l.POST("/sLocalLife/showSLocal", handler.WrapShowSLocalHandler)                    // 服务商本地生活任务详情
-		l.POST("/sLocalLife/taskList", handler.WrapLocalTaskListHandler)                   // 子任务列表
-		l.POST("/sLocalLife/changeTaskStatus", handler.WrapProjectChangeTaskStatusHandler) // 改变子任务的状态 报名通过,拒绝报名
+		l.POST("/localLife/fullLocalList", handler.WrapFullListHandler)                  // 商单广场-公开本地生活任务列表
+		l.POST("/localLife/detail", handler.WrapLocalLifeDetailHandler)                  // 本地生活任务详情
+		l.POST("/sLocalLife/addToList", handler.WrapLocalLifeAddToListHandler)           // 公开本地生活任务服务商加入商单
+		l.POST("/sLocalLife/fullSLocalList", handler.WrapFullSLocalListHandler)          // 商单管理-公开本地生活任务列表
+		l.POST("/sLocalLife/showSLocal", handler.WrapShowSLocalHandler)                  // 服务商本地生活任务详情
+		l.POST("/sLocalLife/taskList", handler.WrapLocalTaskListHandler)                 // 子任务列表
+		l.POST("/sLocalLife/changeTaskStatus", handler.WrapLocalChangeTaskStatusHandler) // 改变子任务的状态 报名通过,拒绝报名
 
-		l.POST("/localLife/specialLocalList", handler.WrapFullListHandler)            // 商单广场-公开本地生活任务列表
-		l.POST("/sLocalLife/specialAddToList", handler.WrapLocalLifeAddToListHandler) // 定向本地生活任务服务商加入商单
+		l.POST("/localLife/specialLocalList", handler.WrapSpecialLocalListHandler)       // 商单广场-定向本地生活任务列表
+		l.POST("/sLocalLife/specialAddToList", handler.WrapSpecialLocalAddToListHandler) // 定向本地生活任务同意/拒绝加入商单
 	}
 
 	// 财务结算板块

+ 85 - 0
service/local_life.go

@@ -84,6 +84,7 @@ func (*localLife) GetFullLocalLifeList(ctx context.Context, pageSize, pageNum in
 		}
 
 		// 2.4. 判断是否加入商单
+		fmt.Println(local.LocalId)
 		sProjectCount, sProjectErr := db.FindSLocalByLocalIdAndSupplierId(ctx, local.LocalId, supplierId)
 		if sProjectErr != nil {
 			return nil, sProjectErr
@@ -96,3 +97,87 @@ func (*localLife) GetFullLocalLifeList(ctx context.Context, pageSize, pageNum in
 	}
 	return fullLocalData, nil
 }
+
+// GetSpecialLocalLifeList 商单广场-定向本地生活
+func (*localLife) GetSpecialLocalLifeList(ctx context.Context, pageSize, pageNum int32, condition *common_model.SSpecialLocalLifeCondition) (*http_model.SpecialLocalListData, error) {
+
+	// 1. 查询本地生活任务基本信息
+	specialLocals, total, err := db.GetSpecialLocalLifeList(ctx, pageSize, pageNum, condition)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[fullLocals service] call GetFullLocalLifeList error,err:%+v", err)
+		return nil, err
+	}
+	var specialLocalData *http_model.SpecialLocalListData
+	specialLocalData = &http_model.SpecialLocalListData{}
+	specialLocalData.Total = total
+	for _, specialLocal := range specialLocals {
+		var specialLocalPreview *http_model.SpecialLocalPreview
+		specialLocalPreview = &http_model.SpecialLocalPreview{}
+		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.SpecialLocalPreview = append(specialLocalData.SpecialLocalPreview, specialLocalPreview)
+	}
+
+	// 2. 查询本地生活补充信息:门店信息,招募策略
+	for _, local := range specialLocalData.SpecialLocalPreview {
+
+		// 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
+}

+ 72 - 4
service/s_local_life.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"github.com/issue9/conv"
 	"github.com/sirupsen/logrus"
+	"time"
 	"youngee_b_api/db"
 	"youngee_b_api/model/common_model"
 	"youngee_b_api/model/gorm_model"
@@ -23,7 +24,7 @@ func (*sLocalLife) CreateSLocalLife(ctx context.Context, request *http_model.Loc
 
 	// 1. 建立SLocalLife信息
 	// 1.1. 根据传入的LocalLifeId去LocalLife表查找信息补全SLocalLife
-	localLifeInfo, localErr := db.GetLocalLifeDetail(ctx, request.LocalLifeId)
+	localLifeInfo, localErr := db.GetLocalLifeDetail(ctx, request.LocalId)
 	if localErr != nil {
 		return localErr
 	}
@@ -33,6 +34,7 @@ func (*sLocalLife) CreateSLocalLife(ctx context.Context, request *http_model.Loc
 		sLocalLifeInfo.RecruitNum = 0
 		sLocalLifeInfo.ApplyNum = 0
 		sLocalLifeInfo.LocalType = localLifeInfo.LocalType
+		sLocalLifeInfo.LocalName = localLifeInfo.LocalName
 		sLocalLifeInfo.LocalPlatform = localLifeInfo.LocalPlatform
 		sLocalLifeInfo.TaskStatus = localLifeInfo.TaskStatus
 		sLocalLifeInfo.StoreId = localLifeInfo.StoreId
@@ -45,12 +47,44 @@ func (*sLocalLife) CreateSLocalLife(ctx context.Context, request *http_model.Loc
 		sLocalLifeInfo.SubAccountId = request.SubAccountId
 		sLocalLifeInfo.SupplierId = request.SupplierId
 		sLocalLifeInfo.OperatorType = request.OperatorType
+		sLocalLifeInfo.CreateTime = time.Now()
 
 		// 2. 入库
-		createErr := db.CreateSLocalLife(ctx, sLocalLifeInfo)
+		sLocalId, createErr := db.CreateSLocalLife(ctx, sLocalLifeInfo)
 		if createErr != nil {
 			return createErr
 		}
+
+		// 2. 建立新的recruitStrategy
+		// 2.1. 根据projectId去查找原来的recruitStrategy
+		recruitStrategys, strategyErr := db.GetRecruitStrategyByProjectId(ctx, request.LocalId)
+		if strategyErr != nil {
+			return strategyErr
+		}
+		// 2.2. 设置新的结构体以写入
+		var currRecruitStrategys []gorm_model.RecruitStrategy
+		for _, strategy := range recruitStrategys {
+			var currStrategy gorm_model.RecruitStrategy
+			currStrategy.StrategyID = strategy.StrategyID
+			currStrategy.QuoteRecruitStrategyId = int(strategy.RecruitStrategyID)
+			currStrategy.FeeForm = strategy.FeeForm
+			currStrategy.FollowersLow = strategy.FollowersLow
+			currStrategy.FollowersUp = strategy.FollowersUp
+			currStrategy.RecruitNumber = strategy.RecruitNumber
+			currStrategy.Offer = strategy.Offer
+			currStrategy.TOffer = strategy.TOffer
+			currStrategy.ProjectID = "0"
+			currStrategy.ServiceCharge = strategy.ServiceCharge
+			currStrategy.ServiceRate = strategy.ServiceRate
+			currStrategy.SLocalId = sLocalId
+			currStrategy.StrategyType = 2
+			currRecruitStrategys = append(currRecruitStrategys, currStrategy)
+		}
+		// 2.3. 写入
+		createStrategyErr := db.CreateSpecialStrategy(ctx, currRecruitStrategys)
+		if createStrategyErr != nil {
+			return createStrategyErr
+		}
 	}
 	return nil
 }
@@ -232,7 +266,6 @@ func (*sLocalLife) GetFullSLocalLifeList(ctx context.Context, pageSize, pageNum
 				}
 			}
 		}
-
 	}
 	return fullLocalData, nil
 }
@@ -289,7 +322,42 @@ func (*sLocalLife) GetLocalTaskList(ctx context.Context, pageSize, pageNum int32
 		}
 
 		// 3. 本地生活任务信息补充
-
+		sLocalInfo, sLocalErr := db.GetSLocalLifeDetail(ctx, condition.SLocalId)
+		if sLocalErr != nil {
+			return nil, sLocalErr
+		}
+		if sLocalInfo != nil {
+			localTaskListData.SettleNum = sLocalInfo.SettleNum
+			localTaskListData.RecruitNum = sLocalInfo.RecruitNum
+			localTaskListData.ServiceChargeActual = sLocalInfo.ServiceChargeActual
+		}
 	}
 	return localTaskListData, nil
 }
+
+// ChangeTaskSupplierStatus 本地生活达人报名通过、拒绝报名
+func (*sLocalLife) ChangeTaskSupplierStatus(ctx context.Context, req *http_model.LocalChangeSupplierStatusRequest) error {
+	RecruitStrategyIDs, err := db.ChangeLocalTaskStatus(ctx, req.TaskIds, req.SupplierStatus)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[project service] call ChangeTaskStatus error,err:%+v", err)
+		return err
+	}
+	fmt.Println(RecruitStrategyIDs)
+	return nil
+}
+
+// ChangeSupplierStatus 定向本地生活加入商单或拒绝
+func (*sLocalLife) ChangeSupplierStatus(ctx context.Context, req *http_model.SpecialLocalAddToListRequest) error {
+	var sLocalInfo *gorm_model.YounggeeSLocalLifeInfo
+	sLocalInfo = &gorm_model.YounggeeSLocalLifeInfo{}
+	sLocalInfo.SLocalId = req.SLocalId
+	sLocalInfo.SupplierId = req.SupplierId
+	sLocalInfo.SubAccountId = req.SubAccountId
+	sLocalInfo.OperatorType = req.OperatorType
+	sLocalInfo.SLocalStatus = req.SLocalStatus
+	err := db.UpdateSLocal(ctx, sLocalInfo)
+	if err != nil {
+		return err
+	}
+	return nil
+}