cxfoot/models/CardUnion.php
2023-10-27 14:25:12 +08:00

140 lines
4.9 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "{{%card_union}}".
*
* @property int $id
* @property int|null $cx_mch_id 平台商户id
* @property string $card_number 银行号号
* @property string $name 姓名
* @property string $identity_number 证件号
* @property string $mobile_phone 手机号
* @property int $province_id 省id
* @property int $city_id 市id
* @property string $acct_bank_id 开户行别
* @property int $bank_id 开户网点id
* @property string $doc_pic 分账证明材料在本系统地址
* @property string|null $doc_id 分账证明材料ID,接口返回
* @property int|null $status 绑定状态0-未请求1-已请求2-已绑定
* @property int|null $created_at
* @property int|null $is_delete
* @property int|null $deleted_at
* @property string $apply_no 此值在商户侧唯一用于【4.7分账接收方进件查询】查询申请单的信息
*/
class CardUnion extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%card_union}}';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['cx_mch_id', 'province_id', 'city_id', 'bank_id', 'status', 'created_at', 'is_delete', 'deleted_at'], 'integer'],
[['card_number', 'name', 'identity_number', 'mobile_phone', 'province_id', 'city_id', 'acct_bank_id', 'bank_id', 'doc_pic', 'apply_no'], 'required'],
[['card_number', 'identity_number', 'doc_pic'], 'string', 'max' => 255],
[['name', 'acct_bank_id', 'doc_id'], 'string', 'max' => 50],
[['mobile_phone'], 'string', 'max' => 128],
[['apply_no'], 'string', 'max' => 64],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'cx_mch_id' => '平台商户id',
'card_number' => '银行号号',
'name' => '姓名',
'identity_number' => '证件号',
'mobile_phone' => '手机号',
'province_id' => '省id',
'city_id' => '市id',
'acct_bank_id' => '开户行别',
'bank_id' => '开户网点id',
'doc_pic' => '分账证明材料在本系统地址',
'doc_id' => '分账证明材料ID,接口返回',
'status' => '绑定状态0-未请求1-已请求2-已绑定',
'created_at' => 'Created At',
'is_delete' => 'Is Delete',
'deleted_at' => 'Deleted At',
'apply_no' => '此值在商户侧唯一用于【4.7分账接收方进件查询】查询申请单的信息',
];
}
public function getCardBank()
{
return $this->hasOne(CardBank::className(), ['id' => 'bank_id'])->where(['is_delete' => 0]);
}
/**
* 获取申请绑定银行卡编号
* @param $order_no string card_union表的apply_no
* @return string
*/
public static function get_apply_no($order_no)
{
return "CA{$order_no}";
}
public static function getPsNo($id)
{
$ps_no = "PSNO{$id}";
return $ps_no;
}
//获取银联配置
public static function getUnion()
{
$YII_ENV = YII_ENV_DEV;
$union = \Yii::$app->params['union'];
$YII_ENV = true;
if ($YII_ENV) {
//测试环境
$appId = $union['dev_appId'];
$mchId = $union['dev_mchId'];
$private_cert = $union['dev_private_cert'];
$public_cert = $union['dev_public_cert'];
$privateKeyPassword = $union['dev_password'];
$public_key = $union['dev_public_key'];
$url = $union['dev_url'];
} else {
$appId = $union['prod_appId'];
$mchId = $union['prod_mchId'];
$private_cert = $union['prod_private_cert'];
$public_cert = $union['prod_public_cert'];
$privateKeyPassword = $union['prod_password'];
$public_key = $union['prod_public_key'];
$url = $union['prod_url'];
}
if (empty($appId) || empty($mchId) || empty($private_cert) || empty($public_cert) || empty($privateKeyPassword) || empty($url)) {
return Model::asReturnError('银联信息尚未配置,暂无法操作');
}
$data['appId'] = $appId;
$data['mchId'] = $mchId;
$data['private_cert'] = $private_cert;
$data['public_cert'] = $public_cert;
$data['password'] = $privateKeyPassword;
$data['public_key'] = $public_key;
$data['url'] = $url;
return Model::asReturnSuccess('ok',$data);
}
}