| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- <?php
- namespace addons\Sicpay\common\models;
- use common\enums\PayTypeEnum;
- use common\models\base\BaseActiveRecord;
- use common\models\user\User;
- use Yii;
- use yii\helpers\Json;
- /**
- * This is the model class for table "{{%addons_sicpay_config}}".
- *
- * @property int $id
- * @property int|null $mall_id
- * @property string|null $agencyId 商户号
- * @property string|null $merRsaPrivateKey 商户RSA私钥
- * @property string|null $rootRsaPublicKey 平台(我司)RSA公
- * @property string|null $merAesKey 商户aes密钥
- * @property string|null $rootAesKey 平台(我司)aes密钥
- * @property string|null $pay_way
- * @property string|null $alipay
- * @property string|null $wechat
- * @property string|null $bank
- * @property string|null $terminal_no
- * @property string|null $child_merchant_no
- * @property int $status
- * @property int $created_at
- * @property int $updated_at
- */
- class SicpayConfig extends BaseActiveRecord
- {
- const ALIPAY_APP = "ALIPAY_APP";
- const WECHAT_APP = "WECHAT_APP";
- const CLOUD_APP = "CLOUD_APP";
- const ALIPAY_WAP = "ALIPAY_WAP";
- const WECHAT_WAP = "WECHAT_WAP";
- const CLOUD_H5 = "CLOUD_H5";
- const ALIPAY_MP = "ALIPAY_MP";
- const WECHAT_MP = "WECHAT_MP";
- const WECHAT_GZH = "WECHAT_GZH";
- const WECHAT_FRONT_QR = "WECHAT_FRONT_QR"; // 微信正扫
- public static $type_text = [
- self::ALIPAY_APP => "支付宝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;
- }
- }
|