12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- /*
- * This file is part of the Jiannei/lumen-api-starter.
- *
- * (c) Jiannei <longjian.huang@foxmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace App\Repositories\Transformers;
- use App\Models\Order;
- use App\Models\Shop;
- use App\Repositories\Enums\OrderStatusEnum;
- use League\Fractal\TransformerAbstract;
- class ShopTransformer extends TransformerAbstract
- {
- public function transform(Shop $shop)
- {
- $data = [
- 'id' => $shop->id,
- 'name' => $shop->name,
- 'address' => $shop->address,
- 'mobile' => $shop->mobile,
- 'cover' => $shop->cover,
- 'lat' => $shop->lat,
- 'lng' => $shop->lng,
- 'intro' => $shop->intro,
- 'opening_hours' => $shop->opening_hours,
- 'contact_name' => $shop->contact_name,
- 'contact_mobile' => $shop->contact_mobile,
- 'royalties' => $shop->royalties,
- 'a_minute_money' => $shop->a_minute_money,
- 'b_minute_money' => $shop->b_minute_money,
- 'ab_minute_money' => $shop->ab_minute_money,
- 'times' => $shop->times,
- 'device_nums' => $shop->device_nums,
- 'distance' => $shop->distance ?? 0,
- 'day_money' => Order::query()->whereDate('pay_time', date("Y-m-d"))->where('shop_id', $shop->id)->where('status', OrderStatusEnum::ORDER_OVER)->sum('pay_money'),
- 'work_time' => Order::query()->whereDate('pay_time', date("Y-m-d"))->where('shop_id', $shop->id)->where('status', OrderStatusEnum::ORDER_OVER)->sum('work_time')
- ];
- return $data;
- }
- }
|