12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace App\Http\Controllers\Coach;
- use App\Http\Controllers\Controller;
- use App\Services\Coach\WalletService;
- use App\Traits\ResponseTrait;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- /**
- * @group 技师端
- *
- * 钱包相关的API接口
- */
- class WalletController extends Controller
- {
- use ResponseTrait;
- protected WalletService $service;
- public function __construct(WalletService $service)
- {
- $this->service = $service;
- }
- /**
- * [钱包]获取钱包信息
- *
- * @description 获取技师钱包余额和收入统计信息
- *
- * @authenticated
- *
- * @response {
- * "data": {
- * "balance": "1000.00",
- * "frozen_amount": "0.00",
- * "total_income": "5000.00",
- * "total_withdraw": "4000.00",
- * "today_income": "100.00",
- * "month_income": "2000.00",
- * "last_month_income": "3000.00"
- * }
- * }
- */
- public function getWallet()
- {
- return $this->success($this->service->getWallet(Auth::user()->id));
- }
- /**
- * [钱包]获取钱包流水记录
- *
- * @description 获取技师钱包的收支明细记录
- *
- * @authenticated
- *
- * @queryParam type integer 记录类型(1:收入 2:支出) Example: 1
- * @queryParam start_date date 开始日期 Example: 2024-01-01
- * @queryParam end_date date 结束日期 Example: 2024-03-21
- * @queryParam page integer 页码 Example: 1
- * @queryParam per_page integer 每页数量 Example: 10
- *
- * @response {
- * "data": {
- * "items": [
- * {
- * "id": 1,
- * "amount": "100.00",
- * "type": 1,
- * "remark": "订单收入",
- * "created_at": "2024-03-21 10:00:00"
- * }
- * ],
- * "total": 100
- * }
- * }
- */
- public function getWalletRecords(Request $request)
- {
- $params = $request->validate([
- 'type' => 'nullable|integer|in:1,2',
- 'start_date' => 'nullable|date',
- 'end_date' => 'nullable|date|after_or_equal:start_date',
- 'page' => 'nullable|integer|min:1',
- 'per_page' => 'nullable|integer|min:1|max:50',
- ]);
- return $this->success($this->service->getWalletRecords(Auth::user()->id, $params));
- }
- }
|