Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = BankList::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'binding_pay_1time_limit' => $this->binding_pay_1time_limit, 'binding_pay_time_limit' => $this->binding_pay_time_limit, 'binding_pay_day_limit' => $this->binding_pay_day_limit, 'binding_pay_time_min_limit' => $this->binding_pay_time_min_limit, 'is_valid' => $this->is_valid, 'create_at' => $this->create_at, 'update_at' => $this->update_at]);
     $query->andFilterWhere(['like', 'bank_code', $this->bank_code])->andFilterWhere(['like', 'card_type', $this->card_type])->andFilterWhere(['like', 'card_attribute', $this->card_attribute]);
     return $dataProvider;
 }
Beispiel #2
0
 /**
  * 获取银行卡信息接口
  * @param $bankcard
  * @return bool|mixed
  */
 public static function bankCardInfo($bankcard)
 {
     $appkey = "b7a4079d8c674ad591679d97821555d1";
     $ch = curl_init();
     $url = "http://apis.haoservice.com/lifeservice/bankcard/query?card=" . $bankcard . "&key=" . $appkey;
     // 执行HTTP请求
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, 500);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_URL, $url);
     $res = curl_exec($ch);
     curl_close($ch);
     $flag = json_decode($res);
     //获取支持的银行列表
     $bank_name_list = array();
     $banklist = BankList::find()->where(['is_valid' => BankList::IS_VALID_TRUE])->asArray()->all();
     if ($banklist !== null) {
         //获取数据库设定的银行列表
         foreach ($banklist as $key => $value) {
             $bank_name_list[$key] = array('bank_name' => $value['bank_name'], 'bank_code' => trim($value['bank_code']), 'bank_logo' => $value['bank_logo']);
         }
     }
     if ($flag->error_code) {
         //有错误
         $error_msg = array('206101' => '参数错误', '206102' => '该卡号暂未收录', '206103' => '捕获到一个异常', '10001' => '错误的请求KEY', '10002' => '该KEY无请求权限', '10003' => 'KEY过期', '10004' => '错误的SDK KEY', '10005' => '应用未审核超时,请提交认证', '10007' => '未知的请求源,(服务器没有获取到IP地址)', '10008' => '被禁止的IP', '10009' => '被禁止的KEY', '10011' => '当前IP请求超过限制', '10012' => '当前Key请求超过限制', '10013' => '测试KEY超过请求限制', '10020' => '接口维护', '10021' => '接口停用', '10022' => 'appKey按需剩余请求次数为零', '10023' => '请求IP无效', '10024' => '网络错误', '10025' => '没有查询到结果', '10026' => '当前请求频率过高超过权限限制');
         $msg = 'error';
         if (array_key_exists($flag->error_code, $error_msg)) {
             $msg = $error_msg[$flag->error_code];
         }
         $data = array('province' => '', 'city' => '', 'bank_code' => '', 'bank_name' => '', 'banklist' => $bank_name_list);
         //接口出现问题---直接用户手工选择
         $return = array('errorNum' => '3', 'errorMsg' => $msg, 'data' => $data);
         return $return;
     } else {
         //设定一个默认数据列表
         $bank_code = array('95588' => 'ICBC', '95599' => 'ABC', '95566' => 'BOC', '95533' => 'CCB', '95528' => 'SPDB', '95561' => 'CIB', '95595' => 'CEB', '95568' => 'CMBC', '95558' => 'CITIC', '95555' => 'CMB', '95580' => 'PSBC', '95511' => 'SZPAB', '95508' => 'GDB', '95577' => 'HXB', '95594' => 'BOS');
         $bank_name = array();
         //获取支持的银行列表
         $banklist = BankList::find()->where(['is_valid' => BankList::IS_VALID_TRUE])->asArray()->all();
         if ($banklist !== null) {
             //获取数据库设定的银行列表
             $bank_code = array();
             foreach ($banklist as $key => $value) {
                 $bank_code[trim($value['service_tel'])] = trim($value['bank_code']);
                 $bank_name[trim($value['bank_name'])] = trim($value['bank_code']);
             }
         }
         $province = trim($flag->result->province);
         $city = trim($flag->result->city);
         $bank = $flag->result->bank;
         $type = $flag->result->type;
         $tel = $flag->result->tel;
         $cardname = $flag->result->cardname;
         $bankcode = "";
         if (array_key_exists($tel, $bank_code) || array_key_exists($bank, $bank_name)) {
             //获取支持的银行卡列表中银行的英文缩写
             if ($tel != '') {
                 $bankcode = $bank_code[$tel];
             } else {
                 $bankcode = $bank_name[$bank];
             }
             //获取银行卡的归属地--缺少省份或城市
             $zxcity = array('北京', '天津', '上海', '重庆', '北京市', '天津市', '上海市', '重庆市');
             if (!in_array($province, $zxcity)) {
                 //不在四大直辖市
                 if ($province == '该卡归属地信息暂未收录') {
                     $data = array('province' => '', 'city' => '', 'bank_code' => $bankcode, 'bank_name' => $bank, 'banklist' => $bank_name_list);
                     $return = array('errorNum' => '3', 'errorMsg' => '该卡归属地信息暂未收录', 'data' => $data);
                     return $return;
                 } elseif (empty($city) || empty($province)) {
                     $data = array('province' => $province, 'city' => $city, 'bank_code' => $bankcode, 'bank_name' => $bank, 'banklist' => $bank_name_list);
                     $return = array('errorNum' => '3', 'errorMsg' => '该卡归属地信息不全', 'data' => $data);
                     return $return;
                 }
             }
             $data = array('province' => trim($province), 'city' => trim($city), 'bank_code' => $bankcode, 'bank_name' => $bank, 'type' => $type, 'cardname' => $cardname);
             $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data);
             return $return;
         } else {
             //不支持的银行列表
             $return = array('errorNum' => '1', 'errorMsg' => '平台暂不支持' . $bank, 'data' => null);
             return $return;
         }
     }
 }
 /**
  * Finds the BankList model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BankList the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BankList::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }