local_life_service.go 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473
  1. package service
  2. import (
  3. "errors"
  4. "github.com/sirupsen/logrus"
  5. "reflect"
  6. "strconv"
  7. "strings"
  8. "time"
  9. "youngee_b_api/app/dao"
  10. "youngee_b_api/app/entity"
  11. "youngee_b_api/app/service/review_service"
  12. "youngee_b_api/app/util"
  13. "youngee_b_api/app/vo"
  14. )
  15. type LocalLifeService struct{}
  16. // 创建本地生活任务
  17. func (s LocalLifeService) CreateLocalLife(localCreateParam *vo.LocalCreateParam) (*string, error) {
  18. // a) 生成本地生活项目id
  19. localId := strings.ReplaceAll(util.GenerateUUID(11), "-", "")
  20. // b) 查找关联门店信息
  21. product, err := dao.StoreDao{}.GetStoreByID(localCreateParam.StoreId)
  22. if err != nil {
  23. return nil, err
  24. }
  25. if product == nil {
  26. return nil, errors.New("未找到关联门店")
  27. }
  28. // c)创建本地生活任务
  29. var operatorType int64
  30. if localCreateParam.SubAccountId == 0 {
  31. operatorType = 1
  32. } else {
  33. operatorType = 2
  34. }
  35. // d) 任务截止时间
  36. recruitDdl, err1 := time.ParseInLocation("2006-01-02 15:04:05", localCreateParam.RecruitDdl, time.Local)
  37. if err1 != nil {
  38. return nil, errors.New("failed to parse recruitDdl")
  39. }
  40. // 获取定时任务配置id
  41. infoAutoTask := entity.InfoAutoTask{}
  42. infoAutoTask = dao.InfoAutoTaskDao{}.GetAutoTaskLast(localCreateParam.EnterpriseId)
  43. infoAutoDefault := entity.InfoAutoDefault{}
  44. infoAutoDefault = dao.InfoAutoDefaultDao{}.GetAutoDefaultLast(localCreateParam.EnterpriseId)
  45. t := time.Now()
  46. if recruitDdl.Before(t) {
  47. return nil, errors.New("请修改截止时间")
  48. }
  49. newLocalLife := entity.LocalLifeInfo{
  50. EnterpriseID: localCreateParam.EnterpriseId,
  51. SubAccountID: localCreateParam.SubAccountId,
  52. OperatorType: operatorType,
  53. TaskStatus: 1,
  54. LocalID: localId,
  55. LocalType: localCreateParam.LocalType,
  56. LocalPlatform: localCreateParam.Platform,
  57. StoreID: localCreateParam.StoreId,
  58. StoreRelatedAt: time.Now(),
  59. PromoteBody: localCreateParam.PromoteBody,
  60. Donate: localCreateParam.Donate,
  61. TeamBuyingId: localCreateParam.TeamBuyingId,
  62. TeamBuyingRelatedAt: time.Now(),
  63. CreatedAt: t,
  64. AutoTaskID: infoAutoTask.AutoTaskID,
  65. AutoDefaultID: infoAutoDefault.AutoDefaultID,
  66. LocalName: localCreateParam.LocalName,
  67. TalentType: localCreateParam.TalentType,
  68. RecruitDdl: recruitDdl,
  69. TaskForm: localCreateParam.TaskForm,
  70. ContentType: localCreateParam.ContentType,
  71. TaskDetail: localCreateParam.TaskDetail,
  72. Tools: localCreateParam.Tools,
  73. }
  74. if localCreateParam.LocalType == 1 {
  75. newLocalLife.ServiceChargeRate = localCreateParam.ServiceChargeRate
  76. }
  77. err = dao.LocalLifeDao{}.CreateLocalLife(newLocalLife)
  78. if err != nil {
  79. return nil, err
  80. }
  81. // 4. 更新选品brief和示例(本地生活任务补充信息)
  82. if localCreateParam.LocalBrief != nil {
  83. // 插入新的brief
  84. for _, v := range localCreateParam.LocalBrief {
  85. brief := entity.LocalLifeBrief{
  86. LocalID: localId,
  87. FileUid: v.FileUid,
  88. FileName: v.Name,
  89. FileUrl: v.FileUrl,
  90. CreatedAt: time.Now(),
  91. Type: v.Type,
  92. }
  93. err = dao.LocalLifeBriefDao{}.CreateLocalBrief(brief)
  94. if err != nil {
  95. return nil, err
  96. }
  97. }
  98. }
  99. if localCreateParam.LocalMaterial != nil {
  100. // 插入新的示例
  101. for _, v := range localCreateParam.LocalMaterial {
  102. material := entity.LocalLifeMaterial{
  103. LocalID: localId,
  104. FileUid: v.FileUid,
  105. FileName: v.Name,
  106. FileUrl: v.FileUrl,
  107. CreatedAt: time.Now(),
  108. Type: v.Type,
  109. }
  110. err = dao.LocalLifeMaterialDao{}.CreateLocalMaterial(material)
  111. if err != nil {
  112. return nil, err
  113. }
  114. }
  115. }
  116. // 更新公开种草任务的招募策略
  117. var totalRecruitNum int64
  118. var estimatedCost float64
  119. if localCreateParam.RecruitStrategys != nil {
  120. // 2. 接收并创建新的招募策略
  121. if len(localCreateParam.RecruitStrategys) != 0 {
  122. var recruits []entity.RecruitStrategy
  123. for _, strategy := range localCreateParam.RecruitStrategys {
  124. if strategy.FeeForm == 2 {
  125. estimatedCost += float64(strategy.RecruitNumber) * strategy.Offer
  126. }
  127. recruitStrategy := entity.RecruitStrategy{
  128. FeeForm: strategy.FeeForm,
  129. StrategyID: strategy.StrategyID,
  130. FollowersLow: strategy.FollowersLow,
  131. FollowersUp: strategy.FollowersUp,
  132. RecruitNumber: strategy.RecruitNumber,
  133. ProjectID: localId,
  134. StrategyType: 1,
  135. ServiceRate: localCreateParam.ServiceChargeRate,
  136. }
  137. totalRecruitNum += strategy.RecruitNumber
  138. if strategy.FeeForm == 2 {
  139. recruitStrategy.Offer = strategy.Offer
  140. recruitStrategy.ServiceCharge = strategy.Offer * localCreateParam.ServiceChargeRate * 0.01
  141. recruitStrategy.TOffer = strategy.Offer * (1 - localCreateParam.ServiceChargeRate*0.01)
  142. }
  143. recruits = append(recruits, recruitStrategy)
  144. }
  145. err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
  146. if err != nil {
  147. return nil, err
  148. }
  149. }
  150. }
  151. _ = dao.LocalLifeDao{}.UpdateLocal(entity.LocalLifeInfo{
  152. LocalID: localId,
  153. EstimatedCost: estimatedCost,
  154. TotalRecruitNum: totalRecruitNum,
  155. })
  156. return &localId, nil
  157. }
  158. // 更新公开本地生活任务(招募要求、执行要求)
  159. func (s LocalLifeService) UpdateLocal(localUpdateParam *vo.LocalUpdateParam) (*string, error) {
  160. // 1. 检查该项目id有无本地任务
  161. localID := localUpdateParam.LocalID
  162. localLife, err := dao.LocalLifeDao{}.GetLocalById(localID)
  163. if err != nil {
  164. return nil, err
  165. }
  166. if localLife == nil {
  167. return nil, errors.New("本地生活项目不存在")
  168. }
  169. recruitDdl := time.Time{} //赋零值
  170. recruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", localUpdateParam.RecruitDdl, time.Local)
  171. if recruitDdl.Before(localLife.CreatedAt) {
  172. return nil, errors.New("请修改截止时间")
  173. }
  174. // 更新公开种草任务的招募策略
  175. var totalRecruitNum int64
  176. var estimatedCost float64
  177. if localUpdateParam.RecruitStrategys != nil {
  178. // 1. 删除已有的招募策略
  179. err = dao.RecruitStrategyDao{}.DeleteRecruitStrategyByProjectID(localUpdateParam.LocalID)
  180. if err != nil {
  181. return nil, err
  182. }
  183. // 2. 接收并创建新的招募策略
  184. if len(localUpdateParam.RecruitStrategys) != 0 {
  185. var recruits []entity.RecruitStrategy
  186. for _, strategy := range localUpdateParam.RecruitStrategys {
  187. if strategy.FeeForm == 2 {
  188. estimatedCost += float64(strategy.RecruitNumber) * strategy.Offer
  189. }
  190. recruitStrategy := entity.RecruitStrategy{
  191. FeeForm: strategy.FeeForm,
  192. StrategyID: strategy.StrategyID,
  193. FollowersLow: strategy.FollowersLow,
  194. FollowersUp: strategy.FollowersUp,
  195. RecruitNumber: strategy.RecruitNumber,
  196. ProjectID: localLife.LocalID,
  197. StrategyType: 1,
  198. ServiceRate: localLife.ServiceChargeRate,
  199. }
  200. totalRecruitNum += strategy.RecruitNumber
  201. if strategy.FeeForm == 2 {
  202. recruitStrategy.Offer = strategy.Offer
  203. recruitStrategy.ServiceCharge = strategy.Offer * localUpdateParam.ServiceChargeRate * 0.01
  204. recruitStrategy.TOffer = strategy.Offer * (1 - localUpdateParam.ServiceChargeRate*0.01)
  205. }
  206. recruits = append(recruits, recruitStrategy)
  207. }
  208. err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
  209. if err != nil {
  210. return nil, err
  211. }
  212. }
  213. }
  214. // 2. 数据准备
  215. //// a) 查找关联商品信息
  216. //product, err := dao.ProductDAO{}.GetProductByID(project.ProductID)
  217. //if err != nil {
  218. // return nil, err
  219. //}
  220. //productPhotos, err := dao.ProductPhotoDAO{}.GetProductPhotoByProductID(project.ProductID)
  221. //productInfoToJson, _ := json.Marshal(product)
  222. //productPhotosToJson, _ := json.Marshal(productPhotos)
  223. // d) 任务截止时间
  224. //// f) 更新选品状态
  225. //if localUpdateParam.LocalStatus != 2 && localUpdateParam.LocalStatus != 8 {
  226. // localUpdateParam.LocalStatus = 1
  227. //}
  228. t := time.Now()
  229. updateLocalLife := entity.LocalLifeInfo{
  230. StoreID: localUpdateParam.StoreId,
  231. TeamBuyingId: localUpdateParam.TeamBuyingId,
  232. ServiceChargeRate: localUpdateParam.ServiceChargeRate,
  233. PromoteBody: localUpdateParam.PromoteBody,
  234. Donate: localUpdateParam.Donate,
  235. //TaskStatus: localUpdateParam.LocalStatus,
  236. LocalName: localUpdateParam.LocalName,
  237. TalentType: localUpdateParam.TalentType,
  238. RecruitDdl: recruitDdl,
  239. TaskForm: localUpdateParam.TaskForm,
  240. ContentType: localUpdateParam.ContentType,
  241. TaskDetail: localUpdateParam.TaskDetail,
  242. UpdatedAt: t,
  243. EstimatedCost: estimatedCost,
  244. TotalRecruitNum: totalRecruitNum,
  245. }
  246. //if localUpdateParam.LocalStatus == 2 {
  247. // updateLocalLife.SubmitAt = t
  248. //}
  249. // 合并传入参数和数据表中原记录,若传入参数字段值为空,则将字段赋值为原记录中值
  250. result := util.MergeStructValue(&updateLocalLife, localLife)
  251. // 利用反射机制将interface类型转换为结构体类型
  252. v := reflect.ValueOf(&result).Elem()
  253. if v.Kind() == reflect.Struct {
  254. updateLocalLife = v.Interface().(entity.LocalLifeInfo)
  255. //fmt.Println(p)
  256. }
  257. // c) 计算预估成本(如果有)
  258. /*
  259. var estimatedCost float64
  260. if conv.MustInt(updateSelection.TaskMode, 0) == 1 {
  261. estimatedCost = conv.MustFloat64(updateSelection.TaskReward, 0) * conv.MustFloat64(updateSelection.SampleNum, 0)
  262. }
  263. estimatedCostToString, _ := conv.String(estimatedCost)
  264. updateSelection.EstimatedCost = estimatedCostToString
  265. */
  266. // 3. 更新选品
  267. err = dao.LocalLifeDao{}.UpdateLocal(updateLocalLife)
  268. if err != nil {
  269. return nil, err
  270. }
  271. // 4. 更新选品brief和示例(本地生活任务补充信息)
  272. if localUpdateParam.LocalBrief != nil {
  273. // 删除已有brief
  274. err = dao.LocalLifeBriefDao{}.DeleteLocalBriefByLocalId(localLife.LocalID)
  275. if err != nil {
  276. return nil, err
  277. }
  278. // 插入新的brief
  279. for _, v := range localUpdateParam.LocalBrief {
  280. brief := entity.LocalLifeBrief{
  281. LocalID: localLife.LocalID,
  282. FileUid: v.FileUid,
  283. FileName: v.Name,
  284. FileUrl: v.FileUrl,
  285. CreatedAt: time.Now(),
  286. Type: v.Type,
  287. }
  288. err = dao.LocalLifeBriefDao{}.CreateLocalBrief(brief)
  289. if err != nil {
  290. return nil, err
  291. }
  292. }
  293. }
  294. if localUpdateParam.LocalMaterial != nil {
  295. // 删除已有示例
  296. err = dao.LocalLifeMaterialDao{}.DeleteLocalMaterialByLocalId(localLife.LocalID)
  297. if err != nil {
  298. return nil, err
  299. }
  300. // 插入新的示例
  301. for _, v := range localUpdateParam.LocalMaterial {
  302. material := entity.LocalLifeMaterial{
  303. LocalID: localLife.LocalID,
  304. FileUid: v.FileUid,
  305. FileName: v.Name,
  306. FileUrl: v.FileUrl,
  307. CreatedAt: time.Now(),
  308. Type: v.Type,
  309. }
  310. err = dao.LocalLifeMaterialDao{}.CreateLocalMaterial(material)
  311. if err != nil {
  312. return nil, err
  313. }
  314. }
  315. }
  316. return &updateLocalLife.LocalID, nil
  317. }
  318. // 更新定向本地生活任务(招募要求、执行要求)
  319. func (s LocalLifeService) UpdateLocalTarget(localUpdateParam *vo.LocalUpdateParam) (*string, error) {
  320. // 1. 检查该项目id有无本地任务
  321. localID := localUpdateParam.LocalID
  322. localLife, err := dao.LocalLifeDao{}.GetLocalById(localID)
  323. if err != nil {
  324. return nil, err
  325. }
  326. if localLife == nil {
  327. return nil, errors.New("本地生活项目不存在")
  328. }
  329. println("更新定向本地生活任务的招募策略")
  330. // 更新公开种草任务的招募策略
  331. var totalRecruitNum int64
  332. var estimatedCost float64
  333. if localUpdateParam.RecruitStrategys != nil {
  334. // 1. 删除已有的招募策略
  335. err = dao.RecruitStrategyDao{}.DeleteRecruitStrategyByProjectID(localUpdateParam.LocalID)
  336. if err != nil {
  337. return nil, err
  338. }
  339. // 2. 接收并创建新的招募策略
  340. if len(localUpdateParam.RecruitStrategys) != 0 {
  341. var recruits []entity.RecruitStrategy
  342. for _, strategy := range localUpdateParam.RecruitStrategys {
  343. if strategy.FeeForm == 2 {
  344. estimatedCost += float64(strategy.RecruitNumber) * strategy.Offer
  345. }
  346. recruitStrategy := entity.RecruitStrategy{
  347. FeeForm: strategy.FeeForm,
  348. StrategyID: strategy.StrategyID,
  349. FollowersLow: strategy.FollowersLow,
  350. FollowersUp: strategy.FollowersUp,
  351. RecruitNumber: strategy.RecruitNumber,
  352. ProjectID: localLife.LocalID,
  353. StrategyType: 1,
  354. ServiceRate: localLife.ServiceChargeRate,
  355. }
  356. totalRecruitNum += strategy.RecruitNumber
  357. if strategy.FeeForm == 2 {
  358. recruitStrategy.Offer = strategy.Offer // 报价
  359. }
  360. recruits = append(recruits, recruitStrategy)
  361. }
  362. err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
  363. if err != nil {
  364. return nil, err
  365. }
  366. }
  367. }
  368. // 2. 数据准备
  369. // a) 查找关联商品信息
  370. //product, err := dao.ProductDAO{}.GetProductByID(project.ProductID)
  371. //if err != nil {
  372. // return nil, err
  373. //}
  374. //productPhotos, err := dao.ProductPhotoDAO{}.GetProductPhotoByProductID(project.ProductID)
  375. //productInfoToJson, _ := json.Marshal(product)
  376. //productPhotosToJson, _ := json.Marshal(productPhotos)
  377. // d) 任务截止时间
  378. recruitDdl := time.Time{} //赋零值
  379. recruitDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", localUpdateParam.RecruitDdl, time.Local)
  380. //// f) 更新选品状态
  381. //if localUpdateParam.LocalStatus != 2 && localUpdateParam.LocalStatus != 8 {
  382. // localUpdateParam.LocalStatus = 1
  383. //}
  384. t := time.Now()
  385. updateLocalLife := entity.LocalLifeInfo{
  386. StoreID: localUpdateParam.StoreId,
  387. TeamBuyingId: localUpdateParam.TeamBuyingId,
  388. ServiceChargeRate: localUpdateParam.ServiceChargeRate,
  389. PromoteBody: localUpdateParam.PromoteBody,
  390. Donate: localUpdateParam.Donate,
  391. //TaskStatus: localUpdateParam.LocalStatus,
  392. LocalName: localUpdateParam.LocalName,
  393. TalentType: localUpdateParam.TalentType,
  394. RecruitDdl: recruitDdl,
  395. TaskForm: localUpdateParam.TaskForm,
  396. ContentType: localUpdateParam.ContentType,
  397. TaskDetail: localUpdateParam.TaskDetail,
  398. UpdatedAt: t,
  399. Tools: localUpdateParam.Tools,
  400. EstimatedCost: estimatedCost,
  401. TotalRecruitNum: totalRecruitNum,
  402. }
  403. //if localUpdateParam.LocalStatus == 2 {
  404. // updateLocalLife.SubmitAt = t
  405. //}
  406. // 合并传入参数和数据表中原记录,若传入参数字段值为空,则将字段赋值为原记录中值
  407. result := util.MergeStructValue(&updateLocalLife, localLife)
  408. // 利用反射机制将interface类型转换为结构体类型
  409. v := reflect.ValueOf(&result).Elem()
  410. if v.Kind() == reflect.Struct {
  411. updateLocalLife = v.Interface().(entity.LocalLifeInfo)
  412. //fmt.Println(p)
  413. }
  414. // c) 计算预估成本(如果有)
  415. /*
  416. var estimatedCost float64
  417. if conv.MustInt(updateSelection.TaskMode, 0) == 1 {
  418. estimatedCost = conv.MustFloat64(updateSelection.TaskReward, 0) * conv.MustFloat64(updateSelection.SampleNum, 0)
  419. }
  420. estimatedCostToString, _ := conv.String(estimatedCost)
  421. updateSelection.EstimatedCost = estimatedCostToString
  422. */
  423. // 3. 更新选品
  424. err = dao.LocalLifeDao{}.UpdateLocal(updateLocalLife)
  425. if err != nil {
  426. return nil, err
  427. }
  428. // 4. 更新选品brief和示例(本地生活任务补充信息)
  429. if localUpdateParam.LocalBrief != nil {
  430. // 删除已有brief
  431. err = dao.ProjectBriefDao{}.DeleteSecBriefBySelectionId(localLife.LocalID)
  432. if err != nil {
  433. return nil, err
  434. }
  435. // 插入新的brief
  436. for _, v := range localUpdateParam.LocalBrief {
  437. brief := entity.ProjectBrief{
  438. ProjectID: localLife.LocalID,
  439. FileUid: v.FileUid,
  440. FileName: v.Name,
  441. FileUrl: v.FileUrl,
  442. CreatedAt: time.Now(),
  443. Type: v.Type,
  444. }
  445. err = dao.ProjectBriefDao{}.CreateProjectBrief(brief)
  446. if err != nil {
  447. return nil, err
  448. }
  449. }
  450. }
  451. if localUpdateParam.LocalMaterial != nil {
  452. // 删除已有示例
  453. err = dao.ProjectMaterialDao{}.DeleteProjectMaterialByProjectId(localLife.LocalID)
  454. if err != nil {
  455. return nil, err
  456. }
  457. // 插入新的示例
  458. for _, v := range localUpdateParam.LocalMaterial {
  459. projectMaterial := entity.ProjectMaterial{
  460. ProjectID: localLife.LocalID,
  461. FileUid: v.FileUid,
  462. FileName: v.Name,
  463. FileUrl: v.FileUrl,
  464. CreatedAt: time.Now(),
  465. Type: v.Type,
  466. }
  467. err = dao.ProjectMaterialDao{}.CreateProjectMaterial(projectMaterial)
  468. if err != nil {
  469. return nil, err
  470. }
  471. }
  472. }
  473. return &updateLocalLife.LocalID, nil
  474. }
  475. // 本地生活任务预览
  476. func (s LocalLifeService) GetLocalLifeDetail(localId string) (*vo.ReLocalDetail, error) {
  477. reLocalDetail := vo.ReLocalDetail{}
  478. localLife, err := dao.LocalLifeDao{}.GetLocalById(localId)
  479. if err != nil {
  480. logrus.Errorf("[localLifeDB service] call GetLocalById error,err:%+v", err)
  481. return nil, err
  482. }
  483. if localLife == nil {
  484. return nil, errors.New("数据不存在")
  485. }
  486. // 系统信息
  487. reLocalDetail.LocalName = localLife.LocalName
  488. reLocalDetail.LocalId = localId
  489. reLocalDetail.LocalStatus = localLife.TaskStatus
  490. reLocalDetail.LocalPlatform = localLife.LocalPlatform
  491. reLocalDetail.CreatedAt = localLife.CreatedAt.Format("2006-01-02 15:04:05")
  492. reLocalDetail.SubmitAt = localLife.SubmitAt.Format("2006-01-02 15:04:05")
  493. reLocalDetail.PassAt = localLife.AutoFailAt.Format("2006-01-02 15:04:05")
  494. reLocalDetail.AutoFailAt = localLife.AutoFailAt.Format("2006-01-02 15:04:05")
  495. reLocalDetail.StartAt = localLife.PayAt.Format("2006-01-02 15:04:05")
  496. reLocalDetail.FinishAt = localLife.FinishAt.Format("2006-01-02 15:04:05")
  497. reLocalDetail.FailAt = localLife.FailAt.Format("2006-01-02 15:04:05")
  498. if localLife.TaskStatus < 6 {
  499. reLocalDetail.EstimatedCost = localLife.EstimatedCost
  500. } else {
  501. reLocalDetail.EstimatedCost = localLife.NeedPay
  502. }
  503. reLocalDetail.ServiceChargeRate = localLife.ServiceChargeRate
  504. var creatorName, phone string
  505. if localLife.OperatorType == 1 && localLife.SubAccountID == 0 {
  506. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(localLife.EnterpriseID)
  507. if err == nil && enterprise != nil {
  508. creatorName = enterprise.BusinessName
  509. phone, err = dao.UserDao{}.GetPhoneByUserId(enterprise.UserId)
  510. }
  511. } else if localLife.OperatorType == 1 && localLife.SubAccountID != 0 {
  512. subAccount, err := dao.SubAccountDao{}.GetSubAccount(localLife.SubAccountID)
  513. if err == nil && subAccount != nil {
  514. creatorName = subAccount.SubAccountName
  515. phone, err = dao.UserDao{}.GetPhoneByUserId(subAccount.UserId)
  516. }
  517. }
  518. reLocalDetail.CreatorName = creatorName
  519. reLocalDetail.Phone = phone
  520. // 关联主体
  521. var reStore vo.ReStorePreview
  522. store, err := dao.StoreDao{}.GetStoreByID(localLife.StoreID)
  523. if err == nil && store != nil {
  524. photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(store.StoreID)
  525. if e != nil {
  526. photoUrl = ""
  527. }
  528. reStore = vo.ReStorePreview{
  529. StoreID: store.StoreID,
  530. StoreName: store.StoreName,
  531. StoreLocation: store.StoreLocation,
  532. StoreCategory: store.StoreCategory,
  533. TeamNum: store.TeamNum,
  534. StoreDetail: store.StoreDetail,
  535. CreatedAt: store.CreatedAt.Format("2006-01-02 15:04:05"),
  536. PhotoUrl: photoUrl,
  537. }
  538. }
  539. reLocalDetail.StoreInfo = &reStore
  540. var reTeamBuying vo.ReTeamBuyingPreview
  541. teamBuying, err := dao.TeamBuyingDao{}.GetTeamBuyingByID(localLife.TeamBuyingId)
  542. if err == nil && teamBuying != nil {
  543. photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByTeamBuyingID(teamBuying.TeamBuyingID)
  544. if e != nil {
  545. photoUrl = ""
  546. }
  547. reTeamBuying = vo.ReTeamBuyingPreview{
  548. TeamBuyingID: teamBuying.TeamBuyingID,
  549. TeamBuyingName: teamBuying.TeamBuyingName,
  550. TeamBuyingPrice: teamBuying.TeamBuyingPrice,
  551. TeamBuyingCategory: teamBuying.TeamBuyingCategory,
  552. TeamBuyingDetail: teamBuying.TeamBuyingDetail,
  553. CreatedAt: teamBuying.CreatedAt.Format("2006-01-02 15:04:05"),
  554. PhotoUrl: photoUrl,
  555. }
  556. }
  557. reLocalDetail.TeamBuyingInfo = &reTeamBuying
  558. reLocalDetail.PromoteBody = localLife.PromoteBody
  559. reLocalDetail.Donate = localLife.Donate
  560. // 招募要求
  561. reLocalDetail.TalentType = localLife.TalentType
  562. reLocalDetail.RecruitDdl = localLife.RecruitDdl.Format("2006-01-02 15:04:05")
  563. var recruitStrategysPreviews []*vo.LocalRecruitStrategy
  564. recruitStrategys, err := dao.RecruitStrategyDao{}.GetRecruitStrategyByProjectId(localId)
  565. if err != nil {
  566. logrus.Errorf("[localLifeDB service] call GetRecruitStrategy error,err:%+v", err)
  567. return nil, err
  568. }
  569. for _, recruitStrategy := range recruitStrategys {
  570. recruitStrategysPreview := &vo.LocalRecruitStrategy{
  571. StrategyId: recruitStrategy.StrategyID,
  572. FeeForm: recruitStrategy.FeeForm,
  573. FollowersLow: recruitStrategy.FollowersLow,
  574. FollowersUp: recruitStrategy.FollowersUp,
  575. RecruitNumber: recruitStrategy.RecruitNumber,
  576. Offer: recruitStrategy.Offer,
  577. TOffer: recruitStrategy.TOffer,
  578. ServiceCharge: recruitStrategy.ServiceCharge,
  579. SelectedNumber: recruitStrategy.SelectedNumber,
  580. TotalOffer: recruitStrategy.TotalOffer,
  581. }
  582. recruitStrategysPreviews = append(recruitStrategysPreviews, recruitStrategysPreview)
  583. }
  584. reLocalDetail.RecruitStrategys = recruitStrategysPreviews
  585. // 执行要求
  586. reLocalDetail.TaskForm = localLife.TaskForm
  587. reLocalDetail.ContentType = localLife.ContentType
  588. reLocalDetail.TaskDetail = localLife.TaskDetail
  589. taskBriefInfos, err := dao.LocalLifeBriefDao{}.GetLocalBriefInfo(localId)
  590. if err != nil {
  591. logrus.Errorf("[localLifeDB service] call GetProjectBriefInfo error,err:%+v", err)
  592. return nil, err
  593. }
  594. taskMaterials, err := dao.LocalLifeMaterialDao{}.GetLocalMaterialInfo(localId)
  595. if err != nil {
  596. logrus.Errorf("[localLifeDB service] call GetprojectMaterialInfo error,err:%+v", err)
  597. return nil, err
  598. }
  599. reLocalDetail.TaskBriefs = taskBriefInfos
  600. reLocalDetail.TaskMaterials = taskMaterials
  601. reLocalDetail.Tools = localLife.Tools
  602. return &reLocalDetail, nil
  603. }
  604. // 复制本地生活任务
  605. func (s LocalLifeService) CopyLocalLife(param *vo.LocalSearchParam) (*string, error) {
  606. localLifeOrigin, err := dao.LocalLifeDao{}.GetLocalById(param.LocalId)
  607. if err != nil {
  608. logrus.Errorf("[localLifeDB service] call GetLocalById error,err:%+v", err)
  609. return nil, err
  610. }
  611. if localLifeOrigin == nil {
  612. return nil, errors.New("任务不存在")
  613. }
  614. localIdOrigin := localLifeOrigin.LocalID
  615. localIdNew := strings.ReplaceAll(util.GenerateUUID(11), "-", "")
  616. t := time.Now()
  617. // 获取定时任务配置id
  618. infoAutoTask := entity.InfoAutoTask{}
  619. infoAutoTask = dao.InfoAutoTaskDao{}.GetAutoTaskLast(localLifeOrigin.EnterpriseID)
  620. infoAutoDefault := entity.InfoAutoDefault{}
  621. infoAutoDefault = dao.InfoAutoDefaultDao{}.GetAutoDefaultLast(localLifeOrigin.EnterpriseID)
  622. // 复制任务
  623. localLifeNew := entity.LocalLifeInfo{
  624. EnterpriseID: localLifeOrigin.EnterpriseID,
  625. SubAccountID: localLifeOrigin.SubAccountID,
  626. OperatorType: localLifeOrigin.OperatorType,
  627. TaskStatus: 1,
  628. LocalID: localIdNew,
  629. LocalType: localLifeOrigin.LocalType,
  630. LocalPlatform: localLifeOrigin.LocalPlatform,
  631. StoreID: localLifeOrigin.StoreID,
  632. StoreRelatedAt: t,
  633. PromoteBody: localLifeOrigin.PromoteBody,
  634. Donate: localLifeOrigin.Donate,
  635. TeamBuyingId: localLifeOrigin.TeamBuyingId,
  636. TeamBuyingRelatedAt: t,
  637. CreatedAt: t,
  638. AutoTaskID: infoAutoTask.AutoTaskID,
  639. AutoDefaultID: infoAutoDefault.AutoDefaultID,
  640. LocalName: localLifeOrigin.LocalName,
  641. TalentType: localLifeOrigin.TalentType,
  642. RecruitDdl: localLifeOrigin.RecruitDdl,
  643. TaskForm: localLifeOrigin.TaskForm,
  644. ContentType: localLifeOrigin.ContentType,
  645. TaskDetail: localLifeOrigin.TaskDetail,
  646. Tools: localLifeOrigin.Tools,
  647. ServiceChargeRate: localLifeOrigin.ServiceChargeRate,
  648. EstimatedCost: localLifeOrigin.EstimatedCost,
  649. }
  650. err = dao.LocalLifeDao{}.CreateLocalLife(localLifeNew)
  651. if err != nil {
  652. return nil, err
  653. }
  654. // 更新选品brief和示例(本地生活任务补充信息)
  655. localBriefInfos, err := dao.LocalLifeBriefDao{}.GetLocalBriefInfo(localIdOrigin)
  656. if err != nil {
  657. logrus.Errorf("[projectDB service] call GetLocalBriefInfo error,err:%+v", err)
  658. return nil, err
  659. }
  660. if localBriefInfos != nil {
  661. for _, v := range localBriefInfos {
  662. brief := entity.LocalLifeBrief{
  663. LocalID: localIdNew,
  664. FileUid: v.FileUid,
  665. FileName: v.FileName,
  666. FileUrl: v.FileUrl,
  667. CreatedAt: time.Now(),
  668. Type: v.Type,
  669. }
  670. err = dao.LocalLifeBriefDao{}.CreateLocalBrief(brief)
  671. if err != nil {
  672. return nil, err
  673. }
  674. }
  675. }
  676. localMaterials, err := dao.LocalLifeMaterialDao{}.GetLocalMaterialInfo(localIdOrigin)
  677. if err != nil {
  678. logrus.Errorf("[projectDB service] call GetLocalMaterialInfo error,err:%+v", err)
  679. return nil, err
  680. }
  681. if localMaterials != nil {
  682. for _, v := range localMaterials {
  683. material := entity.LocalLifeMaterial{
  684. LocalID: localIdNew,
  685. FileUid: v.FileUid,
  686. FileName: v.FileName,
  687. FileUrl: v.FileUrl,
  688. CreatedAt: time.Now(),
  689. Type: v.Type,
  690. }
  691. err = dao.LocalLifeMaterialDao{}.CreateLocalMaterial(material)
  692. if err != nil {
  693. return nil, err
  694. }
  695. }
  696. }
  697. // 更新本地生活任务的招募策略
  698. recruitStrategys, err := dao.RecruitStrategyDao{}.GetRecruitStrategyByProjectId(localIdOrigin)
  699. if err != nil {
  700. logrus.Errorf("[localLifeDB service] call GetRecruitStrategy error,err:%+v", err)
  701. return nil, err
  702. }
  703. var totalRecruitNum int64
  704. if recruitStrategys != nil {
  705. // 2. 接收并创建新的招募策略
  706. if len(recruitStrategys) != 0 {
  707. var recruits []entity.RecruitStrategy
  708. for _, strategy := range recruitStrategys {
  709. recruitStrategy := entity.RecruitStrategy{
  710. FeeForm: strategy.FeeForm,
  711. StrategyID: strategy.StrategyID,
  712. FollowersLow: strategy.FollowersLow,
  713. FollowersUp: strategy.FollowersUp,
  714. RecruitNumber: strategy.RecruitNumber,
  715. ProjectID: localIdNew,
  716. StrategyType: strategy.StrategyType,
  717. ServiceRate: strategy.ServiceRate,
  718. Offer: strategy.Offer,
  719. ServiceCharge: strategy.ServiceCharge,
  720. TOffer: strategy.TOffer,
  721. }
  722. totalRecruitNum += strategy.RecruitNumber
  723. recruits = append(recruits, recruitStrategy)
  724. }
  725. err = dao.RecruitStrategyDao{}.CreateRecruitStrategy(recruits)
  726. if err != nil {
  727. return nil, err
  728. }
  729. }
  730. }
  731. return &localIdNew, nil
  732. }
  733. // 本地生活提交审核
  734. func (s LocalLifeService) LocalLifeToReview(localUpdateParam *vo.LocalUpdateParam) (*string, error) {
  735. localId := localUpdateParam.LocalID
  736. local, err := dao.LocalLifeDao{}.GetLocalById(localId)
  737. if err != nil {
  738. logrus.Errorf("[projectInfoDB service] call GetProject error,err:%+v", err)
  739. return nil, err
  740. }
  741. localName := local.LocalName // 任务标题
  742. localDetail := local.TaskDetail // 任务详情
  743. store, err := dao.StoreDao{}.GetStoreByID(local.StoreID)
  744. if err != nil {
  745. return nil, err
  746. }
  747. storeName := store.StoreName // 门店名称
  748. storeDetail := store.StoreDetail // 门店特点
  749. storeMainPhoto, err1 := dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(store.StoreID)
  750. if err1 != nil {
  751. return nil, err1
  752. }
  753. teamBuying, err2 := dao.TeamBuyingDao{}.GetTeamBuyingByID(local.TeamBuyingId)
  754. if err2 != nil {
  755. return nil, err2
  756. }
  757. teamBuyingName := teamBuying.TeamBuyingName // 团购标题
  758. teamBuyingDetail := teamBuying.TeamBuyingDetail // 团购详情
  759. teamBuyingMainPhoto, err3 := dao.ProductPhotoDAO{}.GetMainPhotoByTeamBuyingID(teamBuying.TeamBuyingID)
  760. if err3 != nil {
  761. return nil, err3
  762. }
  763. var images []string
  764. var videos []string
  765. var videoJobIds []string
  766. var documents []string
  767. var documentJobIds []string
  768. reviewService := review_service.GetConfig()
  769. storePhotos, err4 := dao.ProductPhotoDAO{}.GetProductPhotoByStoreID(local.StoreID)
  770. if err4 != nil {
  771. return nil, err4
  772. }
  773. for _, storePhoto := range storePhotos {
  774. if storePhoto.Symbol == 2 || storePhoto.Symbol == 4 {
  775. images = append(images, storePhoto.PhotoUrl)
  776. } else if storePhoto.Symbol == 3 || storePhoto.Symbol == 5 {
  777. var videoJobId *string
  778. var reviewErr error
  779. i := 10
  780. for {
  781. videoJobId, reviewErr = reviewService.CheckVideo(storePhoto.PhotoUrl)
  782. if reviewErr == nil || i == 0 {
  783. break
  784. }
  785. i -= 1
  786. }
  787. if reviewErr != nil {
  788. return nil, reviewErr
  789. }
  790. videos = append(videos, storePhoto.PhotoUrl)
  791. videoJobIds = append(videoJobIds, *videoJobId)
  792. }
  793. }
  794. teamBuyingPhotos, err5 := dao.ProductPhotoDAO{}.GetProductPhotoByTeamBuyingID(local.TeamBuyingId)
  795. if err5 != nil {
  796. return nil, err5
  797. }
  798. for _, teamBuyingPhoto := range teamBuyingPhotos {
  799. if teamBuyingPhoto.Symbol == 2 || teamBuyingPhoto.Symbol == 4 {
  800. images = append(images, teamBuyingPhoto.PhotoUrl)
  801. } else if teamBuyingPhoto.Symbol == 3 || teamBuyingPhoto.Symbol == 5 {
  802. var videoJobId *string
  803. var reviewErr error
  804. i := 10
  805. for {
  806. videoJobId, reviewErr = reviewService.CheckVideo(teamBuyingPhoto.PhotoUrl)
  807. if reviewErr == nil || i == 0 {
  808. break
  809. }
  810. i -= 1
  811. }
  812. if reviewErr != nil {
  813. return nil, reviewErr
  814. }
  815. videos = append(videos, teamBuyingPhoto.PhotoUrl)
  816. videoJobIds = append(videoJobIds, *videoJobId)
  817. }
  818. }
  819. localBriefInfos, err6 := dao.LocalLifeBriefDao{}.GetLocalBriefInfo(localId)
  820. if err6 != nil {
  821. return nil, err6
  822. }
  823. for _, localBriefInfo := range localBriefInfos {
  824. if localBriefInfo.Type == 1 {
  825. images = append(images, localBriefInfo.FileUrl)
  826. } else if localBriefInfo.Type == 2 {
  827. var documentJobId *string
  828. var reviewErr error
  829. i := 10
  830. fileType := "pdf"
  831. parts := strings.Split(localBriefInfo.FileName, ".")
  832. if len(parts) > 1 {
  833. fileType = parts[len(parts)-1]
  834. }
  835. for {
  836. documentJobId, reviewErr = reviewService.CheckDocument(localBriefInfo.FileUrl, fileType)
  837. if reviewErr == nil || i == 0 {
  838. break
  839. }
  840. i -= 1
  841. }
  842. if reviewErr != nil {
  843. return nil, reviewErr
  844. }
  845. documents = append(documents, localBriefInfo.FileUrl)
  846. documentJobIds = append(documentJobIds, *documentJobId)
  847. }
  848. }
  849. localMaterials, err7 := dao.LocalLifeMaterialDao{}.GetLocalMaterialInfo(localId)
  850. if err7 != nil {
  851. return nil, err7
  852. }
  853. for _, localMaterial := range localMaterials {
  854. if localMaterial.Type == 1 {
  855. images = append(images, localMaterial.FileUrl)
  856. } else if localMaterial.Type == 2 {
  857. var videoJobId *string
  858. var reviewErr error
  859. i := 10
  860. for {
  861. videoJobId, reviewErr = reviewService.CheckVideo(localMaterial.FileUrl)
  862. if reviewErr == nil || i == 0 {
  863. break
  864. }
  865. i -= 1
  866. }
  867. if reviewErr != nil {
  868. return nil, reviewErr
  869. }
  870. videos = append(videos, localMaterial.FileUrl)
  871. videoJobIds = append(videoJobIds, *videoJobId)
  872. }
  873. }
  874. newReviewLocal := &entity.ReviewLocalLife{
  875. LocalID: localId,
  876. TaskName: localName,
  877. TaskDetail: localDetail,
  878. StoreMainPhoto: storeMainPhoto,
  879. StoreName: storeName,
  880. StoreDetail: storeDetail,
  881. TeamBuyingMainPhoto: teamBuyingMainPhoto,
  882. TeamBuyingName: teamBuyingName,
  883. TeamBuyingDetail: teamBuyingDetail,
  884. Images: strings.Join(images, ","),
  885. Videos: strings.Join(videos, ","),
  886. Documents: strings.Join(documents, ","),
  887. VideoJobIds: strings.Join(videoJobIds, ","),
  888. DocumentJobIds: strings.Join(documentJobIds, ","),
  889. Status: 1,
  890. }
  891. err8 := dao.LocalLifeReviewDao{}.Create(newReviewLocal)
  892. if err8 != nil {
  893. return nil, err8
  894. }
  895. t := time.Now()
  896. updateLocal := entity.LocalLifeInfo{
  897. LocalID: localId,
  898. TaskStatus: 2,
  899. SubmitAt: t,
  900. UpdatedAt: t,
  901. }
  902. err9 := dao.LocalLifeDao{}.UpdateLocal(updateLocal)
  903. if err9 != nil {
  904. return nil, err9
  905. }
  906. return &localId, nil
  907. }
  908. // 本地生活任务列表
  909. func (s LocalLifeService) GetLocalLifeTaskList(param *vo.LocalSearchParam) (vo.ResultVO, error) {
  910. if param.Page == 0 {
  911. param.Page = 1
  912. }
  913. if param.PageSize == 0 {
  914. param.PageSize = 10
  915. }
  916. var result vo.ResultVO
  917. reLocalTaskPreviews, total, err := (&dao.LocalLifeDao{}).GetLocalPreviews(param)
  918. if err != nil {
  919. return result, err
  920. }
  921. for i := range reLocalTaskPreviews {
  922. var creatorName string
  923. var storeName string
  924. var storeLocation string
  925. var mainImage string
  926. if reLocalTaskPreviews[i].SubAccountId == 0 {
  927. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reLocalTaskPreviews[i].EnterpriseId)
  928. if err == nil && enterprise != nil {
  929. creatorName = enterprise.BusinessName
  930. }
  931. } else {
  932. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reLocalTaskPreviews[i].SubAccountId)
  933. if err == nil && subAccount != nil {
  934. creatorName = subAccount.SubAccountName
  935. }
  936. }
  937. store, err := dao.StoreDao{}.GetStoreByID(reLocalTaskPreviews[i].StoreId)
  938. if err == nil && store != nil {
  939. storeName = store.StoreName
  940. storeLocation = store.StoreLocation
  941. }
  942. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(reLocalTaskPreviews[i].StoreId)
  943. reLocalTaskPreviews[i].CreatorName = creatorName
  944. reLocalTaskPreviews[i].StoreName = storeName
  945. reLocalTaskPreviews[i].StoreLocation = storeLocation
  946. reLocalTaskPreviews[i].MainImage = mainImage
  947. if param.LocalType == 2 {
  948. paramTemp := &vo.SupplierSearchInTargetTaskParam{}
  949. paramTemp.EnterpriseId = param.EnterpriseId
  950. paramTemp.SubAccountId = param.SubAccountId
  951. paramTemp.TaskId = param.LocalId
  952. paramTemp.TaskType = 3
  953. res := CooperationService{}.GetSupplierInTargetCount(paramTemp)
  954. reLocalTaskPreviews[i].InvitableNum = res["invitableNum"]
  955. reLocalTaskPreviews[i].InvitingNum = res["invitingNum"]
  956. reLocalTaskPreviews[i].CooperatingNum = res["cooperatingNum"]
  957. }
  958. }
  959. result = vo.ResultVO{
  960. Page: param.Page,
  961. PageSize: param.PageSize,
  962. Total: total,
  963. Data: reLocalTaskPreviews,
  964. }
  965. return result, nil
  966. }
  967. // 删除本地生活任务
  968. func (s LocalLifeService) DeleteLocalLife(localId string) (*string, error) {
  969. res, err := dao.LocalLifeDao{}.DeleteLocalLife(localId)
  970. if err != nil {
  971. logrus.Errorf("[DeleteLocalLife service] call DeleteLocalLife error,err:%+v", err)
  972. return res, err
  973. }
  974. return res, nil
  975. }
  976. // 结束本地生活任务
  977. func (s LocalLifeService) CloseLocalLife(localId string) (string, error) {
  978. // 任务待办:待审核、待支付、达人未处理、初稿待审、链接待审、待结算 (待发货、待签收) 达人待预约探店时间、探店时间待确认、达人待探店 未传初稿、未发作品、未传数据
  979. // 合作待办:可邀约、邀约中、合作中
  980. localLife, err := dao.LocalLifeDao{}.GetLocalById(localId)
  981. if err != nil {
  982. return "0", err
  983. }
  984. if localLife == nil {
  985. return "0", errors.New("任务不存在")
  986. }
  987. var needProcess int64
  988. if localLife.TaskStatus == 4 || localLife.TaskStatus == 8 {
  989. // 达人未处理 or 物流待办 or 初稿待审、链接待审、待结算
  990. _ = dao.Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id = ? and (task_status = ? or task_stage < ?)", localId, 1, 15).Count(&needProcess).Error // task_status=1待选
  991. }
  992. if localLife.TaskStatus == 2 || localLife.TaskStatus == 4 || needProcess > 0 {
  993. // 存在待办不可结束
  994. return "1", nil
  995. } else {
  996. err := dao.LocalLifeDao{}.UpdateLocal(entity.LocalLifeInfo{
  997. LocalID: localId,
  998. TaskStatus: 10,
  999. UpdatedAt: time.Now(),
  1000. })
  1001. return "0", err
  1002. }
  1003. }
  1004. // 草稿箱——本地生活
  1005. func (s LocalLifeService) GetLocalLifeDraftList(param *vo.LocalDraftParam) (vo.ResultVO, error) {
  1006. if param.Page == 0 {
  1007. param.Page = 1
  1008. }
  1009. if param.PageSize == 0 {
  1010. param.PageSize = 10
  1011. }
  1012. var result vo.ResultVO
  1013. reLocalTaskPreviews, total, err := (&dao.LocalLifeDao{}).GetLocalDraftList(param)
  1014. if err != nil {
  1015. return result, err
  1016. }
  1017. for i := range reLocalTaskPreviews {
  1018. var creatorName string
  1019. var storeName string
  1020. var storeLocation string
  1021. var mainImage string
  1022. if reLocalTaskPreviews[i].SubAccountId == 0 {
  1023. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reLocalTaskPreviews[i].EnterpriseId)
  1024. if err == nil && enterprise != nil {
  1025. creatorName = enterprise.BusinessName
  1026. }
  1027. } else {
  1028. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reLocalTaskPreviews[i].SubAccountId)
  1029. if err == nil && subAccount != nil {
  1030. creatorName = subAccount.SubAccountName
  1031. }
  1032. }
  1033. store, err := dao.StoreDao{}.GetStoreByID(reLocalTaskPreviews[i].StoreId)
  1034. if err == nil && store != nil {
  1035. storeName = store.StoreName
  1036. storeLocation = store.StoreLocation
  1037. }
  1038. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(reLocalTaskPreviews[i].StoreId)
  1039. reLocalTaskPreviews[i].CreatorName = creatorName
  1040. reLocalTaskPreviews[i].StoreName = storeName
  1041. reLocalTaskPreviews[i].StoreLocation = storeLocation
  1042. reLocalTaskPreviews[i].MainImage = mainImage
  1043. }
  1044. result = vo.ResultVO{
  1045. Page: param.Page,
  1046. PageSize: param.PageSize,
  1047. Total: total,
  1048. Data: reLocalTaskPreviews,
  1049. }
  1050. return result, nil
  1051. }
  1052. // 探店本地生活列表
  1053. func (s LocalLifeService) GetStoreExploreList(param *vo.LocalSearchParam) (vo.ResultVO, error) {
  1054. if param.Page == 0 {
  1055. param.Page = 1
  1056. }
  1057. if param.PageSize == 0 {
  1058. param.PageSize = 10
  1059. }
  1060. var result vo.ResultVO
  1061. reLocalStoreExplorePreviews, total, err := (&dao.LocalLifeDao{}).GetLocalStoreExplorePreviews(param)
  1062. if err != nil {
  1063. return result, err
  1064. }
  1065. for i := range reLocalStoreExplorePreviews {
  1066. var creatorName string
  1067. var storeName string
  1068. var storeLocation string
  1069. var mainImage string
  1070. if reLocalStoreExplorePreviews[i].SubAccountId == 0 {
  1071. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reLocalStoreExplorePreviews[i].EnterpriseId)
  1072. if err == nil && enterprise != nil {
  1073. creatorName = enterprise.BusinessName
  1074. }
  1075. } else {
  1076. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reLocalStoreExplorePreviews[i].SubAccountId)
  1077. if err == nil && subAccount != nil {
  1078. creatorName = subAccount.SubAccountName
  1079. }
  1080. }
  1081. store, err := dao.StoreDao{}.GetStoreByID(reLocalStoreExplorePreviews[i].StoreId)
  1082. if err == nil && store != nil {
  1083. storeName = store.StoreName
  1084. storeLocation = store.StoreLocation
  1085. }
  1086. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(reLocalStoreExplorePreviews[i].StoreId)
  1087. reLocalStoreExplorePreviews[i].CreatorName = creatorName
  1088. reLocalStoreExplorePreviews[i].StoreName = storeName
  1089. reLocalStoreExplorePreviews[i].StoreLocation = storeLocation
  1090. reLocalStoreExplorePreviews[i].MainImage = mainImage
  1091. }
  1092. result = vo.ResultVO{
  1093. Page: param.Page,
  1094. PageSize: param.PageSize,
  1095. Total: total,
  1096. Data: reLocalStoreExplorePreviews,
  1097. }
  1098. return result, nil
  1099. }
  1100. // 探店达人详情
  1101. func (s LocalLifeService) GetStoreExploreInfo(param *vo.StoreExploreParam) (*vo.ResultVO, error) {
  1102. if param.Page <= 0 {
  1103. param.Page = 1
  1104. }
  1105. if param.PageSize <= 0 {
  1106. param.PageSize = 10
  1107. }
  1108. var reStoreExploreTalents []*vo.ReStoreExploreTalent
  1109. var total int64
  1110. result := vo.ResultVO{
  1111. Page: param.Page,
  1112. PageSize: param.PageSize,
  1113. Total: total,
  1114. Data: reStoreExploreTalents,
  1115. }
  1116. var localLifeTaskInfos []*entity.LocalLifeTaskInfo
  1117. var err error
  1118. localLifeId := param.LocalLifeId
  1119. if param.Status == 1 { // 待预约
  1120. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByTaskStage(localLifeId, 4, "", param.Page, param.PageSize)
  1121. } else if param.Status == 2 { // 待确认
  1122. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByTaskStage(localLifeId, 5, param.SearchTime, param.Page, param.PageSize)
  1123. } else if param.Status == 3 { // 待探店
  1124. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByBookStatus(localLifeId, 5, param.SearchTime, param.Page, param.PageSize)
  1125. } else if param.Status == 4 { // 已探店
  1126. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByBookStatus(localLifeId, 6, param.SearchTime, param.Page, param.PageSize)
  1127. }
  1128. if err != nil {
  1129. return nil, err
  1130. }
  1131. for _, localLifeTaskInfo := range localLifeTaskInfos {
  1132. // 获取达人信息
  1133. platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.GetUserInfo(localLifeTaskInfo.OpenID)
  1134. talentPreview := &vo.TalentPreview{
  1135. TalentId: localLifeTaskInfo.TalentID,
  1136. TalentPhoto: platformKuaishouUserInfo.HeadUri,
  1137. TalentName: platformKuaishouUserInfo.NickName,
  1138. Account: platformKuaishouUserInfo.OpenID,
  1139. Location: platformKuaishouUserInfo.City,
  1140. Gender: platformKuaishouUserInfo.Gender,
  1141. }
  1142. reStoreExploreTalent := &vo.ReStoreExploreTalent{
  1143. ReTalentPreview: talentPreview,
  1144. TaskId: localLifeTaskInfo.TaskID,
  1145. }
  1146. if param.Status == 1 {
  1147. reStoreExploreTalent.CooperateTime = localLifeTaskInfo.SelectDate.Format("2006-01-02 15:04:05")
  1148. } else if param.Status == 2 {
  1149. reStoreExploreTalent.ReserveTime = localLifeTaskInfo.ReserveTime.Format("2006-01-02 15:04:05")
  1150. } else if param.Status == 3 {
  1151. reStoreExploreTalent.ExploreTime = localLifeTaskInfo.ExploreTime.Format("2006-01-02 15:04:05")
  1152. reStoreExploreTalent.Operator = ""
  1153. } else if param.Status == 4 {
  1154. reStoreExploreTalent.FinishExploreTime = localLifeTaskInfo.FinishExploreTime.Format("2006-01-02 15:04:05")
  1155. reStoreExploreTalent.Operator = ""
  1156. }
  1157. reStoreExploreTalents = append(reStoreExploreTalents, reStoreExploreTalent)
  1158. }
  1159. result = vo.ResultVO{
  1160. Page: param.Page,
  1161. PageSize: param.PageSize,
  1162. Total: total,
  1163. Data: reStoreExploreTalents,
  1164. }
  1165. return &result, nil
  1166. }
  1167. // 探店达人列表角标
  1168. func (t LocalLifeService) StoreExploreInfoCount(param *vo.StoreExploreParam) map[string]int64 {
  1169. res := make(map[string]int64)
  1170. var needBook int64
  1171. var needConfirm int64
  1172. var needExplore int64
  1173. var explored int64
  1174. dao.Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id = ? AND task_stage = ?", param.LocalLifeId, 4).Count(&needBook)
  1175. dao.Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id = ? AND task_stage = ?", param.LocalLifeId, 5).Count(&needConfirm)
  1176. dao.Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id = ? AND book_status = ?", param.LocalLifeId, 5).Count(&needExplore)
  1177. dao.Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id = ? AND book_status = ?", param.LocalLifeId, 6).Count(&explored)
  1178. res["needBook"] = needBook
  1179. res["needConfirm"] = needConfirm
  1180. res["needExplore"] = needExplore
  1181. res["explored"] = explored
  1182. return res
  1183. }
  1184. // 终止合作
  1185. func (s LocalLifeService) StoreExploreOver(param *vo.LocalTalentOperateParam) (*string, error) {
  1186. taskId := param.TaskId
  1187. if taskId == "" {
  1188. return nil, errors.New("taskId is empty")
  1189. }
  1190. updateData := map[string]interface{}{
  1191. "task_stage": 17,
  1192. "terminate_reason": param.Reason,
  1193. "terminate_time": time.Now(),
  1194. }
  1195. if param.SubAccountId == 0 {
  1196. updateData["terminate_operator_type"] = 1
  1197. updateData["terminate_operator"] = param.EnterpriseId
  1198. } else {
  1199. updateData["terminate_operator_type"] = 2
  1200. updateData["terminate_operator"] = param.SubAccountId
  1201. }
  1202. err := dao.LocalLifeTaskInfoDao{}.UpdateField(param.TaskId, updateData)
  1203. if err != nil {
  1204. return nil, err
  1205. }
  1206. return &taskId, nil
  1207. }
  1208. // 预约时间批量同意/驳回
  1209. func (s LocalLifeService) StoreExploreOperate(param *vo.LocalTalentOperateParam) error {
  1210. taskIds := param.TaskIds
  1211. if taskIds == nil {
  1212. return errors.New("taskIds is empty")
  1213. }
  1214. var bookIds []int64
  1215. for _, taskId := range taskIds {
  1216. bookInfo, err := dao.BookInfoDao{}.GetLastByTaskId(taskId)
  1217. if err != nil {
  1218. return err
  1219. }
  1220. bookIds = append(bookIds, bookInfo.BookID)
  1221. }
  1222. var bookinfoNew entity.BookInfo
  1223. if param.Status == 2 {
  1224. bookinfoNew = entity.BookInfo{
  1225. IsReview: 1,
  1226. IsOk: 2,
  1227. RejectAt: time.Now(),
  1228. ReviseOpinion: param.Reason,
  1229. }
  1230. } else if param.Status == 1 {
  1231. bookinfoNew = entity.BookInfo{
  1232. IsReview: 1,
  1233. IsOk: 1,
  1234. AgreeAt: time.Now(),
  1235. }
  1236. } else {
  1237. return errors.New("status error")
  1238. }
  1239. if param.SubAccountId == 0 {
  1240. bookinfoNew.BOperatorType = 1
  1241. bookinfoNew.BOperator = param.EnterpriseId
  1242. } else {
  1243. bookinfoNew.BOperatorType = 2
  1244. bookinfoNew.BOperator = strconv.FormatInt(param.SubAccountId, 10)
  1245. }
  1246. err1 := dao.BookInfoDao{}.UpdateBookStatus(bookIds, bookinfoNew)
  1247. if err1 != nil {
  1248. return err1
  1249. }
  1250. if param.Status == 1 {
  1251. err2 := dao.LocalLifeTaskInfoDao{}.UpdateLocalStatus(taskIds, entity.LocalLifeTaskInfo{
  1252. TaskStage: 7,
  1253. BookStatus: 5,
  1254. ExploreTime: time.Now(),
  1255. })
  1256. if err2 != nil {
  1257. return err2
  1258. }
  1259. }
  1260. return nil
  1261. }
  1262. // 本地生活任务待办
  1263. func (p LocalLifeService) GetTaskToDo(enterpriseId string, subAccountId int64, taskType int64) (map[string]map[string]int64, error) {
  1264. res := make(map[string]map[string]int64)
  1265. redbook, err1 := dao.LocalLifeDao{}.GetLocalLifeToDo(enterpriseId, subAccountId, 1, taskType)
  1266. if err1 != nil {
  1267. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err1)
  1268. return res, err1
  1269. }
  1270. douyin, err2 := dao.LocalLifeDao{}.GetLocalLifeToDo(enterpriseId, subAccountId, 2, taskType)
  1271. if err2 != nil {
  1272. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err2)
  1273. return res, err2
  1274. }
  1275. kuaishou, err3 := dao.LocalLifeDao{}.GetLocalLifeToDo(enterpriseId, subAccountId, 4, taskType)
  1276. if err3 != nil {
  1277. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err3)
  1278. return res, err3
  1279. }
  1280. weibo, err4 := dao.LocalLifeDao{}.GetLocalLifeToDo(enterpriseId, subAccountId, 3, taskType)
  1281. if err4 != nil {
  1282. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err4)
  1283. return res, err4
  1284. }
  1285. bilibili, err5 := dao.LocalLifeDao{}.GetLocalLifeToDo(enterpriseId, subAccountId, 5, taskType)
  1286. if err5 != nil {
  1287. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err5)
  1288. return res, err5
  1289. }
  1290. all := make(map[string]int64)
  1291. all["needReview"] = redbook["needReview"] + douyin["needReview"] + kuaishou["needReview"] + weibo["needReview"] + bilibili["needReview"]
  1292. all["needPay"] = redbook["needPay"] + douyin["needPay"] + kuaishou["needPay"] + weibo["needPay"] + bilibili["needPay"]
  1293. all["needProcess"] = redbook["needProcess"] + douyin["needProcess"] + kuaishou["needProcess"] + weibo["needProcess"] + bilibili["needProcess"]
  1294. all["needCheck"] = redbook["needCheck"] + douyin["needCheck"] + kuaishou["needCheck"] + weibo["needCheck"] + bilibili["needCheck"]
  1295. all["needQuality"] = redbook["needQuality"] + douyin["needQuality"] + kuaishou["needQuality"] + weibo["needQuality"] + bilibili["needQuality"]
  1296. all["needCalculate"] = redbook["needCalculate"] + douyin["needCalculate"] + kuaishou["needCalculate"] + weibo["needCalculate"] + bilibili["needCalculate"]
  1297. res["redbook"] = redbook
  1298. res["douyin"] = douyin
  1299. res["kuaishou"] = kuaishou
  1300. res["weibo"] = weibo
  1301. res["bilibili"] = bilibili
  1302. res["all"] = all
  1303. return res, nil
  1304. }
  1305. // 探店邀约任务待办
  1306. func (p LocalLifeService) GetExploreToDo(enterpriseId string, subAccountId int64) (map[string]map[string]int64, error) {
  1307. res := make(map[string]map[string]int64)
  1308. redbook, err1 := dao.LocalLifeDao{}.GetExploreToDo(enterpriseId, subAccountId, 1)
  1309. if err1 != nil {
  1310. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err1)
  1311. return res, err1
  1312. }
  1313. douyin, err2 := dao.LocalLifeDao{}.GetExploreToDo(enterpriseId, subAccountId, 2)
  1314. if err2 != nil {
  1315. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err2)
  1316. return res, err2
  1317. }
  1318. kuaishou, err3 := dao.LocalLifeDao{}.GetExploreToDo(enterpriseId, subAccountId, 4)
  1319. if err3 != nil {
  1320. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err3)
  1321. return res, err3
  1322. }
  1323. weibo, err4 := dao.LocalLifeDao{}.GetExploreToDo(enterpriseId, subAccountId, 3)
  1324. if err4 != nil {
  1325. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err4)
  1326. return res, err4
  1327. }
  1328. bilibili, err5 := dao.LocalLifeDao{}.GetExploreToDo(enterpriseId, subAccountId, 5)
  1329. if err5 != nil {
  1330. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err5)
  1331. return res, err5
  1332. }
  1333. all := make(map[string]int64)
  1334. all["needBook"] = redbook["needBook"] + douyin["needBook"] + kuaishou["needBook"] + weibo["needBook"] + bilibili["needBook"]
  1335. all["needConfirm"] = redbook["needConfirm"] + douyin["needConfirm"] + kuaishou["needConfirm"] + weibo["needConfirm"] + bilibili["needConfirm"]
  1336. all["needExplore"] = redbook["needExplore"] + douyin["needExplore"] + kuaishou["needExplore"] + weibo["needExplore"] + bilibili["needExplore"]
  1337. res["redbook"] = redbook
  1338. res["douyin"] = douyin
  1339. res["kuaishou"] = kuaishou
  1340. res["weibo"] = weibo
  1341. res["bilibili"] = bilibili
  1342. res["all"] = all
  1343. return res, nil
  1344. }
  1345. // 违约管理任务待办
  1346. func (p LocalLifeService) GetDefaultToDo(enterpriseId string, subAccountId int64, taskType int64) (map[string]map[string]int64, error) {
  1347. res := make(map[string]map[string]int64)
  1348. redbook, err1 := dao.LocalLifeDao{}.GetDefaultToDo(enterpriseId, subAccountId, 1, taskType)
  1349. if err1 != nil {
  1350. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err1)
  1351. return res, err1
  1352. }
  1353. douyin, err2 := dao.LocalLifeDao{}.GetDefaultToDo(enterpriseId, subAccountId, 2, taskType)
  1354. if err2 != nil {
  1355. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err2)
  1356. return res, err2
  1357. }
  1358. kuaishou, err3 := dao.LocalLifeDao{}.GetDefaultToDo(enterpriseId, subAccountId, 4, taskType)
  1359. if err3 != nil {
  1360. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err3)
  1361. return res, err3
  1362. }
  1363. weibo, err4 := dao.LocalLifeDao{}.GetDefaultToDo(enterpriseId, subAccountId, 3, taskType)
  1364. if err4 != nil {
  1365. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err4)
  1366. return res, err4
  1367. }
  1368. bilibili, err5 := dao.LocalLifeDao{}.GetDefaultToDo(enterpriseId, subAccountId, 5, taskType)
  1369. if err5 != nil {
  1370. logrus.Errorf("[GetLocalLifeToDo service] call GetLocalLifeToDo error,err:%+v", err5)
  1371. return res, err5
  1372. }
  1373. all := make(map[string]int64)
  1374. all["noSketch"] = redbook["noSketch"] + douyin["noSketch"] + kuaishou["noSketch"] + weibo["noSketch"] + bilibili["noSketch"]
  1375. all["noWork"] = redbook["noWork"] + douyin["noWork"] + kuaishou["noWork"] + weibo["noWork"] + bilibili["noWork"]
  1376. all["noData"] = redbook["noData"] + douyin["noData"] + kuaishou["noData"] + weibo["noData"] + bilibili["noData"]
  1377. all["cooperateOver"] = redbook["cooperateOver"] + douyin["cooperateOver"] + kuaishou["cooperateOver"] + weibo["cooperateOver"] + bilibili["cooperateOver"]
  1378. res["redbook"] = redbook
  1379. res["douyin"] = douyin
  1380. res["kuaishou"] = kuaishou
  1381. res["weibo"] = weibo
  1382. res["bilibili"] = bilibili
  1383. res["all"] = all
  1384. return res, nil
  1385. }
  1386. // 合作待办-任务邀约
  1387. func (p LocalLifeService) GetTaskInviteToDo(enterpriseId string, subAccountId int64) (map[string]map[string]int64, error) {
  1388. res := make(map[string]map[string]int64)
  1389. redbook, err1 := dao.LocalLifeDao{}.GetTaskInviteToDo(enterpriseId, subAccountId, 1)
  1390. if err1 != nil {
  1391. logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err1)
  1392. return res, err1
  1393. }
  1394. douyin, err2 := dao.LocalLifeDao{}.GetTaskInviteToDo(enterpriseId, subAccountId, 2)
  1395. if err2 != nil {
  1396. logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err2)
  1397. return res, err2
  1398. }
  1399. kuaishou, err3 := dao.LocalLifeDao{}.GetTaskInviteToDo(enterpriseId, subAccountId, 4)
  1400. if err3 != nil {
  1401. logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err3)
  1402. return res, err3
  1403. }
  1404. weibo, err4 := dao.LocalLifeDao{}.GetTaskInviteToDo(enterpriseId, subAccountId, 3)
  1405. if err4 != nil {
  1406. logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err4)
  1407. return res, err4
  1408. }
  1409. bilibili, err5 := dao.LocalLifeDao{}.GetTaskInviteToDo(enterpriseId, subAccountId, 5)
  1410. if err5 != nil {
  1411. logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err5)
  1412. return res, err5
  1413. }
  1414. all := make(map[string]int64)
  1415. all["availInvitationNum"] = redbook["availInvitationNum"] + douyin["availInvitationNum"] + kuaishou["availInvitationNum"] + weibo["availInvitationNum"] + bilibili["availInvitationNum"]
  1416. all["invitingNum"] = redbook["invitingNum"] + douyin["invitingNum"] + kuaishou["invitingNum"] + weibo["invitingNum"] + bilibili["invitingNum"]
  1417. all["cooperatingNum"] = redbook["cooperatingNum"] + douyin["cooperatingNum"] + kuaishou["cooperatingNum"] + weibo["cooperatingNum"] + bilibili["cooperatingNum"]
  1418. res["redbook"] = redbook
  1419. res["douyin"] = douyin
  1420. res["kuaishou"] = kuaishou
  1421. res["weibo"] = weibo
  1422. res["bilibili"] = bilibili
  1423. res["all"] = all
  1424. return res, nil
  1425. }