s_local_life.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/issue9/conv"
  6. "github.com/sirupsen/logrus"
  7. "time"
  8. "youngee_b_api/db"
  9. "youngee_b_api/model/common_model"
  10. "youngee_b_api/model/gorm_model"
  11. "youngee_b_api/model/http_model"
  12. )
  13. var SLocalLife *sLocalLife
  14. type sLocalLife struct {
  15. }
  16. // CreateSLocalLife 新建服务商加入商单后的公开本地生活
  17. func (*sLocalLife) CreateSLocalLife(ctx context.Context, request *http_model.LocalLifeAddToListRequest) error {
  18. var sLocalLifeInfo *gorm_model.YounggeeSLocalLifeInfo
  19. sLocalLifeInfo = &gorm_model.YounggeeSLocalLifeInfo{}
  20. // 1. 建立SLocalLife信息
  21. // 1.1. 根据传入的LocalLifeId去LocalLife表查找信息补全SLocalLife
  22. localLifeInfo, localErr := db.GetLocalLifeDetail(ctx, request.LocalId)
  23. if localErr != nil {
  24. return localErr
  25. }
  26. if localLifeInfo != nil {
  27. sLocalLifeInfo.LocalId = localLifeInfo.LocalId
  28. sLocalLifeInfo.SettleNum = 0
  29. sLocalLifeInfo.RecruitNum = 0
  30. sLocalLifeInfo.ApplyNum = 0
  31. sLocalLifeInfo.LocalType = localLifeInfo.LocalType
  32. sLocalLifeInfo.LocalName = localLifeInfo.LocalName
  33. sLocalLifeInfo.LocalPlatform = localLifeInfo.LocalPlatform
  34. sLocalLifeInfo.TaskStatus = localLifeInfo.TaskStatus
  35. sLocalLifeInfo.StoreId = localLifeInfo.StoreId
  36. sLocalLifeInfo.TeamBuyingId = localLifeInfo.TeamBuyingId
  37. sLocalLifeInfo.TaskForm = localLifeInfo.TaskForm
  38. sLocalLifeInfo.ContentType = localLifeInfo.ContentType
  39. sLocalLifeInfo.SLocalStatus = 2
  40. // 1.2. 填入加入商单操作人信息
  41. var operatorType int
  42. if request.SubAccountId == 0 {
  43. operatorType = 1
  44. } else {
  45. operatorType = 2
  46. }
  47. sLocalLifeInfo.SubAccountId = request.SubAccountId
  48. sLocalLifeInfo.SupplierId = request.SupplierId
  49. sLocalLifeInfo.OperatorType = operatorType
  50. currTime := time.Now()
  51. sLocalLifeInfo.CreateTime = &currTime
  52. // 2. 入库
  53. sLocalId, createErr := db.CreateSLocalLife(ctx, sLocalLifeInfo)
  54. if createErr != nil {
  55. return createErr
  56. }
  57. // 2. 建立新的recruitStrategy
  58. // 2.1. 根据localId去查找原来的recruitStrategy
  59. recruitStrategys, strategyErr := db.GetRecruitStrategyByProjectId(ctx, request.LocalId)
  60. if strategyErr != nil {
  61. return strategyErr
  62. }
  63. // 2.2. 设置新的结构体以写入
  64. var currRecruitStrategys []gorm_model.RecruitStrategy
  65. for _, strategy := range recruitStrategys {
  66. var currStrategy gorm_model.RecruitStrategy
  67. currStrategy.StrategyID = strategy.StrategyID
  68. currStrategy.QuoteRecruitStrategyId = int(strategy.RecruitStrategyID)
  69. currStrategy.FeeForm = strategy.FeeForm
  70. currStrategy.FollowersLow = strategy.FollowersLow
  71. currStrategy.FollowersUp = strategy.FollowersUp
  72. currStrategy.RecruitNumber = strategy.RecruitNumber
  73. currStrategy.Offer = strategy.Offer
  74. currStrategy.TOffer = strategy.TOffer
  75. currStrategy.ProjectID = "0"
  76. currStrategy.ServiceCharge = strategy.ServiceCharge
  77. currStrategy.ServiceRate = strategy.ServiceRate
  78. currStrategy.SLocalId = sLocalId
  79. currStrategy.StrategyType = 2
  80. currRecruitStrategys = append(currRecruitStrategys, currStrategy)
  81. }
  82. // 2.3. 写入
  83. createStrategyErr := db.CreateSpecialStrategy(ctx, currRecruitStrategys)
  84. if createStrategyErr != nil {
  85. return createStrategyErr
  86. }
  87. }
  88. return nil
  89. }
  90. func (*sLocalLife) ShowSLocalLife(ctx context.Context, req *http_model.ShowSLocalRequest) (*http_model.ShowSLocalData, error) {
  91. var sLocalInfo *http_model.ShowSLocalData
  92. sLocalInfo = &http_model.ShowSLocalData{}
  93. // 1. 查询系统信息
  94. localInfo, localErr := db.GetLocalLifeDetail(ctx, req.LocalId)
  95. if localErr != nil {
  96. return nil, localErr
  97. }
  98. if localInfo != nil {
  99. sLocalInfo.LocalId = localInfo.LocalId
  100. sLocalInfo.SLocalId = req.SLocalId
  101. sLocalInfo.LocalPlatform = localInfo.LocalPlatform
  102. sLocalInfo.TaskStatus = localInfo.TaskStatus
  103. sLocalInfo.EnterpriseId = localInfo.EnterpriseId
  104. sLocalInfo.ServiceChargeRate = localInfo.ServiceChargeRate
  105. sLocalInfo.EstimatedCost = localInfo.EstimatedCost
  106. sLocalInfo.CreateAt = conv.MustString(localInfo.CreatedAt)
  107. // 2. 关联主体
  108. // 2.1. 门店信息
  109. storeInfo, storeErr := db.FindStoreById(ctx, localInfo.StoreId)
  110. if storeErr != nil {
  111. return nil, storeErr
  112. }
  113. if storeInfo != nil {
  114. sLocalInfo.StoreId = storeInfo.StoreId
  115. sLocalInfo.StoreName = storeInfo.StoreName
  116. sLocalInfo.StoreCategory = storeInfo.StoreCategory
  117. sLocalInfo.StoreRelatedAt = conv.MustString(localInfo.StoreRelatedAt)
  118. // 2.2. 门店图片信息
  119. storePhotoInfo, storePhotoErr := db.GetStorePhotoByStoreID(ctx, localInfo.StoreId)
  120. if storePhotoErr != nil {
  121. return nil, storePhotoErr
  122. }
  123. if storePhotoInfo != nil {
  124. for _, photo := range storePhotoInfo {
  125. if photo.Symbol == 1 {
  126. sLocalInfo.StoreMainPhotoSymbol = 1
  127. sLocalInfo.StoreMainPhotoUrl = photo.PhotoUrl
  128. sLocalInfo.StoreMainPhotoUid = photo.PhotoUid
  129. }
  130. }
  131. }
  132. }
  133. // 2.3. 团购信息
  134. teamInfo, teamErr := db.FindTeamById(ctx, localInfo.StoreId)
  135. if teamErr != nil {
  136. return nil, teamErr
  137. }
  138. if teamInfo != nil {
  139. sLocalInfo.TeamBuyingId = teamInfo.StoreId
  140. sLocalInfo.TeamBuyingName = teamInfo.TeamBuyingName
  141. sLocalInfo.TeamBuyingCategory = teamInfo.TeamBuyingCategory
  142. sLocalInfo.TeamBuyingRelatedAt = conv.MustString(localInfo.TeamBuyingRelatedAt)
  143. // 2.4. 团购图片信息
  144. teamPhotoInfo, teamPhotoErr := db.GetTeamPhotoByStoreID(ctx, localInfo.StoreId)
  145. if teamPhotoErr != nil {
  146. return nil, teamPhotoErr
  147. }
  148. if teamPhotoInfo != nil {
  149. for _, photo := range teamPhotoInfo {
  150. if photo.Symbol == 1 {
  151. sLocalInfo.TeamMainPhotoSymbol = 1
  152. sLocalInfo.TeamMainPhotoUrl = photo.PhotoUrl
  153. sLocalInfo.TeamMainPhotoUid = photo.PhotoUid
  154. }
  155. }
  156. }
  157. }
  158. // 3. 招募要求
  159. sLocalInfo.TalentType = localInfo.TalentType
  160. sLocalInfo.RecruitDdl = conv.MustString(localInfo.RecruitDdl)
  161. recruitStrategy, recruitErr := db.GetRecruitStrategyBySLocalId(ctx, req.SLocalId)
  162. if recruitErr != nil {
  163. return nil, recruitErr
  164. }
  165. if recruitStrategy != nil {
  166. for _, strategy := range recruitStrategy {
  167. showStrategy := http_model.ShowSRecruitStrategy{
  168. StrategyID: strategy.StrategyID,
  169. FeeForm: strategy.FeeForm,
  170. FollowersLow: strategy.FollowersLow,
  171. FollowersUp: strategy.FollowersUp,
  172. RecruitNumber: strategy.RecruitNumber,
  173. Offer: strategy.Offer,
  174. }
  175. sLocalInfo.RecruitStrategys = append(sLocalInfo.RecruitStrategys, showStrategy)
  176. }
  177. }
  178. // 4. 执行要求
  179. sLocalInfo.TaskForm = localInfo.TaskForm
  180. sLocalInfo.ContentType = localInfo.ContentType
  181. briefInfo, briefErr := db.FindBriefByLocalId(ctx, req.LocalId)
  182. if briefErr != nil {
  183. return nil, briefErr
  184. }
  185. if briefInfo != nil {
  186. sLocalInfo.LocalBrief = briefInfo
  187. }
  188. materialInfo, materialErr := db.FindMaterialByLocalId(ctx, req.LocalId)
  189. if materialErr != nil {
  190. return nil, materialErr
  191. }
  192. if materialInfo != nil {
  193. sLocalInfo.LocalMaterial = materialInfo
  194. }
  195. }
  196. return sLocalInfo, nil
  197. }
  198. func (*sLocalLife) GetFullSLocalLifeList(ctx context.Context, pageSize, pageNum int32, supplierId int, condition *common_model.SLocalLifeCondition) (*http_model.FullSLocalListData, error) {
  199. // 1. 查询本地生活任务基本信息
  200. fullLocals, total, err := db.GetFullSLocalLifeList(ctx, pageSize, pageNum, condition)
  201. if err != nil {
  202. logrus.WithContext(ctx).Errorf("[fullLocals service] call GetFullSLocalLifeList error,err:%+v", err)
  203. return nil, err
  204. }
  205. var fullLocalData *http_model.FullSLocalListData
  206. fullLocalData = &http_model.FullSLocalListData{}
  207. fullLocalData.Total = total
  208. for _, fullLocal := range fullLocals {
  209. var fullLocalPreview *http_model.FullSLocalPreview
  210. fullLocalPreview = &http_model.FullSLocalPreview{}
  211. fullLocalPreview.LocalId = fullLocal.LocalId
  212. fullLocalPreview.TaskStatus = fullLocal.TaskStatus
  213. fullLocalPreview.LocalPlatform = fullLocal.LocalPlatform
  214. fullLocalPreview.TaskForm = fullLocal.TaskForm
  215. fullLocalPreview.LocalType = fullLocal.LocalType
  216. fullLocalPreview.LocalContentType = fullLocal.ContentType
  217. fullLocalPreview.SupplierId = supplierId
  218. fullLocalPreview.SubAccountId = fullLocal.SubAccountId
  219. fullLocalPreview.OperatorType = fullLocal.OperatorType
  220. fullLocalPreview.CreateTime = conv.MustString(fullLocal.CreateTime)
  221. fullLocalPreview.ServiceCharge = fullLocal.ServiceCharge
  222. fullLocalPreview.ServiceChargeActual = fullLocal.ServiceChargeActual
  223. fullLocalPreview.ApplyNum = fullLocal.ApplyNum
  224. fullLocalPreview.RecruitNum = fullLocal.RecruitNum
  225. fullLocalPreview.SettleNum = fullLocal.SettleNum
  226. fullLocalData.FullSLocalPreview = append(fullLocalData.FullSLocalPreview, fullLocalPreview)
  227. }
  228. // 2. 查询本地生活补充信息:门店信息,招募策略
  229. for _, local := range fullLocalData.FullSLocalPreview {
  230. // 2.1. 门店信息
  231. storeInfo, productErr := db.FindStoreById(ctx, local.StoreId)
  232. if productErr != nil {
  233. return nil, productErr
  234. }
  235. if storeInfo != nil {
  236. local.StoreId = storeInfo.StoreId
  237. local.StoreName = storeInfo.StoreName
  238. }
  239. // 2.2. 门店图片信息
  240. productPhotoInfo, productPhotoErr := db.GetStorePhotoByStoreID(ctx, local.StoreId)
  241. if productPhotoErr != nil {
  242. return nil, productPhotoErr
  243. }
  244. if productPhotoInfo != nil {
  245. for _, photo := range productPhotoInfo {
  246. fmt.Println(photo)
  247. if photo.Symbol == 1 {
  248. local.StoreMainPhotoSymbol = 1
  249. local.StoreMainPhotoUrl = photo.PhotoUrl
  250. local.StoreMainPhotoUid = photo.PhotoUid
  251. }
  252. }
  253. }
  254. }
  255. return fullLocalData, nil
  256. }
  257. // GetLocalTaskList 查询本地生活子任务
  258. func (*sLocalLife) GetLocalTaskList(ctx context.Context, pageSize, pageNum int32, orderBy []string, orderDesc []int, condition *common_model.LocalTaskConditions) (*http_model.LocalTaskListData, error) {
  259. var localTaskListData *http_model.LocalTaskListData
  260. localTaskListData = &http_model.LocalTaskListData{}
  261. // 1. 根据condition查询子任务信息
  262. localTaskList, total, localTaskErr := db.GetLocalTaskList(ctx, pageSize, pageNum, orderBy, orderDesc, condition)
  263. if localTaskErr != nil {
  264. return nil, localTaskErr
  265. }
  266. if localTaskList != nil {
  267. localTaskListData.Total = total
  268. for _, localTask := range localTaskList {
  269. var localTaskInfo *http_model.LocalTaskPreview
  270. localTaskInfo = &http_model.LocalTaskPreview{}
  271. // 2. 补充查询达人身份信息
  272. talentInfo, talentErr := db.FindUserInfoByTalentId(ctx, localTask.TalentID)
  273. if talentErr != nil {
  274. return nil, talentErr
  275. }
  276. if talentInfo != nil {
  277. localTaskInfo.TaskId = localTask.TaskID
  278. localTaskInfo.TaskStage = localTask.TaskStage
  279. localTaskInfo.ServiceCharge = localTask.ServiceCharge
  280. localTaskInfo.DraftFee = localTask.DraftFee
  281. localTaskInfo.SupportFee = localTask.SupportFee
  282. localTaskInfo.StrategyId = localTask.StrategyID
  283. localTaskInfo.TaskStatus = localTask.TaskStatus
  284. localTaskInfo.CreateDate = conv.MustString(localTask.CreateDate)
  285. localTaskInfo.SelectDate = conv.MustString(localTask.SelectDate)
  286. localTaskInfo.DeliveryDate = conv.MustString(localTask.DeliveryDate)
  287. localTaskInfo.SignedTime = conv.MustString(localTask.SignedTime)
  288. localTaskInfo.CurBreakAt = conv.MustString(localTask.CurBreakAt)
  289. localTaskInfo.FansNum = localTask.FansNum
  290. localTaskInfo.VoteAvg = localTask.VoteAvg
  291. localTaskInfo.CommitAvg = localTask.CommitAvg
  292. localTaskInfo.BOperator = localTask.BOperator
  293. localTaskInfo.BOperatorType = localTask.BOperatorType
  294. localTaskInfo.SOperator = localTask.SOperator
  295. localTaskInfo.SOperatorType = localTask.SOperatorType
  296. localTaskInfo.PlatformNickname = talentInfo.NickName
  297. localTaskInfo.FansCount = talentInfo.Fan
  298. localTaskInfo.AvatarUrl = talentInfo.HeadUri
  299. localTaskInfo.Location = talentInfo.City
  300. localTaskInfo.Gender = talentInfo.Gender
  301. localTaskListData.LocalTaskPreview = append(localTaskListData.LocalTaskPreview, localTaskInfo)
  302. }
  303. }
  304. // 3. 本地生活任务信息补充
  305. sLocalInfo, sLocalErr := db.GetSLocalLifeDetail(ctx, condition.SLocalId)
  306. if sLocalErr != nil {
  307. return nil, sLocalErr
  308. }
  309. if sLocalInfo != nil {
  310. localTaskListData.SettleNum = sLocalInfo.SettleNum
  311. localTaskListData.RecruitNum = sLocalInfo.RecruitNum
  312. localTaskListData.ServiceChargeActual = sLocalInfo.ServiceChargeActual
  313. localTaskListData.ServiceChargeSettle = sLocalInfo.ServiceChargeSettle
  314. localTaskListData.EstimateServiceCharge = sLocalInfo.ServiceChargeActual
  315. localTaskListData.EstimateDraftFee = sLocalInfo.EstimateDraftFee
  316. localTaskListData.EstimateSupportFee = sLocalInfo.EstimateSupportFee
  317. }
  318. }
  319. return localTaskListData, nil
  320. }
  321. // ChangeTaskSupplierStatus 本地生活达人报名通过、拒绝报名
  322. func (*sLocalLife) ChangeTaskSupplierStatus(ctx context.Context, req *http_model.LocalChangeSupplierStatusRequest) error {
  323. // 1. 同意/拒绝
  324. RecruitStrategyIDs, err := db.ChangeLocalTaskStatus(ctx, req.TaskIds, req.SupplierStatus, req.SupplierId, req.SubAccountId)
  325. if err != nil {
  326. logrus.WithContext(ctx).Errorf("[project service] call ChangeTaskStatus error,err:%+v", err)
  327. return err
  328. }
  329. fmt.Println(RecruitStrategyIDs)
  330. return nil
  331. }
  332. // ChangeSupplierStatus 定向本地生活加入商单或拒绝
  333. func (*sLocalLife) ChangeSupplierStatus(ctx context.Context, req *http_model.SpecialLocalAddToListRequest) error {
  334. var sLocalInfo *gorm_model.YounggeeSLocalLifeInfo
  335. sLocalInfo = &gorm_model.YounggeeSLocalLifeInfo{}
  336. var operatorType int
  337. if req.SubAccountId == 0 {
  338. operatorType = 1
  339. } else {
  340. operatorType = 2
  341. }
  342. sLocalInfo.SLocalId = req.SLocalId
  343. sLocalInfo.SupplierId = req.SupplierId
  344. sLocalInfo.SubAccountId = req.SubAccountId
  345. sLocalInfo.OperatorType = operatorType
  346. sLocalInfo.SLocalStatus = req.SLocalStatus
  347. err := db.UpdateSLocal(ctx, sLocalInfo)
  348. if err != nil {
  349. return err
  350. }
  351. return nil
  352. }
  353. // CreateSpecialStrategy 定向本地生活替换服务费率
  354. func (*sLocalLife) CreateSpecialStrategy(ctx context.Context, request *http_model.LocalSpecialAddStrategyRequest) error {
  355. // 1. 添加服务商招募策略
  356. // 1.1. 整理数据
  357. for _, strategy := range request.RecruitStrategys {
  358. // 一口价需要计算服务费率和达人所见报价
  359. strategy.ServiceRate = int(strategy.ServiceCharge / strategy.Offer)
  360. strategy.TOffer = strategy.Offer - strategy.ServiceCharge
  361. strategy.ProjectID = "0"
  362. strategy.SLocalId = request.SLocalId
  363. strategy.QuoteRecruitStrategyId = int(strategy.RecruitStrategyID)
  364. }
  365. createErr := db.CreateSpecialStrategy(ctx, request.RecruitStrategys)
  366. if createErr != nil {
  367. return createErr
  368. }
  369. // 2. 修改sProject中的字段
  370. var sLocalInfo *gorm_model.YounggeeSLocalLifeInfo
  371. sLocalInfo = &gorm_model.YounggeeSLocalLifeInfo{}
  372. if request.SubAccountId == 0 {
  373. sLocalInfo.CreateStrategyType = 1
  374. sLocalInfo.CreateStrategyId = request.SupplierId
  375. } else {
  376. sLocalInfo.CreateStrategyType = 2
  377. sLocalInfo.CreateStrategyId = request.SubAccountId
  378. }
  379. sLocalInfo.SLocalId = request.SLocalId
  380. sLocalInfo.StrategyStatus = 1
  381. updateErr := db.UpdateSLocal(ctx, sLocalInfo)
  382. if updateErr != nil {
  383. return updateErr
  384. }
  385. return nil
  386. }
  387. // GetFullSLocalBillList 服务商本地生活任务账单列表
  388. func (*sLocalLife) GetFullSLocalBillList(ctx context.Context, req *http_model.FullSLocalBillListRequest) (*http_model.FullSLocalBillData, error) {
  389. // 1. 查询本地生活任务基本信息
  390. fullLocals, total, err := db.GetFullSLocalBillList(ctx, req.PageSize, req.PageNum, req.SupplierId)
  391. if err != nil {
  392. logrus.WithContext(ctx).Errorf("[fullLocals service] call GetFullSLocalLifeList error,err:%+v", err)
  393. return nil, err
  394. }
  395. var fullLocalData *http_model.FullSLocalBillData
  396. fullLocalData = &http_model.FullSLocalBillData{}
  397. fullLocalData.Total = total
  398. for _, fullLocal := range fullLocals {
  399. var fullLocalPreview *http_model.FullSLocalBillListData
  400. fullLocalPreview = &http_model.FullSLocalBillListData{}
  401. fullLocalPreview.SLocalId = fullLocal.SLocalId
  402. fullLocalPreview.LocalId = fullLocal.LocalId
  403. fullLocalPreview.LocalPlatform = fullLocal.LocalPlatform
  404. fullLocalPreview.TaskForm = fullLocal.TaskForm
  405. fullLocalPreview.ContentType = fullLocal.ContentType
  406. fullLocalPreview.TaskStatus = fullLocal.TaskStatus
  407. fullLocalPreview.EnterpriseId = fullLocal.EnterpriseId
  408. fullLocalPreview.SupplierId = fullLocal.SupplierId
  409. fullLocalPreview.SubAccountId = fullLocal.SubAccountId
  410. fullLocalPreview.ServiceChargeActual = fullLocal.ServiceChargeActual
  411. fullLocalPreview.ServiceChargeSettle = fullLocal.ServiceChargeSettle
  412. fullLocalPreview.StoreId = fullLocal.StoreId
  413. fullLocalData.SLocalList = append(fullLocalData.SLocalList, fullLocalPreview)
  414. }
  415. // 2. 查询本地生活补充信息:门店信息,招募策略
  416. for _, local := range fullLocalData.SLocalList {
  417. // 2.1. 门店信息
  418. storeInfo, productErr := db.FindStoreById(ctx, local.StoreId)
  419. if productErr != nil {
  420. return nil, productErr
  421. }
  422. if storeInfo != nil {
  423. local.StoreId = storeInfo.StoreId
  424. local.StoreName = storeInfo.StoreName
  425. }
  426. // 2.2. 门店图片信息
  427. productPhotoInfo, productPhotoErr := db.GetStorePhotoByStoreID(ctx, local.StoreId)
  428. if productPhotoErr != nil {
  429. return nil, productPhotoErr
  430. }
  431. if productPhotoInfo != nil {
  432. for _, photo := range productPhotoInfo {
  433. fmt.Println(photo)
  434. if photo.Symbol == 1 {
  435. local.StorePhotoSymbol = 1
  436. local.StorePhotoUrl = photo.PhotoUrl
  437. local.StorePhotoUid = photo.PhotoUid
  438. }
  439. }
  440. }
  441. }
  442. return fullLocalData, nil
  443. }
  444. // FullSLocalTaskBillList 服务商本地生活子任务账单列表
  445. func (*sLocalLife) FullSLocalTaskBillList(ctx context.Context, request *http_model.FullSLocalTaskBillListRequest) (*http_model.FullSLocalTaskBillData, error) {
  446. var currSLocalTaskBillData *http_model.FullSLocalTaskBillData
  447. currSLocalTaskBillData = &http_model.FullSLocalTaskBillData{}
  448. currSLocalTaskBillData.DraftFee = 0
  449. currSLocalTaskBillData.DraftFeeSettle = 0
  450. // 1. 查找子任务
  451. taskList, total, taskListErr := db.GetSLocalTaskList(ctx, request.SLocalId, request.TalentId, request.PageSize, request.PageNum)
  452. if taskListErr != nil {
  453. return nil, taskListErr
  454. }
  455. if taskList != nil {
  456. currSLocalTaskBillData.Total = total
  457. for _, task := range taskList {
  458. var curr *http_model.FullSLocalTaskBillListData
  459. curr = &http_model.FullSLocalTaskBillListData{}
  460. curr.TaskId = task.TaskID
  461. curr.ServiceCharge = task.ServiceCharge
  462. curr.ViewNum = 0
  463. curr.VoteNum = 0
  464. curr.CommitNum = 0
  465. curr.CollectNum = 0
  466. curr.ServiceCharge = task.ServiceCharge
  467. curr.DraftFee = task.DraftFee
  468. curr.DelayRate = task.ScriptBreakRate + task.SketchBreakRate + task.LinkBreakRate + task.DataBreakRate
  469. curr.RealServiceCharge = task.RealPayment - task.SettleAmount
  470. curr.SettleAmount = task.SettleAmount
  471. curr.SettleTime = conv.MustString(task.CompleteDate)
  472. currSLocalTaskBillData.DraftFee += curr.DraftFee
  473. currSLocalTaskBillData.DraftFeeSettle += curr.SettleAmount
  474. currSLocalTaskBillData.SLocalTaskList = append(currSLocalTaskBillData.SLocalTaskList, curr)
  475. }
  476. // 2. 补充任务信息
  477. sLocalInfo, sLocalErr := db.GetSLocalLifeDetail(ctx, request.SLocalId)
  478. if sLocalErr != nil {
  479. return nil, sLocalErr
  480. }
  481. if sLocalInfo != nil {
  482. currSLocalTaskBillData.SettleNum = sLocalInfo.SettleNum
  483. currSLocalTaskBillData.ChooseNum = sLocalInfo.ApplyNum
  484. currSLocalTaskBillData.ServiceCharge = sLocalInfo.ServiceCharge
  485. currSLocalTaskBillData.ServiceChargeSettle = sLocalInfo.ServiceChargeSettle
  486. }
  487. }
  488. return currSLocalTaskBillData, nil
  489. }
  490. // CountLocalTask 按照状态统计子任务数量
  491. func (*sLocalLife) CountLocalTask(ctx context.Context, req *http_model.LocalTaskCountRequest) (*http_model.LocalTaskCountData, error) {
  492. var counter *http_model.LocalTaskCountData
  493. counter = &http_model.LocalTaskCountData{}
  494. // 1. Stage1
  495. stage1, stage1Err := db.CountLocalTaskNumByTaskStage(ctx, 0, 1, req.SLocalId)
  496. if stage1Err != nil {
  497. return nil, stage1Err
  498. }
  499. counter.Stage1 = stage1
  500. // 2. Stage2
  501. stage2, stage2Err := db.CountLocalTaskNumByTaskStage(ctx, 0, 2, req.SLocalId)
  502. if stage2Err != nil {
  503. return nil, stage2Err
  504. }
  505. counter.Stage2 = stage2
  506. // 3. Stage3
  507. stage3, stage3Err := db.CountLocalTaskNumByTaskStage(ctx, 0, 3, req.SLocalId)
  508. if stage3Err != nil {
  509. return nil, stage3Err
  510. }
  511. counter.Stage3 = stage3
  512. // 4. Stage4
  513. stage4, stage4Err := db.CountLocalTaskNumByTaskStage(ctx, 1, 2, req.SLocalId)
  514. if stage4Err != nil {
  515. return nil, stage4Err
  516. }
  517. counter.Stage4 = stage4
  518. // 5. Stage5
  519. stage5, stage5Err := db.CountLocalTaskNumByTaskStage(ctx, 2, 2, req.SLocalId)
  520. if stage5Err != nil {
  521. return nil, stage5Err
  522. }
  523. counter.Stage5 = stage5
  524. // 6. Stage6
  525. stage6, stage6Err := db.CountLocalTaskNumByTaskStage(ctx, 3, 2, req.SLocalId)
  526. if stage6Err != nil {
  527. return nil, stage6Err
  528. }
  529. counter.Stage6 = stage6
  530. // 7. Stage7
  531. stage7, stage7Err := db.CountLocalTaskNumByTaskStage(ctx, 0, 0, req.SLocalId)
  532. if stage7Err != nil {
  533. return nil, stage7Err
  534. }
  535. counter.Stage7 = stage7
  536. return counter, nil
  537. }