|
@@ -17,11 +17,11 @@ import (
|
|
|
type LocalLifeService struct{}
|
|
|
|
|
|
// 创建本地生活任务
|
|
|
-func (s LocalLifeService) CreateLocalLife(param *vo.LocalCreateParam) (*string, error) {
|
|
|
+func (s LocalLifeService) CreateLocalLife(localCreateParam *vo.LocalCreateParam) (*string, error) {
|
|
|
// a) 生成本地生活项目id
|
|
|
localId := string(util.GenerateUUID(10))
|
|
|
// b) 查找关联门店信息
|
|
|
- product, err := dao.StoreDao{}.GetStoreByID(param.StoreId)
|
|
|
+ product, err := dao.StoreDao{}.GetStoreByID(localCreateParam.StoreId)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
@@ -30,43 +30,126 @@ func (s LocalLifeService) CreateLocalLife(param *vo.LocalCreateParam) (*string,
|
|
|
}
|
|
|
// c)创建种草任务
|
|
|
var operatorType int64
|
|
|
- if param.SubAccountId == 0 {
|
|
|
+ if localCreateParam.SubAccountId == 0 {
|
|
|
operatorType = 1
|
|
|
} else {
|
|
|
operatorType = 2
|
|
|
}
|
|
|
+ // d) 任务截止时间
|
|
|
+ recruitDdl := time.Time{} //赋零值
|
|
|
+ recruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", localCreateParam.RecruitDdl, time.Local)
|
|
|
// 获取定时任务配置id
|
|
|
infoAutoTask := entity.InfoAutoTask{}
|
|
|
- infoAutoTask = dao.InfoAutoTaskDao{}.GetAutoTaskLast(param.EnterpriseId)
|
|
|
+ infoAutoTask = dao.InfoAutoTaskDao{}.GetAutoTaskLast(localCreateParam.EnterpriseId)
|
|
|
infoAutoDefault := entity.InfoAutoDefault{}
|
|
|
- infoAutoDefault = dao.InfoAutoDefaultDao{}.GetAutoDefaultLast(param.EnterpriseId)
|
|
|
+ infoAutoDefault = dao.InfoAutoDefaultDao{}.GetAutoDefaultLast(localCreateParam.EnterpriseId)
|
|
|
t := time.Now()
|
|
|
newLocalLife := entity.LocalLifeInfo{
|
|
|
- EnterpriseID: param.EnterpriseId,
|
|
|
- SubAccountID: param.SubAccountId,
|
|
|
+ EnterpriseID: localCreateParam.EnterpriseId,
|
|
|
+ SubAccountID: localCreateParam.SubAccountId,
|
|
|
OperatorType: operatorType,
|
|
|
TaskStatus: 1,
|
|
|
LocalID: localId,
|
|
|
- LocalType: param.LocalType,
|
|
|
- LocalPlatform: param.Platform,
|
|
|
- StoreID: param.StoreId,
|
|
|
+ LocalType: localCreateParam.LocalType,
|
|
|
+ LocalPlatform: localCreateParam.Platform,
|
|
|
+ StoreID: localCreateParam.StoreId,
|
|
|
StoreRelatedAt: time.Now(),
|
|
|
- PromoteBody: param.PromoteBody,
|
|
|
- Donate: param.Donate,
|
|
|
- TeamBuyingId: param.TeamBuyingId,
|
|
|
+ PromoteBody: localCreateParam.PromoteBody,
|
|
|
+ Donate: localCreateParam.Donate,
|
|
|
+ TeamBuyingId: localCreateParam.TeamBuyingId,
|
|
|
TeamBuyingRelatedAt: time.Now(),
|
|
|
CreatedAt: t,
|
|
|
AutoTaskID: infoAutoTask.AutoTaskID,
|
|
|
AutoDefaultID: infoAutoDefault.AutoDefaultID,
|
|
|
+ LocalName: localCreateParam.LocalName,
|
|
|
+ TalentType: localCreateParam.TalentType,
|
|
|
+ RecruitDdl: recruitDdl,
|
|
|
+ TaskForm: localCreateParam.TaskForm,
|
|
|
+ ContentType: localCreateParam.ContentType,
|
|
|
+ TaskDetail: localCreateParam.TaskDetail,
|
|
|
}
|
|
|
- if param.LocalType == 1 {
|
|
|
- newLocalLife.ServiceChargeRate = param.ServiceChargeRate
|
|
|
+ if localCreateParam.LocalType == 1 {
|
|
|
+ newLocalLife.ServiceChargeRate = localCreateParam.ServiceChargeRate
|
|
|
}
|
|
|
err = dao.LocalLifeDao{}.CreateLocalLife(newLocalLife)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
+ // 4. 更新选品brief和示例(本地生活任务补充信息)
|
|
|
+ if localCreateParam.LocalBrief != nil {
|
|
|
+ // 插入新的brief
|
|
|
+ for _, v := range localCreateParam.LocalBrief {
|
|
|
+ brief := entity.LocalLifeBrief{
|
|
|
+ LocalID: localId,
|
|
|
+ FileUid: v.FileUid,
|
|
|
+ FileName: v.Name,
|
|
|
+ FileUrl: v.FileUrl,
|
|
|
+ CreatedAt: time.Now(),
|
|
|
+ Type: v.Type,
|
|
|
+ }
|
|
|
+ err = dao.LocalLifeBriefDao{}.CreateLocalBrief(brief)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if localCreateParam.LocalMaterial != nil {
|
|
|
+ // 删除已有示例
|
|
|
+ err = dao.LocalLifeMaterialDao{}.DeleteLocalMaterialByLocalId(localId)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 插入新的示例
|
|
|
+ for _, v := range localCreateParam.LocalMaterial {
|
|
|
+ material := entity.LocalLifeMaterial{
|
|
|
+ LocalID: localId,
|
|
|
+ FileUid: v.FileUid,
|
|
|
+ FileName: v.Name,
|
|
|
+ FileUrl: v.FileUrl,
|
|
|
+ CreatedAt: time.Now(),
|
|
|
+ Type: v.Type,
|
|
|
+ }
|
|
|
+ err = dao.LocalLifeMaterialDao{}.CreateLocalMaterial(material)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新公开种草任务的招募策略
|
|
|
+ var totalRecruitNum int64
|
|
|
+ if localCreateParam.RecruitStrategys != nil {
|
|
|
+ // 2. 接收并创建新的招募策略
|
|
|
+ if len(localCreateParam.RecruitStrategys) != 0 {
|
|
|
+ var recruits []entity.RecruitStrategy
|
|
|
+ for _, strategy := range localCreateParam.RecruitStrategys {
|
|
|
+ recruitStrategy := entity.RecruitStrategy{
|
|
|
+ FeeForm: strategy.FeeForm,
|
|
|
+ StrategyID: strategy.StrategyID,
|
|
|
+ FollowersLow: strategy.FollowersLow,
|
|
|
+ FollowersUp: strategy.FollowersUp,
|
|
|
+ RecruitNumber: strategy.RecruitNumber,
|
|
|
+ ProjectID: localId,
|
|
|
+ StrategyType: 1,
|
|
|
+ ServiceRate: localCreateParam.ServiceChargeRate,
|
|
|
+ }
|
|
|
+ totalRecruitNum += strategy.RecruitNumber
|
|
|
+ if strategy.FeeForm == 2 {
|
|
|
+ recruitStrategy.Offer = strategy.Offer
|
|
|
+ recruitStrategy.ServiceCharge = strategy.Offer * localCreateParam.ServiceChargeRate
|
|
|
+ recruitStrategy.TOffer = strategy.Offer * (1 - localCreateParam.ServiceChargeRate)
|
|
|
+ }
|
|
|
+ recruits = append(recruits, recruitStrategy)
|
|
|
+ }
|
|
|
+ err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return &localId, nil
|
|
|
}
|
|
|
|
|
@@ -81,7 +164,6 @@ func (s LocalLifeService) UpdateLocal(localUpdateParam *vo.LocalUpdateParam) (*s
|
|
|
if localLife == nil {
|
|
|
return nil, errors.New("本地生活项目不存在")
|
|
|
}
|
|
|
- println("更新公开本地生活任务的招募策略")
|
|
|
// 更新公开种草任务的招募策略
|
|
|
var totalRecruitNum int64
|
|
|
if localUpdateParam.RecruitStrategys != nil {
|
|
@@ -130,10 +212,10 @@ func (s LocalLifeService) UpdateLocal(localUpdateParam *vo.LocalUpdateParam) (*s
|
|
|
// 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
|
|
|
- }
|
|
|
+ //// f) 更新选品状态
|
|
|
+ //if localUpdateParam.LocalStatus != 2 && localUpdateParam.LocalStatus != 8 {
|
|
|
+ // localUpdateParam.LocalStatus = 1
|
|
|
+ //}
|
|
|
t := time.Now()
|
|
|
updateLocalLife := entity.LocalLifeInfo{
|
|
|
StoreID: localUpdateParam.StoreId,
|
|
@@ -141,18 +223,18 @@ func (s LocalLifeService) UpdateLocal(localUpdateParam *vo.LocalUpdateParam) (*s
|
|
|
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
|
|
|
- }
|
|
|
+ //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类型转换为结构体类型
|
|
@@ -283,10 +365,10 @@ func (s LocalLifeService) UpdateLocalTarget(localUpdateParam *vo.LocalUpdatePara
|
|
|
// 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
|
|
|
- }
|
|
|
+ //// f) 更新选品状态
|
|
|
+ //if localUpdateParam.LocalStatus != 2 && localUpdateParam.LocalStatus != 8 {
|
|
|
+ // localUpdateParam.LocalStatus = 1
|
|
|
+ //}
|
|
|
t := time.Now()
|
|
|
updateLocalLife := entity.LocalLifeInfo{
|
|
|
StoreID: localUpdateParam.StoreId,
|
|
@@ -294,19 +376,19 @@ func (s LocalLifeService) UpdateLocalTarget(localUpdateParam *vo.LocalUpdatePara
|
|
|
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
|
|
|
- }
|
|
|
+ //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类型转换为结构体类型
|