|
@@ -2,6 +2,7 @@ package service
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "github.com/issue9/conv"
|
|
|
"youngee_b_api/db"
|
|
|
"youngee_b_api/model/gorm_model"
|
|
|
"youngee_b_api/model/http_model"
|
|
@@ -13,7 +14,7 @@ type sLocalLife struct {
|
|
|
}
|
|
|
|
|
|
// CreateSLocalLife 新建服务商加入商单后的公开本地生活
|
|
|
-func (*sLocalLife) CreateSLocalLife(ctx context.Context, request http_model.LocalLifeAddToListRequest) error {
|
|
|
+func (*sLocalLife) CreateSLocalLife(ctx context.Context, request *http_model.LocalLifeAddToListRequest) error {
|
|
|
var sLocalLifeInfo *gorm_model.YounggeeSLocalLifeInfo
|
|
|
sLocalLifeInfo = &gorm_model.YounggeeSLocalLifeInfo{}
|
|
|
|
|
@@ -24,11 +25,147 @@ func (*sLocalLife) CreateSLocalLife(ctx context.Context, request http_model.Loca
|
|
|
return localErr
|
|
|
}
|
|
|
if localLifeInfo != nil {
|
|
|
- sLocalLifeInfo.LocalLifeId = localLifeInfo.LocalId
|
|
|
+ sLocalLifeInfo.LocalId = localLifeInfo.LocalId
|
|
|
sLocalLifeInfo.SettleNum = 0
|
|
|
sLocalLifeInfo.RecruitNum = 0
|
|
|
sLocalLifeInfo.ApplyNum = 0
|
|
|
- }
|
|
|
+ sLocalLifeInfo.LocalType = localLifeInfo.LocalType
|
|
|
+ sLocalLifeInfo.LocalPlatform = localLifeInfo.LocalPlatform
|
|
|
+ sLocalLifeInfo.TaskStatus = localLifeInfo.TaskStatus
|
|
|
+ sLocalLifeInfo.StoreId = localLifeInfo.StoreId
|
|
|
+ sLocalLifeInfo.TeamBuyingId = localLifeInfo.TeamBuyingId
|
|
|
+ sLocalLifeInfo.TaskForm = localLifeInfo.TaskForm
|
|
|
+ sLocalLifeInfo.ContentType = localLifeInfo.ContentType
|
|
|
+ sLocalLifeInfo.SLocalStatus = 2
|
|
|
+
|
|
|
+ // 1.2. 填入加入商单操作人信息
|
|
|
+ sLocalLifeInfo.SubAccountId = request.SubAccountId
|
|
|
+ sLocalLifeInfo.SupplierId = request.SupplierId
|
|
|
+ sLocalLifeInfo.OperatorType = request.OperatorType
|
|
|
|
|
|
+ // 2. 入库
|
|
|
+ createErr := db.CreateSLocalLife(ctx, sLocalLifeInfo)
|
|
|
+ if createErr != nil {
|
|
|
+ return createErr
|
|
|
+ }
|
|
|
+ }
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+func (*sLocalLife) ShowSLocalLife(ctx context.Context, req *http_model.ShowSLocalRequest) (*http_model.ShowSLocalData, error) {
|
|
|
+ var sLocalInfo *http_model.ShowSLocalData
|
|
|
+ sLocalInfo = &http_model.ShowSLocalData{}
|
|
|
+
|
|
|
+ // 1. 查询系统信息
|
|
|
+ localInfo, localErr := db.GetLocalLifeDetail(ctx, req.LocalId)
|
|
|
+ if localErr != nil {
|
|
|
+ return nil, localErr
|
|
|
+ }
|
|
|
+ if localInfo != nil {
|
|
|
+ sLocalInfo.LocalId = localInfo.LocalId
|
|
|
+ sLocalInfo.SLocalId = req.SLocalId
|
|
|
+ sLocalInfo.LocalPlatform = localInfo.LocalPlatform
|
|
|
+ sLocalInfo.TaskStatus = localInfo.TaskStatus
|
|
|
+ sLocalInfo.EnterpriseId = localInfo.EnterpriseId
|
|
|
+ sLocalInfo.ServiceChargeRate = localInfo.ServiceChargeRate
|
|
|
+ sLocalInfo.EstimatedCost = localInfo.EstimatedCost
|
|
|
+ sLocalInfo.CreateAt = conv.MustString(localInfo.CreatedAt)
|
|
|
+
|
|
|
+ // 2. 关联主体
|
|
|
+ // 2.1. 门店信息
|
|
|
+ storeInfo, storeErr := db.FindStoreById(ctx, localInfo.StoreId)
|
|
|
+ if storeErr != nil {
|
|
|
+ return nil, storeErr
|
|
|
+ }
|
|
|
+ if storeInfo != nil {
|
|
|
+ sLocalInfo.StoreId = storeInfo.StoreId
|
|
|
+ sLocalInfo.StoreName = storeInfo.StoreName
|
|
|
+ sLocalInfo.StoreCategory = storeInfo.StoreCategory
|
|
|
+ sLocalInfo.StoreRelatedAt = conv.MustString(localInfo.StoreRelatedAt)
|
|
|
+
|
|
|
+ // 2.2. 门店图片信息
|
|
|
+ storePhotoInfo, storePhotoErr := db.GetStorePhotoByStoreID(ctx, localInfo.StoreId)
|
|
|
+ if storePhotoErr != nil {
|
|
|
+ return nil, storePhotoErr
|
|
|
+ }
|
|
|
+ if storePhotoInfo != nil {
|
|
|
+ for _, photo := range storePhotoInfo {
|
|
|
+ if photo.Symbol == 1 {
|
|
|
+ sLocalInfo.StoreMainPhotoSymbol = 1
|
|
|
+ sLocalInfo.StoreMainPhotoUrl = photo.PhotoUrl
|
|
|
+ sLocalInfo.StoreMainPhotoUid = photo.PhotoUid
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.3. 团购信息
|
|
|
+ teamInfo, teamErr := db.FindTeamById(ctx, localInfo.StoreId)
|
|
|
+ if teamErr != nil {
|
|
|
+ return nil, teamErr
|
|
|
+ }
|
|
|
+ if teamInfo != nil {
|
|
|
+ sLocalInfo.TeamBuyingId = teamInfo.StoreId
|
|
|
+ sLocalInfo.TeamBuyingName = teamInfo.TeamBuyingName
|
|
|
+ sLocalInfo.TeamBuyingCategory = teamInfo.TeamBuyingCategory
|
|
|
+ sLocalInfo.TeamBuyingRelatedAt = conv.MustString(localInfo.TeamBuyingRelatedAt)
|
|
|
+
|
|
|
+ // 2.4. 团购图片信息
|
|
|
+ teamPhotoInfo, teamPhotoErr := db.GetTeamPhotoByStoreID(ctx, localInfo.StoreId)
|
|
|
+ if teamPhotoErr != nil {
|
|
|
+ return nil, teamPhotoErr
|
|
|
+ }
|
|
|
+ if teamPhotoInfo != nil {
|
|
|
+ for _, photo := range teamPhotoInfo {
|
|
|
+ if photo.Symbol == 1 {
|
|
|
+ sLocalInfo.TeamMainPhotoSymbol = 1
|
|
|
+ sLocalInfo.TeamMainPhotoUrl = photo.PhotoUrl
|
|
|
+ sLocalInfo.TeamMainPhotoUid = photo.PhotoUid
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 招募要求
|
|
|
+ sLocalInfo.TalentType = localInfo.TalentType
|
|
|
+ sLocalInfo.RecruitDdl = conv.MustString(localInfo.RecruitDdl)
|
|
|
+ recruitStrategy, recruitErr := db.GetRecruitStrategyBySLocalId(ctx, req.SLocalId)
|
|
|
+ if recruitErr != nil {
|
|
|
+ return nil, recruitErr
|
|
|
+ }
|
|
|
+ if recruitStrategy != nil {
|
|
|
+ for _, strategy := range recruitStrategy {
|
|
|
+ showStrategy := http_model.ShowSRecruitStrategy{
|
|
|
+ StrategyID: strategy.StrategyID,
|
|
|
+ FeeForm: strategy.FeeForm,
|
|
|
+ FollowersLow: strategy.FollowersLow,
|
|
|
+ FollowersUp: strategy.FollowersUp,
|
|
|
+ RecruitNumber: strategy.RecruitNumber,
|
|
|
+ Offer: strategy.Offer,
|
|
|
+ }
|
|
|
+ sLocalInfo.RecruitStrategys = append(sLocalInfo.RecruitStrategys, showStrategy)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4. 执行要求
|
|
|
+ sLocalInfo.TaskForm = localInfo.TaskForm
|
|
|
+ sLocalInfo.ContentType = localInfo.ContentType
|
|
|
+ briefInfo, briefErr := db.FindBriefByLocalId(ctx, req.LocalId)
|
|
|
+ if briefErr != nil {
|
|
|
+ return nil, briefErr
|
|
|
+ }
|
|
|
+ if briefInfo != nil {
|
|
|
+ sLocalInfo.LocalBrief = briefInfo
|
|
|
+ }
|
|
|
+ materialInfo, materialErr := db.FindMaterialByLocalId(ctx, req.LocalId)
|
|
|
+ if materialErr != nil {
|
|
|
+ return nil, materialErr
|
|
|
+ }
|
|
|
+ if materialInfo != nil {
|
|
|
+ sLocalInfo.LocalMaterial = materialInfo
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return sLocalInfo, nil
|
|
|
+}
|