PayMerchantService.php 1.4 KB

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