ソースを参照

商品管理&门店管理

Ethan 5 ヶ月 前
コミット
23fcb3d4d2

+ 174 - 0
app/controller/cooperation_controller.go

@@ -88,3 +88,177 @@ func (o CooperationController) GetSupplierConfirmingList(c *gin.Context) {
 	}
 	returnSuccess(c, 20000, result)
 }
+
+// 门店详情
+func (o CooperationController) GetStoreDetail(c *gin.Context) {
+	param := &vo.StoreSearchParam{}
+	err := c.BindJSON(param)
+	if err != nil || 0 == param.StoreId {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	reStoreInfo, err := service.StoreService{}.GetStoreDetail(param)
+	if err != nil {
+		logrus.Errorf("[GetStoreDetail] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, reStoreInfo)
+}
+
+// 更新门店
+func (o CooperationController) UpdateStore(c *gin.Context) {
+	param := &vo.StoreUpdateParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	storeId, err := service.StoreService{}.UpdateStore(param)
+	if err != nil {
+		logrus.Errorf("[UpdateStore] 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 (o CooperationController) DeleteStore(c *gin.Context) {
+	param := &vo.StoreUpdateParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	storeId, err := service.StoreService{}.DeleteStore(param)
+	if err != nil {
+		logrus.Errorf("[DeleteStore] 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 (o CooperationController) GetTeamBuyingDetail(c *gin.Context) {
+	param := &vo.TeamBuyingSearchParam{}
+	err := c.BindJSON(param)
+	if err != nil || 0 == param.TeamBuyingId {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	reTeamBuyingInfo, err := service.TeamBuyingService{}.GetTeamBuyingDetail(param)
+	if err != nil {
+		logrus.Errorf("[GetTeamBuyingDetail] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, reTeamBuyingInfo)
+}
+
+// 更新团购
+func (o CooperationController) UpdateTeamBuying(c *gin.Context) {
+	param := &vo.TeamBuyingUpdateParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	teamBuyingId, err := service.TeamBuyingService{}.UpdateTeamBuying(param)
+	if err != nil {
+		logrus.Errorf("[UpdateTeamBuying] 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 (o CooperationController) DeleteTeamBuying(c *gin.Context) {
+	param := &vo.TeamBuyingUpdateParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	teamBuyingId, err := service.TeamBuyingService{}.DeleteTeamBuying(param)
+	if err != nil {
+		logrus.Errorf("[DeleteTeamBuying] 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 (o CooperationController) GetProductDetail(c *gin.Context) {
+	param := &vo.ProductSearchParam{}
+	err := c.BindJSON(param)
+	if err != nil || 0 == param.ProductId {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	reStoreInfo, err := service.ProductService{}.GetProductDetail(param)
+	if err != nil {
+		logrus.Errorf("[GetProductDetail] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, reStoreInfo)
+}
+
+// 更新商品
+func (o CooperationController) UpdateProduct(c *gin.Context) {
+	param := &vo.ProductUpdateParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	productId, err := service.ProductService{}.UpdateProduct(param)
+	if err != nil {
+		logrus.Errorf("[UpdateProduct] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	resultMap := make(map[string]int64)
+	resultMap["productId"] = productId
+	returnSuccess(c, 20000, resultMap)
+}
+
+// 删除商品
+func (o CooperationController) DeleteProduct(c *gin.Context) {
+	param := &vo.ProductUpdateParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	productId, err := service.ProductService{}.DeleteProduct(param)
+	if err != nil {
+		logrus.Errorf("[DeleteProduct] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	resultMap := make(map[string]int64)
+	resultMap["productId"] = productId
+	returnSuccess(c, 20000, resultMap)
+}

+ 13 - 0
app/dao/product_dao.go

@@ -63,6 +63,19 @@ func (d ProductDAO) CreateProduct(product entity.Product) (int64, error) {
 	return product.ProductID, nil
 }
 
+func (d ProductDAO) UpdateProduct(product entity.Product) (int64, error) {
+	err := Db.Model(&entity.Product{}).Where("product_id = ?", product.ProductID).Updates(product).Error
+	if err != nil {
+		return 0, err
+	}
+	return product.ProductID, nil
+}
+
+func (d ProductDAO) DeleteProduct(productId int64) error {
+	err := Db.Where("product_id = ?", productId).Delete(&entity.Product{}).Error
+	return err
+}
+
 func (d ProductDAO) GetProductByID(productId int64) (*entity.Product, error) {
 	var product entity.Product
 	err := Db.Debug().Where("product_id = ?", productId).First(&product).Error

+ 3 - 3
app/dao/product_photo_dao.go

@@ -18,7 +18,7 @@ func (d ProductPhotoDAO) CreateProductPhoto(productPhotos []entity.ProductPhoto)
 // 获取所属商品的图片
 func (d ProductPhotoDAO) GetProductPhotoByProductID(productId int64) ([]entity.ProductPhoto, error) {
 	var productPhotos []entity.ProductPhoto
-	err := Db.Where("product_id = ?", productId).Find(&productPhotos).Error
+	err := Db.Where("product_id = ?", productId).Order("created_at asc").Find(&productPhotos).Error
 	if err != nil {
 		return nil, err
 	}
@@ -38,7 +38,7 @@ func (d ProductPhotoDAO) GetMainPhotoByProductID(productId int64) (string, error
 // 获取所属门店的图片
 func (d ProductPhotoDAO) GetProductPhotoByStoreID(storeId int64) ([]entity.ProductPhoto, error) {
 	var productPhotos []entity.ProductPhoto
-	err := Db.Where("store_id = ?", storeId).Find(&productPhotos).Error
+	err := Db.Where("store_id = ?", storeId).Order("created_at asc").Find(&productPhotos).Error
 	if err != nil {
 		return nil, err
 	}
@@ -58,7 +58,7 @@ func (d ProductPhotoDAO) GetMainPhotoByStoreID(storeId int64) (string, error) {
 // 获取所属团购的图片
 func (d ProductPhotoDAO) GetProductPhotoByTeamBuyingID(teamBuyingId int64) ([]entity.ProductPhoto, error) {
 	var productPhotos []entity.ProductPhoto
-	err := Db.Where("team_buying_id = ?", teamBuyingId).Find(&productPhotos).Error
+	err := Db.Where("team_buying_id = ?", teamBuyingId).Order("created_at asc").Find(&productPhotos).Error
 	if err != nil {
 		return nil, err
 	}

+ 19 - 0
app/dao/store_dao.go

@@ -16,6 +16,19 @@ func (d StoreDao) CreateStore(store entity.Store) (int64, error) {
 	return store.StoreID, nil
 }
 
+func (d StoreDao) UpdateStore(store entity.Store) (int64, error) {
+	err := Db.Model(&entity.Store{}).Where("store_id = ?", store.StoreID).Updates(store).Error
+	if err != nil {
+		return 0, err
+	}
+	return store.StoreID, nil
+}
+
+func (d StoreDao) DeleteStore(storeId int64) error {
+	err := Db.Where("store_id = ?", storeId).Delete(&entity.Store{}).Error
+	return err
+}
+
 func (d StoreDao) GetStoreByID(storeId int64) (*entity.Store, error) {
 	var store entity.Store
 	err := Db.Debug().Where("store_id = ?", storeId).First(&store).Error
@@ -61,3 +74,9 @@ func (d StoreDao) GetStoresByEnterpriseIDAndStoreName(enterpriseId string, store
 	}
 	return stores, total, nil
 }
+
+// 更新team_num字段值
+func (d StoreDao) IncrementTeamNum(storeId int64) error {
+	err := Db.Model(&entity.Store{}).Where("store_id = ?", storeId).Update("team_num", gorm.Expr("team_num + ?", 1)).Error
+	return err
+}

+ 13 - 0
app/dao/team_buying_dao.go

@@ -16,6 +16,19 @@ func (d TeamBuyingDao) CreateTeamBuying(teamBuying entity.TeamBuying) (int64, er
 	return teamBuying.TeamBuyingID, nil
 }
 
+func (d TeamBuyingDao) UpdateTeamBuying(teamBuying entity.TeamBuying) (int64, error) {
+	err := Db.Model(&entity.TeamBuying{}).Where("team_buying_id = ?", teamBuying.TeamBuyingID).Updates(teamBuying).Error
+	if err != nil {
+		return 0, err
+	}
+	return teamBuying.TeamBuyingID, nil
+}
+
+func (d TeamBuyingDao) DeleteTeamBuying(teamBuyingId int64) error {
+	err := Db.Where("team_buying_id = ?", teamBuyingId).Delete(&entity.TeamBuying{}).Error
+	return err
+}
+
 func (d TeamBuyingDao) GetTeamBuyingByID(teamBuyingId int64) (*entity.TeamBuying, error) {
 	var teamBuying entity.TeamBuying
 	err := Db.Debug().Where("team_buying_id = ?", teamBuyingId).First(&teamBuying).Error

+ 1 - 0
app/entity/store.go

@@ -20,6 +20,7 @@ type Store struct {
 	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
+	UpdatedAt          time.Time `gorm:"column:updated_at"`                          // 更新时间
 }
 
 func (m *Store) TableName() string {

+ 1 - 0
app/entity/team_buying.go

@@ -17,6 +17,7 @@ type TeamBuying struct {
 	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
+	UpdatedAt          time.Time `gorm:"column:updated_at"`                                // 更新时间
 }
 
 func (m *TeamBuying) TableName() string {

+ 4 - 4
app/service/local_life_service.go

@@ -404,14 +404,14 @@ func (s LocalLifeService) GetLocalLifeDetail(localId string) (*vo.ReLocalDetail,
 	reLocalDetail.CreatorName = creatorName
 	reLocalDetail.Phone = phone
 	// 关联主体
-	var reStore vo.ReStore
+	var reStore vo.ReStorePreview
 	store, err := dao.StoreDao{}.GetStoreByID(localLife.StoreID)
 	if err == nil {
 		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(store.StoreID)
 		if e != nil {
 			photoUrl = ""
 		}
-		reStore = vo.ReStore{
+		reStore = vo.ReStorePreview{
 			StoreID:       store.StoreID,
 			StoreName:     store.StoreName,
 			StoreLocation: store.StoreLocation,
@@ -423,14 +423,14 @@ func (s LocalLifeService) GetLocalLifeDetail(localId string) (*vo.ReLocalDetail,
 		}
 	}
 	reLocalDetail.StoreInfo = &reStore
-	var reTeamBuying vo.ReTeamBuying
+	var reTeamBuying vo.ReTeamBuyingPreview
 	teamBuying, err := dao.TeamBuyingDao{}.GetTeamBuyingByID(localLife.TeamBuyingId)
 	if err == nil {
 		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByTeamBuyingID(teamBuying.TeamBuyingID)
 		if e != nil {
 			photoUrl = ""
 		}
-		reTeamBuying = vo.ReTeamBuying{
+		reTeamBuying = vo.ReTeamBuyingPreview{
 			TeamBuyingID:       teamBuying.TeamBuyingID,
 			TeamBuyingName:     teamBuying.TeamBuyingName,
 			TeamBuyingPrice:    teamBuying.TeamBuyingPrice,

+ 93 - 2
app/service/product_service.go

@@ -39,13 +39,13 @@ func (p ProductService) GetTaskProductsByUserId(param vo.GetAllProductParam) (vo
 		// 数据库查询error
 		return result, err
 	}
-	var reProducts []vo.ReTaskProduct
+	var reProducts []vo.ReProductPreview
 	for _, product := range products {
 		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByProductID(product.ProductID)
 		if e != nil {
 			photoUrl = ""
 		}
-		reProduct := vo.ReTaskProduct{
+		reProduct := vo.ReProductPreview{
 			ProductID:       product.ProductID,
 			ProductName:     product.ProductName,
 			ProductType:     product.ProductType,
@@ -103,3 +103,94 @@ func (p ProductService) CreateProduct(productCreateParam *vo.ProductCreateParam)
 	}
 	return productID, nil
 }
+
+// 商品详情
+func (s ProductService) GetProductDetail(param *vo.ProductSearchParam) (*vo.ReProductInfo, error) {
+	var reProductInfo *vo.ReProductInfo
+	product, err := dao.ProductDAO{}.GetProductByID(param.ProductId)
+	if err != nil {
+		return nil, err
+	}
+	photoMain, _ := dao.ProductPhotoDAO{}.GetMainPhotoByProductID(param.ProductId)
+	photosAll, _ := dao.ProductPhotoDAO{}.GetProductPhotoByProductID(param.ProductId)
+	var photoRotates []vo.Photo
+	var photoDetails []vo.Photo
+	for _, photosOne := range photosAll {
+		if photosOne.Symbol == 2 || photosOne.Symbol == 3 {
+			photo := vo.Photo{
+				PhotoUrl: photosOne.PhotoUrl,
+				Symbol:   photosOne.Symbol,
+			}
+			photoRotates = append(photoRotates, photo)
+		} else if photosOne.Symbol == 4 || photosOne.Symbol == 5 {
+			photo := vo.Photo{
+				PhotoUrl: photosOne.PhotoUrl,
+				Symbol:   photosOne.Symbol,
+			}
+			photoDetails = append(photoDetails, photo)
+		}
+	}
+	reProductInfo = &vo.ReProductInfo{
+		ProductID:           product.ProductID,
+		ProductName:         product.ProductName,
+		ProductCategory:     product.ProductCategory,
+		ProductPrice:        product.ProductPrice,
+		ExclusiveCommission: product.ExclusiveCommission,
+		CommissionPrice:     product.CommissionPrice,
+		ProductDetail:       product.ProductDetail,
+		ProductUrl:          product.ProductUrl,
+		PhotoMain:           photoMain,
+		PhotoRotates:        photoRotates,
+		PhotoDetails:        photoDetails,
+		CreatedAt:           product.CreatedAt.Format("2006-01-02 15:04:05"),
+	}
+
+	return reProductInfo, nil
+}
+
+// 更新商品
+func (p ProductService) UpdateProduct(param *vo.ProductUpdateParam) (int64, error) {
+	newProduct := entity.Product{
+		ProductID:           param.ProductId,
+		ProductName:         param.ProductName,
+		ProductCategory:     param.ProductCategory,
+		ProductPrice:        param.ProductPrice,
+		ExclusiveCommission: param.ExclusiveCommission,
+		CommissionPrice:     param.CommissionPrice,
+		ProductDetail:       param.ProductDetail,
+		ProductUrl:          param.ProductUrl,
+		UpdatedAt:           time.Now(),
+	}
+	productId, err := dao.ProductDAO{}.UpdateProduct(newProduct)
+	if err != nil {
+		return 0, err
+	}
+	if param.ProductPhotos != nil {
+		productPhotos := []entity.ProductPhoto{}
+		for _, photo := range param.ProductPhotos {
+			productPhoto := entity.ProductPhoto{
+				PhotoUrl:         photo.PhotoUrl,
+				PhotoUid:         photo.PhotoUid,
+				Symbol:           photo.Symbol,
+				StoreID:          productId,
+				ProductPhotoType: 1,
+				CreatedAt:        time.Now(),
+			}
+			productPhotos = append(productPhotos, productPhoto)
+		}
+		err = dao.ProductPhotoDAO{}.CreateProductPhoto(productPhotos)
+		if err != nil {
+			return 0, err
+		}
+	}
+	return productId, nil
+}
+
+// 删除商品
+func (p ProductService) DeleteProduct(param *vo.ProductUpdateParam) (int64, error) {
+	err := dao.ProductDAO{}.DeleteProduct(param.ProductId)
+	if err != nil {
+		return 0, err
+	}
+	return param.ProductId, nil
+}

+ 2 - 2
app/service/project_service.go

@@ -404,14 +404,14 @@ func (s ProjectService) GetProjectDetail(projectId string) (*vo.ReProjectDetail,
 	reProjectDetail.CreatorName = creatorName
 	reProjectDetail.Phone = phone
 	// 关联商品
-	var reProduct vo.ReTaskProduct
+	var reProduct vo.ReProductPreview
 	product, err := dao.ProductDAO{}.GetProductByID(project.ProductID)
 	if err == nil {
 		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByProductID(product.ProductID)
 		if e != nil {
 			photoUrl = ""
 		}
-		reProduct = vo.ReTaskProduct{
+		reProduct = vo.ReProductPreview{
 			ProductID:       product.ProductID,
 			ProductName:     product.ProductName,
 			ProductType:     product.ProductType,

+ 2 - 2
app/service/selection_info_service.go

@@ -324,14 +324,14 @@ func (s SelectionInfoService) GetSelectionDetail(selectionId string) (*vo.ReSele
 	reSelectionDetail.CreatorName = creatorName
 	reSelectionDetail.Phone = phone
 	// 关联商品
-	var reProduct vo.ReTaskProduct
+	var reProduct vo.ReProductPreview
 	product, err := dao.ProductDAO{}.GetProductByID(selection.ProductID)
 	if err == nil {
 		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByProductID(product.ProductID)
 		if e != nil {
 			photoUrl = ""
 		}
-		reProduct = vo.ReTaskProduct{
+		reProduct = vo.ReProductPreview{
 			ProductID:       product.ProductID,
 			ProductName:     product.ProductName,
 			ProductType:     product.ProductType,

+ 92 - 2
app/service/store_service.go

@@ -30,13 +30,13 @@ func (p StoreService) GetStoresByEnterpriseId(param vo.GetAllStoreParam) (vo.Res
 		// 数据库查询error
 		return result, err
 	}
-	var reStores []vo.ReStore
+	var reStores []vo.ReStorePreview
 	for _, store := range stores {
 		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(store.StoreID)
 		if e != nil {
 			photoUrl = ""
 		}
-		reStore := vo.ReStore{
+		reStore := vo.ReStorePreview{
 			StoreID:       store.StoreID,
 			StoreName:     store.StoreName,
 			StoreLocation: store.StoreLocation,
@@ -58,6 +58,7 @@ func (p StoreService) GetStoresByEnterpriseId(param vo.GetAllStoreParam) (vo.Res
 	return result, nil
 }
 
+// 新建门店
 func (p StoreService) CreateStore(param *vo.StoreCreateParam) (int64, error) {
 	newStore := entity.Store{
 		StoreName:          param.StoreName,
@@ -96,3 +97,92 @@ func (p StoreService) CreateStore(param *vo.StoreCreateParam) (int64, error) {
 	}
 	return storeId, nil
 }
+
+// 门店详情
+func (s StoreService) GetStoreDetail(param *vo.StoreSearchParam) (*vo.ReStoreInfo, error) {
+	var reStoreInfo *vo.ReStoreInfo
+	store, err := dao.StoreDao{}.GetStoreByID(param.StoreId)
+	if err != nil {
+		return nil, err
+	}
+	photoMain, _ := dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(param.StoreId)
+	photosAll, _ := dao.ProductPhotoDAO{}.GetProductPhotoByStoreID(param.StoreId)
+	var photoRotates []vo.Photo
+	var photoDetails []vo.Photo
+	for _, photosOne := range photosAll {
+		if photosOne.Symbol == 2 || photosOne.Symbol == 3 {
+			photo := vo.Photo{
+				PhotoUrl: photosOne.PhotoUrl,
+				Symbol:   photosOne.Symbol,
+			}
+			photoRotates = append(photoRotates, photo)
+		} else if photosOne.Symbol == 4 || photosOne.Symbol == 5 {
+			photo := vo.Photo{
+				PhotoUrl: photosOne.PhotoUrl,
+				Symbol:   photosOne.Symbol,
+			}
+			photoDetails = append(photoDetails, photo)
+		}
+	}
+	reStoreInfo = &vo.ReStoreInfo{
+		StoreID:       store.StoreID,
+		StoreName:     store.StoreName,
+		StoreCategory: store.StoreCategory,
+		StoreType:     store.StoreType,
+		StoreLocation: store.StoreLocation,
+		TeamNum:       store.TeamNum,
+		StoreDetail:   store.StoreDetail,
+		PhotoMain:     photoMain,
+		PhotoRotates:  photoRotates,
+		PhotoDetails:  photoDetails,
+		CreatedAt:     store.CreatedAt.Format("2006-01-02 15:04:05"),
+	}
+
+	return reStoreInfo, nil
+}
+
+// 更新门店
+func (p StoreService) UpdateStore(param *vo.StoreUpdateParam) (int64, error) {
+	newStore := entity.Store{
+		StoreID:       param.StoreId,
+		StoreName:     param.StoreName,
+		StoreCategory: param.StoreCategory,
+		StoreType:     param.StoreType,
+		StoreLocation: param.StoreLocation,
+		StoreDetail:   param.StoreDetail,
+		StoreLink:     param.StoreLink,
+		UpdatedAt:     time.Now(),
+	}
+	storeId, err := dao.StoreDao{}.UpdateStore(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
+}
+
+// 删除门店
+func (p StoreService) DeleteStore(param *vo.StoreUpdateParam) (int64, error) {
+	err := dao.StoreDao{}.DeleteStore(param.StoreId)
+	if err != nil {
+		return 0, err
+	}
+	return param.StoreId, nil
+}

+ 96 - 2
app/service/teambuying_service.go

@@ -26,13 +26,13 @@ func (p TeamBuyingService) GetTeamBuyingsByStoreId(param vo.GetAllTeamBuyingPara
 		// 数据库查询error
 		return result, err
 	}
-	var reTeamBuyings []vo.ReTeamBuying
+	var reTeamBuyings []vo.ReTeamBuyingPreview
 	for _, teamBuying := range teamBuyings {
 		photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByTeamBuyingID(teamBuying.TeamBuyingID)
 		if e != nil {
 			photoUrl = ""
 		}
-		reTeamBuying := vo.ReTeamBuying{
+		reTeamBuying := vo.ReTeamBuyingPreview{
 			TeamBuyingID:       teamBuying.TeamBuyingID,
 			TeamBuyingName:     teamBuying.TeamBuyingName,
 			TeamBuyingPrice:    teamBuying.TeamBuyingPrice,
@@ -52,6 +52,7 @@ func (p TeamBuyingService) GetTeamBuyingsByStoreId(param vo.GetAllTeamBuyingPara
 	return result, nil
 }
 
+// 新建团购
 func (p TeamBuyingService) CreateTeamBuying(param *vo.TeamBuyingCreateParam) (int64, error) {
 	newTeamBuying := entity.TeamBuying{
 		TeamBuyingName:     param.TeamBuyingName,
@@ -70,6 +71,10 @@ func (p TeamBuyingService) CreateTeamBuying(param *vo.TeamBuyingCreateParam) (in
 	if err != nil {
 		return 0, err
 	}
+	err = dao.StoreDao{}.IncrementTeamNum(param.StoreId)
+	if err != nil {
+		return 0, err
+	}
 	if param.TeamBuyingPhotos != nil {
 		teamBuyingPhotos := []entity.ProductPhoto{}
 		for _, photo := range param.TeamBuyingPhotos {
@@ -90,3 +95,92 @@ func (p TeamBuyingService) CreateTeamBuying(param *vo.TeamBuyingCreateParam) (in
 	}
 	return teamBuyingId, nil
 }
+
+// 团购详情
+func (s TeamBuyingService) GetTeamBuyingDetail(param *vo.TeamBuyingSearchParam) (*vo.ReTeamBuyingInfo, error) {
+	var reTeamBuyingInfo *vo.ReTeamBuyingInfo
+	teamBuying, err := dao.TeamBuyingDao{}.GetTeamBuyingByID(param.TeamBuyingId)
+	if err != nil {
+		return nil, err
+	}
+	photoMain, _ := dao.ProductPhotoDAO{}.GetMainPhotoByTeamBuyingID(param.TeamBuyingId)
+	photosAll, _ := dao.ProductPhotoDAO{}.GetProductPhotoByTeamBuyingID(param.TeamBuyingId)
+	var photoRotates []vo.Photo
+	var photoDetails []vo.Photo
+	for _, photosOne := range photosAll {
+		if photosOne.Symbol == 2 || photosOne.Symbol == 3 {
+			photo := vo.Photo{
+				PhotoUrl: photosOne.PhotoUrl,
+				Symbol:   photosOne.Symbol,
+			}
+			photoRotates = append(photoRotates, photo)
+		} else if photosOne.Symbol == 4 || photosOne.Symbol == 5 {
+			photo := vo.Photo{
+				PhotoUrl: photosOne.PhotoUrl,
+				Symbol:   photosOne.Symbol,
+			}
+			photoDetails = append(photoDetails, photo)
+		}
+	}
+	reTeamBuyingInfo = &vo.ReTeamBuyingInfo{
+		TeamBuyingID:       teamBuying.StoreID,
+		TeamBuyingName:     teamBuying.TeamBuyingName,
+		TeamBuyingPrice:    teamBuying.TeamBuyingPrice,
+		PublicCommission:   teamBuying.PublicCommission,
+		TeamBuyingCategory: teamBuying.TeamBuyingCategory,
+		TeamBuyingDetail:   teamBuying.TeamBuyingDetail,
+		TeamBuyingLink:     teamBuying.TeamBuyingLink,
+		PhotoMain:          photoMain,
+		PhotoRotates:       photoRotates,
+		PhotoDetails:       photoDetails,
+		CreatedAt:          teamBuying.CreatedAt.Format("2006-01-02 15:04:05"),
+	}
+
+	return reTeamBuyingInfo, nil
+}
+
+// 更新团购
+func (p TeamBuyingService) UpdateTeamBuying(param *vo.TeamBuyingUpdateParam) (int64, error) {
+	newTeamBuying := entity.TeamBuying{
+		TeamBuyingID:       param.TeamBuyingId,
+		TeamBuyingName:     param.TeamBuyingName,
+		TeamBuyingCategory: param.TeamBuyingCategory,
+		TeamBuyingPrice:    param.TeamBuyingPrice,
+		PublicCommission:   param.PublicCommission,
+		TeamBuyingDetail:   param.TeamBuyingDetail,
+		TeamBuyingLink:     param.TeamBuyingLink,
+		UpdatedAt:          time.Now(),
+	}
+	teamBuyingId, err := dao.TeamBuyingDao{}.UpdateTeamBuying(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,
+				StoreID:          teamBuyingId,
+				ProductPhotoType: 3,
+				CreatedAt:        time.Now(),
+			}
+			teamBuyingPhotos = append(teamBuyingPhotos, teamBuyingPhoto)
+		}
+		err = dao.ProductPhotoDAO{}.CreateProductPhoto(teamBuyingPhotos)
+		if err != nil {
+			return 0, err
+		}
+	}
+	return teamBuyingId, nil
+}
+
+// 删除团购
+func (p TeamBuyingService) DeleteTeamBuying(param *vo.TeamBuyingUpdateParam) (int64, error) {
+	err := dao.TeamBuyingDao{}.DeleteTeamBuying(param.TeamBuyingId)
+	if err != nil {
+		return 0, err
+	}
+	return param.TeamBuyingId, nil
+}

+ 6 - 0
app/vo/product_search_param.go

@@ -0,0 +1,6 @@
+package vo
+
+type ProductSearchParam struct {
+	ProductId int64 `json:"product_id"`
+	//EnterpriseId string `json:"enterprise_id"`
+}

+ 14 - 0
app/vo/product_update_param.go

@@ -0,0 +1,14 @@
+package vo
+
+type ProductUpdateParam struct {
+	ProductId           int64          `json:"product_id"`           // 商品ID(注:非导入解析项商品ID)
+	ProductName         string         `json:"product_name"`         // 商品标题
+	ProductCategory     string         `json:"product_category"`     // 商品类目
+	ProductPrice        float64        `json:"product_price"`        // 商品价值
+	ExclusiveCommission float64        `json:"exclusive_commission"` // 专属佣金
+	CommissionPrice     float64        `json:"commission_price"`     // 佣金金额
+	ProductDetail       string         `json:"product_detail"`       // 卖点总结
+	ProductPhotos       []ProductPhoto `json:"product_photos"`       // 商品图片列表
+	ProductUrl          string         `json:"product_url"`          // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;
+	PublicCommission    float64        `json:"public_commission"`    // 公开佣金
+}

+ 4 - 4
app/vo/re_local_detail.go

@@ -16,10 +16,10 @@ type ReLocalDetail struct {
 	ServiceChargeRate float64 `json:"serviceChargeRate"` // 公开服务费率
 	// 支付方式参数待定
 	// 关联主体
-	StoreInfo      *ReStore      `json:"storeInfo"`
-	PromoteBody    int64         `json:"promoteBody"`
-	TeamBuyingInfo *ReTeamBuying `json:"teamBuyingInfo"`
-	Donate         int64         `json:"donate"`
+	StoreInfo      *ReStorePreview      `json:"storeInfo"`
+	PromoteBody    int64                `json:"promoteBody"`
+	TeamBuyingInfo *ReTeamBuyingPreview `json:"teamBuyingInfo"`
+	Donate         int64                `json:"donate"`
 	// 招募要求
 	TalentType       string                  `json:"talentType"`
 	RecruitDdl       string                  `json:"recruitDdl"`

+ 16 - 0
app/vo/re_product_info.go

@@ -0,0 +1,16 @@
+package vo
+
+type ReProductInfo struct {
+	ProductID           int64   `json:"productId"`
+	ProductName         string  `json:"productName"`
+	ProductCategory     string  `json:"productCategory"`
+	ProductPrice        float64 `json:"productPrice"`
+	ExclusiveCommission float64 `json:"exclusiveCommission"` // 专属佣金
+	CommissionPrice     float64 `json:"commissionPrice"`     // 佣金金额
+	ProductDetail       string  `json:"productDetail"`       // 卖点总结
+	ProductUrl          string  `json:"product_url"`         // 商品链接
+	CreatedAt           string  `json:"createdAt"`
+	PhotoMain           string  `json:"photoMail"`    // 门店主图
+	PhotoRotates        []Photo `json:"photoRotates"` // 轮播图
+	PhotoDetails        []Photo `json:"photoDetails"` // 详情图`
+}

+ 1 - 1
app/vo/re_task_product.go → app/vo/re_product_preview.go

@@ -1,6 +1,6 @@
 package vo
 
-type ReTaskProduct struct {
+type ReProductPreview struct {
 	ProductID       int64   `json:"productId"`
 	ProductName     string  `json:"productName"`
 	ProductType     int64   `json:"productType"`

+ 1 - 1
app/vo/re_project_detail.go

@@ -16,7 +16,7 @@ type ReProjectDetail struct {
 	ServiceChargeRate float64 `json:"serviceChargeRate"` // 公开服务费率
 	// 支付方式参数待定
 	// 关联商品
-	ProductInfo *ReTaskProduct `json:"productInfo"`
+	ProductInfo *ReProductPreview `json:"productInfo"`
 	// 招募要求
 	TalentType       string                    `json:"talentType"`
 	RecruitDdl       string                    `json:"recruitDdl"`

+ 1 - 1
app/vo/re_selection_detail.go

@@ -16,7 +16,7 @@ type ReSelectionDetail struct {
 	SubmitAt          string  `json:"submitAt"`          // 提交审核时间
 	// 支付方式参数待定
 	// 关联商品
-	ProductInfo *ReTaskProduct `json:"productInfo"`
+	ProductInfo *ReProductPreview `json:"productInfo"`
 	// 样品奖励
 	TaskDdl         string                   `json:"taskDdl"`
 	SampleNum       int64                    `json:"sampleNum"` // 样品数量

+ 20 - 0
app/vo/re_store_info.go

@@ -0,0 +1,20 @@
+package vo
+
+type ReStoreInfo struct {
+	StoreID       int64   `json:"storeId"`
+	StoreName     string  `json:"storeName"`
+	StoreCategory string  `json:"storeCategory"` // 门店类目
+	StoreType     int64   `json:"storeType"`     // 门店类型 1单门店,2连锁门店
+	StoreLocation string  `json:"storeLocation"`
+	TeamNum       int64   `json:"teamNum"` // 包含团购套餐
+	StoreDetail   string  `json:"storeDetail"`
+	CreatedAt     string  `json:"createdAt"`
+	PhotoMain     string  `json:"photoMain"`    // 门店主图
+	PhotoRotates  []Photo `json:"photoRotates"` // 轮播图
+	PhotoDetails  []Photo `json:"photoDetails"` // 详情图
+}
+
+type Photo struct {
+	PhotoUrl string `json:"photoUrl"`
+	Symbol   int64  `json:"symbol"` // 标志位,1为主图,2为轮播图,3为轮播图视频,4详情图,5详情图视频
+}

+ 1 - 1
app/vo/re_store.go → app/vo/re_store_preview.go

@@ -1,6 +1,6 @@
 package vo
 
-type ReStore struct {
+type ReStorePreview struct {
 	StoreID       int64  `json:"storeId"`
 	StoreName     string `json:"storeName"`
 	StoreLocation string `json:"storeLocation"`

+ 15 - 0
app/vo/re_teambuying_info.go

@@ -0,0 +1,15 @@
+package vo
+
+type ReTeamBuyingInfo struct {
+	TeamBuyingID       int64   `json:"teamBuyingId"`
+	TeamBuyingName     string  `json:"teamBuyingName"`
+	TeamBuyingPrice    float64 `json:"teamBuyingPrice"`
+	PublicCommission   int64   `json:"publicCommission"`   // 公开佣金%
+	TeamBuyingCategory string  `json:"teamBuyingCategory"` // 团购类目
+	TeamBuyingDetail   string  `json:"teamBuyingDetail"`
+	TeamBuyingLink     string  `json:"teamBuyingLink"` // 分销链接
+	CreatedAt          string  `json:"createdAt"`
+	PhotoMain          string  `json:"photoMail"`    // 门店主图
+	PhotoRotates       []Photo `json:"photoRotates"` // 轮播图
+	PhotoDetails       []Photo `json:"photoDetails"` // 详情图
+}

+ 1 - 1
app/vo/re_teambuying.go → app/vo/re_teambuying_preview.go

@@ -1,6 +1,6 @@
 package vo
 
-type ReTeamBuying struct {
+type ReTeamBuyingPreview struct {
 	TeamBuyingID       int64   `json:"teamBuyingId"`
 	TeamBuyingName     string  `json:"teamBuyingName"`
 	TeamBuyingPrice    float64 `json:"teamBuyingPrice"`

+ 6 - 0
app/vo/store_search_param.go

@@ -0,0 +1,6 @@
+package vo
+
+type StoreSearchParam struct {
+	StoreId int64 `json:"store_id"`
+	//EnterpriseId string `json:"enterprise_id"`
+}

+ 12 - 0
app/vo/store_update_param.go

@@ -0,0 +1,12 @@
+package vo
+
+type StoreUpdateParam struct {
+	StoreId       int64        `json:"store_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"`   // 图片列表
+}

+ 6 - 0
app/vo/teambuying_search_param.go

@@ -0,0 +1,6 @@
+package vo
+
+type TeamBuyingSearchParam struct {
+	TeamBuyingId int64 `json:"team_buying_id"`
+	//StoreId      int64 `json:"store_id"`
+}

+ 12 - 0
app/vo/teambuying_update_param.go

@@ -0,0 +1,12 @@
+package vo
+
+type TeamBuyingUpdateParam struct {
+	TeamBuyingId       int64             `json:"team_buying_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"`   // 图片列表
+}

+ 21 - 8
route/init.go

@@ -215,16 +215,10 @@ func InitRoute(r *gin.Engine) {
 		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("/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)              // 更新公开本地生活任务
@@ -274,5 +268,24 @@ func InitRoute(r *gin.Engine) {
 		cooperation.POST("/inPool", controller.CooperationController{}.GetEnterprisePoolList)         // 在库服务商列表
 		cooperation.POST("/confirming", controller.CooperationController{}.GetSupplierConfirmingList) // 邀请待确认服务商列表
 	}
+	// 推广合作-商品管理相关接口
+	product := r.Group("/youngee/b/cooperation/product")
+	{
+		product.Use(middleware.LoginAuthMiddleware)
+		product.POST("/detail", controller.CooperationController{}.GetProductDetail) // 商品详情
+		product.POST("/update", controller.CooperationController{}.UpdateProduct)    // 更新商品
+		product.POST("/del", controller.CooperationController{}.DeleteProduct)       // 删除商品
+	}
+	// 推广合作-门店管理相关接口
+	store := r.Group("/youngee/b/cooperation/store")
+	{
+		store.Use(middleware.LoginAuthMiddleware)
+		store.POST("/detail", controller.CooperationController{}.GetStoreDetail)                 // 门店详情
+		store.POST("/update", controller.CooperationController{}.UpdateStore)                    // 更新门店
+		store.POST("/del", controller.CooperationController{}.DeleteStore)                       // 删除门店
+		store.POST("/teamBuying/detail", controller.CooperationController{}.GetTeamBuyingDetail) // 团购详情
+		store.POST("/teamBuying/update", controller.CooperationController{}.UpdateTeamBuying)    // 更新团购
+		store.POST("/teamBuying/del", controller.CooperationController{}.DeleteTeamBuying)       // 删除团购
+	}
 
 }