HuijuBillTypeEnum.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. namespace common\enums;
  3. use common\enums\BaseEnum;
  4. use common\models\user\User;
  5. use ReflectionClass;
  6. /**
  7. * 汇聚聚合支付类型
  8. *
  9. * Class HuijuBillTypeEnum
  10. * @package common\enums
  11. */
  12. class HuijuBillTypeEnum extends BaseEnum
  13. {
  14. // 当前只支持的交易类型
  15. /**
  16. * 支付宝H5
  17. */
  18. const ALIPAY_H5 = 'ALIPAY_H5';
  19. /**
  20. * 公众号支付
  21. */
  22. const WEIXIN_GZH = 'WEIXIN_GZH';
  23. /**
  24. * 微信小程序支付
  25. */
  26. const WEIXIN_XCX = 'WEIXIN_XCX';
  27. /**
  28. * 汇聚分账支付支付方式名称
  29. */
  30. const HUIJU_BILL_JOINPAY = 'huiju_bill';
  31. /**
  32. * 汇聚分账支付支付方式标识
  33. */
  34. const BILL_JOINPAY = 10;
  35. // 汇聚支付可以配置的支付渠道
  36. const JOINPAY_CHANNEL_ORDER = 1;
  37. const JOINPAY_CHANNEL_RECHARGE = 2;
  38. /**
  39. * @return array|string[]
  40. */
  41. public static function getMap(): array
  42. {
  43. return [
  44. self::ALIPAY_H5 => '支付宝H5',
  45. self::WEIXIN_GZH => '微信公众号',
  46. self::WEIXIN_XCX => '微信小程序',
  47. ];
  48. }
  49. /**
  50. * 根据环境获取微信交易类型
  51. * @param $platform
  52. * @return mixed|string
  53. */
  54. public static function getTypeByPlatform($platform)
  55. {
  56. $arr = [
  57. User::PLATFORM_APP => [self::ALIPAY_H5],
  58. // User::PLATFORM_H5 => [self::ALIPAY_H5],
  59. User::PLATFORM_H5 => [self::ALIPAY_H5],
  60. User::PLATFORM_WECHAT => [self::WEIXIN_GZH, self::ALIPAY_H5],
  61. User::PLATFORM_MP_WX => self::WEIXIN_XCX,
  62. ];
  63. return $arr[$platform] ?? '';
  64. }
  65. /**
  66. * 获取当前类所有定义常量
  67. *
  68. * @return array
  69. */
  70. public static function getConstants()
  71. {
  72. $class = new ReflectionClass(__CLASS__);
  73. return $class->getConstants();
  74. }
  75. public static function action($type)
  76. {
  77. $ations = self::allAction();
  78. return $ations[$type] ?? '';
  79. }
  80. public static function getPaymentMap(): array
  81. {
  82. return [
  83. self::BILL_JOINPAY => '汇聚分账支付',
  84. // self::BILL_JOINPAY_FAST_PAY => '银行卡支付',
  85. ];
  86. }
  87. /**
  88. * 所有支付方式
  89. * @return array
  90. */
  91. public static function allAction(){
  92. return [
  93. self::BILL_JOINPAY => self::HUIJU_BILL_JOINPAY,
  94. // self::BILL_JOINPAY_FAST_PAY => 'bill_joinpay_fast',
  95. ];
  96. }
  97. /**
  98. * 获取所有支付方式描述
  99. * @return array
  100. */
  101. public static function allTypeConf()
  102. {
  103. $protocol = ($_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http') . '://';
  104. $host = $protocol.$_SERVER['HTTP_HOST'];
  105. $map = self::getPaymentMap();
  106. $actions = self::allAction();
  107. $return = [];
  108. foreach($actions as $key => $val){
  109. $return[$val] = [
  110. 'name' => $map[$key],
  111. 'img' => $host . '/resources/img/payment/' . $val . '.png',
  112. 'pay_type' => $key
  113. ];
  114. }
  115. return $return;
  116. }
  117. }