提交
This commit is contained in:
160
app/home/controller/Visa.php
Normal file
160
app/home/controller/Visa.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Cookie;
|
||||
use think\facade\Log;
|
||||
use think\facade\Session;
|
||||
use think\facade\View;
|
||||
use think\Request;
|
||||
|
||||
class Visa extends Base
|
||||
{
|
||||
public $provinces = [
|
||||
'安徽' => 'ANHUI',
|
||||
'北京' => 'BEIJING',
|
||||
'重庆' => 'CHONGQING',
|
||||
'福建' => 'FUJIAN',
|
||||
'甘肃' => 'GANSU',
|
||||
'广东' => 'GUANGDONG',
|
||||
'广西壮族自治区' => 'GUANGXI ZHUANG',
|
||||
'贵州' => 'GUIZHOU',
|
||||
'海南' => 'HAINAN',
|
||||
'河北' => 'HEBEI',
|
||||
'黑龙江' => 'HEILONGJIANG',
|
||||
'河南' => 'HENAN',
|
||||
'香港特别行政区' => 'HONG KONG SAR',
|
||||
'湖北' => 'HUBEI',
|
||||
'湖南' => 'HUNAN',
|
||||
'内蒙古自治区' => 'INNER MONGOLIA',
|
||||
'江苏' => 'JIANGSU',
|
||||
'江西' => 'JIANGXI',
|
||||
'吉林' => 'JILIN',
|
||||
'辽宁' => 'LIAONING',
|
||||
'澳门特别行政区' => 'MACAU SAR',
|
||||
'宁夏回族自治区' => 'NINGXIA HUI',
|
||||
'青海' => 'QINGHAI',
|
||||
'陕西' => 'SHAANXI',
|
||||
'山东' => 'SHANDONG',
|
||||
'上海' => 'SHANGHAI',
|
||||
'山西' => 'SHANXI',
|
||||
'四川' => 'SICHUAN',
|
||||
'台湾' => 'TAIWAN',
|
||||
'天津' => 'TIANJIN',
|
||||
'新疆维吾尔自治区' => 'XINJIANG',
|
||||
'西藏自治区' => 'XIZANG',
|
||||
'云南' => 'YUNNAN',
|
||||
'浙江' => 'ZHEJIANG'
|
||||
];
|
||||
public function index()
|
||||
{
|
||||
View::assign('th_province', json_decode(file_get_contents(CONFIG_JSON_TH_PROVINCE), true));
|
||||
View::assign('nation', json_decode(file_get_contents(CONFIG_JSON_VISA_NATIONALITY), true));
|
||||
if (Cookie::get('think_var') == 'en-us') {
|
||||
View::assign('travel_country', json_decode(file_get_contents(CONFIG_JSON_COUNTRY_EN), true));
|
||||
} else {
|
||||
View::assign('travel_country', json_decode(file_get_contents(CONFIG_JSON_COUNTRY), true));
|
||||
}
|
||||
return View::fetch();
|
||||
}
|
||||
public function getCountry()
|
||||
{
|
||||
if (Cookie::get('think_var') == 'en-us') {
|
||||
$birth_country = file_get_contents(CONFIG_JSON_COUNTRY_EN);
|
||||
} else {
|
||||
$birth_country = file_get_contents(CONFIG_JSON_COUNTRY);
|
||||
}
|
||||
return $this->success('成功', '', json_decode($birth_country, true));
|
||||
}
|
||||
|
||||
public function get_sub_city(Request $request)
|
||||
{
|
||||
$id = $request->param('id');
|
||||
$city = find_json(CONFIG_JSON_TH_CITY, 'provinceCode', $id);
|
||||
if ($city) {
|
||||
return $this->success('成功', '', $city);
|
||||
} else {
|
||||
return $this->success('成功', '', []);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_sub_istrict(Request $request)
|
||||
{
|
||||
$id = $request->param('id');
|
||||
$city = find_json(CONFIG_JSON_TH_DISTRICT, 'districtCode', $id);
|
||||
if ($city) {
|
||||
return $this->success('成功', '', $city);
|
||||
} else {
|
||||
return $this->success('成功', '', []);
|
||||
}
|
||||
}
|
||||
public function get_common_json($json_name, $field, $value, $flag, $key)
|
||||
{
|
||||
$data = find_json($json_name, $field, $value);
|
||||
if ($data) {
|
||||
if ($flag == 1) {
|
||||
return $data;
|
||||
} else {
|
||||
return $data[0][$key];
|
||||
}
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getprovince($data)
|
||||
{
|
||||
if (array_key_exists($data, $this->provinces)) {
|
||||
return $this->provinces[$data];
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
public function do_apply()
|
||||
{
|
||||
$request = $this->request;
|
||||
$data = $request->post();
|
||||
$order_sn = getOrderNumber();
|
||||
unset($data['check1']);
|
||||
unset($data['check2']);
|
||||
unset($data['visit_info1']);
|
||||
|
||||
$data['model'] = MODEL;
|
||||
$data['token'] = md5(MODEL);
|
||||
$data['source'] = Session::get('source');
|
||||
$data['order_sn'] = $order_sn;
|
||||
$data['is_mobile'] = isMobile();
|
||||
$data['live_city'] = $this->getprovince($data['live_city']);
|
||||
/*处理 map */
|
||||
$nationality_map = json_decode(file_get_contents(CONFIG_JSON_NATIONALITY_MAP), true) ?? [];
|
||||
$data['nation'] = $nationality_map[$data['nation']] ?? $data['nation'];
|
||||
|
||||
$order_res = Httpcurl::request(config('app.CREATE_ORDER_URL'), 'post', $data);
|
||||
$order = json_decode($order_res[0], true);
|
||||
Log::info(json_encode($order));
|
||||
if (!$order['code']) {
|
||||
return $this->error(lang('controller.submit_failed'));
|
||||
}
|
||||
Session::set('order_sn', $order_sn);
|
||||
Session::set('total_price', $data['total_price']);
|
||||
$url = url('wepay/pcpay', ['order_sn' => $order_sn]);
|
||||
if (isMobile()) {
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
|
||||
$url = url('wepay/wxpay', ['order_sn' => $order_sn]);
|
||||
}else{
|
||||
$url = url('wepay/h5pay', ['order_sn' => $order_sn]);
|
||||
}
|
||||
|
||||
}
|
||||
return $this->success(lang('controller.success'), $url);
|
||||
/*if ($_REQUEST['pay_type'] == '3') {
|
||||
return $this->success(lang('controller.success'), url('sqpay/pay',['order_sn'=>$order_sn]));
|
||||
} else {
|
||||
return $this->success(lang('controller.submit_success'), url('pay/pay',['order_sn'=>$order_sn]), '1');
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user