PayMerchantService.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Servicess;
  3. use App\Models\Pay\PayMerchant;
  4. use App\Services\Pay;
  5. class PayMerchantService
  6. {
  7. /**
  8. * 查找微信支付配置信息
  9. */
  10. public static function findPayConfig(int $id)
  11. {
  12. $pay_merchant = PayMerchant::find($id);
  13. $pay_config = json_decode($pay_merchant->config_info);
  14. return [
  15. 'appid' => $pay_config->appid,
  16. 'merchant_id' => $pay_config->merchant_id,
  17. 'key' => $pay_config->key,
  18. ];
  19. }
  20. /**
  21. * 查找微信支付配置信息
  22. */
  23. public static function findAliPayConfig(int $id)
  24. {
  25. $pay_merchant = PayMerchant::find($id);
  26. $pay_config = json_decode($pay_merchant->config_info);
  27. return [
  28. 'app_id' => $pay_config->app_id,
  29. 'ali_pub_key' => $pay_config->ali_pub_key,
  30. 'pri_key' => $pay_config->pri_key,
  31. ];
  32. }
  33. /**
  34. * 根据ID查找
  35. * @param $id
  36. * @return mixed
  37. */
  38. public static function getPayMerchantSingle($id)
  39. {
  40. return PayMerchant::find($id);
  41. }
  42. /**
  43. * 查找所有的支付渠道通道
  44. * @return mixed
  45. */
  46. public static function getPayMerchantSourceList()
  47. {
  48. $result = PayMerchant::select('source')->distinct();
  49. return $result;
  50. }
  51. }