MerchantChannelController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Modules\Api\Controllers;
  3. use App\Models\MerchantModel;
  4. use Illuminate\Support\Facades\Validator;
  5. use Modules\Api\Services\PaymentService;
  6. class MerchantChannelController extends BaseController
  7. {
  8. /**
  9. * 商户支付通道列表
  10. *
  11. * @return \Illuminate\Http\JsonResponse|mixed
  12. */
  13. public function channelLists()
  14. {
  15. $inputData = $this->getJsonData();
  16. $rules = [
  17. 'merchant_code' => 'required|string',
  18. 'key' => 'required|string',
  19. ];
  20. $validator = Validator::make($inputData, $rules);
  21. if ($validator->fails()) {
  22. // 如果有错误(可能是多个信息),这里只取第一个错误信息返回.
  23. return json_fail($validator->errors()->first());
  24. }
  25. $merchantInfo = MerchantModel::query()->where(['merchant_code' => $inputData['merchant_code'], 'key' => $inputData['key'], 'status' => 1])->first();
  26. if (empty($merchantInfo)) {
  27. return json_fail('该商户不存在');
  28. }
  29. $res = make(PaymentService::class)->getAllPayments($merchantInfo->uid);
  30. return json_success($res);
  31. }
  32. }