小说推广数据系统

OrderService.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Services;
  3. use App\Models\Account;
  4. use App\Models\Order;
  5. class OrderService
  6. {
  7. /**
  8. * 获取订单列表数据
  9. * @param $channelId string 公众账号渠道ID
  10. * @param $platformId int 书城平台ID 0:未设置 1:掌中云 2:阅文 3:阳光 4:掌读
  11. * @param $regTimeSt string 用户在书城注册起始时间
  12. * @param $regTimeEt string 用户在书城注册截止时间
  13. * @param $orderTimeSt string 订单创建起始时间
  14. * @param $orderTimeEt string 订单创建截止时间
  15. * @param $minMoney float 最小订单金额
  16. * @param $maxMoney float 最大订单金额
  17. * @param $page integer 当前页码数
  18. * @param $pageSize integer 每页显示条数
  19. * */
  20. public static function getList(
  21. $channelId, $platformId, $regTimeSt, $regTimeEt, $orderTimeSt, $orderTimeEt, $minMoney, $maxMoney, $page, $pageSize
  22. )
  23. {
  24. list($list, $count, $condition) = Order::getList(
  25. $channelId, $platformId, $regTimeSt, $regTimeEt, $orderTimeSt, $orderTimeEt, $minMoney, $maxMoney, $page, $pageSize
  26. );
  27. # 获取公众号列表
  28. $accountList = Account::select(['platform_id', 'channel_id', 'nickname'])->where('enable', 1)->get();
  29. # 获取书城信息
  30. $platformList = config('platform');
  31. foreach ($list as $item) {
  32. # 处理书城信息
  33. $item->platform = isset($platformList[$item->platform_id]) ? $platformList[$item->platform_id] : '未知';
  34. # 处理公众账号信息
  35. $accountInfo = $accountList->where('platform_id', $item->platform_id)
  36. ->where('channel_id', $item->channel_id)
  37. ->first();
  38. $item->nickname = isset($accountInfo->nickname) ? $accountInfo->nickname : '-';
  39. # 处理价格信息
  40. $item->price = $item->price / 100;
  41. # 处理下单时间
  42. $platformCreatedAt = strtotime($item->platform_created_at);
  43. $item->platform_created_at = $platformCreatedAt ? date('Y-m-d', $platformCreatedAt) : '';
  44. # 处理注册时间
  45. $userCreatedAt = strtotime($item->user_created_at);
  46. $item->user_created_at = $userCreatedAt ? date('Y-m-d', $userCreatedAt) : '';
  47. }
  48. return [$list, $count, $accountList, $platformList, $condition];
  49. }
  50. }