| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace App\Http\Controllers\admin;
- use App\Constants\HttpStatus;
- use App\Http\Controllers\Controller;
- use App\Models\Wallet as WalletModel;
- use App\Services\ActivityUserService;
- use App\Services\BalanceLogService;
- use App\Services\TopUpService;
- use Illuminate\Http\JsonResponse;
- use Illuminate\Support\Facades\Cache;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Validation\ValidationException;
- use Exception;
- use App\Models\ActivityUser as ActivityUserModel;
- class ActivityUser extends Controller
- {
- public function finish(): JsonResponse
- {
- DB::beginTransaction();
- try {
- $params = request()->validate([
- 'id' => ['required', 'integer', 'min:1'],
- ]);
- ActivityUserService::finish($params['id']);
- DB::commit();
- } catch (ValidationException $e) {
- DB::rollBack();
- return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
- } catch (Exception $e) {
- DB::rollBack();
- return $this->error($e->getCode(), $e->getMessage());
- }
- return $this->success();
- }
- //赠送金额(充值)
- public function gift()
- {
- DB::beginTransaction();
- try {
- $params = request()->validate([
- 'id' => ['required', 'integer', 'min:1'],
- 'amount' => ['required', 'numeric', 'min:0.01'],
- 'betting_amount' => ['required', 'integer', 'min:0', 'max:9999999'],
- ]);
- ActivityUserService::gift($params['id'], $params['amount'], $params['betting_amount']);
- DB::commit();
- } catch (ValidationException $e) {
- DB::rollBack();
- return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
- } catch (Exception $e) {
- DB::rollBack();
- return $this->error($e->getCode(), $e->getMessage());
- }
- return $this->success();
- }
- public function index(): JsonResponse
- {
- try {
- $params = request()->validate([
- 'page' => ['required', 'integer', 'min:1'],
- 'limit' => ['required', 'integer', 'min:1'],
- 'title' => ['nullable', 'string'],
- 'member_id' => ['nullable', 'string'],
- ]);
- $page = request()->input('page', 1);
- $limit = request()->input('limit', 10);
- $where = ActivityUserService::getWhere($params);
- $query = ActivityUserModel::where($where);
- $count = $query->count();
- $list = $query->orderBy('status')
- ->with(['member'])
- ->orderByDesc('id')
- ->forPage($page, $limit)->get()->toArray();
- $result = ['total' => $count, 'data' => $list];
- } catch (ValidationException $e) {
- return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
- } catch (Exception $e) {
- return $this->error($e->getCode(), $e->getMessage());
- }
- return $this->success($result);
- }
- }
|