123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Services;
- use App\Models\Account;
- use App\Models\Order;
- class OrderService
- {
- /**
- * 获取订单列表数据
- * @param $channelId string 公众账号渠道ID
- * @param $platformId int 书城平台ID 0:未设置 1:掌中云 2:阅文 3:阳光 4:掌读
- * @param $regTimeSt string 用户在书城注册起始时间
- * @param $regTimeEt string 用户在书城注册截止时间
- * @param $orderTimeSt string 订单创建起始时间
- * @param $orderTimeEt string 订单创建截止时间
- * @param $minMoney float 最小订单金额
- * @param $maxMoney float 最大订单金额
- * @param $page integer 当前页码数
- * @param $pageSize integer 每页显示条数
- * */
- public static function getList(
- $channelId, $platformId, $regTimeSt, $regTimeEt, $orderTimeSt, $orderTimeEt, $minMoney, $maxMoney, $page, $pageSize
- )
- {
- list($list, $count, $condition) = Order::getList(
- $channelId, $platformId, $regTimeSt, $regTimeEt, $orderTimeSt, $orderTimeEt, $minMoney, $maxMoney, $page, $pageSize
- );
- # 获取公众号列表
- $accountList = Account::select(['platform_id', 'channel_id', 'nickname'])->where('enable', 1)->get();
- # 获取书城信息
- $platformList = config('platform');
- foreach ($list as $item) {
- # 处理书城信息
- $item->platform = isset($platformList[$item->platform_id]) ? $platformList[$item->platform_id] : '未知';
- # 处理公众账号信息
- $accountInfo = $accountList->where('platform_id', $item->platform_id)
- ->where('channel_id', $item->channel_id)
- ->first();
- $item->nickname = isset($accountInfo->nickname) ? $accountInfo->nickname : '-';
- # 处理价格信息
- $item->price = $item->price / 100;
- # 处理下单时间
- $platformCreatedAt = strtotime($item->platform_created_at);
- $item->platform_created_at = $platformCreatedAt ? date('Y-m-d', $platformCreatedAt) : '';
- # 处理注册时间
- $userCreatedAt = strtotime($item->user_created_at);
- $item->user_created_at = $userCreatedAt ? date('Y-m-d', $userCreatedAt) : '';
- }
- return [$list, $count, $accountList, $platformList, $condition];
- }
- }
|