Browse Source

公开本地生活

Ethan 5 months ago
parent
commit
3e60939c45

+ 194 - 5
app/controller/task_controller.go

@@ -22,6 +22,12 @@ type ProjectDetailParam struct {
 	//SubAccountId int    `json:"sub_account_id"`
 }
 
+type LocalLifeDetailParam struct {
+	LocalLifeId string `json:"local_id"`
+	//EnterpriseId string `json:"enterprise_id"`
+	//SubAccountId int    `json:"sub_account_id"`
+}
+
 // 关联商品-已有商品展示
 func (t TaskController) GetAllProduct(c *gin.Context) {
 	search := vo.GetAllProductParam{}
@@ -34,7 +40,8 @@ func (t TaskController) GetAllProduct(c *gin.Context) {
 	var result vo.ResultVO
 	result, err = service.ProductService{}.GetTaskProductsByUserId(search)
 	if err != nil {
-		returnError(c, 40000, "error")
+		logrus.Errorf("[GetAllProduct] call GetAllProduct err:%+v\n", err)
+		returnError(c, 40000, err.Error())
 		return
 	}
 	returnSuccess(c, 20000, result)
@@ -51,6 +58,11 @@ func (t TaskController) CreateProduct(c *gin.Context) {
 		return
 	}
 	productId, err := service.ProductService{}.CreateProduct(data)
+	if err != nil {
+		logrus.Errorf("[CreateProduct] call CreateProduct err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
 	resultMap := make(map[string]int64)
 	resultMap["productId"] = productId
 	returnSuccess(c, 20000, resultMap)
@@ -245,7 +257,7 @@ func (t TaskController) CreateProject(c *gin.Context) {
 	projectId, err := service.ProjectService{}.CreateProject(data)
 	if err != nil {
 		logrus.Errorf("[CreateProject] call CreateProject err:%+v\n", err)
-		returnError(c, 40000, "error")
+		returnError(c, 40000, err.Error())
 		return
 	}
 	resultMap := make(map[string]string)
@@ -265,7 +277,7 @@ func (t TaskController) UpdateProject(c *gin.Context) {
 	projectId, err := service.ProjectService{}.UpdateProject(data)
 	if err != nil {
 		logrus.Errorf("[UpdateProject] call UpdateProject err:%+v\n", err)
-		returnError(c, 40000, "error")
+		returnError(c, 40000, err.Error())
 		return
 	}
 	resultMap := make(map[string]string)
@@ -285,7 +297,7 @@ func (t TaskController) UpdateProjectTarget(c *gin.Context) {
 	projectId, err := service.ProjectService{}.UpdateProjectTarget(data)
 	if err != nil {
 		logrus.Errorf("[UpdateProject] call UpdateProject err:%+v\n", err)
-		returnError(c, 40000, "error")
+		returnError(c, 40000, err.Error())
 		return
 	}
 	resultMap := make(map[string]string)
@@ -305,7 +317,7 @@ func (t TaskController) GetProjectDetail(c *gin.Context) {
 	res, err := service.ProjectService{}.GetProjectDetail(data.ProjectId)
 	if err != nil {
 		logrus.Errorf("[GetProjectDetail] call Show err:%+v\n", err)
-		returnError(c, 40000, "error")
+		returnError(c, 40000, err.Error())
 		return
 	}
 
@@ -560,3 +572,180 @@ func (o TaskController) InviteSupplier(c *gin.Context) {
 	}
 	returnSuccess(c, 20000, nil)
 }
+
+// 关联门店-已有门店展示
+func (t TaskController) GetAllStore(c *gin.Context) {
+	search := vo.GetAllStoreParam{}
+	err := c.BindJSON(&search)
+	if err != nil || search.EnterpriseId == "" {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	var result vo.ResultVO
+	result, err = service.StoreService{}.GetStoresByEnterpriseId(search)
+	if err != nil {
+		logrus.Errorf("[GetAllStore] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, result)
+}
+
+// 关联门店-新建门店
+func (t TaskController) CreateStore(c *gin.Context) {
+	param := &vo.StoreCreateParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	storeId, err := service.StoreService{}.CreateStore(param)
+	if err != nil {
+		logrus.Errorf("[CreateStore] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	resultMap := make(map[string]int64)
+	resultMap["storeId"] = storeId
+	returnSuccess(c, 20000, resultMap)
+}
+
+// 门店团购列表
+func (t TaskController) GetAllTeamBuying(c *gin.Context) {
+	search := vo.GetAllTeamBuyingParam{}
+	err := c.BindJSON(&search)
+	if err != nil || search.StoreId == 0 {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	var result vo.ResultVO
+	result, err = service.TeamBuyingService{}.GetTeamBuyingsByStoreId(search)
+	if err != nil {
+		logrus.Errorf("[GetAllTeamBuying] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, result)
+}
+
+// 新建团购
+func (t TaskController) CreateTeamBuying(c *gin.Context) {
+	param := &vo.TeamBuyingCreateParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	teamBuyingId, err := service.TeamBuyingService{}.CreateTeamBuying(param)
+	if err != nil {
+		logrus.Errorf("[CreateTeamBuying] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	resultMap := make(map[string]int64)
+	resultMap["teamBuyingId"] = teamBuyingId
+	returnSuccess(c, 20000, resultMap)
+}
+
+// 创建本地生活任务
+func (t TaskController) CreateLocalLife(c *gin.Context) {
+	data := &vo.LocalCreateParam{}
+	err := c.BindJSON(data)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	localId, err := service.LocalLifeService{}.CreateLocalLife(data)
+	if err != nil {
+		logrus.Errorf("[CreateLocalLife] call CreateLocalLife err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	resultMap := make(map[string]string)
+	resultMap["localId"] = *localId
+	returnSuccess(c, 20000, resultMap)
+}
+
+// 更新本地生活任务
+func (t TaskController) UpdateLocalLife(c *gin.Context) {
+	data := &vo.LocalUpdateParam{}
+	err := c.BindJSON(data)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	localId, err := service.LocalLifeService{}.UpdateLocal(data)
+	if err != nil {
+		logrus.Errorf("[UpdateLocalLife] call UpdateLocalLife err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	resultMap := make(map[string]string)
+	resultMap["localId"] = *localId
+	returnSuccess(c, 20000, resultMap)
+}
+
+// 更新定向本地生活任务
+func (t TaskController) UpdateLocalLifeTarget(c *gin.Context) {
+	data := &vo.LocalUpdateParam{}
+	err := c.BindJSON(data)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	localId, err := service.LocalLifeService{}.UpdateLocalTarget(data)
+	if err != nil {
+		logrus.Errorf("[UpdateLocalLifeTarget] call UpdateLocalLifeTarget err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	resultMap := make(map[string]string)
+	resultMap["localId"] = *localId
+	returnSuccess(c, 20000, resultMap)
+}
+
+// 本地生活任务预览
+func (t TaskController) GetLocalLifeDetail(c *gin.Context) {
+	param := &LocalLifeDetailParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	res, err := service.LocalLifeService{}.GetLocalLifeDetail(param.LocalLifeId)
+	if err != nil {
+		logrus.Errorf("[GetLocalLifeDetail] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+
+	returnSuccess(c, 20000, res)
+}
+
+// 本地生活提交审核
+func (t TaskController) LocalLifeToReview(c *gin.Context) {
+	data := &vo.LocalUpdateParam{}
+	err := c.BindJSON(data)
+	if err != nil || data.LocalID == "" {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	localId, err := service.LocalLifeService{}.LocalLifeToReview(data)
+	if err != nil {
+		logrus.Errorf("[ProjectToReview] call ProjectToReview err:%+v\n", err)
+		returnError(c, 40000, "error")
+		return
+	}
+	resultMap := make(map[string]string)
+	resultMap["localId"] = *localId
+	returnSuccess(c, 20000, resultMap)
+}

+ 75 - 0
app/dao/local_life_dao.go

@@ -0,0 +1,75 @@
+package dao
+
+import (
+	"errors"
+	"gorm.io/gorm"
+	"time"
+	"youngee_b_api/app/entity"
+)
+
+type LocalLifeDao struct{}
+
+// 根据localId获取localLife信息
+func (d LocalLifeDao) GetLocalById(localId string) (*entity.LocalLifeInfo, error) {
+	var localLife entity.LocalLifeInfo
+	err := Db.Model(&entity.LocalLifeInfo{}).Where("local_id = ?", localId).First(&localLife).Error
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	return &localLife, err
+}
+
+// 根据localId获取违约状态id
+func (d LocalLifeDao) GetAutoDefaultId(localId string) (*int64, error) {
+	var autoDefaultId int64
+	err := Db.Model(&entity.LocalLifeInfo{}).Where("local_id = ?", localId).Select("auto_default_id").Find(&autoDefaultId).Error
+	if err != nil {
+		return nil, nil
+	}
+	return &autoDefaultId, nil
+}
+
+// 根据enterpriseId查询指定某天的所有本地生活数据
+func (d LocalLifeDao) GetLocalListOfDay(enterpriseId string, date time.Time) ([]entity.LocalLifeInfo, error) {
+	var localLifes []entity.LocalLifeInfo
+	// 构建查询
+	query := Db.Model(&entity.LocalLifeInfo{})
+	if enterpriseId != "" {
+		query = query.Where("enterprise_id = ?", enterpriseId)
+	}
+	// 将日期部分提取出来进行匹配
+	query = query.Where("DATE(created_at) = ?", date.Format("2006-01-02"))
+	err := query.Find(&localLifes).Error
+	return localLifes, err
+}
+
+// 创建本地生活任务
+func (d LocalLifeDao) CreateLocalLife(localLife entity.LocalLifeInfo) error {
+	err := Db.Omit("recruit_ddl", "auto_fail_at", "pay_at", "submit_at", "pass_at", "finish_at").Create(&localLife).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+// 更新本地生活任务
+func (d LocalLifeDao) UpdateLocal(localLife entity.LocalLifeInfo) error {
+	err := Db.Model(&entity.LocalLifeInfo{}).Where("local_id = ?", localLife.LocalID).Updates(localLife).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+// 更新开票状态字段
+func (d LocalLifeDao) UpdateInvoiceStatus(localIDs []string) error {
+	err := Db.Debug().Model(&entity.LocalLifeInfo{}).Where("local_id IN ?", localIDs).Updates(entity.LocalLifeInfo{InvoiceStatus: 1}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 23 - 5
app/dao/product_dao.go

@@ -12,11 +12,29 @@ type ProductDAO struct{}
 func (d ProductDAO) GetProductsByEnterpriseID(enterpriseId string, page int, pageSize int) ([]entity.Product, int64, error) {
 	var products []entity.Product
 	var total int64
-	Db.Model(&entity.Product{}).Where("enterprise_id = ?", enterpriseId).Count(&total)
+	Db.Model(&entity.Product{}).Where("enterprise_id = ? AND is_deleted = 0", enterpriseId).Count(&total)
 	// 计算偏移量
 	offset := (page - 1) * pageSize
 	// 分页查询
-	err := Db.Where("enterprise_id = ?", enterpriseId).Order("created_at desc").Offset(offset).Limit(pageSize).Find(&products).Error
+	err := Db.Where("enterprise_id = ? AND is_deleted = 0", enterpriseId).Order("created_at desc").Offset(offset).Limit(pageSize).Find(&products).Error
+	if err != nil {
+		return nil, 0, err
+	}
+	return products, total, nil
+}
+
+func (d ProductDAO) GetProductsByEnterpriseIDAndTypeTitle(enterpriseId string, productType int64, productTitle string, page int, pageSize int) ([]entity.Product, int64, error) {
+	var products []entity.Product
+	var total int64
+	query := Db.Model(&entity.Product{}).Where("enterprise_id = ? AND product_type = ? AND is_deleted = 0", enterpriseId, productType)
+	if productTitle != "" {
+		query = query.Where("product_name LIKE ?", "%"+productTitle+"%")
+	}
+	query.Count(&total)
+	// 计算偏移量
+	offset := (page - 1) * pageSize
+	// 分页查询
+	err := query.Order("created_at desc").Offset(offset).Limit(pageSize).Find(&products).Error
 	if err != nil {
 		return nil, 0, err
 	}
@@ -26,11 +44,11 @@ func (d ProductDAO) GetProductsByEnterpriseID(enterpriseId string, page int, pag
 func (d ProductDAO) GetProductsBySubAccountId(subAccountId int64, page int, pageSize int) ([]entity.Product, int64, error) {
 	var products []entity.Product
 	var total int64
-	Db.Model(&entity.Product{}).Where("sub_account_id = ?", subAccountId).Count(&total)
+	Db.Model(&entity.Product{}).Where("sub_account_id = ? AND is_deleted = 0", subAccountId).Count(&total)
 	// 计算偏移量
 	offset := (page - 1) * pageSize
 	// 分页查询
-	err := Db.Where("sub_account_id = ?", subAccountId).Order("created_at desc").Offset(offset).Limit(pageSize).Find(&products).Error
+	err := Db.Where("sub_account_id = ? AND is_deleted = 0", subAccountId).Order("created_at desc").Offset(offset).Limit(pageSize).Find(&products).Error
 	if err != nil {
 		return nil, 0, err
 	}
@@ -47,7 +65,7 @@ func (d ProductDAO) CreateProduct(product entity.Product) (int64, error) {
 
 func (d ProductDAO) GetProductByID(productId int64) (*entity.Product, error) {
 	var product entity.Product
-	err := Db.Where("product_id = ?", productId).First(&product).Error
+	err := Db.Debug().Where("product_id = ?", productId).First(&product).Error
 	if err != nil {
 		if errors.Is(err, gorm.ErrRecordNotFound) {
 			return nil, nil

+ 48 - 6
app/dao/product_photo_dao.go

@@ -7,6 +7,25 @@ import (
 
 type ProductPhotoDAO struct{}
 
+func (d ProductPhotoDAO) CreateProductPhoto(productPhotos []entity.ProductPhoto) error {
+	err := Db.Create(&productPhotos).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+// 获取所属商品的图片
+func (d ProductPhotoDAO) GetProductPhotoByProductID(productId int64) ([]entity.ProductPhoto, error) {
+	var productPhotos []entity.ProductPhoto
+	err := Db.Where("product_id = ?", productId).Find(&productPhotos).Error
+	if err != nil {
+		return nil, err
+	}
+	return productPhotos, nil
+}
+
+// 获取所属商品的主图
 func (d ProductPhotoDAO) GetMainPhotoByProductID(productId int64) (string, error) {
 	var productPhoto entity.ProductPhoto
 	err := Db.Where("product_id = ? AND symbol = ?", productId, 1).First(&productPhoto).Error
@@ -16,23 +35,46 @@ func (d ProductPhotoDAO) GetMainPhotoByProductID(productId int64) (string, error
 	return productPhoto.PhotoUrl, nil
 }
 
-func (d ProductPhotoDAO) CreateProductPhoto(productPhotos []entity.ProductPhoto) error {
-	err := Db.Create(&productPhotos).Error
+// 获取所属门店的图片
+func (d ProductPhotoDAO) GetProductPhotoByStoreID(storeId int64) ([]entity.ProductPhoto, error) {
+	var productPhotos []entity.ProductPhoto
+	err := Db.Where("store_id = ?", storeId).Find(&productPhotos).Error
 	if err != nil {
-		return err
+		return nil, err
 	}
-	return nil
+	return productPhotos, nil
+}
+
+// 获取所属门店的主图
+func (d ProductPhotoDAO) GetMainPhotoByStoreID(storeId int64) (string, error) {
+	var productPhoto entity.ProductPhoto
+	err := Db.Where("store_id = ? AND symbol = ?", storeId, 1).First(&productPhoto).Error
+	if err != nil {
+		return "", err
+	}
+	return productPhoto.PhotoUrl, nil
 }
 
-func (d ProductPhotoDAO) GetProductPhotoByProductID(productID int64) ([]entity.ProductPhoto, error) {
+// 获取所属团购的图片
+func (d ProductPhotoDAO) GetProductPhotoByTeamBuyingID(teamBuyingId int64) ([]entity.ProductPhoto, error) {
 	var productPhotos []entity.ProductPhoto
-	err := Db.Where("product_id = ?", productID).Find(&productPhotos).Error
+	err := Db.Where("team_buying_id = ?", teamBuyingId).Find(&productPhotos).Error
 	if err != nil {
 		return nil, err
 	}
 	return productPhotos, nil
 }
 
+// 获取所属团购的主图
+func (d ProductPhotoDAO) GetMainPhotoByTeamBuyingID(teamBuyingId int64) (string, error) {
+	var productPhoto entity.ProductPhoto
+	err := Db.Where("team_buying_id = ? AND symbol = ?", teamBuyingId, 1).First(&productPhoto).Error
+	if err != nil {
+		return "", err
+	}
+	return productPhoto.PhotoUrl, nil
+}
+
 func (d ProductPhotoDAO) GetProductPhotosBySelectionId(selectionId string) ([]*entity.ProductPhoto, error) {
 	productId := 0
 	err := Db.Model(entity.SelectionInfo{}).Select("product_id").Where("selection_id = ?", selectionId).Find(&productId).Error

+ 6 - 6
app/dao/project_dao.go

@@ -13,8 +13,8 @@ type ProjectDAO struct{}
 
 // 根据projectId获取project信息
 func (d ProjectDAO) GetProjectById(projectId string) (*entity.Project, error) {
-	var Project entity.Project
-	err := Db.Where("project_id = ?", projectId).First(&Project).Error
+	var project entity.Project
+	err := Db.Where("project_id = ?", projectId).First(&project).Error
 	if err != nil {
 		if errors.Is(err, gorm.ErrRecordNotFound) {
 			return nil, nil
@@ -22,7 +22,7 @@ func (d ProjectDAO) GetProjectById(projectId string) (*entity.Project, error) {
 			return nil, err
 		}
 	}
-	return &Project, err
+	return &project, err
 }
 
 // 根据projectId获取违约状态id
@@ -37,7 +37,7 @@ func (d ProjectDAO) GetAutoDefaultId(projectId string) (*int64, error) {
 
 // 根据enterpriseId查询指定某天的所有带货数据
 func (d ProjectDAO) GetProjectListOfDay(enterpriseId string, date time.Time) ([]entity.Project, error) {
-	var Projects []entity.Project
+	var projects []entity.Project
 	// 构建查询
 	query := Db.Model(&entity.Project{})
 	if enterpriseId != "" {
@@ -45,8 +45,8 @@ func (d ProjectDAO) GetProjectListOfDay(enterpriseId string, date time.Time) ([]
 	}
 	// 将日期部分提取出来进行匹配
 	query = query.Where("DATE(created_at) = ?", date.Format("2006-01-02"))
-	err := query.Find(&Projects).Error
-	return Projects, err
+	err := query.Find(&projects).Error
+	return projects, err
 }
 
 // 创建种草任务

+ 63 - 0
app/dao/store_dao.go

@@ -0,0 +1,63 @@
+package dao
+
+import (
+	"errors"
+	"gorm.io/gorm"
+	"youngee_b_api/app/entity"
+)
+
+type StoreDao struct{}
+
+func (d StoreDao) CreateStore(store entity.Store) (int64, error) {
+	err := Db.Model(&entity.Store{}).Create(&store).Error
+	if err != nil {
+		return 0, err
+	}
+	return store.StoreID, nil
+}
+
+func (d StoreDao) GetStoreByID(storeId int64) (*entity.Store, error) {
+	var store entity.Store
+	err := Db.Debug().Where("store_id = ?", storeId).First(&store).Error
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	return &store, nil
+}
+
+func (d StoreDao) GetStoresByEnterpriseID(enterpriseId string, page int, pageSize int) ([]entity.Store, int64, error) {
+	var stores []entity.Store
+	var total int64
+	query := Db.Model(&entity.Store{}).Where("enterprise_id = ? AND is_deleted = ?", enterpriseId, 0)
+	query.Count(&total)
+	// 计算偏移量
+	offset := (page - 1) * pageSize
+	// 分页查询
+	err := query.Order("created_at desc").Offset(offset).Limit(pageSize).Find(&stores).Error
+	if err != nil {
+		return nil, 0, err
+	}
+	return stores, total, nil
+}
+
+func (d StoreDao) GetStoresByEnterpriseIDAndStoreName(enterpriseId string, storeName string, page int, pageSize int) ([]entity.Store, int64, error) {
+	var stores []entity.Store
+	var total int64
+	query := Db.Model(&entity.Store{}).Where("enterprise_id = ? AND is_deleted = ?", enterpriseId, 0)
+	if storeName != "" {
+		query = query.Where("store_name LIKE ?", "%"+storeName+"%")
+	}
+	query.Count(&total)
+	// 计算偏移量
+	offset := (page - 1) * pageSize
+	// 分页查询
+	err := query.Order("created_at desc").Offset(offset).Limit(pageSize).Find(&stores).Error
+	if err != nil {
+		return nil, 0, err
+	}
+	return stores, total, nil
+}

+ 63 - 0
app/dao/team_buying_dao.go

@@ -0,0 +1,63 @@
+package dao
+
+import (
+	"errors"
+	"gorm.io/gorm"
+	"youngee_b_api/app/entity"
+)
+
+type TeamBuyingDao struct{}
+
+func (d TeamBuyingDao) CreateTeamBuying(teamBuying entity.TeamBuying) (int64, error) {
+	err := Db.Model(&entity.TeamBuying{}).Create(&teamBuying).Error
+	if err != nil {
+		return 0, err
+	}
+	return teamBuying.TeamBuyingID, nil
+}
+
+func (d TeamBuyingDao) GetTeamBuyingByID(teamBuyingId int64) (*entity.TeamBuying, error) {
+	var teamBuying entity.TeamBuying
+	err := Db.Debug().Where("team_buying_id = ?", teamBuyingId).First(&teamBuying).Error
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	return &teamBuying, nil
+}
+
+func (d TeamBuyingDao) GetTeamBuyingsByStoreId(storeId int64, page int, pageSize int) ([]entity.TeamBuying, int64, error) {
+	var teamBuyings []entity.TeamBuying
+	var total int64
+	query := Db.Model(&entity.TeamBuying{}).Where("store_id = ? AND is_deleted = ?", storeId, 0)
+	query.Count(&total)
+	// 计算偏移量
+	offset := (page - 1) * pageSize
+	// 分页查询
+	err := Db.Model(&entity.TeamBuying{}).Where("store_id = ? AND is_deleted = ?", storeId, 0).Order("created_at desc").Offset(offset).Limit(pageSize).Find(&teamBuyings).Error
+	if err != nil {
+		return nil, 0, err
+	}
+	return teamBuyings, total, nil
+}
+
+func (d TeamBuyingDao) GetTeamBuyingsByStoreIdAndTeamBuyingTitle(storeId int64, teamBuyingTitle string, page int, pageSize int) ([]entity.TeamBuying, int64, error) {
+	var teamBuyings []entity.TeamBuying
+	var total int64
+	query := Db.Model(&entity.TeamBuying{}).Where("store_id = ? AND is_deleted = ?", storeId, 0)
+	if teamBuyingTitle != "" {
+		query = query.Where("team_buying_name LIKE ?", "%"+teamBuyingTitle+"%")
+	}
+	query.Count(&total)
+	// 计算偏移量
+	offset := (page - 1) * pageSize
+	// 分页查询
+	err := Db.Model(&entity.TeamBuying{}).Where("store_id = ? AND is_deleted = ?", storeId, 0).Order("created_at desc").Offset(offset).Limit(pageSize).Find(&teamBuyings).Error
+	if err != nil {
+		return nil, 0, err
+	}
+	return teamBuyings, total, nil
+}

+ 51 - 0
app/entity/local_life_info.go

@@ -0,0 +1,51 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package entity
+
+import (
+	"time"
+)
+
+type LocalLifeInfo struct {
+	ID                  int64     `gorm:"column:id;primary_key;AUTO_INCREMENT"`             // 本地生活表主键ID
+	LocalID             string    `gorm:"column:local_id;NOT NULL"`                         // 项目id
+	LocalType           int64     `gorm:"column:local_type"`                                // 项目类型,1代表全流程项目,2代表专项项目
+	LocalPlatform       int64     `gorm:"column:local_platform"`                            // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	ServiceChargeRate   float64   `gorm:"column:service_charge_rate;default:0.00;NOT NULL"` // 公开服务费率
+	StoreID             int64     `gorm:"column:store_id"`                                  // 关联门店id
+	StoreRelatedAt      time.Time `gorm:"column:store_related_at"`                          // 关联门店时间
+	TeamBuyingId        int64     `gorm:"column:team_buying_id"`                            // 关联团购id
+	TeamBuyingRelatedAt time.Time `gorm:"column:team_buying_related_at"`                    // 关联团购时间
+	PromoteBody         int64     `gorm:"column:promote_body"`                              // 推广主体(1门店 2团购)
+	Donate              int64     `gorm:"column:donate"`                                    // 赠送达人套餐(1有赠送 2无赠送)
+	LocalName           string    `gorm:"column:local_name"`                                // 任务标题
+	TalentType          string    `gorm:"column:talent_type"`                               // 达人类型(,分隔)
+	RecruitDdl          time.Time `gorm:"column:recruit_ddl"`                               // 招募截止时间
+	TaskForm            int64     `gorm:"column:task_form"`                                 // 任务形式,1-3分别代表商品寄拍、素材分发、虚拟产品测评
+	ContentType         int64     `gorm:"column:content_type"`                              // 内容形式,1代表图文,2代表视频
+	TaskDetail          string    `gorm:"column:task_detail"`                               // 任务详情
+	TaskStatus          int64     `gorm:"column:task_status"`                               // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、执行中、失效、已结案
+	EnterpriseID        string    `gorm:"column:enterprise_id"`                             // 所属企业id
+	SubAccountID        int64     `gorm:"column:sub_account_id;default:0;NOT NULL"`         // 子账号id
+	OperatorType        int64     `gorm:"column:operator_type;default:NULL"`                // 创建者类型,1商家主账号,2商家子账号
+	ApplyNum            int64     `gorm:"column:apply_num;default:0;NOT NULL"`              // 报名人数
+	RecruitNum          int64     `gorm:"column:recruit_num;default:0;NOT NULL"`            // 已招募人数
+	CreatedAt           time.Time `gorm:"column:created_at"`                                // 创建时间
+	UpdatedAt           time.Time `gorm:"column:updated_at"`                                // 修改时间
+	AutoFailAt          time.Time `gorm:"column:auto_fail_at"`                              // 失效自动处理时间
+	AutoTaskID          int64     `gorm:"column:auto_task_id;default:0;NOT NULL"`           // 定时任务id
+	AutoDefaultID       int64     `gorm:"column:auto_default_id;default:0;NOT NULL"`        // 违约状态id
+	PaymentAmount       float64   `gorm:"column:payment_amount"`                            // 支付金额
+	PayAt               time.Time `gorm:"column:pay_at"`                                    // 支付时间
+	SubmitAt            time.Time `gorm:"column:submit_at"`                                 // 提交审核时间
+	PassAt              time.Time `gorm:"column:pass_at"`                                   // 审核通过时间
+	FinishAt            time.Time `gorm:"column:finish_at"`                                 // 结案时间
+	EstimatedCost       float64   `gorm:"column:estimated_cost"`                            // 预估成本
+	SettlementAmount    float64   `gorm:"column:settlement_amount"`                         // 结算金额
+	TotalRecruitNum     int64     `gorm:"column:total_recruit_num"`                         // 此任务各策略招募人数总和
+	Tools               string    `gorm:"column:tools"`                                     // 工具选择,1邀约招募 2结算账单 3样品物流 4审稿工具 5作品审查 6数据巡检(,分隔)
+	InvoiceStatus       int64     `gorm:"column:invoice_status;default:0;NOT NULL"`         // 开票状态(1开票中 2已开票)
+}
+
+func (m *LocalLifeInfo) TableName() string {
+	return "younggee_local_life_info"
+}

+ 14 - 7
app/entity/product_photo.go

@@ -1,14 +1,21 @@
+// Code generated by sql2gorm. DO NOT EDIT.
 package entity
 
-import "time"
+import (
+	"time"
+)
 
+// 商品、门店、团购相关图片或视频
 type ProductPhoto struct {
-	ProductPhotoID int64     `gorm:"column:product_photo_id;primary_key;AUTO_INCREMENT"` // 商品图片id
-	PhotoUrl       string    `gorm:"column:photo_url"`                                   // 图片或视频url
-	PhotoUid       string    `gorm:"column:photo_uid"`
-	Symbol         int64     `gorm:"column:symbol"`     // 图片为主图或详情图标志位,1为主图,2为详情图,3为视频
-	ProductID      int64     `gorm:"column:product_id"` // 所属商品id
-	CreatedAt      time.Time `gorm:"column:created_at"` // 创建时间
+	ProductPhotoID   int64     `gorm:"column:product_photo_id;primary_key;AUTO_INCREMENT"` // 商品图片id
+	ProductID        int64     `gorm:"column:product_id"`                                  // 所属商品id
+	Symbol           int64     `gorm:"column:symbol"`                                      // 标志位 1为主图,2为轮播图,3为轮播图视频,4详情图,5详情图视频
+	PhotoUrl         string    `gorm:"column:photo_url"`                                   // 图片或视频url
+	PhotoUid         string    `gorm:"column:photo_uid"`
+	CreatedAt        time.Time `gorm:"column:created_at"`                   // 创建时间
+	ProductPhotoType int64     `gorm:"column:product_photo_type;default:1"` // 商品图片类型:1商品,2门店,3团购
+	StoreID          int64     `gorm:"column:store_id"`                     // 门店ID
+	TeamBuyingID     int64     `gorm:"column:team_buying_id"`               // 团购ID
 }
 
 func (m *ProductPhoto) TableName() string {

+ 27 - 0
app/entity/store.go

@@ -0,0 +1,27 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package entity
+
+import (
+	"time"
+)
+
+type Store struct {
+	StoreID            int64     `gorm:"column:store_id;primary_key;AUTO_INCREMENT"` // 门店ID
+	StoreName          string    `gorm:"column:store_name;NOT NULL"`                 // 门店名称
+	StoreCategory      string    `gorm:"column:store_category;NOT NULL"`             // 门店类目(/分隔)
+	StoreType          int64     `gorm:"column:store_type;NOT NULL"`                 // 门店类型,1单门店,2连锁门店
+	StoreLocation      string    `gorm:"column:store_location;NOT NULL"`             // 门店地址
+	StoreDetail        string    `gorm:"column:store_detail"`                        // 门店特点
+	StoreLink          string    `gorm:"column:store_link"`                          // 分销链接
+	TeamNum            int64     `gorm:"column:team_num;NOT NULL"`                   // 包含团购套餐数
+	BelongEnterpriseID string    `gorm:"column:belong_enterprise_id"`                // 门店所属商家ID
+	CreatedAt          time.Time `gorm:"column:created_at;NOT NULL"`                 // 创建时间
+	IsDeleted          int64     `gorm:"column:is_deleted;default:0;NOT NULL"`       // 已删除(0否 1是)
+	OperateType        int64     `gorm:"column:operate_type;NOT NULL"`               // 操作人类型(1商家 2后台)
+	EnterpriseID       string    `gorm:"column:enterprise_id;NOT NULL"`              // 商家id
+	SubAccountID       int64     `gorm:"column:sub_account_id;default:0;NOT NULL"`   // 商家子账号id
+}
+
+func (m *Store) TableName() string {
+	return "younggee_store"
+}

+ 13 - 0
app/entity/store_category.go

@@ -0,0 +1,13 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package entity
+
+// 门店类目表
+type YounggeeStoreCategory struct {
+	ID       int    `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
+	Category string `gorm:"column:category;NOT NULL"`             // 一级类目
+	Detail   string `gorm:"column:detail;NOT NULL"`               // 二级类目
+}
+
+func (m *YounggeeStoreCategory) TableName() string {
+	return "younggee_store_category"
+}

+ 24 - 0
app/entity/team_buying.go

@@ -0,0 +1,24 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package entity
+
+import "time"
+
+type TeamBuying struct {
+	TeamBuyingID       int64     `gorm:"column:team_buying_id;primary_key;AUTO_INCREMENT"` // 团购id
+	StoreID            int64     `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    float64   `gorm:"column:team_buying_price;NOT NULL"`                // 团购售价
+	PublicCommission   int64     `gorm:"column:public_commission"`                         // 公开佣金%
+	TeamBuyingDetail   string    `gorm:"column:team_buying_detail;NOT NULL"`               // 团购详情
+	TeamBuyingLink     string    `gorm:"column:team_buying_link"`                          // 分销链接
+	CreatedAt          time.Time `gorm:"column:created_at;NOT NULL"`                       // 创建时间
+	IsDeleted          int64     `gorm:"column:is_deleted;default:0;NOT NULL"`             // 删除(0否 1是)
+	OperateType        int64     `gorm:"column:operate_type;NOT NULL"`                     // 操作人类型(1商家 2后台)
+	EnterpriseID       string    `gorm:"column:enterprise_id;NOT NULL"`                    // 商家id
+	SubAccountID       int64     `gorm:"column:sub_account_id;default:0;NOT NULL"`         // 商家子账号id
+}
+
+func (m *TeamBuying) TableName() string {
+	return "younggee_team_buying"
+}

+ 507 - 0
app/service/local_life_service.go

@@ -0,0 +1,507 @@
+package service
+
+import (
+	"errors"
+	"github.com/sirupsen/logrus"
+	"reflect"
+	"time"
+	"youngee_b_api/app/dao"
+	"youngee_b_api/app/entity"
+	"youngee_b_api/app/util"
+	"youngee_b_api/app/vo"
+)
+
+type LocalLifeService struct{}
+
+// 创建本地生活任务
+func (s LocalLifeService) CreateLocalLife(param *vo.LocalCreateParam) (*string, error) {
+	// a) 生成本地生活项目id
+	localId := string(util.GenerateUUID(10))
+	// b) 查找关联门店信息
+	product, err := dao.StoreDao{}.GetStoreByID(param.StoreId)
+	if err != nil {
+		return nil, err
+	}
+	if product == nil {
+		return nil, errors.New("未找到关联门店")
+	}
+	// c)创建种草任务
+	var operatorType int64
+	if param.SubAccountId == 0 {
+		operatorType = 1
+	} else {
+		operatorType = 2
+	}
+	// 获取定时任务配置id
+	infoAutoTask := entity.InfoAutoTask{}
+	infoAutoTask = dao.InfoAutoTaskDao{}.GetAutoTaskLast(param.EnterpriseId)
+	infoAutoDefault := entity.InfoAutoDefault{}
+	infoAutoDefault = dao.InfoAutoDefaultDao{}.GetAutoDefaultLast(param.EnterpriseId)
+	t := time.Now()
+	newLocalLife := entity.LocalLifeInfo{
+		EnterpriseID:        param.EnterpriseId,
+		SubAccountID:        param.SubAccountId,
+		OperatorType:        operatorType,
+		TaskStatus:          1,
+		LocalID:             localId,
+		LocalType:           param.LocalType,
+		LocalPlatform:       param.Platform,
+		StoreID:             param.StoreId,
+		StoreRelatedAt:      time.Now(),
+		PromoteBody:         param.PromoteBody,
+		Donate:              param.Donate,
+		TeamBuyingId:        param.TeamBuyingId,
+		TeamBuyingRelatedAt: time.Now(),
+		CreatedAt:           t,
+		AutoTaskID:          infoAutoTask.AutoTaskID,
+		AutoDefaultID:       infoAutoDefault.AutoDefaultID,
+	}
+	if param.LocalType == 1 {
+		newLocalLife.ServiceChargeRate = param.ServiceChargeRate
+	}
+	err = dao.LocalLifeDao{}.CreateLocalLife(newLocalLife)
+	if err != nil {
+		return nil, err
+	}
+
+	return &localId, nil
+}
+
+// 更新公开本地生活任务(招募要求、执行要求)
+func (s LocalLifeService) UpdateLocal(localUpdateParam *vo.LocalUpdateParam) (*string, error) {
+	// 1. 检查该项目id有无本地任务
+	localID := localUpdateParam.LocalID
+	localLife, err := dao.LocalLifeDao{}.GetLocalById(localID)
+	if err != nil {
+		return nil, err
+	}
+	if localLife == nil {
+		return nil, errors.New("本地生活项目不存在")
+	}
+	println("更新公开本地生活任务的招募策略")
+	// 更新公开种草任务的招募策略
+	var totalRecruitNum int64
+	if localUpdateParam.RecruitStrategys != nil {
+		// 1. 删除已有的招募策略
+		err = dao.RecruitStrategyDao{}.DeleteRecruitStrategyByProjectID(localUpdateParam.LocalID)
+		if err != nil {
+			return nil, err
+		}
+		// 2. 接收并创建新的招募策略
+		if len(localUpdateParam.RecruitStrategys) != 0 {
+			var recruits []entity.RecruitStrategy
+			for _, strategy := range localUpdateParam.RecruitStrategys {
+				recruitStrategy := entity.RecruitStrategy{
+					FeeForm:       strategy.FeeForm,
+					StrategyID:    strategy.StrategyID,
+					FollowersLow:  strategy.FollowersLow,
+					FollowersUp:   strategy.FollowersUp,
+					RecruitNumber: strategy.RecruitNumber,
+					ProjectID:     localLife.LocalID,
+					StrategyType:  1,
+					ServiceRate:   localLife.ServiceChargeRate,
+				}
+				totalRecruitNum += strategy.RecruitNumber
+				if strategy.FeeForm == 2 {
+					recruitStrategy.Offer = strategy.Offer
+					recruitStrategy.ServiceCharge = strategy.Offer * localUpdateParam.ServiceChargeRate
+					recruitStrategy.TOffer = strategy.Offer * (1 - localUpdateParam.ServiceChargeRate)
+				}
+				recruits = append(recruits, recruitStrategy)
+			}
+			err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+	// 2. 数据准备
+	//// a) 查找关联商品信息
+	//product, err := dao.ProductDAO{}.GetProductByID(project.ProductID)
+	//if err != nil {
+	//	return nil, err
+	//}
+	//productPhotos, err := dao.ProductPhotoDAO{}.GetProductPhotoByProductID(project.ProductID)
+	//productInfoToJson, _ := json.Marshal(product)
+	//productPhotosToJson, _ := json.Marshal(productPhotos)
+	// d) 任务截止时间
+	recruitDdl := time.Time{} //赋零值
+	recruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", localUpdateParam.RecruitDdl, time.Local)
+	// f) 更新选品状态
+	if localUpdateParam.LocalStatus != 2 && localUpdateParam.LocalStatus != 8 {
+		localUpdateParam.LocalStatus = 1
+	}
+	t := time.Now()
+	updateLocalLife := entity.LocalLifeInfo{
+		StoreID:           localUpdateParam.StoreId,
+		TeamBuyingId:      localUpdateParam.TeamBuyingId,
+		ServiceChargeRate: localUpdateParam.ServiceChargeRate,
+		PromoteBody:       localUpdateParam.PromoteBody,
+		Donate:            localUpdateParam.Donate,
+		TaskStatus:        localUpdateParam.LocalStatus,
+		LocalName:         localUpdateParam.LocalName,
+		TalentType:        localUpdateParam.TalentType,
+		RecruitDdl:        recruitDdl,
+		TaskForm:          localUpdateParam.TaskForm,
+		ContentType:       localUpdateParam.ContentType,
+		TaskDetail:        localUpdateParam.TaskDetail,
+		UpdatedAt:         t,
+	}
+	if localUpdateParam.LocalStatus == 2 {
+		updateLocalLife.SubmitAt = t
+	}
+	// 合并传入参数和数据表中原记录,若传入参数字段值为空,则将字段赋值为原记录中值
+	result := util.MergeStructValue(&updateLocalLife, localLife)
+	// 利用反射机制将interface类型转换为结构体类型
+	v := reflect.ValueOf(&result).Elem()
+	if v.Kind() == reflect.Struct {
+		updateLocalLife = v.Interface().(entity.LocalLifeInfo)
+		//fmt.Println(p)
+	}
+	// c) 计算预估成本(如果有)
+	/*
+		var estimatedCost float64
+		if conv.MustInt(updateSelection.TaskMode, 0) == 1 {
+			estimatedCost = conv.MustFloat64(updateSelection.TaskReward, 0) * conv.MustFloat64(updateSelection.SampleNum, 0)
+		}
+		estimatedCostToString, _ := conv.String(estimatedCost)
+		updateSelection.EstimatedCost = estimatedCostToString
+	*/
+	// 3. 更新选品
+	err = dao.LocalLifeDao{}.UpdateLocal(updateLocalLife)
+	if err != nil {
+		return nil, err
+	}
+	// 4. 更新选品brief和示例(本地生活任务补充信息)
+	if localUpdateParam.LocalBrief != nil {
+		// 删除已有brief
+		err = dao.ProjectBriefDao{}.DeleteSecBriefBySelectionId(localLife.LocalID)
+		if err != nil {
+			return nil, err
+		}
+		// 插入新的brief
+		for _, v := range localUpdateParam.LocalBrief {
+			brief := entity.ProjectBrief{
+				ProjectID: localLife.LocalID,
+				FileUid:   v.FileUid,
+				FileName:  v.Name,
+				FileUrl:   v.FileUrl,
+				CreatedAt: time.Now(),
+			}
+			err = dao.ProjectBriefDao{}.CreateProjectBrief(brief)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+
+	if localUpdateParam.LocalMaterial != nil {
+		// 删除已有示例
+		err = dao.ProjectMaterialDao{}.DeleteProjectMaterialByProjectId(localLife.LocalID)
+		if err != nil {
+			return nil, err
+		}
+		// 插入新的示例
+		for _, v := range localUpdateParam.LocalMaterial {
+			projectMaterial := entity.ProjectMaterial{
+				ProjectID: localLife.LocalID,
+				FileUid:   v.FileUid,
+				FileName:  v.Name,
+				FileUrl:   v.FileUrl,
+				CreatedAt: time.Now(),
+			}
+			err = dao.ProjectMaterialDao{}.CreateProjectMaterial(projectMaterial)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+
+	return &updateLocalLife.LocalID, nil
+}
+
+// 更新定向本地生活任务(招募要求、执行要求)
+func (s LocalLifeService) UpdateLocalTarget(localUpdateParam *vo.LocalUpdateParam) (*string, error) {
+	// 1. 检查该项目id有无本地任务
+	localID := localUpdateParam.LocalID
+	localLife, err := dao.LocalLifeDao{}.GetLocalById(localID)
+	if err != nil {
+		return nil, err
+	}
+	if localLife == nil {
+		return nil, errors.New("本地生活项目不存在")
+	}
+	println("更新定向本地生活任务的招募策略")
+	// 更新公开种草任务的招募策略
+	var totalRecruitNum int64
+	if localUpdateParam.RecruitStrategys != nil {
+		// 1. 删除已有的招募策略
+		err = dao.RecruitStrategyDao{}.DeleteRecruitStrategyByProjectID(localUpdateParam.LocalID)
+		if err != nil {
+			return nil, err
+		}
+		// 2. 接收并创建新的招募策略
+		if len(localUpdateParam.RecruitStrategys) != 0 {
+			var recruits []entity.RecruitStrategy
+			for _, strategy := range localUpdateParam.RecruitStrategys {
+				recruitStrategy := entity.RecruitStrategy{
+					FeeForm:       strategy.FeeForm,
+					StrategyID:    strategy.StrategyID,
+					FollowersLow:  strategy.FollowersLow,
+					FollowersUp:   strategy.FollowersUp,
+					RecruitNumber: strategy.RecruitNumber,
+					ProjectID:     localLife.LocalID,
+					StrategyType:  1,
+					ServiceRate:   localLife.ServiceChargeRate,
+				}
+				totalRecruitNum += strategy.RecruitNumber
+				if strategy.FeeForm == 2 {
+					recruitStrategy.Offer = strategy.Offer // 报价
+				}
+				recruits = append(recruits, recruitStrategy)
+			}
+			err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+	// 2. 数据准备
+	// a) 查找关联商品信息
+	//product, err := dao.ProductDAO{}.GetProductByID(project.ProductID)
+	//if err != nil {
+	//	return nil, err
+	//}
+	//productPhotos, err := dao.ProductPhotoDAO{}.GetProductPhotoByProductID(project.ProductID)
+	//productInfoToJson, _ := json.Marshal(product)
+	//productPhotosToJson, _ := json.Marshal(productPhotos)
+	// d) 任务截止时间
+	recruitDdl := time.Time{} //赋零值
+	recruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", localUpdateParam.RecruitDdl, time.Local)
+	// f) 更新选品状态
+	if localUpdateParam.LocalStatus != 2 && localUpdateParam.LocalStatus != 8 {
+		localUpdateParam.LocalStatus = 1
+	}
+	t := time.Now()
+	updateLocalLife := entity.LocalLifeInfo{
+		StoreID:           localUpdateParam.StoreId,
+		TeamBuyingId:      localUpdateParam.TeamBuyingId,
+		ServiceChargeRate: localUpdateParam.ServiceChargeRate,
+		PromoteBody:       localUpdateParam.PromoteBody,
+		Donate:            localUpdateParam.Donate,
+		TaskStatus:        localUpdateParam.LocalStatus,
+		LocalName:         localUpdateParam.LocalName,
+		TalentType:        localUpdateParam.TalentType,
+		RecruitDdl:        recruitDdl,
+		TaskForm:          localUpdateParam.TaskForm,
+		ContentType:       localUpdateParam.ContentType,
+		TaskDetail:        localUpdateParam.TaskDetail,
+		UpdatedAt:         t,
+		Tools:             localUpdateParam.Tools,
+	}
+	if localUpdateParam.LocalStatus == 2 {
+		updateLocalLife.SubmitAt = t
+	}
+	// 合并传入参数和数据表中原记录,若传入参数字段值为空,则将字段赋值为原记录中值
+	result := util.MergeStructValue(&updateLocalLife, localLife)
+	// 利用反射机制将interface类型转换为结构体类型
+	v := reflect.ValueOf(&result).Elem()
+	if v.Kind() == reflect.Struct {
+		updateLocalLife = v.Interface().(entity.LocalLifeInfo)
+		//fmt.Println(p)
+	}
+	// c) 计算预估成本(如果有)
+	/*
+		var estimatedCost float64
+		if conv.MustInt(updateSelection.TaskMode, 0) == 1 {
+			estimatedCost = conv.MustFloat64(updateSelection.TaskReward, 0) * conv.MustFloat64(updateSelection.SampleNum, 0)
+		}
+		estimatedCostToString, _ := conv.String(estimatedCost)
+		updateSelection.EstimatedCost = estimatedCostToString
+	*/
+	// 3. 更新选品
+	err = dao.LocalLifeDao{}.UpdateLocal(updateLocalLife)
+	if err != nil {
+		return nil, err
+	}
+	// 4. 更新选品brief和示例(本地生活任务补充信息)
+	if localUpdateParam.LocalBrief != nil {
+		// 删除已有brief
+		err = dao.ProjectBriefDao{}.DeleteSecBriefBySelectionId(localLife.LocalID)
+		if err != nil {
+			return nil, err
+		}
+		// 插入新的brief
+		for _, v := range localUpdateParam.LocalBrief {
+			brief := entity.ProjectBrief{
+				ProjectID: localLife.LocalID,
+				FileUid:   v.FileUid,
+				FileName:  v.Name,
+				FileUrl:   v.FileUrl,
+				CreatedAt: time.Now(),
+			}
+			err = dao.ProjectBriefDao{}.CreateProjectBrief(brief)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+
+	if localUpdateParam.LocalMaterial != nil {
+		// 删除已有示例
+		err = dao.ProjectMaterialDao{}.DeleteProjectMaterialByProjectId(localLife.LocalID)
+		if err != nil {
+			return nil, err
+		}
+		// 插入新的示例
+		for _, v := range localUpdateParam.LocalMaterial {
+			projectMaterial := entity.ProjectMaterial{
+				ProjectID: localLife.LocalID,
+				FileUid:   v.FileUid,
+				FileName:  v.Name,
+				FileUrl:   v.FileUrl,
+				CreatedAt: time.Now(),
+			}
+			err = dao.ProjectMaterialDao{}.CreateProjectMaterial(projectMaterial)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+
+	return &updateLocalLife.LocalID, nil
+}
+
+// 本地生活任务预览
+func (s LocalLifeService) GetLocalLifeDetail(localId string) (*vo.ReLocalDetail, error) {
+	reLocalDetail := vo.ReLocalDetail{}
+	localLife, err := dao.LocalLifeDao{}.GetLocalById(localId)
+	if err != nil {
+		logrus.Errorf("[localLifeDB service] call GetLocalById error,err:%+v", err)
+		return nil, err
+	}
+	// 系统信息
+	reLocalDetail.LocalId = localId
+	reLocalDetail.LocalStatus = localLife.TaskStatus
+	reLocalDetail.LocalPlatform = localLife.LocalPlatform
+	reLocalDetail.CreatedAt = localLife.CreatedAt.Format("2006-01-02 15:04:05")
+	reLocalDetail.EstimatedCost = localLife.EstimatedCost // 预估成本
+	reLocalDetail.ServiceChargeRate = localLife.ServiceChargeRate
+	var creatorName, phone string
+	if localLife.OperatorType == 1 && localLife.SubAccountID == 0 {
+		enterprise, err := dao.EnterpriseDao{}.GetEnterprise(localLife.EnterpriseID)
+		if err == nil && enterprise != nil {
+			creatorName = enterprise.BusinessName
+			phone, err = dao.UserDao{}.GetPhoneByUserId(enterprise.UserId)
+		}
+	} else if localLife.OperatorType == 1 && localLife.SubAccountID != 0 {
+		subAccount, err := dao.SubAccountDao{}.GetSubAccount(localLife.SubAccountID)
+		if err == nil && subAccount != nil {
+			creatorName = subAccount.SubAccountName
+			phone, err = dao.UserDao{}.GetPhoneByUserId(subAccount.UserId)
+		}
+	}
+	reLocalDetail.CreatorName = creatorName
+	reLocalDetail.Phone = phone
+	// 关联主体
+	var reStore vo.ReStore
+	store, err := dao.StoreDao{}.GetStoreByID(localLife.StoreID)
+	if err == nil {
+		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(store.StoreID)
+		if e != nil {
+			photoUrl = ""
+		}
+		reStore = vo.ReStore{
+			StoreID:       store.StoreID,
+			StoreName:     store.StoreName,
+			StoreLocation: store.StoreLocation,
+			StoreCategory: store.StoreCategory,
+			TeamNum:       store.TeamNum,
+			StoreDetail:   store.StoreDetail,
+			CreatedAt:     store.CreatedAt.Format("2006-01-02 15:04:05"),
+			PhotoUrl:      photoUrl,
+		}
+	}
+	reLocalDetail.StoreInfo = &reStore
+	var reTeamBuying vo.ReTeamBuying
+	teamBuying, err := dao.TeamBuyingDao{}.GetTeamBuyingByID(localLife.TeamBuyingId)
+	if err == nil {
+		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByTeamBuyingID(teamBuying.TeamBuyingID)
+		if e != nil {
+			photoUrl = ""
+		}
+		reTeamBuying = vo.ReTeamBuying{
+			TeamBuyingID:       teamBuying.TeamBuyingID,
+			TeamBuyingName:     teamBuying.TeamBuyingName,
+			TeamBuyingPrice:    teamBuying.TeamBuyingPrice,
+			TeamBuyingCategory: teamBuying.TeamBuyingCategory,
+			TeamBuyingDetail:   teamBuying.TeamBuyingDetail,
+			CreatedAt:          teamBuying.CreatedAt.Format("2006-01-02 15:04:05"),
+			PhotoUrl:           photoUrl,
+		}
+	}
+	reLocalDetail.TeamBuyingInfo = &reTeamBuying
+	reLocalDetail.PromoteBody = localLife.PromoteBody
+	reLocalDetail.Donate = localLife.Donate
+	// 招募要求
+	reLocalDetail.TalentType = localLife.TalentType
+	reLocalDetail.RecruitDdl = localLife.RecruitDdl.Format("2006-01-02 15:04:05")
+
+	var recruitStrategysPreviews []*vo.LocalRecruitStrategy
+	recruitStrategys, err := dao.RecruitStrategyDao{}.GetRecruitStrategyByProjectId(localId)
+	if err != nil {
+		logrus.Errorf("[localLifeDB service] call GetRecruitStrategy error,err:%+v", err)
+		return nil, err
+	}
+	for _, recruitStrategy := range recruitStrategys {
+		recruitStrategysPreview := &vo.LocalRecruitStrategy{
+			StrategyId:     recruitStrategy.StrategyID,
+			FeeForm:        recruitStrategy.FeeForm,
+			FollowersLow:   recruitStrategy.FollowersLow,
+			FollowersUp:    recruitStrategy.FollowersUp,
+			RecruitNumber:  recruitStrategy.RecruitNumber,
+			Offer:          recruitStrategy.Offer,
+			TOffer:         recruitStrategy.TOffer,
+			ServiceCharge:  recruitStrategy.ServiceCharge,
+			SelectedNumber: recruitStrategy.SelectedNumber,
+			TotalOffer:     recruitStrategy.TotalOffer,
+		}
+		recruitStrategysPreviews = append(recruitStrategysPreviews, recruitStrategysPreview)
+	}
+	reLocalDetail.RecruitStrategys = recruitStrategysPreviews
+	// 执行要求
+	reLocalDetail.TaskForm = localLife.TaskForm
+	reLocalDetail.ContentType = localLife.ContentType
+	reLocalDetail.TaskDetail = localLife.TaskDetail
+	taskBriefInfos, err := dao.ProjectBriefDao{}.GetProjectBriefInfo(localId)
+	if err != nil {
+		logrus.Errorf("[localLifeDB service] call GetProjectBriefInfo error,err:%+v", err)
+		return nil, err
+	}
+	taskMaterials, err := dao.ProjectMaterialDao{}.GetProjectMaterialInfo(localId)
+	if err != nil {
+		logrus.Errorf("[localLifeDB service] call GetprojectMaterialInfo error,err:%+v", err)
+		return nil, err
+	}
+	reLocalDetail.TaskBriefs = taskBriefInfos
+	reLocalDetail.TaskMaterials = taskMaterials
+	reLocalDetail.Tools = localLife.Tools
+
+	return &reLocalDetail, nil
+}
+
+// 本地生活提交审核
+func (s LocalLifeService) LocalLifeToReview(localUpdateParam *vo.LocalUpdateParam) (*string, error) {
+	localId := localUpdateParam.LocalID
+	t := time.Now()
+	updateLocal := entity.LocalLifeInfo{
+		LocalID:    localId,
+		TaskStatus: 2,
+		UpdatedAt:  t,
+	}
+	err := dao.LocalLifeDao{}.UpdateLocal(updateLocal)
+	if err != nil {
+		return nil, err
+	}
+	return &localId, nil
+}

+ 14 - 9
app/service/product_service.go

@@ -21,15 +21,20 @@ func (p ProductService) GetTaskProductsByUserId(param vo.GetAllProductParam) (vo
 	var products []entity.Product
 	var err error
 	var total int64
-	if param.SubAccountId == 0 {
-		enterpriseId := param.EnterpriseId
-		if enterpriseId == "" {
-			return result, errors.New("enterpriseId is empty")
-		}
-		products, total, err = (&dao.ProductDAO{}).GetProductsByEnterpriseID(enterpriseId, param.Page, param.PageSize)
-	} else {
-		products, total, err = (&dao.ProductDAO{}).GetProductsBySubAccountId(param.SubAccountId, param.Page, param.PageSize)
+	//if param.SubAccountId == 0 {
+	//	enterpriseId := param.EnterpriseId
+	//	if enterpriseId == "" {
+	//		return result, errors.New("enterpriseId is empty")
+	//	}
+	//	products, total, err = (&dao.ProductDAO{}).GetProductsByEnterpriseID(enterpriseId, param.Page, param.PageSize)
+	//} else {
+	//	products, total, err = (&dao.ProductDAO{}).GetProductsBySubAccountId(param.SubAccountId, param.Page, param.PageSize)
+	//}
+	enterpriseId := param.EnterpriseId
+	if enterpriseId == "" {
+		return result, errors.New("enterpriseId is empty")
 	}
+	products, total, err = (&dao.ProductDAO{}).GetProductsByEnterpriseIDAndTypeTitle(enterpriseId, param.ProductType, param.ProductTitle, param.Page, param.PageSize)
 	if err != nil {
 		// 数据库查询error
 		return result, err
@@ -87,7 +92,7 @@ func (p ProductService) CreateProduct(productCreateParam *vo.ProductCreateParam)
 				PhotoUid:  photo.PhotoUid,
 				Symbol:    photo.Symbol,
 				ProductID: productID,
-				CreatedAt: time.Time{},
+				CreatedAt: time.Now(),
 			}
 			productPhotos = append(productPhotos, productPhoto)
 		}

+ 15 - 23
app/service/project_service.go

@@ -3,7 +3,6 @@ package service
 import (
 	"encoding/json"
 	"errors"
-	"github.com/issue9/conv"
 	"github.com/sirupsen/logrus"
 	"reflect"
 	"time"
@@ -20,7 +19,7 @@ func (s ProjectService) CreateProject(param *vo.ProjectCreateParam) (*string, er
 	// a) 生成种草项目id
 	projectId := util.GetProjectID()
 	// b) 查找关联商品信息
-	product, err := dao.ProductDAO{}.GetProductByID(conv.MustInt64(param.ProductId, 0))
+	product, err := dao.ProductDAO{}.GetProductByID(param.ProductId)
 	if err != nil {
 		return nil, err
 	}
@@ -73,7 +72,7 @@ func (s ProjectService) CreateProject(param *vo.ProjectCreateParam) (*string, er
 
 // 更新公开种草任务(招募要求、执行要求)
 func (s ProjectService) UpdateProject(projectUpdateParam *vo.ProjectUpdateParam) (*string, error) {
-	// 1. 检查该企业id和商品id有无种草任务
+	// 1. 检查该项目id有无种草任务
 	projectID := projectUpdateParam.ProjectID
 	project, err := dao.ProjectDAO{}.GetProjectById(projectID)
 	if err != nil {
@@ -137,21 +136,18 @@ func (s ProjectService) UpdateProject(projectUpdateParam *vo.ProjectUpdateParam)
 	}
 	t := time.Now()
 	updateProject := entity.Project{
-		EnterpriseID:     projectUpdateParam.EnterpriseId,
-		SubAccountId:     projectUpdateParam.SubAccountId,
-		ProjectId:        projectUpdateParam.ProjectID,
-		ProjectType:      projectUpdateParam.ProjectType,
-		ProjectStatus:    projectUpdateParam.ProjectStatus,
-		ProjectName:      projectUpdateParam.ProjectName,
-		ProductID:        projectUpdateParam.ProductId,
-		TalentType:       projectUpdateParam.TalentType,
-		RecruitDdl:       recruitDdl,
-		ProductSnap:      string(productInfoToJson),
-		ProductPhotoSnap: string(productPhotosToJson),
-		UpdatedAt:        t,
-		ProjectForm:      projectUpdateParam.ProjectForm,
-		ContentType:      projectUpdateParam.ContentType,
-		ProjectDetail:    projectUpdateParam.ProjectDetail,
+		ProjectStatus:     projectUpdateParam.ProjectStatus,
+		ServiceChargeRate: projectUpdateParam.ServiceChargeRate,
+		ProjectName:       projectUpdateParam.ProjectName,
+		ProductID:         projectUpdateParam.ProductId,
+		TalentType:        projectUpdateParam.TalentType,
+		RecruitDdl:        recruitDdl,
+		ProductSnap:       string(productInfoToJson),
+		ProductPhotoSnap:  string(productPhotosToJson),
+		UpdatedAt:         t,
+		ProjectForm:       projectUpdateParam.ProjectForm,
+		ContentType:       projectUpdateParam.ContentType,
+		ProjectDetail:     projectUpdateParam.ProjectDetail,
 	}
 	if projectUpdateParam.ProjectStatus == 2 {
 		updateProject.SubmitAt = t
@@ -228,7 +224,7 @@ func (s ProjectService) UpdateProject(projectUpdateParam *vo.ProjectUpdateParam)
 
 // 更新定向种草任务(招募要求、执行要求)
 func (s ProjectService) UpdateProjectTarget(projectUpdateParam *vo.ProjectUpdateParam) (*string, error) {
-	// 1. 检查该企业id和商品id有无种草任务
+	// 1. 检查该项目id有无种草任务
 	projectID := projectUpdateParam.ProjectID
 	project, err := dao.ProjectDAO{}.GetProjectById(projectID)
 	if err != nil {
@@ -290,10 +286,6 @@ func (s ProjectService) UpdateProjectTarget(projectUpdateParam *vo.ProjectUpdate
 	}
 	t := time.Now()
 	updateProject := entity.Project{
-		EnterpriseID:     projectUpdateParam.EnterpriseId,
-		SubAccountId:     projectUpdateParam.SubAccountId,
-		ProjectId:        projectUpdateParam.ProjectID,
-		ProjectType:      projectUpdateParam.ProjectType,
 		ProjectStatus:    projectUpdateParam.ProjectStatus,
 		ProjectName:      projectUpdateParam.ProjectName,
 		ProductID:        projectUpdateParam.ProductId,

+ 98 - 0
app/service/store_service.go

@@ -0,0 +1,98 @@
+package service
+
+import (
+	"errors"
+	"time"
+	"youngee_b_api/app/dao"
+	"youngee_b_api/app/entity"
+	"youngee_b_api/app/vo"
+)
+
+type StoreService struct{}
+
+func (p StoreService) GetStoresByEnterpriseId(param vo.GetAllStoreParam) (vo.ResultVO, error) {
+	if param.Page == 0 {
+		param.Page = 1
+	}
+	if param.PageSize == 0 {
+		param.PageSize = 10
+	}
+	var result vo.ResultVO
+	var stores []entity.Store
+	var err error
+	var total int64
+	enterpriseId := param.EnterpriseId
+	if enterpriseId == "" {
+		return result, errors.New("enterpriseId is empty")
+	}
+	stores, total, err = (&dao.StoreDao{}).GetStoresByEnterpriseIDAndStoreName(enterpriseId, param.StoreName, param.Page, param.PageSize)
+	if err != nil {
+		// 数据库查询error
+		return result, err
+	}
+	var reStores []vo.ReStore
+	for _, store := range stores {
+		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(store.StoreID)
+		if e != nil {
+			photoUrl = ""
+		}
+		reStore := vo.ReStore{
+			StoreID:       store.StoreID,
+			StoreName:     store.StoreName,
+			StoreLocation: store.StoreLocation,
+			StoreType:     store.StoreType,
+			StoreCategory: store.StoreCategory,
+			TeamNum:       store.TeamNum,
+			StoreDetail:   store.StoreDetail,
+			CreatedAt:     store.CreatedAt.Format("2006-01-02 15:04:05"),
+			PhotoUrl:      photoUrl,
+		}
+		reStores = append(reStores, reStore)
+	}
+	result = vo.ResultVO{
+		Page:     param.Page,
+		PageSize: param.PageSize,
+		Total:    total,
+		Data:     reStores,
+	}
+	return result, nil
+}
+
+func (p StoreService) CreateStore(param *vo.StoreCreateParam) (int64, error) {
+	newStore := entity.Store{
+		StoreName:          param.StoreName,
+		StoreCategory:      param.StoreCategory,
+		StoreType:          param.StoreType,
+		StoreLocation:      param.StoreLocation,
+		StoreDetail:        param.StoreDetail,
+		StoreLink:          param.StoreLink,
+		BelongEnterpriseID: param.EnterpriseId,
+		EnterpriseID:       param.EnterpriseId,
+		SubAccountID:       param.SubAccountId,
+		OperateType:        1,
+		CreatedAt:          time.Now(),
+	}
+	storeId, err := dao.StoreDao{}.CreateStore(newStore)
+	if err != nil {
+		return 0, err
+	}
+	if param.StorePhotos != nil {
+		storePhotos := []entity.ProductPhoto{}
+		for _, photo := range param.StorePhotos {
+			storePhoto := entity.ProductPhoto{
+				PhotoUrl:         photo.PhotoUrl,
+				PhotoUid:         photo.PhotoUid,
+				Symbol:           photo.Symbol,
+				StoreID:          storeId,
+				ProductPhotoType: 2,
+				CreatedAt:        time.Now(),
+			}
+			storePhotos = append(storePhotos, storePhoto)
+		}
+		err = dao.ProductPhotoDAO{}.CreateProductPhoto(storePhotos)
+		if err != nil {
+			return 0, err
+		}
+	}
+	return storeId, nil
+}

+ 92 - 0
app/service/teambuying_service.go

@@ -0,0 +1,92 @@
+package service
+
+import (
+	"time"
+	"youngee_b_api/app/dao"
+	"youngee_b_api/app/entity"
+	"youngee_b_api/app/vo"
+)
+
+type TeamBuyingService struct{}
+
+func (p TeamBuyingService) GetTeamBuyingsByStoreId(param vo.GetAllTeamBuyingParam) (vo.ResultVO, error) {
+	if param.Page == 0 {
+		param.Page = 1
+	}
+	if param.PageSize == 0 {
+		param.PageSize = 10
+	}
+	var result vo.ResultVO
+	var teamBuyings []entity.TeamBuying
+	var err error
+	var total int64
+	storeId := param.StoreId
+	teamBuyings, total, err = (&dao.TeamBuyingDao{}).GetTeamBuyingsByStoreIdAndTeamBuyingTitle(storeId, param.TeamBuyingTitle, param.Page, param.PageSize)
+	if err != nil {
+		// 数据库查询error
+		return result, err
+	}
+	var reTeamBuyings []vo.ReTeamBuying
+	for _, teamBuying := range teamBuyings {
+		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByTeamBuyingID(teamBuying.TeamBuyingID)
+		if e != nil {
+			photoUrl = ""
+		}
+		reTeamBuying := vo.ReTeamBuying{
+			TeamBuyingID:       teamBuying.TeamBuyingID,
+			TeamBuyingName:     teamBuying.TeamBuyingName,
+			TeamBuyingPrice:    teamBuying.TeamBuyingPrice,
+			TeamBuyingCategory: teamBuying.TeamBuyingCategory,
+			TeamBuyingDetail:   teamBuying.TeamBuyingDetail,
+			CreatedAt:          teamBuying.CreatedAt.Format("2006-01-02 15:04:05"),
+			PhotoUrl:           photoUrl,
+		}
+		reTeamBuyings = append(reTeamBuyings, reTeamBuying)
+	}
+	result = vo.ResultVO{
+		Page:     param.Page,
+		PageSize: param.PageSize,
+		Total:    total,
+		Data:     reTeamBuyings,
+	}
+	return result, nil
+}
+
+func (p TeamBuyingService) CreateTeamBuying(param *vo.TeamBuyingCreateParam) (int64, error) {
+	newTeamBuying := entity.TeamBuying{
+		TeamBuyingName:     param.TeamBuyingName,
+		TeamBuyingCategory: param.TeamBuyingCategory,
+		TeamBuyingPrice:    param.TeamBuyingPrice,
+		PublicCommission:   param.PublicCommission,
+		TeamBuyingDetail:   param.TeamBuyingDetail,
+		TeamBuyingLink:     param.TeamBuyingLink,
+		StoreID:            param.StoreId,
+		CreatedAt:          time.Now(),
+		EnterpriseID:       param.EnterpriseId,
+		SubAccountID:       param.SubAccountId,
+		OperateType:        1,
+	}
+	teamBuyingId, err := dao.TeamBuyingDao{}.CreateTeamBuying(newTeamBuying)
+	if err != nil {
+		return 0, err
+	}
+	if param.TeamBuyingPhotos != nil {
+		teamBuyingPhotos := []entity.ProductPhoto{}
+		for _, photo := range param.TeamBuyingPhotos {
+			teamBuyingPhoto := entity.ProductPhoto{
+				PhotoUrl:         photo.PhotoUrl,
+				PhotoUid:         photo.PhotoUid,
+				Symbol:           photo.Symbol,
+				TeamBuyingID:     teamBuyingId,
+				ProductPhotoType: 3,
+				CreatedAt:        time.Now(),
+			}
+			teamBuyingPhotos = append(teamBuyingPhotos, teamBuyingPhoto)
+		}
+		err = dao.ProductPhotoDAO{}.CreateProductPhoto(teamBuyingPhotos)
+		if err != nil {
+			return 0, err
+		}
+	}
+	return teamBuyingId, nil
+}

+ 5 - 6
app/util/uuid.go

@@ -20,12 +20,6 @@ func init() {
 	}
 	snowflakeInstance = s
 }
-func GetUUID() string {
-	return uuid.New().String()
-}
-func GetSnowflakeID() int64 {
-	return snowflakeInstance.NextVal()
-}
 
 func GetSelectionID() string {
 	rand.Seed(time.Now().UnixNano())
@@ -95,3 +89,8 @@ func GenerateDateRelatedUUID(num int64) string {
 	u := uuid.New()
 	return date + u.String()[:(num-8)]
 }
+
+func GenerateUUID(num int) string {
+	u := uuid.New()
+	return u.String()[:num]
+}

+ 2 - 0
app/vo/get_all_product_param.go

@@ -3,6 +3,8 @@ package vo
 type GetAllProductParam struct {
 	EnterpriseId string `json:"enterprise_id"`
 	SubAccountId int64  `json:"sub_account_id"`
+	ProductType  int64  `json:"product_type"`  // 商品类型(0一般商品 1快手商品
+	ProductTitle string `json:"product_title"` // 商品标题
 	Page         int    `json:"page"`
 	PageSize     int    `json:"page_size"`
 }

+ 9 - 0
app/vo/get_all_store_param.go

@@ -0,0 +1,9 @@
+package vo
+
+type GetAllStoreParam struct {
+	EnterpriseId string `json:"enterprise_id"`
+	SubAccountId int64  `json:"sub_account_id"`
+	StoreName    string `json:"store_name"` // 门店名称
+	Page         int    `json:"page"`
+	PageSize     int    `json:"page_size"`
+}

+ 8 - 0
app/vo/get_all_teambuying_param.go

@@ -0,0 +1,8 @@
+package vo
+
+type GetAllTeamBuyingParam struct {
+	StoreId         int64  `json:"store_id"`
+	TeamBuyingTitle string `json:"team_buying_title"` // 团购标题
+	Page            int    `json:"page"`
+	PageSize        int    `json:"page_size"`
+}

+ 13 - 0
app/vo/local_create_param.go

@@ -0,0 +1,13 @@
+package vo
+
+type LocalCreateParam struct {
+	EnterpriseId      string  `json:"enterprise_id"`
+	SubAccountId      int64   `json:"sub_account_id"`
+	Platform          int64   `json:"platform"`
+	LocalType         int64   `json:"local_type"` // 项目类型,1代表全流程项目,2代表专项项目
+	ServiceChargeRate float64 `json:"service_charge_rate"`
+	StoreId           int64   `json:"store_id"`       // 门店id
+	PromoteBody       int64   `json:"promote_body"`   // 推广主体(1门店 2团购)
+	Donate            int64   `json:"donate"`         // 赠送达人套餐(1有赠送 2无赠送)
+	TeamBuyingId      int64   `json:"team_buying_id"` // 团购id
+}

+ 48 - 0
app/vo/local_update_param.go

@@ -0,0 +1,48 @@
+package vo
+
+type LocalUpdateParam struct {
+	EnterpriseId      string  `json:"enterprise_id"`
+	SubAccountId      int64   `json:"sub_account_id"`
+	LocalID           string  `json:"local_id"`
+	StoreId           int64   `json:"store_id"`
+	TeamBuyingId      int64   `json:"team_buying_id"`
+	ServiceChargeRate float64 `json:"service_charge_rate"`
+	PromoteBody       int64   `json:"promote_body"` // 推广主体(1门店 2团购)
+	//LocalType         int64                        `json:"local_type"`        // 项目类型,1代表全流程项目,2代表专项项目
+	Donate           int64                        `json:"donate"`            // 赠送达人套餐(1有赠送 2无赠送)
+	LocalStatus      int64                        `json:"local_status"`      // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、失效、执行中、已结案
+	LocalName        string                       `json:"local_name"`        // 项目名称(任务标题)
+	TalentType       string                       `json:"talent_type"`       // 达人类型(,分隔)
+	RecruitDdl       string                       `json:"recruit_ddl"`       // 招募截止时间
+	RecruitStrategys []CreateLocalRecruitStrategy `json:"recruit_strategys"` // 招募策略
+
+	TaskForm      int64                `json:"task_form"`    // 项目形式,1-3分别代表商品寄拍、素材分发、虚拟产品测评
+	ContentType   int64                `json:"content_type"` // 内容形式,1代表图文,2代表视频
+	TaskDetail    string               `json:"task_detail"`  // 项目详情
+	Tools         string               `json:"tools"`        // 工具选择 1邀约招募 2结算账单 3样品物流 4审稿工具 5作品审查 6数据巡检(,分隔)
+	LocalBrief    []*LocalBriefInfo    `json:"local_brief"`
+	LocalMaterial []*LocalMaterialInfo `json:"local_material"`
+}
+
+type LocalBriefInfo struct {
+	FileUrl string `json:"file_url"`
+	FileUid string `json:"file_uid"`
+	Name    string `json:"name"`
+}
+
+type LocalMaterialInfo struct {
+	FileUrl string `json:"file_url"`
+	FileUid string `json:"file_uid"`
+	Name    string `json:"name"`
+}
+
+// 招募策略
+type CreateLocalRecruitStrategy struct {
+	StrategyID    int64   `json:"strategy_id"`    // 策略id
+	FeeForm       int64   `json:"fee_form"`       // 稿费形式,1-3分别代表无费置换、一口价、自报价
+	FollowersLow  int64   `json:"followers_low"`  // 达人粉丝数下限
+	FollowersUp   int64   `json:"followers_up"`   // 达人粉丝数上限
+	RecruitNumber int64   `json:"recruit_number"` // 招募数量
+	Offer         float64 `json:"offer"`          // 报价
+	ServiceCharge float64 `json:"service_charge"` // 服务费
+}

+ 47 - 0
app/vo/re_local_detail.go

@@ -0,0 +1,47 @@
+package vo
+
+import (
+	"youngee_b_api/app/entity"
+)
+
+type ReLocalDetail struct {
+	// 系统信息
+	LocalId           string  `json:"localId"`           // 项目id
+	LocalStatus       int64   `json:"localStatus"`       // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、失效、执行中、已结案
+	LocalPlatform     int64   `json:"localPlatform"`     //  项目平台,1-7分别代表红book、抖音、微博、快手、b站、大众点评、知乎
+	CreatedAt         string  `json:"createdAt"`         // 创建时间
+	CreatorName       string  `json:"creatorName"`       // 创建者
+	Phone             string  `json:"phone"`             // 联系方式
+	EstimatedCost     float64 `json:"estimatedCost"`     // 成本预估
+	ServiceChargeRate float64 `json:"serviceChargeRate"` // 公开服务费率
+	// 支付方式参数待定
+	// 关联主体
+	StoreInfo      *ReStore      `json:"storeInfo"`
+	PromoteBody    int64         `json:"promoteBody"`
+	TeamBuyingInfo *ReTeamBuying `json:"teamBuyingInfo"`
+	Donate         int64         `json:"donate"`
+	// 招募要求
+	TalentType       string                  `json:"talentType"`
+	RecruitDdl       string                  `json:"recruitDdl"`
+	RecruitStrategys []*LocalRecruitStrategy `json:"recruitStrategys"` // 招募策略
+	// 执行要求
+	TaskForm      int64                     `json:"taskForm"`
+	ContentType   int64                     `json:"contentType"`
+	TaskDetail    string                    `json:"taskDetail"`
+	TaskBriefs    []*entity.ProjectBrief    `json:"taskBriefs"`    // 选品brief列表
+	TaskMaterials []*entity.ProjectMaterial `json:"taskMaterials"` // 选品示例列表
+	Tools         string                    `json:"tools"`         // 工具选择
+}
+
+type LocalRecruitStrategy struct {
+	StrategyId     int64   `json:"strategyId"`
+	FeeForm        int64   `json:"feeForm"`
+	FollowersLow   int64   `json:"followersLow"`
+	FollowersUp    int64   `json:"followersUp"`
+	RecruitNumber  int64   `json:"recruitNumber"`
+	Offer          float64 `json:"offer"`
+	TOffer         float64 `json:"tOffer"` // 达人所见报价
+	ServiceCharge  float64 `json:"serviceCharge"`
+	SelectedNumber int64   `json:"selectedNumber"` // 确认合作数量
+	TotalOffer     float64 `json:"totalOffer"`     // 合计
+}

+ 8 - 8
app/vo/re_project_detail.go

@@ -6,14 +6,14 @@ import (
 
 type ReProjectDetail struct {
 	// 系统信息
-	ProjectId         string  `json:"projectId"`           // 项目id 生成规则:年(2位)+一年中的第几天(3位)+5位数随机数,雪花算法也可,生成10位订单号
-	ProjectStatus     int64   `json:"projectStatus"`       // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、失效、执行中、已结案
-	ProjectPlatform   int64   `json:"projectPlatform"`     //  项目平台,1-7分别代表红book、抖音、微博、快手、b站、大众点评、知乎
-	CreatedAt         string  `json:"createdAt"`           // 创建时间
-	CreatorName       string  `json:"creatorName"`         // 创建者
-	Phone             string  `json:"phone"`               // 联系方式
-	EstimatedCost     float64 `json:"estimatedCost"`       // 成本预估
-	ServiceChargeRate float64 `json:"service_charge_rate"` // 公开服务费率
+	ProjectId         string  `json:"projectId"`         // 项目id 生成规则:年(2位)+一年中的第几天(3位)+5位数随机数,雪花算法也可,生成10位订单号
+	ProjectStatus     int64   `json:"projectStatus"`     // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、失效、执行中、已结案
+	ProjectPlatform   int64   `json:"projectPlatform"`   //  项目平台,1-7分别代表红book、抖音、微博、快手、b站、大众点评、知乎
+	CreatedAt         string  `json:"createdAt"`         // 创建时间
+	CreatorName       string  `json:"creatorName"`       // 创建者
+	Phone             string  `json:"phone"`             // 联系方式
+	EstimatedCost     float64 `json:"estimatedCost"`     // 成本预估
+	ServiceChargeRate float64 `json:"serviceChargeRate"` // 公开服务费率
 	// 支付方式参数待定
 	// 关联商品
 	ProductInfo *ReTaskProduct `json:"productInfo"`

+ 13 - 0
app/vo/re_store.go

@@ -0,0 +1,13 @@
+package vo
+
+type ReStore struct {
+	StoreID       int64  `json:"storeId"`
+	StoreName     string `json:"storeName"`
+	StoreLocation string `json:"storeLocation"`
+	StoreType     int64  `json:"storeType"`     // 门店类型 1单门店,2连锁门店
+	StoreCategory string `json:"storeCategory"` // 门店类目
+	TeamNum       int64  `json:"teamNum"`       // 包含团购套餐
+	StoreDetail   string `json:"storeDetail"`
+	CreatedAt     string `json:"createdAt"`
+	PhotoUrl      string `json:"photoUrl"`
+}

+ 11 - 0
app/vo/re_teambuying.go

@@ -0,0 +1,11 @@
+package vo
+
+type ReTeamBuying struct {
+	TeamBuyingID       int64   `json:"teamBuyingId"`
+	TeamBuyingName     string  `json:"teamBuyingName"`
+	TeamBuyingPrice    float64 `json:"teamBuyingPrice"`
+	TeamBuyingCategory string  `json:"teamBuyingCategory"` // 团购类目
+	TeamBuyingDetail   string  `json:"teamBuyingDetail"`
+	CreatedAt          string  `json:"createdAt"`
+	PhotoUrl           string  `json:"photoUrl"`
+}

+ 19 - 0
app/vo/store_create_param.go

@@ -0,0 +1,19 @@
+package vo
+
+type StorePhoto struct {
+	PhotoUrl string `json:"photo_url"` // 图片或视频url
+	PhotoUid string `json:"photo_uid"`
+	Symbol   int64  `json:"symbol"` // 图片为主图或详情图标志位,1为主图,2为轮播图,3为轮播视频. 4为详情图. 5为详情视频
+}
+
+type StoreCreateParam struct {
+	EnterpriseId  string       `json:"enterprise_id"` // 要绑定的企业id
+	SubAccountId  int64        `json:"sub_account_id"`
+	StoreName     string       `json:"store_name"`     // 门店名称
+	StoreCategory string       `json:"store_category"` // 门店类目(/分隔)
+	StoreType     int64        `json:"store_type"`     // 门店类型,1单门店,2连锁门店
+	StoreLocation string       `json:"store_location"` // 门店地址
+	StoreDetail   string       `json:"store_detail"`   // 门店特点
+	StoreLink     string       `json:"store_link"`     // 分销链接
+	StorePhotos   []StorePhoto `json:"store_photos"`   // 图片列表
+}

+ 0 - 0
app/vo/TalentCancelParam.go → app/vo/talent_cancel_param.go


+ 20 - 0
app/vo/teambuying_create_param.go

@@ -0,0 +1,20 @@
+package vo
+
+type TeamBuyingPhoto struct {
+	PhotoUrl string `json:"photo_url"` // 图片或视频url
+	PhotoUid string `json:"photo_uid"`
+	Symbol   int64  `json:"symbol"` // 图片为主图或详情图标志位,1为主图,2为轮播图,3为轮播视频. 4为详情图. 5为详情视频
+}
+
+type TeamBuyingCreateParam struct {
+	StoreId            int64             `json:"store_id"`             // 要绑定的门店id
+	TeamBuyingName     string            `json:"team_buying_name"`     // 团购标题
+	TeamBuyingCategory string            `json:"team_buying_category"` // 团购类目(/分隔)
+	TeamBuyingPrice    float64           `json:"team_buying_price"`    // 团购售价
+	PublicCommission   int64             `json:"public_commission"`    // 公开佣金%
+	TeamBuyingDetail   string            `json:"team_buying_detail"`   // 团购详情
+	TeamBuyingLink     string            `json:"team_buying_link"`     // 分销链接
+	TeamBuyingPhotos   []TeamBuyingPhoto `json:"team_buying_photos"`   // 图片列表
+	EnterpriseId       string            `json:"enterprise_id"`        // 操作企业id
+	SubAccountId       int64             `json:"sub_account_id"`
+}

+ 20 - 1
route/init.go

@@ -196,6 +196,8 @@ func InitRoute(r *gin.Engine) {
 
 		task.POST("/product/findAll", controller.TaskController{}.GetAllProduct) // 关联商品-已有商品展示
 		task.POST("/product/create", controller.TaskController{}.CreateProduct)  // 关联商品-新建商品
+		// 商品编辑
+		// 商品删除
 
 		task.POST("/selection/create", controller.TaskController{}.CreateSelection)      // 创建带货任务
 		task.POST("/selection/update", controller.TaskController{}.UpdateSelection)      // 更新带货任务(样品奖励、补充信息)
@@ -206,13 +208,30 @@ func InitRoute(r *gin.Engine) {
 		task.POST("/selection/check", controller.TaskController{}.CheckSelectionInfo)    // 电商带货任务审核
 
 		task.POST("/project/create", controller.TaskController{}.CreateProject)              // 创建种草任务
-		task.POST("/project/update", controller.TaskController{}.UpdateProject)              // 更新种草任务
+		task.POST("/project/update", controller.TaskController{}.UpdateProject)              // 更新公开种草任务
 		task.POST("/project/target/update", controller.TaskController{}.UpdateProjectTarget) // 更新定向种草任务
 		task.POST("/project/detail", controller.TaskController{}.GetProjectDetail)           // 品牌种草任务预览
 		task.POST("/project/toReview", controller.TaskController{}.ProjectToReview)          // 种草提交审核
 		task.POST("/project/task/list", controller.TaskController{}.ProjectTaskList)         // 种草任务列表
 		task.POST("/project/del", controller.TaskController{}.ProjectDel)                    // 删除种草任务
 
+		task.POST("/store/findAll", controller.TaskController{}.GetAllStore) // 关联门店-已有门店展示
+		task.POST("/store/create", controller.TaskController{}.CreateStore)  // 关联门店-新建门店
+		// 门店详情
+		// 门店删除
+		// 门店更新
+		task.POST("/teamBuying/findAll", controller.TaskController{}.GetAllTeamBuying) // 门店团购列表
+		task.POST("/teamBuying/create", controller.TaskController{}.CreateTeamBuying)  // 新建团购
+		// 团购详情
+		// 团购删除
+		// 团购更新
+
+		task.POST("/localLife/create", controller.TaskController{}.CreateLocalLife)              // 创建本地生活任务
+		task.POST("/localLife/update", controller.TaskController{}.UpdateLocalLife)              // 更新公开本地生活任务
+		task.POST("/localLife/target/update", controller.TaskController{}.UpdateLocalLifeTarget) // 更新定向本地生活任务
+		task.POST("/localLife/detail", controller.TaskController{}.GetLocalLifeDetail)           // 本地生活任务预览
+		task.POST("/localLife/toReview", controller.TaskController{}.LocalLifeToReview)          // 本地生活提交审核
+
 		task.POST("/draft/selection/list", controller.TaskController{}.GetSelectionDraftList) // 草稿箱——电商带货列表
 		task.POST("/draft/project/list", controller.TaskController{}.GetProjectDraftList)     // 草稿箱——品牌种草列表