1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Modules\Mini\Controllers;
- use App\Base\BaseController;
- use App\Models\Order\Order;
- use App\Modules\Mini\Services\FavService;
- use App\Modules\Mini\Services\GoodsService;
- use App\Modules\Mini\Services\OrderService;
- use Faker\Provider\Image;
- use Illuminate\Support\Facades\Auth;
- class GoodsController extends BaseController
- {
- protected GoodsService $service;
- /**
- * @param GoodsService $service
- */
- public function __construct(GoodsService $service)
- {
- $this->service = $service;
- }
- public function goods()
- {
- $params = $this->valid([
- "id" => "required",
- ]);
- return $this->ok($this->service->info($params));
- }
- public function search()
- {
- return $this->ok([
- "total" => 1,
- "page_total" => 1,
- "list" => [
- [
- "id" => 1,
- "name" => "商品名称",
- "thumb" => Image::imageUrl(),
- ],
- ],
- "category" => [
- [
- "id" => 1,
- "thumb" => Image::imageUrl(),
- "name" => "分类名称",
- ],
- ],
- ]);
- }
- public function fav()
- {
- $params = $this->valid([
- "id" => "required",
- ]);
- return $this->ok([
- "was_created" => app(FavService::class)->fav(Auth::id(), $params)->wasRecentlyCreated,
- ]);
- }
- public function ask()
- {
- $params = $this->valid([
- "id" => "required",
- "sku_id" => "required",
- "sku_custom" => "",
- ]);
- $params['source'] = Order::SOURCE_GOODS;
- return $this->ok(app(OrderService::class)->askOne(Auth::user(), $params));
- }
- }
|