selection_info_service.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. package service
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "github.com/sirupsen/logrus"
  6. "reflect"
  7. "time"
  8. "youngee_b_api/app/dao"
  9. "youngee_b_api/app/entity"
  10. "youngee_b_api/app/util"
  11. "youngee_b_api/app/vo"
  12. )
  13. type SelectionInfoService struct{}
  14. //func (s *SelectionInfoService) GetSelectionInfo(ctx *gin.Context, selectionId string) (*http_model.SelectionDetail, error) {
  15. // selectionDetail := http_model.SelectionDetail{}
  16. // selectionInfo, err := db.GetSelectionById(ctx, selectionId)
  17. //
  18. // if err != nil {
  19. // logrus.WithContext(ctx).Errorf("[selectionDB service] call GetSelectionInfo error,err:%+v", err)
  20. // return nil, err
  21. // }
  22. // selectionBriefInfo, err := db.GetSelectionBriefInfo(ctx, selectionId)
  23. // if err != nil {
  24. // logrus.WithContext(ctx).Errorf("[selectionDB service] call GetSelectionBriefInfo error,err:%+v", err)
  25. // return nil, err
  26. // }
  27. // selectionExampleInfo, err := db.GetSelectionExampleInfo(ctx, selectionId)
  28. // if err != nil {
  29. // logrus.WithContext(ctx).Errorf("[selectionDB service] call GetSelectionExampleInfo error,err:%+v", err)
  30. // return nil, err
  31. // }
  32. // productInfo, err := db.GetProductInfoBySelectionId(ctx, selectionId)
  33. // if err != nil {
  34. // logrus.WithContext(ctx).Errorf("[selectionDB service] call GetProductInfo error,err:%+v", err)
  35. // return nil, err
  36. // }
  37. // productPhotoInfo, err := db.GetProductPhotoInfoBySelectionId(ctx, selectionId)
  38. // if err != nil {
  39. // logrus.WithContext(ctx).Errorf("[selectionDB service] call GetProductPhotoInfo error,err:%+v", err)
  40. // return nil, err
  41. // }
  42. // selectionDetail.SelectionBrief = selectionBriefInfo
  43. // selectionDetail.SelectionInfo = selectionInfo
  44. // selectionDetail.SelectionExample = selectionExampleInfo
  45. // selectionDetail.ProductInfo = productInfo
  46. // selectionDetail.ProductPhotoInfo = productPhotoInfo
  47. // return &selectionDetail, nil
  48. //}
  49. // 创建带货任务
  50. func (s SelectionInfoService) CreateSelectionInfo(param *vo.SelectionInfoCreateParam) (*string, error) {
  51. // a) 生成选品id
  52. selectionId := util.GetSelectionID()
  53. // b) 查找关联商品信息
  54. product, err := dao.ProductDAO{}.GetProductByID(param.ProductId)
  55. if err != nil {
  56. return nil, err
  57. }
  58. if product == nil {
  59. return nil, errors.New("未找到关联商品")
  60. }
  61. productPhotos, err := dao.ProductPhotoDAO{}.GetProductPhotoByProductID(param.ProductId)
  62. productInfoToJson, _ := json.Marshal(product)
  63. productPhotosToJson, _ := json.Marshal(productPhotos)
  64. // c) 选品名称
  65. //selectionName := product.ProductName
  66. // d)创建选品
  67. // 获取定时任务配置
  68. infoAutoTask := entity.InfoAutoTask{}
  69. infoAutoTask = dao.InfoAutoTaskDao{}.GetAutoTaskLast(param.EnterpriseId)
  70. t := time.Now()
  71. newSelection := entity.SelectionInfo{
  72. SelectionStatus: 1,
  73. SelectionID: selectionId,
  74. ProductID: param.ProductId,
  75. ProductCategory: product.ProductCategory,
  76. EnterpriseID: param.EnterpriseId,
  77. SubAccountId: param.SubAccountId,
  78. Platform: param.Platform,
  79. ProductSnap: string(productInfoToJson),
  80. ProductPhotoSnap: string(productPhotosToJson),
  81. CreatedAt: t,
  82. UpdatedAt: t,
  83. AutoTaskID: infoAutoTask.AutoTaskID,
  84. }
  85. err = dao.SelectionInfoDAO{}.CreateSelectionInfo(newSelection)
  86. if err != nil {
  87. return nil, err
  88. }
  89. return &selectionId, nil
  90. }
  91. // 更新带货任务(样品奖励、补充信息)
  92. func (s SelectionInfoService) UpdateSelectionInfo(selectionUpdateParam *vo.SelectionInfoUpdateParam) (*string, error) {
  93. // 1. 检查该企业id和商品id有无选品
  94. selectionID := selectionUpdateParam.SelectionID
  95. selectionInfo, err := dao.SelectionInfoDAO{}.GetSelectionInfoById(selectionID)
  96. if err != nil {
  97. return nil, err
  98. }
  99. if selectionInfo == nil {
  100. return nil, errors.New("选品不存在")
  101. }
  102. // 2. 数据准备
  103. // a) 查找关联商品信息
  104. product, err := dao.ProductDAO{}.GetProductByID(selectionInfo.ProductID)
  105. if err != nil {
  106. return nil, err
  107. }
  108. productPhotos, err := dao.ProductPhotoDAO{}.GetProductPhotoByProductID(selectionInfo.ProductID)
  109. productInfoToJson, _ := json.Marshal(product)
  110. productPhotosToJson, _ := json.Marshal(productPhotos)
  111. // d) 任务截止时间
  112. taskDdl := time.Time{} //赋零值
  113. taskDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", selectionUpdateParam.TaskDdl, time.Local)
  114. // f) 更新选品状态
  115. if selectionUpdateParam.SelectionStatus != 2 && selectionUpdateParam.SelectionStatus != 7 {
  116. selectionUpdateParam.SelectionStatus = 1
  117. }
  118. t := time.Now()
  119. var sampleMode, taskMode int64
  120. if len(selectionUpdateParam.FreeStrategys) > 0 {
  121. sampleMode = 1
  122. } else {
  123. sampleMode = 3
  124. }
  125. if len(selectionUpdateParam.RewardStrategys) > 0 {
  126. taskMode = 1
  127. } else {
  128. taskMode = 2
  129. }
  130. updateSelection := entity.SelectionInfo{
  131. SelectionID: selectionUpdateParam.SelectionID,
  132. SelectionStatus: selectionUpdateParam.SelectionStatus,
  133. SelectionName: selectionUpdateParam.SelectionName,
  134. EnterpriseID: selectionUpdateParam.EnterpriseId,
  135. SubAccountId: selectionUpdateParam.SubAccountId,
  136. ProductID: selectionUpdateParam.ProductId,
  137. ProductUrl: selectionUpdateParam.ProductUrl,
  138. TaskMode: taskMode,
  139. SampleMode: sampleMode,
  140. SampleNum: selectionUpdateParam.SampleNum,
  141. RemainNum: selectionUpdateParam.SampleNum,
  142. CommissionRate: selectionUpdateParam.CommissionRate,
  143. TaskReward: selectionUpdateParam.TaskReward,
  144. SettlementAmount: selectionUpdateParam.SettlementAmount,
  145. EstimatedCost: selectionInfo.EstimatedCost,
  146. SampleCondition: selectionUpdateParam.SampleCondition,
  147. RewardCondition: selectionUpdateParam.RewardCondition,
  148. TaskDdl: taskDdl,
  149. Detail: selectionUpdateParam.Detail,
  150. ProductSnap: string(productInfoToJson),
  151. ProductPhotoSnap: string(productPhotosToJson),
  152. CreatedAt: selectionInfo.CreatedAt,
  153. UpdatedAt: t,
  154. }
  155. if selectionUpdateParam.SelectionStatus == 2 {
  156. updateSelection.SubmitAt = t
  157. }
  158. if selectionUpdateParam.Status == 1 {
  159. updateSelection.Status = 1
  160. }
  161. // 合并传入参数和数据表中原记录,若传入参数字段值为空,则将字段赋值为原记录中值
  162. result := util.MergeStructValue(&updateSelection, selectionInfo)
  163. // 利用反射机制将interface类型转换为结构体类型
  164. v := reflect.ValueOf(&result).Elem()
  165. if v.Kind() == reflect.Struct {
  166. updateSelection = v.Interface().(entity.SelectionInfo)
  167. //fmt.Println(p)
  168. }
  169. // c) 计算预估成本(如果有)
  170. /*
  171. var estimatedCost float64
  172. if conv.MustInt(updateSelection.TaskMode, 0) == 1 {
  173. estimatedCost = conv.MustFloat64(updateSelection.TaskReward, 0) * conv.MustFloat64(updateSelection.SampleNum, 0)
  174. }
  175. estimatedCostToString, _ := conv.String(estimatedCost)
  176. updateSelection.EstimatedCost = estimatedCostToString
  177. */
  178. // 3. 更新选品
  179. err = dao.SelectionInfoDAO{}.UpdateSelectionInfo(updateSelection)
  180. if err != nil {
  181. return nil, err
  182. }
  183. // 4. 更新选品brief和示例(带货任务补充信息)
  184. if selectionUpdateParam.SecBrief != nil {
  185. // 删除已有brief
  186. err = dao.SecBriefDao{}.DeleteSecBriefBySelectionId(selectionInfo.SelectionID)
  187. if err != nil {
  188. return nil, err
  189. }
  190. // 插入新的brief
  191. for _, v := range selectionUpdateParam.SecBrief {
  192. brief := entity.SecBrief{
  193. SelectionID: selectionInfo.SelectionID,
  194. FileUid: v.FileUid,
  195. FileName: v.Name,
  196. FileUrl: v.FileUrl,
  197. CreatedAt: time.Now(),
  198. }
  199. err = dao.SecBriefDao{}.CreateSecBrief(brief)
  200. if err != nil {
  201. return nil, err
  202. }
  203. }
  204. }
  205. if selectionUpdateParam.SecMaterial != nil {
  206. // 删除已有示例
  207. err = dao.SecMaterialDao{}.DeleteSecMaterialBySelectionId(selectionInfo.SelectionID)
  208. if err != nil {
  209. return nil, err
  210. }
  211. // 插入新的示例
  212. for _, v := range selectionUpdateParam.SecMaterial {
  213. secMaterial := entity.SecMaterial{
  214. SelectionID: selectionInfo.SelectionID,
  215. FileUid: v.FileUid,
  216. FileName: v.Name,
  217. FileUrl: v.FileUrl,
  218. CreatedAt: time.Now(),
  219. }
  220. err = dao.SecMaterialDao{}.CreateSecMaterial(secMaterial)
  221. if err != nil {
  222. return nil, err
  223. }
  224. }
  225. }
  226. println("更新带货任务的免费领样策略")
  227. // 更新带货任务的免费领样策略
  228. if selectionUpdateParam.FreeStrategys != nil {
  229. // 1. 删除已有的免费领样策略
  230. err = dao.FreeStrategyDao{}.DeleteFreeStrategyBySelectionId(selectionUpdateParam.SelectionID)
  231. if err != nil {
  232. return nil, err
  233. }
  234. // 2. 接收并创建新的免费领样策略
  235. if sampleMode == 1 {
  236. var frees []entity.FreeStrategy
  237. for _, v := range selectionUpdateParam.FreeStrategys {
  238. free := entity.FreeStrategy{
  239. SelectionId: selectionInfo.SelectionID,
  240. StrategyId: v.StrategyId,
  241. FansNum: v.FansNum,
  242. SaleNum: v.SaleNum,
  243. StrategyStatus: 1,
  244. EnrollNum: 0,
  245. ChooseNum: 0,
  246. }
  247. frees = append(frees, free)
  248. }
  249. err = dao.FreeStrategyDao{}.CreateFreeStrategy(frees)
  250. if err != nil {
  251. return nil, err
  252. }
  253. }
  254. }
  255. println("更新带货任务的悬赏策略")
  256. // 更新带货任务的悬赏策略
  257. if selectionUpdateParam.RewardStrategys != nil {
  258. // 1. 删除已有的悬赏策略
  259. err = dao.RewardStrategyDao{}.DeleteRewardStrategyBySelectionId(selectionUpdateParam.SelectionID)
  260. if err != nil {
  261. return nil, err
  262. }
  263. if taskMode == 1 {
  264. var rewards []entity.RewardStrategy
  265. for _, v := range selectionUpdateParam.RewardStrategys {
  266. reward := entity.RewardStrategy{
  267. SelectionId: selectionInfo.SelectionID,
  268. Reward: v.Reward,
  269. SaleActual: v.SaleActual,
  270. PerReward: v.PerReward,
  271. StrategyStatus: 1,
  272. }
  273. rewards = append(rewards, reward)
  274. }
  275. err = dao.RewardStrategyDao{}.CreateRewardStrategy(rewards)
  276. if err != nil {
  277. return nil, err
  278. }
  279. }
  280. }
  281. return &updateSelection.SelectionID, nil
  282. }
  283. // 电商带货任务预览
  284. func (s SelectionInfoService) GetSelectionDetail(selectionId string) (*vo.ReSelectionDetail, error) {
  285. reSelectionDetail := vo.ReSelectionDetail{}
  286. selection, err := dao.SelectionInfoDAO{}.GetSelectionInfoById(selectionId)
  287. if err != nil {
  288. logrus.Errorf("[selectionInfoDB service] call GetSelection error,err:%+v", err)
  289. return nil, err
  290. }
  291. // 系统信息
  292. reSelectionDetail.SelectionId = selectionId
  293. reSelectionDetail.SelectionStatus = selection.SelectionStatus
  294. reSelectionDetail.SelectionPlatform = selection.Platform
  295. reSelectionDetail.CreatedAt = selection.CreatedAt.Format("2006-01-02 15:04:05")
  296. reSelectionDetail.SubmitAt = selection.SubmitAt.Format("2006-01-02 15:04:05")
  297. var creatorName, phone string
  298. var rewardSum float64
  299. if selection.SubAccountId == 0 {
  300. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(selection.EnterpriseID)
  301. if err == nil && enterprise != nil {
  302. creatorName = enterprise.BusinessName
  303. phone, err = dao.UserDao{}.GetPhoneByUserId(enterprise.UserId)
  304. }
  305. } else {
  306. subAccount, err := dao.SubAccountDao{}.GetSubAccount(selection.SubAccountId)
  307. if err == nil && subAccount != nil {
  308. creatorName = subAccount.SubAccountName
  309. phone, err = dao.UserDao{}.GetPhoneByUserId(subAccount.UserId)
  310. }
  311. }
  312. reSelectionDetail.CreatorName = creatorName
  313. reSelectionDetail.Phone = phone
  314. // 关联商品
  315. var reProduct vo.ReTaskProduct
  316. product, err := dao.ProductDAO{}.GetProductByID(selection.ProductID)
  317. if err == nil {
  318. photoUrl, e := dao.ProductPhotoDAO{}.GetMainPhotoByProductID(product.ProductID)
  319. if e != nil {
  320. photoUrl = ""
  321. }
  322. reProduct = vo.ReTaskProduct{
  323. ProductID: product.ProductID,
  324. ProductName: product.ProductName,
  325. ProductType: product.ProductType,
  326. ProductCategory: product.ProductCategory,
  327. ProductPrice: product.ProductPrice,
  328. ProductDetail: product.ProductDetail,
  329. CreatedAt: product.CreatedAt.Format("2006-01-02 15:04:05"),
  330. PhotoUrl: photoUrl,
  331. }
  332. }
  333. reSelectionDetail.ProductInfo = &reProduct
  334. // 样品奖励
  335. reSelectionDetail.TaskDdl = selection.TaskDdl.Format("2006-01-02 15:04:05")
  336. reSelectionDetail.SampleNum = selection.SampleNum
  337. var freeStrategyPreviews []*vo.FreeStrategyPreview // 领样策略
  338. freeStrategys, err := dao.FreeStrategyDao{}.GetFreeStrategyBySelectionId(selectionId)
  339. if err != nil {
  340. logrus.Errorf("[selectionInfoDB service] call GetFreeStrategy error,err:%+v", err)
  341. return nil, err
  342. }
  343. for _, freeStrategy := range freeStrategys {
  344. freeStrategyPreview := &vo.FreeStrategyPreview{
  345. StrategyId: freeStrategy.StrategyId,
  346. FansNum: freeStrategy.FansNum,
  347. SaleNum: freeStrategy.SaleNum,
  348. StrategyStatus: freeStrategy.StrategyStatus,
  349. }
  350. freeStrategyPreviews = append(freeStrategyPreviews, freeStrategyPreview)
  351. }
  352. reSelectionDetail.FreeStrategys = freeStrategyPreviews
  353. var rewardStrategyPreviews []*vo.RewardStrategyPreview // 悬赏策略
  354. rewardStrategys, err := dao.RewardStrategyDao{}.GetRewardStrategyBySelectionId(selectionId)
  355. if err != nil {
  356. logrus.Errorf("[selectionInfoDB service] call GetRewardStrategy error,err:%+v", err)
  357. return nil, err
  358. }
  359. for _, rewardStrategy := range rewardStrategys {
  360. rewardStrategyPreview := &vo.RewardStrategyPreview{
  361. Reward: rewardStrategy.Reward,
  362. SaleActual: rewardStrategy.SaleActual,
  363. PerReward: rewardStrategy.PerReward,
  364. StrategyStatus: rewardStrategy.StrategyStatus,
  365. }
  366. rewardStrategyPreviews = append(rewardStrategyPreviews, rewardStrategyPreview)
  367. }
  368. reSelectionDetail.FreeStrategys = freeStrategyPreviews
  369. reSelectionDetail.RewardStrategys = rewardStrategyPreviews
  370. for _, rewardStrategy := range rewardStrategys {
  371. rewardSum += rewardStrategy.Reward
  372. }
  373. reSelectionDetail.RewardSum = rewardSum
  374. // 补充信息
  375. selectionBriefInfos, err := dao.SecBriefDao{}.GetSelectionBriefInfo(selectionId)
  376. if err != nil {
  377. logrus.Errorf("[selectionInfoDB service] call GetSelectionBriefInfo error,err:%+v", err)
  378. return nil, err
  379. }
  380. selectionMaterials, err := dao.SecMaterialDao{}.GetSelectionMaterialInfo(selectionId)
  381. if err != nil {
  382. logrus.Errorf("[selectionInfoDB service] call GetSelectionMaterialInfo error,err:%+v", err)
  383. return nil, err
  384. }
  385. reSelectionDetail.SelectionBriefs = selectionBriefInfos
  386. reSelectionDetail.SelectionMaterials = selectionMaterials
  387. return &reSelectionDetail, nil
  388. }
  389. // 电商带货提交审核
  390. func (s SelectionInfoService) SelectionToReview(selectionUpdateParam *vo.SelectionInfoUpdateParam) (*string, error) {
  391. selectionId := selectionUpdateParam.SelectionID
  392. t := time.Now()
  393. updateSelection := entity.SelectionInfo{
  394. SelectionID: selectionId,
  395. SelectionStatus: 2,
  396. UpdatedAt: t,
  397. }
  398. err := dao.SelectionInfoDAO{}.UpdateSelectionInfo(updateSelection)
  399. if err != nil {
  400. return nil, err
  401. }
  402. return &selectionId, nil
  403. }
  404. // 电商带货任务列表
  405. func (s SelectionInfoService) GetSelectionTaskList(param *vo.SelectionSearchParam) (vo.ResultVO, error) {
  406. if param.Page == 0 {
  407. param.Page = 1
  408. }
  409. if param.PageSize == 0 {
  410. param.PageSize = 10
  411. }
  412. var result vo.ResultVO
  413. reSelectionTaskPreviews, total, err := (&dao.SelectionInfoDAO{}).GetSelectionPreviews(param)
  414. if err != nil {
  415. return result, err
  416. }
  417. for i := range reSelectionTaskPreviews {
  418. var creatorName string
  419. var productName string
  420. var productPrice float64
  421. var mainImage string
  422. var reward float64
  423. if reSelectionTaskPreviews[i].SubAccountId == 0 {
  424. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reSelectionTaskPreviews[i].EnterpriseId)
  425. if err == nil && enterprise != nil {
  426. creatorName = enterprise.BusinessName
  427. }
  428. } else {
  429. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reSelectionTaskPreviews[i].SubAccountId)
  430. if err == nil && subAccount != nil {
  431. creatorName = subAccount.SubAccountName
  432. }
  433. }
  434. product, err := dao.ProductDAO{}.GetProductByID(reSelectionTaskPreviews[i].ProductId)
  435. if err == nil && product != nil {
  436. productName = product.ProductName
  437. productPrice = product.ProductPrice
  438. }
  439. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(reSelectionTaskPreviews[i].ProductId)
  440. rewardStrategys, err := dao.RewardStrategyDao{}.GetRewardStrategyBySelectionId(reSelectionTaskPreviews[i].SelectionId)
  441. for _, rewardStrategy := range rewardStrategys {
  442. reward += rewardStrategy.Reward
  443. }
  444. reSelectionTaskPreviews[i].CreatorName = creatorName
  445. reSelectionTaskPreviews[i].ProductName = productName
  446. reSelectionTaskPreviews[i].ProductPrice = productPrice
  447. reSelectionTaskPreviews[i].MainImage = mainImage
  448. reSelectionTaskPreviews[i].Reward = reward
  449. }
  450. result = vo.ResultVO{
  451. Page: param.Page,
  452. PageSize: param.PageSize,
  453. Total: total,
  454. Data: reSelectionTaskPreviews,
  455. }
  456. return result, nil
  457. }
  458. // 删除带货任务
  459. func (s SelectionInfoService) DeleteSelection(selectionId string) (*string, error) {
  460. res, err := dao.SelectionInfoDAO{}.DeleteSelection(selectionId)
  461. if err != nil {
  462. logrus.Errorf("[projectDB service] call DeleteSelection error,err:%+v", err)
  463. return res, err
  464. }
  465. return res, nil
  466. }
  467. // 草稿箱——电商带货
  468. func (s SelectionInfoService) GetSelectionDraftList(param *vo.SelectionDraftParam) (vo.ResultVO, error) {
  469. if param.Page == 0 {
  470. param.Page = 1
  471. }
  472. if param.PageSize == 0 {
  473. param.PageSize = 10
  474. }
  475. var result vo.ResultVO
  476. reSelectionTaskPreviews, total, err := (&dao.SelectionInfoDAO{}).GetSelectionDraftList(param)
  477. if err != nil {
  478. return result, err
  479. }
  480. for i := range reSelectionTaskPreviews {
  481. var creatorName string
  482. var productName string
  483. var productPrice float64
  484. var mainImage string
  485. if reSelectionTaskPreviews[i].SubAccountId == 0 {
  486. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reSelectionTaskPreviews[i].EnterpriseId)
  487. if err == nil && enterprise != nil {
  488. creatorName = enterprise.BusinessName
  489. }
  490. } else {
  491. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reSelectionTaskPreviews[i].SubAccountId)
  492. if err == nil && subAccount != nil {
  493. creatorName = subAccount.SubAccountName
  494. }
  495. }
  496. product, err := dao.ProductDAO{}.GetProductByID(reSelectionTaskPreviews[i].ProductId)
  497. if err == nil && product != nil {
  498. productName = product.ProductName
  499. productPrice = product.ProductPrice
  500. }
  501. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(reSelectionTaskPreviews[i].ProductId)
  502. reSelectionTaskPreviews[i].CreatorName = creatorName
  503. reSelectionTaskPreviews[i].ProductName = productName
  504. reSelectionTaskPreviews[i].ProductPrice = productPrice
  505. reSelectionTaskPreviews[i].MainImage = mainImage
  506. }
  507. result = vo.ResultVO{
  508. Page: param.Page,
  509. PageSize: param.PageSize,
  510. Total: total,
  511. Data: reSelectionTaskPreviews,
  512. }
  513. return result, nil
  514. }