| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- namespace common\enums;
- use common\enums\BaseEnum;
- use common\models\user\User;
- use ReflectionClass;
- /**
- * 汇聚聚合支付类型
- *
- * Class HuijuBillTypeEnum
- * @package common\enums
- */
- class HuijuBillTypeEnum extends BaseEnum
- {
- // 当前只支持的交易类型
- /**
- * 支付宝H5
- */
- const ALIPAY_H5 = 'ALIPAY_H5';
- /**
- * 公众号支付
- */
- const WEIXIN_GZH = 'WEIXIN_GZH';
- /**
- * 微信小程序支付
- */
- const WEIXIN_XCX = 'WEIXIN_XCX';
- /**
- * 汇聚分账支付支付方式名称
- */
- const HUIJU_BILL_JOINPAY = 'huiju_bill';
- /**
- * 汇聚分账支付支付方式标识
- */
- const BILL_JOINPAY = 10;
- // 汇聚支付可以配置的支付渠道
- const JOINPAY_CHANNEL_ORDER = 1;
- const JOINPAY_CHANNEL_RECHARGE = 2;
- /**
- * @return array|string[]
- */
- public static function getMap(): array
- {
- return [
- self::ALIPAY_H5 => '支付宝H5',
- self::WEIXIN_GZH => '微信公众号',
- self::WEIXIN_XCX => '微信小程序',
- ];
- }
- /**
- * 根据环境获取微信交易类型
- * @param $platform
- * @return mixed|string
- */
- public static function getTypeByPlatform($platform)
- {
- $arr = [
- User::PLATFORM_APP => [self::ALIPAY_H5],
- // User::PLATFORM_H5 => [self::ALIPAY_H5],
- User::PLATFORM_H5 => [self::ALIPAY_H5],
- User::PLATFORM_WECHAT => [self::WEIXIN_GZH, self::ALIPAY_H5],
- User::PLATFORM_MP_WX => self::WEIXIN_XCX,
- ];
- return $arr[$platform] ?? '';
- }
- /**
- * 获取当前类所有定义常量
- *
- * @return array
- */
- public static function getConstants()
- {
- $class = new ReflectionClass(__CLASS__);
- return $class->getConstants();
- }
- public static function action($type)
- {
- $ations = self::allAction();
- return $ations[$type] ?? '';
- }
- public static function getPaymentMap(): array
- {
- return [
- self::BILL_JOINPAY => '汇聚分账支付',
- // self::BILL_JOINPAY_FAST_PAY => '银行卡支付',
- ];
- }
- /**
- * 所有支付方式
- * @return array
- */
- public static function allAction(){
- return [
- self::BILL_JOINPAY => self::HUIJU_BILL_JOINPAY,
- // self::BILL_JOINPAY_FAST_PAY => 'bill_joinpay_fast',
- ];
- }
- /**
- * 获取所有支付方式描述
- * @return array
- */
- public static function allTypeConf()
- {
- $protocol = ($_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http') . '://';
- $host = $protocol.$_SERVER['HTTP_HOST'];
- $map = self::getPaymentMap();
- $actions = self::allAction();
- $return = [];
- foreach($actions as $key => $val){
- $return[$val] = [
- 'name' => $map[$key],
- 'img' => $host . '/resources/img/payment/' . $val . '.png',
- 'pay_type' => $key
- ];
- }
- return $return;
- }
- }
|