|
@@ -3,6 +3,7 @@ package service
|
|
|
import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
+ "github.com/issue9/conv"
|
|
|
"github.com/sirupsen/logrus"
|
|
|
"youngee_b_api/db"
|
|
|
"youngee_b_api/model/common_model"
|
|
@@ -39,21 +40,20 @@ func (*localLife) GetFullLocalLifeList(ctx context.Context, pageSize, pageNum in
|
|
|
}
|
|
|
|
|
|
// 2. 查询本地生活补充信息:门店信息,招募策略
|
|
|
- for _, project := range fullLocalData.FullPreview {
|
|
|
+ for _, local := range fullLocalData.FullPreview {
|
|
|
|
|
|
// 2.1. 门店信息
|
|
|
- storeInfo, productErr := db.FindStoreById(ctx, project.StoreId)
|
|
|
+ storeInfo, productErr := db.FindStoreById(ctx, local.StoreId)
|
|
|
if productErr != nil {
|
|
|
return nil, productErr
|
|
|
}
|
|
|
if storeInfo != nil {
|
|
|
- project.StoreId = storeInfo.StoreId
|
|
|
- // project.ProductPrice = storeInfo.S
|
|
|
- project.StoreName = storeInfo.StoreName
|
|
|
+ local.StoreId = storeInfo.StoreId
|
|
|
+ local.StoreName = storeInfo.StoreName
|
|
|
}
|
|
|
|
|
|
// 2.2. 门店图片信息
|
|
|
- productPhotoInfo, productPhotoErr := db.GetStorePhotoByStoreID(ctx, project.StoreId)
|
|
|
+ productPhotoInfo, productPhotoErr := db.GetStorePhotoByStoreID(ctx, local.StoreId)
|
|
|
if productPhotoErr != nil {
|
|
|
return nil, productPhotoErr
|
|
|
}
|
|
@@ -61,15 +61,15 @@ func (*localLife) GetFullLocalLifeList(ctx context.Context, pageSize, pageNum in
|
|
|
for _, photo := range productPhotoInfo {
|
|
|
fmt.Println(photo)
|
|
|
if photo.Symbol == 1 {
|
|
|
- project.ProductPhotoSymbol = 1
|
|
|
- project.ProductPhotoUrl = photo.PhotoUrl
|
|
|
- project.ProductPhotoUid = photo.PhotoUid
|
|
|
+ local.ProductPhotoSymbol = 1
|
|
|
+ local.ProductPhotoUrl = photo.PhotoUrl
|
|
|
+ local.ProductPhotoUid = photo.PhotoUid
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 2.3. 招募策略信息
|
|
|
- recruitStrategyInfo, recruitErr := db.GetRecruitStrategyByProjectId(ctx, project.LocalId)
|
|
|
+ recruitStrategyInfo, recruitErr := db.GetRecruitStrategyByProjectId(ctx, local.LocalId)
|
|
|
if recruitErr != nil {
|
|
|
return nil, recruitErr
|
|
|
}
|
|
@@ -80,20 +80,85 @@ func (*localLife) GetFullLocalLifeList(ctx context.Context, pageSize, pageNum in
|
|
|
recruitStrategy.StrategyId = strategy.StrategyID
|
|
|
recruitStrategy.FeeForm = strategy.FeeForm
|
|
|
recruitStrategy.RecruitNumber = strategy.RecruitNumber
|
|
|
- project.RecruitStrategy = append(project.RecruitStrategy, recruitStrategy)
|
|
|
+ local.RecruitStrategy = append(local.RecruitStrategy, recruitStrategy)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 2.4. 判断是否加入商单
|
|
|
- //sProjectCount, sProjectErr := db.UpdateSProjectByProjectIdAndSupplierId(ctx, project.LocalId, supplierId)
|
|
|
- //if sProjectErr != nil {
|
|
|
- // return nil, sProjectErr
|
|
|
- //}
|
|
|
- //if sProjectCount > 0 {
|
|
|
- // project.AddToListStatus = 1
|
|
|
- //} else {
|
|
|
- // project.AddToListStatus = 2
|
|
|
- //}
|
|
|
+ sProjectCount, sProjectErr := db.FindSLocalByLocalIdAndSupplierId(ctx, local.LocalId, supplierId)
|
|
|
+ if sProjectErr != nil {
|
|
|
+ return nil, sProjectErr
|
|
|
+ }
|
|
|
+ if sProjectCount > 0 {
|
|
|
+ local.AddToListStatus = 1
|
|
|
+ } else {
|
|
|
+ local.AddToListStatus = 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return fullLocalData, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (*localLife) GetFullSLocalLifeList(ctx context.Context, pageSize, pageNum int32, supplierId int, condition *common_model.SLocalLifeCondition) (*http_model.FullSLocalListData, error) {
|
|
|
+
|
|
|
+ // 1. 查询本地生活任务基本信息
|
|
|
+ fullLocals, total, err := db.GetFullSLocalLifeList(ctx, pageSize, pageNum, condition)
|
|
|
+ if err != nil {
|
|
|
+ logrus.WithContext(ctx).Errorf("[fullLocals service] call GetFullSLocalLifeList error,err:%+v", err)
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ var fullLocalData *http_model.FullSLocalListData
|
|
|
+ fullLocalData = &http_model.FullSLocalListData{}
|
|
|
+ fullLocalData.Total = total
|
|
|
+ for _, fullLocal := range fullLocals {
|
|
|
+ var fullLocalPreview *http_model.FullSLocalPreview
|
|
|
+ fullLocalPreview = &http_model.FullSLocalPreview{}
|
|
|
+ fullLocalPreview.LocalId = fullLocal.LocalId
|
|
|
+ fullLocalPreview.TaskStatus = fullLocal.TaskStatus
|
|
|
+ fullLocalPreview.LocalPlatform = fullLocal.LocalPlatform
|
|
|
+ fullLocalPreview.TaskForm = fullLocal.TaskForm
|
|
|
+ fullLocalPreview.LocalType = fullLocal.LocalType
|
|
|
+ fullLocalPreview.LocalContentType = fullLocal.ContentType
|
|
|
+ fullLocalPreview.SupplierId = supplierId
|
|
|
+ fullLocalPreview.SubAccountId = fullLocal.SubAccountId
|
|
|
+ fullLocalPreview.OperatorType = fullLocal.OperatorType
|
|
|
+ fullLocalPreview.CreateTime = conv.MustString(fullLocal.CreateTime)
|
|
|
+ fullLocalPreview.ServiceCharge = fullLocal.ServiceCharge
|
|
|
+ fullLocalPreview.ServiceChargeActual = fullLocal.ServiceChargeActual
|
|
|
+ fullLocalPreview.ApplyNum = fullLocal.ApplyNum
|
|
|
+ fullLocalPreview.RecruitNum = fullLocal.RecruitNum
|
|
|
+ fullLocalPreview.SettleNum = fullLocal.SettleNum
|
|
|
+ fullLocalData.FullSLocalPreview = append(fullLocalData.FullSLocalPreview, fullLocalPreview)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 查询本地生活补充信息:门店信息,招募策略
|
|
|
+ for _, local := range fullLocalData.FullSLocalPreview {
|
|
|
+
|
|
|
+ // 2.1. 门店信息
|
|
|
+ storeInfo, productErr := db.FindStoreById(ctx, local.StoreId)
|
|
|
+ if productErr != nil {
|
|
|
+ return nil, productErr
|
|
|
+ }
|
|
|
+ if storeInfo != nil {
|
|
|
+ local.StoreId = storeInfo.StoreId
|
|
|
+ local.StoreName = storeInfo.StoreName
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2. 门店图片信息
|
|
|
+ productPhotoInfo, productPhotoErr := db.GetStorePhotoByStoreID(ctx, local.StoreId)
|
|
|
+ if productPhotoErr != nil {
|
|
|
+ return nil, productPhotoErr
|
|
|
+ }
|
|
|
+ if productPhotoInfo != nil {
|
|
|
+ for _, photo := range productPhotoInfo {
|
|
|
+ fmt.Println(photo)
|
|
|
+ if photo.Symbol == 1 {
|
|
|
+ local.ProductPhotoSymbol = 1
|
|
|
+ local.ProductPhotoUrl = photo.PhotoUrl
|
|
|
+ local.ProductPhotoUid = photo.PhotoUid
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return fullLocalData, nil
|
|
|
}
|