PayMerchantService.php 1.4 KB

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