bill_service.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. package service
  2. import (
  3. "errors"
  4. "fmt"
  5. "strconv"
  6. "time"
  7. "youngee_b_api/app/dao"
  8. "youngee_b_api/app/entity"
  9. "youngee_b_api/app/vo"
  10. )
  11. type BillService struct{}
  12. // 电商带货账单支付
  13. func (s BillService) PaySelection(param *vo.PayParam) error {
  14. selectionId := param.ObjectId
  15. selectionInfo, err1 := dao.SelectionInfoDAO{}.GetSelectionInfoById(selectionId)
  16. if err1 != nil {
  17. return err1
  18. }
  19. selectionStatus := selectionInfo.SelectionStatus
  20. if selectionStatus != 4 {
  21. return errors.New("状态异常")
  22. }
  23. _, err2 := dao.EnterpriseDao{}.UpdateEnterpriseBalanceAndFrozen(selectionInfo.EnterpriseID, selectionInfo.EstimatedCost)
  24. if err2 != nil {
  25. return err2
  26. }
  27. err3 := dao.SelectionInfoDAO{}.UpdateSelectionInfo(entity.SelectionInfo{SelectionID: selectionId, SelectionStatus: 6, PayAt: time.Now()})
  28. if err3 != nil {
  29. return err3
  30. }
  31. return nil
  32. }
  33. // 品牌种草账单支付
  34. func (s BillService) PayProject(param *vo.PayParam) error {
  35. projectId := param.ObjectId
  36. projectInfo, err1 := dao.ProjectDAO{}.GetProjectById(projectId)
  37. if err1 != nil {
  38. return err1
  39. }
  40. projectStatus := projectInfo.ProjectStatus
  41. if projectStatus != 6 {
  42. return errors.New("状态异常")
  43. }
  44. _, err2 := dao.EnterpriseDao{}.UpdateEnterpriseBalanceAndFrozen(projectInfo.EnterpriseID, projectInfo.NeedPay)
  45. if err2 != nil {
  46. return err2
  47. }
  48. err3 := dao.ProjectDAO{}.UpdateProject(entity.Project{ProjectId: projectId, ProjectStatus: 8, PayAt: time.Now()})
  49. if err3 != nil {
  50. return err3
  51. }
  52. return nil
  53. }
  54. // 本地生活账单支付
  55. func (s BillService) PayLocalLife(param *vo.PayParam) error {
  56. localId := param.ObjectId
  57. localInfo, err1 := dao.LocalLifeDao{}.GetLocalById(localId)
  58. if err1 != nil {
  59. return err1
  60. }
  61. localStatus := localInfo.TaskStatus
  62. if localStatus != 6 {
  63. return errors.New("状态异常")
  64. }
  65. _, err2 := dao.EnterpriseDao{}.UpdateEnterpriseBalanceAndFrozen(localInfo.EnterpriseID, localInfo.NeedPay)
  66. if err2 != nil {
  67. return err2
  68. }
  69. err3 := dao.LocalLifeDao{}.UpdateLocal(entity.LocalLifeInfo{LocalID: localId, TaskStatus: 8, PayAt: time.Now()})
  70. if err3 != nil {
  71. return err3
  72. }
  73. return nil
  74. }
  75. // 电商带货账单列表
  76. func (s BillService) GetBillSelectionTaskList(param *vo.SelectionSearchParam) (vo.ResultVO, error) {
  77. if param.Page == 0 {
  78. param.Page = 1
  79. }
  80. if param.PageSize == 0 {
  81. param.PageSize = 10
  82. }
  83. var result vo.ResultVO
  84. reBillSelectionTaskPreviews, total, err := (&dao.SelectionInfoDAO{}).GetBillSelectionPreviews(param)
  85. if err != nil {
  86. return result, err
  87. }
  88. for i := range reBillSelectionTaskPreviews {
  89. var creatorName string
  90. var productName string
  91. var productPrice float64
  92. var mainImage string
  93. var reward float64
  94. if reBillSelectionTaskPreviews[i].SubAccountId == 0 {
  95. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reBillSelectionTaskPreviews[i].EnterpriseId)
  96. if err == nil && enterprise != nil {
  97. creatorName = enterprise.BusinessName
  98. }
  99. } else {
  100. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reBillSelectionTaskPreviews[i].SubAccountId)
  101. if err == nil && subAccount != nil {
  102. creatorName = subAccount.SubAccountName
  103. }
  104. }
  105. product, err := dao.ProductDAO{}.GetProductByID(reBillSelectionTaskPreviews[i].ProductId)
  106. if err == nil && product != nil {
  107. productName = product.ProductName
  108. productPrice = product.ProductPrice
  109. }
  110. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(reBillSelectionTaskPreviews[i].ProductId)
  111. rewardStrategys, err := dao.RewardStrategyDao{}.GetRewardStrategyBySelectionId(reBillSelectionTaskPreviews[i].SelectionId)
  112. for _, rewardStrategy := range rewardStrategys {
  113. reward += rewardStrategy.Reward
  114. }
  115. reBillSelectionTaskPreviews[i].CreatorName = creatorName
  116. reBillSelectionTaskPreviews[i].ProductName = productName
  117. reBillSelectionTaskPreviews[i].ProductPrice = productPrice
  118. reBillSelectionTaskPreviews[i].MainImage = mainImage
  119. reBillSelectionTaskPreviews[i].Reward = reward
  120. }
  121. result = vo.ResultVO{
  122. Page: param.Page,
  123. PageSize: param.PageSize,
  124. Total: total,
  125. Data: reBillSelectionTaskPreviews,
  126. }
  127. return result, nil
  128. }
  129. // 品牌种草账单列表
  130. func (s BillService) GetBillProjectTaskList(param *vo.ProjectSearchParam) (vo.ResultVO, error) {
  131. if param.Page == 0 {
  132. param.Page = 1
  133. }
  134. if param.PageSize == 0 {
  135. param.PageSize = 10
  136. }
  137. var result vo.ResultVO
  138. reBillProjectTaskPreviews, total, err := (&dao.ProjectDAO{}).GetBillProjectPreviews(param)
  139. if err != nil {
  140. return result, err
  141. }
  142. for i := range reBillProjectTaskPreviews {
  143. var creatorName string
  144. var productName string
  145. var productPrice float64
  146. var mainImage string
  147. if reBillProjectTaskPreviews[i].SubAccountId == 0 {
  148. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reBillProjectTaskPreviews[i].EnterpriseId)
  149. if err == nil && enterprise != nil {
  150. creatorName = enterprise.BusinessName
  151. }
  152. } else {
  153. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reBillProjectTaskPreviews[i].SubAccountId)
  154. if err == nil && subAccount != nil {
  155. creatorName = subAccount.SubAccountName
  156. }
  157. }
  158. product, err := dao.ProductDAO{}.GetProductByID(reBillProjectTaskPreviews[i].ProductId)
  159. if err == nil && product != nil {
  160. productName = product.ProductName
  161. productPrice = product.ProductPrice
  162. }
  163. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(reBillProjectTaskPreviews[i].ProductId)
  164. reBillProjectTaskPreviews[i].CreatorName = creatorName
  165. reBillProjectTaskPreviews[i].ProductName = productName
  166. reBillProjectTaskPreviews[i].ProductPrice = productPrice
  167. reBillProjectTaskPreviews[i].MainImage = mainImage
  168. }
  169. result = vo.ResultVO{
  170. Page: param.Page,
  171. PageSize: param.PageSize,
  172. Total: total,
  173. Data: reBillProjectTaskPreviews,
  174. }
  175. return result, nil
  176. }
  177. // 品牌种草账单服务商列表
  178. func (s BillService) GetBillProjectSupplierList(param *vo.SearchSupplierBillParam) (vo.ResultVO, error) {
  179. if param.Page == 0 {
  180. param.Page = 1
  181. }
  182. if param.PageSize == 0 {
  183. param.PageSize = 10
  184. }
  185. var result vo.ResultVO
  186. var reBillSuppliers []vo.ReBillSupplier
  187. var status int64
  188. if param.Status == 1 {
  189. status = 8
  190. } else if param.Status == 2 {
  191. status = 10
  192. }
  193. sProjectInfos, total, err := dao.SProjectDao{}.GetSProjectByProjectStatus(param.TaskId, status, param.Page, param.PageSize)
  194. if err != nil {
  195. return result, err
  196. }
  197. project, err01 := dao.ProjectDAO{}.GetProjectById(param.TaskId)
  198. if err01 != nil || project == nil {
  199. return result, err01
  200. }
  201. serviceRate := project.ServiceChargeRate
  202. type SumResult struct {
  203. PayAmount float64 `json:"payAmount" gorm:"column:payAmount"`
  204. RealAmount float64 `json:"realAmount" gorm:"column:realAmount"`
  205. Count int `json:"count" gorm:"column:count"`
  206. }
  207. var sumResult SumResult
  208. _ = dao.Db.Debug().
  209. Model(&entity.ProjectTaskInfo{}).
  210. Where("project_id = ? and task_status = ? and supplier_id = ?", param.TaskId, 2, 0).
  211. Select("SUM(real_payment) as payAmount, SUM(real_service_charge) as realAmount, count(1) as count").
  212. Scan(&sumResult).Error
  213. for _, sProjectInfo := range sProjectInfos {
  214. reBillSupplier := vo.ReBillSupplier{
  215. SupplierId: sProjectInfo.SupplierID,
  216. TalentNum: sProjectInfo.RecruitNum,
  217. ChargeActual: sProjectInfo.ServiceChargeActual,
  218. ChargeSettle: sProjectInfo.ServiceChargeSettle,
  219. ServiceRate: serviceRate,
  220. }
  221. supplier, err1 := dao.SupplierDao{}.GetSupplierInfoById(sProjectInfo.SupplierID)
  222. if err1 == nil && supplier != nil {
  223. reBillSupplier.SupplierName = supplier.SupplierName
  224. reBillSupplier.Avatar = supplier.Avatar
  225. reBillSupplier.SupplierName = supplier.SupplierName
  226. reBillSupplier.CompanyName = supplier.CompanyName
  227. reBillSupplier.SupplierType = supplier.SupplierType
  228. }
  229. if sProjectInfo.BOperatorType == 1 {
  230. // 商家主账号
  231. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(sProjectInfo.BOperator)
  232. if err == nil && enterprise != nil {
  233. reBillSupplier.Inviter = enterprise.BusinessName
  234. }
  235. } else {
  236. // 商家子账号
  237. subId, err2 := strconv.ParseInt(sProjectInfo.BOperator, 10, 64)
  238. if err2 != nil {
  239. fmt.Println("子账号转换错误:", err)
  240. subId = 0
  241. }
  242. subAccount, err := dao.SubAccountDao{}.GetSubAccount(subId)
  243. if err == nil && subAccount != nil {
  244. reBillSupplier.Inviter = subAccount.SubAccountName
  245. }
  246. }
  247. reBillSuppliers = append(reBillSuppliers, reBillSupplier)
  248. }
  249. resMap := make(map[string]interface{})
  250. resMap["talentNum"] = sumResult.Count
  251. resMap["payAmount"] = sumResult.PayAmount
  252. resMap["realAmount"] = sumResult.RealAmount
  253. resMap["reBillSuppliers"] = reBillSuppliers
  254. result = vo.ResultVO{
  255. Page: param.Page,
  256. PageSize: param.PageSize,
  257. Total: total,
  258. Data: resMap,
  259. }
  260. return result, nil
  261. }
  262. // 本地生活账单服务商列表
  263. func (s BillService) GetBillLocalSupplierList(param *vo.SearchSupplierBillParam) (vo.ResultVO, error) {
  264. if param.Page == 0 {
  265. param.Page = 1
  266. }
  267. if param.PageSize == 0 {
  268. param.PageSize = 10
  269. }
  270. var result vo.ResultVO
  271. var reBillSuppliers []vo.ReBillSupplier
  272. var status int64
  273. if param.Status == 1 {
  274. status = 8
  275. } else if param.Status == 2 {
  276. status = 10
  277. }
  278. sLocalInfos, total, err := dao.SLocalLifeDao{}.GetSLocalByLocalStatus(param.TaskId, status, param.Page, param.PageSize)
  279. if err != nil {
  280. return result, err
  281. }
  282. local, err01 := dao.LocalLifeDao{}.GetLocalById(param.TaskId)
  283. if err01 != nil || local == nil {
  284. return result, err01
  285. }
  286. serviceRate := local.ServiceChargeRate
  287. type SumResult struct {
  288. PayAmount float64 `json:"payAmount" gorm:"column:payAmount"`
  289. RealAmount float64 `json:"realAmount" gorm:"column:realAmount"`
  290. Count int `json:"count" gorm:"column:count"`
  291. }
  292. var sumResult SumResult
  293. _ = dao.Db.Debug().
  294. Model(&entity.LocalLifeTaskInfo{}).
  295. Where("local_id = ? and task_status = ? and supplier_id = ?", param.TaskId, 2, 0).
  296. Select("SUM(real_payment) as payAmount, SUM(real_service_charge) as realAmount, count(1) as count").
  297. Scan(&sumResult).Error
  298. for _, sLocalInfo := range sLocalInfos {
  299. reBillSupplier := vo.ReBillSupplier{
  300. SupplierId: sLocalInfo.SupplierID,
  301. TalentNum: sLocalInfo.RecruitNum,
  302. ChargeActual: sLocalInfo.ServiceChargeActual,
  303. ChargeSettle: sLocalInfo.ServiceChargeSettle,
  304. ServiceRate: serviceRate,
  305. }
  306. supplier, err1 := dao.SupplierDao{}.GetSupplierInfoById(sLocalInfo.SupplierID)
  307. if err1 == nil && supplier != nil {
  308. reBillSupplier.SupplierName = supplier.SupplierName
  309. reBillSupplier.Avatar = supplier.Avatar
  310. reBillSupplier.SupplierName = supplier.SupplierName
  311. reBillSupplier.CompanyName = supplier.CompanyName
  312. reBillSupplier.SupplierType = supplier.SupplierType
  313. }
  314. if sLocalInfo.BOperatorType == 1 {
  315. // 商家主账号
  316. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(sLocalInfo.BOperator)
  317. if err == nil && enterprise != nil {
  318. reBillSupplier.Inviter = enterprise.BusinessName
  319. }
  320. } else {
  321. // 商家子账号
  322. subId, err2 := strconv.ParseInt(sLocalInfo.BOperator, 10, 64)
  323. if err2 != nil {
  324. fmt.Println("子账号转换错误:", err)
  325. subId = 0
  326. }
  327. subAccount, err := dao.SubAccountDao{}.GetSubAccount(subId)
  328. if err == nil && subAccount != nil {
  329. reBillSupplier.Inviter = subAccount.SubAccountName
  330. }
  331. }
  332. reBillSuppliers = append(reBillSuppliers, reBillSupplier)
  333. }
  334. resMap := make(map[string]interface{})
  335. resMap["talentNum"] = sumResult.Count
  336. resMap["payAmount"] = sumResult.PayAmount
  337. resMap["realAmount"] = sumResult.RealAmount
  338. resMap["reBillSuppliers"] = reBillSuppliers
  339. result = vo.ResultVO{
  340. Page: param.Page,
  341. PageSize: param.PageSize,
  342. Total: total,
  343. Data: resMap,
  344. }
  345. return result, nil
  346. }
  347. // 品牌种草账单达人列表
  348. func (s BillService) GetBillProjectTalentList(param *vo.SearchTalentBillParam) (vo.ResultVO, error) {
  349. if param.Page == 0 {
  350. param.Page = 1
  351. }
  352. if param.PageSize == 0 {
  353. param.PageSize = 10
  354. }
  355. var result vo.ResultVO
  356. var reBillTalents []vo.ReBillTalent
  357. var stage int64
  358. if param.Status == 1 {
  359. stage = 15
  360. } else if param.Status == 2 {
  361. stage = 15
  362. }
  363. taskInfos, total, err := dao.ProjectTaskInfoDao{}.GetListByTaskStage2(param.TaskId, stage, param.Page, param.PageSize, param.Others)
  364. if err != nil {
  365. return result, err
  366. }
  367. for _, taskInfo := range taskInfos {
  368. talentId := taskInfo.TalentID
  369. talentInfo, _ := dao.TalentInfoDao{}.GetTalentInfo(talentId)
  370. platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.GetUserInfo(taskInfo.OpenID)
  371. reBillTalent := vo.ReBillTalent{
  372. TalentId: talentId,
  373. OpenId: platformKuaishouUserInfo.OpenID,
  374. PlatformId: platformKuaishouUserInfo.PlatformID,
  375. NickName: talentInfo.TalentNickname,
  376. HeadUri: platformKuaishouUserInfo.HeadUri,
  377. City: platformKuaishouUserInfo.City,
  378. Gender: platformKuaishouUserInfo.Gender,
  379. ViewNum: taskInfo.ViewNum,
  380. VoteAvg: taskInfo.VoteAvg,
  381. CollectNum: taskInfo.CollectNum,
  382. CommitAvg: taskInfo.CommitAvg,
  383. ChargeActual: taskInfo.RealPayment,
  384. ChargeSettle: taskInfo.SettleAmount,
  385. SettleTime: taskInfo.CompleteDate.Format("2006-01-02 15:04:05"),
  386. }
  387. if taskInfo.SupplierId == 0 {
  388. reBillTalent.TalentSource = "公海"
  389. } else {
  390. reBillTalent.TalentSource = taskInfo.SOperateName
  391. }
  392. reBillTalents = append(reBillTalents, reBillTalent)
  393. }
  394. result = vo.ResultVO{
  395. Page: param.Page,
  396. PageSize: param.PageSize,
  397. Total: total,
  398. Data: reBillTalents,
  399. }
  400. return result, nil
  401. }
  402. // 本地生活账单达人列表
  403. func (s BillService) GetBillLocalTalentList(param *vo.SearchTalentBillParam) (vo.ResultVO, error) {
  404. if param.Page == 0 {
  405. param.Page = 1
  406. }
  407. if param.PageSize == 0 {
  408. param.PageSize = 10
  409. }
  410. var result vo.ResultVO
  411. var reBillTalents []vo.ReBillTalent
  412. var stage int64
  413. if param.Status == 1 {
  414. stage = 15
  415. } else if param.Status == 2 {
  416. stage = 15
  417. }
  418. taskInfos, total, err := dao.LocalLifeTaskInfoDao{}.GetListByTaskStage2(param.TaskId, stage, param.Page, param.PageSize, param.Others)
  419. if err != nil {
  420. return result, err
  421. }
  422. for _, taskInfo := range taskInfos {
  423. talentId := taskInfo.TalentID
  424. talentInfo, _ := dao.TalentInfoDao{}.GetTalentInfo(talentId)
  425. platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.GetUserInfo(taskInfo.OpenID)
  426. reBillTalent := vo.ReBillTalent{
  427. TalentId: talentId,
  428. OpenId: platformKuaishouUserInfo.OpenID,
  429. PlatformId: platformKuaishouUserInfo.PlatformID,
  430. NickName: talentInfo.TalentNickname,
  431. HeadUri: platformKuaishouUserInfo.HeadUri,
  432. City: platformKuaishouUserInfo.City,
  433. Gender: platformKuaishouUserInfo.Gender,
  434. ViewNum: taskInfo.ViewNum,
  435. VoteAvg: taskInfo.VoteAvg,
  436. CollectNum: taskInfo.CollectNum,
  437. CommitAvg: taskInfo.CommitAvg,
  438. ChargeActual: taskInfo.RealPayment,
  439. ChargeSettle: taskInfo.SettleAmount,
  440. SettleTime: taskInfo.CompleteDate.Format("2006-01-02 15:04:05"),
  441. }
  442. if taskInfo.SupplierID == 0 {
  443. reBillTalent.TalentSource = "公海"
  444. } else {
  445. reBillTalent.TalentSource = taskInfo.SOperateName
  446. }
  447. reBillTalents = append(reBillTalents, reBillTalent)
  448. }
  449. result = vo.ResultVO{
  450. Page: param.Page,
  451. PageSize: param.PageSize,
  452. Total: total,
  453. Data: reBillTalents,
  454. }
  455. return result, nil
  456. }
  457. // 账单查询-顶部数据预览
  458. func (s BillService) GetBillPreview(param *vo.SearchTalentBillParam) (vo.ReBillDataPreview, error) {
  459. var reBillDataPreview vo.ReBillDataPreview
  460. if param.Task == 2 {
  461. project, err := dao.ProjectDAO{}.GetProjectById(param.TaskId)
  462. if err != nil {
  463. return reBillDataPreview, err
  464. }
  465. if project == nil {
  466. return reBillDataPreview, nil
  467. }
  468. var talentTotalAmount, supplierTotalAmount float64
  469. taskInfos, _, err2 := dao.ProjectTaskInfoDao{}.GetListByTaskStage2(param.TaskId, 15, param.Page, param.PageSize, "")
  470. if err2 != nil || len(taskInfos) == 0 {
  471. talentTotalAmount = 0.0
  472. supplierTotalAmount = 0.0
  473. }
  474. for _, taskInfo := range taskInfos {
  475. if taskInfo.SupplierId == 0 {
  476. talentTotalAmount += taskInfo.SettleAmount
  477. } else {
  478. supplierTotalAmount += taskInfo.RealServiceCharge
  479. }
  480. }
  481. reBillDataPreview = vo.ReBillDataPreview{
  482. FrozenTotalAmount: project.NeedPay,
  483. SettleTotalAmount: project.SettlementAmount,
  484. TalentNum: project.SettleNum,
  485. TalentTotalAmount: talentTotalAmount,
  486. SupplierTotalAmount: supplierTotalAmount,
  487. }
  488. } else if param.Task == 3 {
  489. local, err := dao.LocalLifeDao{}.GetLocalById(param.TaskId)
  490. if err != nil {
  491. return reBillDataPreview, err
  492. }
  493. if local == nil {
  494. return reBillDataPreview, nil
  495. }
  496. var talentTotalAmount, supplierTotalAmount float64
  497. taskInfos, _, err2 := dao.LocalLifeTaskInfoDao{}.GetListByTaskStage2(param.TaskId, 15, param.Page, param.PageSize, "")
  498. if err2 != nil || len(taskInfos) == 0 {
  499. talentTotalAmount = 0.0
  500. supplierTotalAmount = 0.0
  501. }
  502. for _, taskInfo := range taskInfos {
  503. if taskInfo.SupplierID == 0 {
  504. talentTotalAmount += taskInfo.SettleAmount
  505. } else {
  506. supplierTotalAmount += taskInfo.RealServiceCharge
  507. }
  508. }
  509. reBillDataPreview = vo.ReBillDataPreview{
  510. FrozenTotalAmount: local.NeedPay,
  511. SettleTotalAmount: local.SettlementAmount,
  512. TalentNum: local.SettleNum,
  513. TalentTotalAmount: talentTotalAmount,
  514. SupplierTotalAmount: supplierTotalAmount,
  515. }
  516. }
  517. return reBillDataPreview, nil
  518. }
  519. // 本地生活账单列表
  520. func (s BillService) GetBillLocalLifeTaskList(param *vo.LocalSearchParam) (vo.ResultVO, error) {
  521. if param.Page == 0 {
  522. param.Page = 1
  523. }
  524. if param.PageSize == 0 {
  525. param.PageSize = 10
  526. }
  527. var result vo.ResultVO
  528. reBillLocalTaskPreviews, total, err := (&dao.LocalLifeDao{}).GetBillLocalPreviews(param)
  529. if err != nil {
  530. return result, err
  531. }
  532. for i := range reBillLocalTaskPreviews {
  533. var creatorName string
  534. var storeName string
  535. var storeLocation string
  536. var mainImage string
  537. if reBillLocalTaskPreviews[i].SubAccountId == 0 {
  538. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reBillLocalTaskPreviews[i].EnterpriseId)
  539. if err == nil && enterprise != nil {
  540. creatorName = enterprise.BusinessName
  541. }
  542. } else {
  543. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reBillLocalTaskPreviews[i].SubAccountId)
  544. if err == nil && subAccount != nil {
  545. creatorName = subAccount.SubAccountName
  546. }
  547. }
  548. store, err := dao.StoreDao{}.GetStoreByID(reBillLocalTaskPreviews[i].StoreId)
  549. if err == nil && store != nil {
  550. storeName = store.StoreName
  551. storeLocation = store.StoreLocation
  552. }
  553. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(reBillLocalTaskPreviews[i].StoreId)
  554. reBillLocalTaskPreviews[i].CreatorName = creatorName
  555. reBillLocalTaskPreviews[i].StoreName = storeName
  556. reBillLocalTaskPreviews[i].StoreLocation = storeLocation
  557. reBillLocalTaskPreviews[i].MainImage = mainImage
  558. }
  559. result = vo.ResultVO{
  560. Page: param.Page,
  561. PageSize: param.PageSize,
  562. Total: total,
  563. Data: reBillLocalTaskPreviews,
  564. }
  565. return result, nil
  566. }