"支付宝APP", self::WECHAT_APP => "微信APP", self::CLOUD_APP => "云闪付APP", self::ALIPAY_WAP => "支付宝H5", self::WECHAT_WAP => "微信H5", self::CLOUD_H5 => "在线银联", self::WECHAT_GZH => "微信公众号", self::ALIPAY_MP => "支付宝小程序", self::WECHAT_MP => "公众号小程序", self::WECHAT_FRONT_QR => "微信正扫", ]; const APP = 1; // app const H5 = 2; // h5 const MP = 3; // 小程序 const WECHAT = 4; // 公众号 const CLOUD = 1; // 云闪付 /** * {@inheritdoc} */ public static function tableName() { return '{{%addons_sicpay_config}}'; } /** * {@inheritdoc} */ public function rules() { return [ [['mall_id', 'created_at', 'updated_at','status'], 'integer'], [['merRsaPrivateKey', 'rootRsaPublicKey', 'merAesKey', 'rootAesKey'], 'string'], [['agencyId'], 'string', 'max' => 32], [['pay_way', 'alipay', 'wechat', 'bank','terminal_no','child_merchant_no'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'agencyId' => '商户号', 'merRsaPrivateKey' => '商户RSA私钥', 'rootRsaPublicKey' => '平台(我司)RSA公', 'merAesKey' => '商户aes密钥', 'rootAesKey' => '平台(我司)aes密钥', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public function beforeValidate () { if (!parent::beforeValidate()) { return false; } return true; } public static function getConfig($mall_id) { $config = self::find()->where(['mall_id'=>$mall_id])->one(); if(!empty($config)){ $config->pay_way = Json::decode($config['pay_way']); $config->alipay = Json::decode($config['alipay']); $config->wechat = Json::decode($config['wechat']); $config->bank = Json::decode($config['bank']); }else{ return []; } return $config; } // 获取app支付渠道 public function _get_app_way(){ $way = []; // 支付宝 // if(in_array(self::APP,$this->alipay)){ // $way[] = [ // "name"=>"中金-支付宝", // "img"=>"resources/img/payment/alipay.png", // "pay_type"=>PayTypeEnum::SIC_PAY, // "action"=>"sic_pay", // "trade_type"=>self::ALIPAY_APP // ]; // } // // 微信 // if(in_array(self::APP,$this->wechat)){ // $way[] = [ // "name"=>"中金-微信", // "img"=>"resources/img/payment/wechat.png", // "pay_type"=>PayTypeEnum::SIC_PAY, // "action"=>"sic_pay", // "trade_type"=>self::WECHAT_APP // ]; // } // // 银联 // if(in_array(self::APP,$this->bank)){ // $way[] = [ // "name"=>"中金-云闪付", // "img"=>"resources/img/payment/cloud.jpg", // "pay_type"=>PayTypeEnum::SIC_PAY, // "action"=>"sic_pay", // "trade_type"=>self::CLOUD_APP // ]; // } // 支付宝 if(in_array(self::H5,$this->alipay)){ $way[] = [ "name"=>"中金-支付宝", "img"=>"resources/img/payment/alipay.png", "pay_type"=>PayTypeEnum::SIC_PAY, "action"=>"sic_pay", "trade_type"=>self::ALIPAY_WAP ]; } // 微信 if(in_array(self::APP,$this->wechat)){ $way[] = [ "name"=>"中金-微信", "img"=>"resources/img/payment/wechat.png", "pay_type"=>PayTypeEnum::SIC_PAY, "action"=>"sic_pay", "trade_type"=>self::WECHAT_APP ]; } // 银联 if(in_array(self::H5,$this->bank)){ $way[] = [ "name"=>"中金-在线银联", "img"=>"resources/img/payment/joinpay_fast.png", "pay_type"=>PayTypeEnum::SIC_PAY, "action"=>"sic_pay", "trade_type"=>self::CLOUD_H5, ]; } return $way; } // 获取h5支付渠道 public function _get_h5_way(){ $way = []; // 支付宝 if(in_array(self::H5,$this->alipay)){ $way[] = [ "name"=>"中金-支付宝", "img"=>"resources/img/payment/alipay.png", "pay_type"=>PayTypeEnum::SIC_PAY, "action"=>"sic_pay", "trade_type"=>self::ALIPAY_WAP ]; } // 微信 if(in_array(self::H5,$this->wechat)){ $way[] = [ "name"=>"中金-微信", "img"=>"resources/img/payment/wechat.png", "pay_type"=>PayTypeEnum::SIC_PAY, "action"=>"sic_pay", "trade_type"=>self::WECHAT_WAP ]; } // 银联 if(in_array(self::H5,$this->bank)){ $way[] = [ "name"=>"中金-在线银联", "img"=>"resources/img/payment/joinpay_fast.png", "pay_type"=>PayTypeEnum::SIC_PAY, "action"=>"sic_pay", "trade_type"=>self::CLOUD_H5, ]; } return $way; } // 获取小程序支付渠道 public function _get_mp_way(){ $way = []; // 支付宝 if(in_array(self::MP,$this->alipay)){ $way[] = [ "name"=>"中金-支付宝", "img"=>"resources/img/payment/alipay.png", "pay_type"=>PayTypeEnum::SIC_PAY, "action"=>"sic_pay", "trade_type"=>self::ALIPAY_MP, ]; } // 微信 if(in_array(self::MP,$this->wechat)){ $way[] = [ "name"=>"中金-微信", "img"=>"resources/img/payment/wechat.png", "pay_type"=>PayTypeEnum::SIC_PAY, "action"=>"sic_pay", "trade_type"=>self::WECHAT_MP, ]; } return $way; } // 获取公众号支付 public function _get_wechat_way(){ $way = []; // 微信 if(in_array(self::WECHAT,$this->wechat)){ $way[] = [ "name"=>"中金-微信", "img"=>"resources/img/payment/wechat.png", "pay_type"=>PayTypeEnum::SIC_PAY, "action"=>"sic_pay", "trade_type"=>self::WECHAT_GZH, ]; } // 银联 if(in_array(self::H5,$this->bank)){ $way[] = [ "name"=>"中金-在线银联", "img"=>"resources/img/payment/joinpay_fast.png", "pay_type"=>PayTypeEnum::SIC_PAY, "action"=>"sic_pay", "trade_type"=>self::CLOUD_H5, ]; } return $way; } public static function getTypeText(){ $list = []; foreach (self::$type_text as $key=>$val){ $list[] = [ 'label'=>$val, 'value'=>$key, ]; } return $list; } }