提交
This commit is contained in:
163
app/home/controller/Base.php
Normal file
163
app/home/controller/Base.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use app\BaseController;
|
||||
use think\facade\Config;
|
||||
use think\facade\Cookie;
|
||||
use think\facade\Lang;
|
||||
use think\facade\Log;
|
||||
use think\facade\Request;
|
||||
use think\facade\Session;
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
* 控制器基础类
|
||||
*/
|
||||
class Base extends BaseController
|
||||
{
|
||||
protected $_userId;
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$source = Request::instance()->param('source', '');
|
||||
if (!empty($source)) {
|
||||
Session::set('source', $source);
|
||||
} else {
|
||||
$source = Session::get('source');
|
||||
if (empty($source)) {
|
||||
Session::set('source', $_SERVER['HTTP_HOST']);
|
||||
} else {
|
||||
Session::set('source', $source);
|
||||
}
|
||||
}
|
||||
// 获取 当前用户ID
|
||||
$this->_userId = cmf_get_current_user_id();
|
||||
// 网站配置信息获取
|
||||
if (!file_exists(app()->getRootPath().'data/config.json')) {
|
||||
$domain = $_SERVER['HTTP_HOST'];
|
||||
$web_config = Httpcurl::request(GET_WEB_CONFIG_URL . MODEL . '/domain/' . $domain, 'get');
|
||||
if ($web_config[3]) {
|
||||
abort(500, '网站配置信息获取失败');
|
||||
}
|
||||
$config_result = json_decode($web_config[0], true);
|
||||
if (empty($config_result)) {
|
||||
abort(500, '网站配置信息获取失败');
|
||||
}
|
||||
if ($config_result['code'] != 1) {
|
||||
abort(500, '网站配置信息获取失败');
|
||||
}
|
||||
file_put_contents(app()->getRootPath().'data/config.json', json_encode($config_result));
|
||||
} else {
|
||||
$config_result = json_decode(file_get_contents(app()->getRootPath().'data/config.json'), true);
|
||||
}
|
||||
|
||||
Lang::setLangSet(Cookie::get('think_var', 'zh-cn'));
|
||||
View::assign('think_lang', Cookie::get('think_var'));
|
||||
View::assign('menu_url', strtolower(Request::controller() . '/' . Request::action()));
|
||||
|
||||
/* URL 配置*/
|
||||
Config::set(['GET_ORDER_DETAIL_URL' => $config_result['data']['get_order_detail_url']], 'app');
|
||||
Config::set(['LOOKUP_URL' => $config_result['data']['lookup_url']], 'app');
|
||||
Config::set(['CREATE_ORDER_URL' => $config_result['data']['create_order_url']], 'app');
|
||||
Config::set(['NEWS_LIST' => $config_result['data']['news_list']], 'app');
|
||||
Config::set(['NEWS_DETAIL' => $config_result['data']['news_detail']], 'app');
|
||||
Config::set(['CREATE_CONTACT_URL' => $config_result['data']['create_contact_url']], 'app');
|
||||
Config::set(['GET_ORDER_URL' => $config_result['data']['get_order_url']], 'app');
|
||||
Config::set(['YZM_URL' => $config_result['data']['yzm_url']], 'app');
|
||||
/*ocr 识别 配置参数 */
|
||||
Config::set(['OCR_BASE_URL' => $config_result['data']['ocr_base_url']], 'app');
|
||||
Config::set(['OCR_APP_ID' => $config_result['data']['ocr_app_id']], 'app');
|
||||
Config::set(['OCR_SECRET' => $config_result['data']['ocr_secret']], 'app');
|
||||
|
||||
$ocr_config = build_ocr_signature($config_result['data']['ocr_app_id'], $config_result['data']['ocr_secret']);
|
||||
View::assign('ocr_config', json_encode($ocr_config));
|
||||
|
||||
/* 国内支付配置*/
|
||||
Config::set(['wechatpay' => $config_result['data']['pay']['wechatpay']], 'app');
|
||||
Config::set(['wechath5pay' => $config_result['data']['pay']['wechath5pay']], 'app');
|
||||
Config::set(['wechatpcpay' => $config_result['data']['pay']['wechatpcpay']], 'app');
|
||||
Config::set(['alipcpay' => $config_result['data']['pay']['alipcpay']], 'app');
|
||||
|
||||
Config::set(['user_url' => $config_result['data']['user_url']], 'app');
|
||||
Config::set(['order_url' => $config_result['data']['order_url']], 'app');
|
||||
View::assign('company_address', $config_result['data']['company_address']);
|
||||
View::assign('company_phone', $config_result['data']['phone'] ?? '');
|
||||
View::assign('base_path', BASE_PATH);
|
||||
View::assign('fapiao_kefu', $config_result['data']['fapiao_png']);
|
||||
|
||||
if (Cookie::get('think_var') == 'en-us') {
|
||||
View::assign('footer', $config_result['data']['footer_en']);
|
||||
View::assign('goods', $config_result['data']['MALA_GOODS_EN']);
|
||||
View::assign('country', COUNTRY_EN);
|
||||
|
||||
View::assign('phone_prefix', json_decode(file_get_contents(CONFIG_JSON_PHONE_PREFIX_EN), true));
|
||||
View::assign('travel_country', json_decode(file_get_contents(CONFIG_JSON_TRAVEL_COUNTRY_EN), true));
|
||||
} else {
|
||||
View::assign('phone_prefix', json_decode(file_get_contents(CONFIG_JSON_PHONE_PREFIX), true));
|
||||
View::assign('travel_country', json_decode(file_get_contents(CONFIG_JSON_TRAVEL_COUNTRY), true));
|
||||
|
||||
View::assign('country', COUNTRY);
|
||||
View::assign('footer', $config_result['data']['footer']);
|
||||
View::assign('goods', $config_result['data']['MALA_GOODS']);
|
||||
}
|
||||
}
|
||||
public function langs($lang='zh-cn')
|
||||
{
|
||||
Cookie::set('think_var', $lang);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function success($msg = '操作成功', $url = '', $data = [], $wait = 3)
|
||||
{
|
||||
if (is_null($url) && isset($_SERVER["HTTP_REFERER"])) {
|
||||
$url = $_SERVER["HTTP_REFERER"];
|
||||
} elseif ('' !== $url && is_object($url)) {
|
||||
$url = $url->build();
|
||||
}
|
||||
if (request()->isAjax()) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => $msg,
|
||||
'data' => $data,
|
||||
'url' => $url
|
||||
]);
|
||||
} else {
|
||||
return View::fetch('public/jump', [
|
||||
'msg' => $msg,
|
||||
'url' => $url,
|
||||
'wait' => $wait,
|
||||
'type' => 'success',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function error($msg = '操作失败', $url = '', $wait = 3, $data = [])
|
||||
{
|
||||
if (is_null($url) && isset($_SERVER["HTTP_REFERER"])) {
|
||||
$url = $_SERVER["HTTP_REFERER"];
|
||||
} elseif ('' !== $url && is_object($url)) {
|
||||
$url = $url->build();
|
||||
}
|
||||
if (request()->isAjax()) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => $msg,
|
||||
'data' => $data,
|
||||
'url' => $url
|
||||
]);
|
||||
} else {
|
||||
return View::fetch('public/jump', [
|
||||
'msg' => $msg,
|
||||
'url' => $url,
|
||||
'wait' => $wait,
|
||||
'type' => 'error',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
app/home/controller/Contact.php
Normal file
49
app/home/controller/Contact.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use think\facade\Cookie;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Contact extends Base
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if (Cookie::get('think_var') == 'en-us') {
|
||||
View::assign('reason', CONTACT_REASON_EN);
|
||||
} else {
|
||||
View::assign('reason', CONTACT_REASON);
|
||||
}
|
||||
return View::fetch();
|
||||
}
|
||||
public function do_apply()
|
||||
{
|
||||
if(!captcha_check($_REQUEST['yzm'])){
|
||||
return $this->error(lang('contact.yzm_error'));
|
||||
}
|
||||
if ($_REQUEST['email'] !== $_REQUEST['re_email']) {
|
||||
return $this->error(lang('contact.email_error'));
|
||||
}
|
||||
unset($_REQUEST['re_email']);
|
||||
unset($_REQUEST['s']);
|
||||
unset($_REQUEST['yzm']);
|
||||
$_REQUEST['reg_time'] = date('Y-m-d H:i:s');
|
||||
$_REQUEST['source'] = MODEL;
|
||||
$_REQUEST['model'] = CONTACT_MODEL;
|
||||
$_REQUEST['lang'] = Cookie::get('think_var');
|
||||
$_REQUEST['token'] = md5(CONTACT_MODEL);
|
||||
try {
|
||||
$order_res = Httpcurl::request(config('app.CREATE_CONTACT_URL'), 'post', $_REQUEST);
|
||||
$order = json_decode($order_res[0], true);
|
||||
if (!$order['code']) {
|
||||
return $this->error($order['msg']);
|
||||
}
|
||||
return $this->success(lang('controller.success'));
|
||||
} catch (\Exception $e) {
|
||||
return $this->error(lang('controller.fail'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
24
app/home/controller/Index.php
Normal file
24
app/home/controller/Index.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use think\facade\View;
|
||||
|
||||
class Index extends Base
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return View::fetch();
|
||||
}
|
||||
public function langset()
|
||||
{
|
||||
|
||||
$lang = input('lang') ? input('lang') : 'zh-cn';
|
||||
parent::langs($lang);
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => lang('controller.success'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
92
app/home/controller/Invoice.php
Normal file
92
app/home/controller/Invoice.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use think\exception\HttpResponseException;
|
||||
use think\facade\Config;
|
||||
use think\facade\Log;
|
||||
use think\facade\Request;
|
||||
use think\Response;
|
||||
|
||||
class Invoice extends Base
|
||||
{
|
||||
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
if (!$this->_userId) {
|
||||
throw new HttpResponseException(Response::create($this->error('请先登录', url('user/index'))));
|
||||
}
|
||||
}
|
||||
|
||||
/**个人中心
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//获取用户的登记信息
|
||||
$order_sn = Request::instance()->param('order_sn');
|
||||
|
||||
if (empty($order_sn)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$base_url = config('app.order_url');
|
||||
$order_url = $base_url . 'getOrder';
|
||||
$response = Httpcurl::request($order_url, 'post', ['order_sn' => $order_sn, 'model' => MODEL]);
|
||||
if ($response[3]) {
|
||||
return $this->error('异常错误,请重新提交');
|
||||
}
|
||||
$pay_result = json_decode($response[0], true);
|
||||
if (empty($pay_result)) {
|
||||
return $this->error('异常错误,请重新提交');
|
||||
}
|
||||
Log::info(json_encode($pay_result));
|
||||
if (!$pay_result['code']) {
|
||||
return $this->error($pay_result['msg']);
|
||||
}
|
||||
$data = $pay_result['data'];
|
||||
if (empty($data)) {
|
||||
return $this->error('无此数据');
|
||||
}
|
||||
$total_price = $data['total_price'] ? $data['total_price'] : $data['origin_price'];
|
||||
$data['total_price'] = ($total_price / 100) . "元";
|
||||
return view('', [
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function add_invoice()
|
||||
{
|
||||
$res = [
|
||||
'status' => 0,
|
||||
'msg' => '操作失败,请重新填写'
|
||||
];
|
||||
unset($_REQUEST['s']);
|
||||
$_REQUEST['invoiceType'] = INCOICETYPE;
|
||||
$_REQUEST['model'] = MODEL;
|
||||
$_REQUEST['principals'] = config('app.principals');
|
||||
$_REQUEST['uid'] = $this->_userId;
|
||||
$base_url = config('app.order_url');
|
||||
$order_url = $base_url . 'add_invoice';
|
||||
$response = Httpcurl::request($order_url, 'post', $_REQUEST);
|
||||
if ($response[3]) {
|
||||
return json($res);
|
||||
}
|
||||
$pay_result = json_decode($response[0], true);
|
||||
Log::info(json_encode($pay_result));
|
||||
if (empty($pay_result)) {
|
||||
return json($res);
|
||||
}
|
||||
if (!$pay_result['code']) {
|
||||
$res['msg'] = $pay_result['msg'];
|
||||
return json($res);
|
||||
}
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = $pay_result['msg'];
|
||||
$res['url'] = url('user/index')->build();
|
||||
return json($res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
36
app/home/controller/Lookup.php
Normal file
36
app/home/controller/Lookup.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use think\facade\Log;
|
||||
use think\facade\View;
|
||||
|
||||
class Lookup extends Base
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return View::fetch();
|
||||
}
|
||||
public function enrollment()
|
||||
{
|
||||
$data = request()->post();
|
||||
$map = [
|
||||
'passport_number' => $data['passport_number'],
|
||||
'birth_date' => $data['birth_date'],
|
||||
'last_name' => $data['last_name'],
|
||||
'first_name' => $data['first_name'],
|
||||
'model' => MODEL,
|
||||
];
|
||||
$res = Httpcurl::request(config('app.LOOKUP_URL'), 'post', $map);
|
||||
$res = json_decode($res[0], true);
|
||||
Log::info(json_encode($res));
|
||||
if (empty($res)) {
|
||||
return json(['code' => 0, 'msg' => lang("controller.no_records_found")]);
|
||||
}
|
||||
if ($res['code'] == 0) {
|
||||
return json(['code' => 0, 'msg' => $res['msg']]);
|
||||
}
|
||||
return json(['code' => 1, 'msg' => $res['msg'], 'data' => $res['data']]);
|
||||
}
|
||||
}
|
||||
55
app/home/controller/News.php
Normal file
55
app/home/controller/News.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use think\facade\Log;
|
||||
use think\facade\View;
|
||||
use think\Request;
|
||||
|
||||
class News extends Base
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
$page = input('page') ? input('page') : 1;
|
||||
$size = input('size') ? input('size') : 10;
|
||||
$news_list = Httpcurl::request(config('app.NEWS_LIST'), 'post', [
|
||||
'type' => MODEL,
|
||||
'page' => $page,
|
||||
'size' => $size,
|
||||
]);
|
||||
$news_list = json_decode($news_list[0], true);
|
||||
Log::info(json_encode($news_list));
|
||||
if ($news_list['code'] == 1) {
|
||||
View::assign('news_list', $news_list['data']);
|
||||
View::assign('count', $news_list['count']);
|
||||
View::assign('page', $page);
|
||||
View::assign('size', $size);
|
||||
} else {
|
||||
View::assign('news_list', []);
|
||||
}
|
||||
return View::fetch('news');
|
||||
}
|
||||
|
||||
public function detail(Request $request)
|
||||
{
|
||||
$data = $request->param();
|
||||
if (empty($data['id'])) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$info = Httpcurl::request(config('app.NEWS_DETAIL'), 'post', [
|
||||
'type' => MODEL,
|
||||
'id' => $data['id'],
|
||||
]);
|
||||
$info = json_decode($info[0], true);
|
||||
Log::info(json_encode($info));
|
||||
$info_detail = [];
|
||||
if ($info['code'] == 1) {
|
||||
$info_detail = $info['data'];
|
||||
}
|
||||
|
||||
View::assign('info', $info_detail);
|
||||
return View::fetch('news_detail');
|
||||
}
|
||||
}
|
||||
34
app/home/controller/Policy.php
Normal file
34
app/home/controller/Policy.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use think\facade\View;
|
||||
|
||||
class Policy extends Base
|
||||
{
|
||||
public function cookie()
|
||||
{
|
||||
return View::fetch();
|
||||
}
|
||||
public function disclaimer()
|
||||
{
|
||||
return View::fetch();
|
||||
}
|
||||
public function privacy()
|
||||
{
|
||||
return View::fetch();
|
||||
}
|
||||
public function pay()
|
||||
{
|
||||
return View::fetch();
|
||||
}
|
||||
public function refund()
|
||||
{
|
||||
return View::fetch();
|
||||
}
|
||||
public function user()
|
||||
{
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
}
|
||||
199
app/home/controller/Upload.php
Normal file
199
app/home/controller/Upload.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use app\service\AwsUploadService;
|
||||
use app\service\BaiduOcrService;
|
||||
use app\service\CompressImgService;
|
||||
use app\service\SwooleService;
|
||||
use think\facade\Log;
|
||||
use think\file\UploadedFile;
|
||||
|
||||
class Upload extends Base
|
||||
{
|
||||
public function upload_passport()
|
||||
{
|
||||
// 获取上传的文件
|
||||
$file = request()->file('file');
|
||||
$path = request()->param('path', '');
|
||||
|
||||
if (!$file) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => lang('controller.upload_missing'),
|
||||
]);
|
||||
}
|
||||
$imgdata = file_get_contents($file->getPathname());
|
||||
/*同时上传护照文件*/
|
||||
$fileName = $path . '/' . date('YmdHis') . uniqid() . '.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
|
||||
try {
|
||||
$client = SwooleService::getInstance();
|
||||
|
||||
$client->sendTask([
|
||||
'type' => 'upload_ali',
|
||||
'data' => [
|
||||
'Bucket' => BUCKET,
|
||||
'Key' => $fileName, //重命名的文件名
|
||||
'file_content' => base64_encode($imgdata),
|
||||
]
|
||||
]);
|
||||
$client->close();
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => lang('controller.upload_success'),
|
||||
'path' => OSS_URL . $fileName,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => lang('controller.upload_failed'),
|
||||
'path' => ''
|
||||
]);
|
||||
}
|
||||
}
|
||||
public function visa()
|
||||
{
|
||||
// 获取上传的文件
|
||||
$file = request()->file('file');
|
||||
$path = request()->param('path', '');
|
||||
|
||||
if (!$file) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => lang('controller.upload_missing'),
|
||||
]);
|
||||
}
|
||||
$imgdata = file_get_contents($file->getPathname());
|
||||
/*同时上传签证文件*/
|
||||
$fileName = $path . '/' . date('YmdHis') . uniqid() . '.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
|
||||
try {
|
||||
$client = SwooleService::getInstance();
|
||||
$client->sendTask([
|
||||
'type' => 'upload_ali',
|
||||
'data' => [
|
||||
'Bucket' => BUCKET,
|
||||
'Key' => $fileName, //重命名的文件名
|
||||
'file_content' => base64_encode($imgdata),
|
||||
]
|
||||
]);
|
||||
$client->close();
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => lang('controller.upload_success'),
|
||||
'path' => OSS_URL . $fileName,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => lang('controller.upload_failed'),
|
||||
'path' => ''
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function identification()
|
||||
{
|
||||
// 获取上传的文件
|
||||
$file = request()->file('file');
|
||||
$path = request()->param('path', '');
|
||||
|
||||
if (!$file) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => lang('controller.upload_missing'),
|
||||
]);
|
||||
}
|
||||
$imgdata = file_get_contents($file->getPathname());
|
||||
/*同时上传身份证文件*/
|
||||
$fileName = $path . '/' . date('YmdHis') . uniqid() . '.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
|
||||
try {
|
||||
$client = SwooleService::getInstance();
|
||||
$client->sendTask([
|
||||
'type' => 'upload_ali',
|
||||
'data' => [
|
||||
'Bucket' => BUCKET,
|
||||
'Key' => $fileName, //重命名的文件名
|
||||
'file_content' => base64_encode($imgdata),
|
||||
]
|
||||
]);
|
||||
$client->close();
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => lang('controller.upload_success'),
|
||||
'path' => OSS_URL . $fileName,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => lang('controller.upload_failed'),
|
||||
'path' => ''
|
||||
]);
|
||||
}
|
||||
}
|
||||
public function awsUpload($file, $fileName)
|
||||
{
|
||||
$fileSize = $file->getSize();
|
||||
$originalName = $file->getOriginalName();
|
||||
$extension = strtolower(pathinfo($originalName, PATHINFO_EXTENSION));
|
||||
$sizeLimit = 3 * 1024 * 1024;
|
||||
if ($fileSize > $sizeLimit && in_array($extension, ['jpg', 'jpeg', 'png', 'gif'])) {
|
||||
$compressedFilePath = (new CompressImgService())->compressImage($file->getRealPath(), $fileSize);
|
||||
$file = new UploadedFile(
|
||||
$compressedFilePath,
|
||||
pathinfo($originalName, PATHINFO_FILENAME) . '_compressed.' . $extension,
|
||||
mime_content_type($compressedFilePath) ?: $file->getMime(),
|
||||
0,
|
||||
true
|
||||
);
|
||||
}
|
||||
$service = new AwsUploadService();
|
||||
// 额外传递的字段
|
||||
$extraFields = [
|
||||
'Bucket' => BUCKET,
|
||||
'Key' => $fileName //重命名的文件名
|
||||
];
|
||||
$result = $service->uploadAndForward($file, 'file', $extraFields);
|
||||
Log::info(json_encode($result));
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function file_upload()
|
||||
{
|
||||
// 获取上传的文件
|
||||
$file = request()->file('file');
|
||||
$path = request()->param('path', '');
|
||||
|
||||
if (!$file) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => lang('controller.upload_missing'),
|
||||
]);
|
||||
}
|
||||
$imgdata = file_get_contents($file->getPathname());
|
||||
$fileName = $path . '/' . date('YmdHis') . uniqid() . '.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
|
||||
try {
|
||||
$client = SwooleService::getInstance();
|
||||
$client->sendTask([
|
||||
'type' => 'upload_ali',
|
||||
'data' => [
|
||||
'Bucket' => BUCKET,
|
||||
'Key' => $fileName, //重命名的文件名
|
||||
'file_content' => base64_encode($imgdata),
|
||||
]
|
||||
]);
|
||||
$client->close();
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => lang('controller.upload_success'),
|
||||
'path' => OSS_URL . $fileName,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => lang('controller.upload_failed'),
|
||||
'path' => '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
200
app/home/controller/User.php
Normal file
200
app/home/controller/User.php
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use think\facade\Log;
|
||||
use think\facade\Request;
|
||||
|
||||
class User extends Base
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if (!empty($this->_userId)) {
|
||||
$paystatus = Request::instance()->param('paystatus', '');
|
||||
$paystatus = $paystatus ? $paystatus : 'pay';
|
||||
if (!in_array($paystatus, ['pay', 'nopay'])) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$list = Httpcurl::request(config('app.GET_ORDER_URL'), 'post', [
|
||||
'model' => MODEL,
|
||||
'user_id' => $this->_userId,
|
||||
'invoiceType' => INCOICETYPE,
|
||||
'pay_status' => '',
|
||||
]);
|
||||
$result = json_decode($list[0], true);
|
||||
Log::info(json_encode($result));
|
||||
if (!$result['code']) {
|
||||
return $this->error('获取订单失败');
|
||||
}
|
||||
return view('', [
|
||||
'paystauts' => $paystatus,
|
||||
'order_list' => $result['data'],
|
||||
]);
|
||||
} else {
|
||||
return view('login');
|
||||
}
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return view('invoice');
|
||||
}
|
||||
|
||||
public function multiple()
|
||||
{
|
||||
return view('multiple');
|
||||
}
|
||||
|
||||
public function checkInvoice()
|
||||
{
|
||||
$res = [
|
||||
'status' => 0,
|
||||
'msg' => '操作失败'
|
||||
];
|
||||
$passport_number = Request::instance()->param('passport_number');
|
||||
$order_sn = Request::instance()->param('order_sn');
|
||||
$last_name = Request::instance()->param('last_name');
|
||||
$first_name = Request::instance()->param('first_name');
|
||||
if (empty($passport_number) || empty($order_sn) || empty($last_name) || empty($first_name)) {
|
||||
$res['msg'] = '参数错误';
|
||||
return json($res);
|
||||
}
|
||||
$base_url = config('app.order_url');
|
||||
|
||||
$order_url = $base_url . 'checkInvoice';
|
||||
$response = Httpcurl::request($order_url, 'post', [
|
||||
'passport_number' => trim($passport_number),
|
||||
'order_sn' => trim($order_sn),
|
||||
'last_name' => trim($last_name),
|
||||
'first_name' => trim($first_name),
|
||||
'model' => MODEL
|
||||
]);
|
||||
if ($response[3]) {
|
||||
$res['msg'] = '参数错误';
|
||||
return json($res);
|
||||
}
|
||||
$data = json_decode($response[0], true);
|
||||
Log::info(json_encode($data));
|
||||
if (empty($data)) {
|
||||
$res['msg'] = '系统错误,请联系管理员!';
|
||||
return json($res);
|
||||
}
|
||||
if (!$data['code']) {
|
||||
$res['msg'] = "暂无订单信息";
|
||||
return json($res);
|
||||
}
|
||||
$invoice_url = $base_url . 'getInvoice';
|
||||
//判断是否已经开票了
|
||||
$response = Httpcurl::request($invoice_url, 'post', [
|
||||
'order_sn' => $order_sn,
|
||||
'invoiceType' => INCOICETYPE,
|
||||
'model' => MODEL
|
||||
]);
|
||||
if ($response[3]) {
|
||||
$res['msg'] = '参数错误';
|
||||
return json($res);
|
||||
}
|
||||
$order = json_decode($response[0], true);
|
||||
Log::info(json_encode($order));
|
||||
if (empty($order)) {
|
||||
$res['msg'] = '系统错误,请联系管理员!';
|
||||
return json($res);
|
||||
}
|
||||
if (!$order['code']) {
|
||||
return json($res);
|
||||
}
|
||||
if (!empty($order['data'])) {
|
||||
$res['msg'] = '已经开票';
|
||||
return json($res);
|
||||
}
|
||||
$res = [
|
||||
'status' => 1,
|
||||
'msg' => '操作成功',
|
||||
'url' => url('home/invoice/index', ['order_sn' => $order_sn])->build()
|
||||
];
|
||||
return json($res);
|
||||
|
||||
}
|
||||
|
||||
public function checkMultiple()
|
||||
{
|
||||
$res = [
|
||||
'status' => 0,
|
||||
'msg' => '操作失败'
|
||||
];
|
||||
$datas = Request::instance()->param('datas');
|
||||
if (empty($datas)) {
|
||||
$res['msg'] = '参数错误';
|
||||
return json($res);
|
||||
}
|
||||
$datas = json_decode(html_entity_decode(stripslashes($datas)), true);
|
||||
if (empty($datas)) {
|
||||
$res['msg'] = '数据错误';
|
||||
return json($res);
|
||||
}
|
||||
$order_sns = array_column($datas, 'order_sn');
|
||||
//判断是否有重复订单
|
||||
if (count($order_sns) != count(array_unique($order_sns))) {
|
||||
$res['msg'] = '有重复订单,请删除后重新提交';
|
||||
return json($res);
|
||||
}
|
||||
$base_url = config('app.order_url');
|
||||
|
||||
$order_url = $base_url . 'checkInvoice';
|
||||
$invoice_url = $base_url . 'getInvoice';
|
||||
foreach ($datas as $da) {
|
||||
//获取信息
|
||||
$response = Httpcurl::request($order_url, 'post', [
|
||||
'passport_number' => trim($da['passport_number']),
|
||||
'order_sn' => trim($da['order_sn']),
|
||||
'last_name' => trim($da['last_name']),
|
||||
'first_name' => trim($da['first_name']),
|
||||
'model' => MODEL
|
||||
]);
|
||||
if ($response[3]) {
|
||||
$res['msg'] = '参数错误';
|
||||
return json($res);
|
||||
}
|
||||
$data = json_decode($response[0], true);
|
||||
Log::info(json_encode($data));
|
||||
if (empty($data)) {
|
||||
$res['msg'] = '未查到订单信息';
|
||||
return json($res);
|
||||
}
|
||||
//查询是否已经开票了
|
||||
$response = Httpcurl::request($invoice_url, 'post', [
|
||||
'order_sn' => trim($da['order_sn']),
|
||||
'invoiceType' => INCOICETYPE,
|
||||
'model' => MODEL
|
||||
]);
|
||||
if ($response[3]) {
|
||||
$res['msg'] = '参数错误';
|
||||
return json($res);
|
||||
}
|
||||
$order = json_decode($response[0], true);
|
||||
Log::info(json_encode($order));
|
||||
if (empty($order)) {
|
||||
$res['msg'] = '系统错误,请联系管理员!';
|
||||
return json($res);
|
||||
}
|
||||
if (!$order['code']) {
|
||||
$res['msg'] = $order['msg'];
|
||||
return json($res);
|
||||
}
|
||||
if (!empty($order['data'])) {
|
||||
$res['msg'] = '订单号:' . $da['order_sn'] . '已经开票';
|
||||
return json($res);
|
||||
}
|
||||
}
|
||||
$order_sns = implode('-', $order_sns);
|
||||
|
||||
$res = [
|
||||
'status' => 1,
|
||||
'msg' => '操作成功',
|
||||
'url' => url('home/multiple/index', ['id' => base64_encode($order_sns)])->build()
|
||||
];
|
||||
return json($res);
|
||||
|
||||
}
|
||||
}
|
||||
70
app/home/controller/Visa.php
Normal file
70
app/home/controller/Visa.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Log;
|
||||
use think\facade\Session;
|
||||
use think\facade\View;
|
||||
use think\Request;
|
||||
|
||||
class Visa extends Base
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
View::assign('nation', json_decode(file_get_contents(CONFIG_JSON_VISA_NATIONALITY), true));
|
||||
View::assign('ismobile', isMobile() ? 1 : 0);
|
||||
return View::fetch();
|
||||
}
|
||||
public function get_sub_city(Request $request)
|
||||
{
|
||||
$id = $request->param('id');
|
||||
$city = find_json(CONFIG_JSON_STATE, 'id', $id);
|
||||
if ($city) {
|
||||
return $this->success('成功', '', $city[0]);
|
||||
} else {
|
||||
return $this->success('成功', '', []);
|
||||
}
|
||||
}
|
||||
|
||||
public function do_apply()
|
||||
{
|
||||
$request = $this->request;
|
||||
$data = $request->post();
|
||||
$order_sn = getOrderNumber();
|
||||
unset($data['check1']);
|
||||
unset($data['check2']);
|
||||
|
||||
$data['model'] = MODEL;
|
||||
$data['token'] = md5(MODEL);
|
||||
$data['order_sn'] = $order_sn;
|
||||
$data['source'] = Session::get('source');
|
||||
$data['is_mobile'] = isMobile();
|
||||
|
||||
/*处理 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.submission_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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
37
app/home/controller/Wechatpay.php
Normal file
37
app/home/controller/Wechatpay.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use think\facade\Request;
|
||||
|
||||
class Wechatpay extends Base
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$order_sn = Request::instance()->param('order_sn');
|
||||
if (!$order_sn) {
|
||||
return $this->error(lang('wepay.missing_order_sn'), url('visa/index'));
|
||||
}
|
||||
|
||||
$response = Httpcurl::request(config('app.GET_ORDER_DETAIL_URL'), 'post', ['order_sn' => $order_sn, 'model' => MODEL]);
|
||||
if ($response[3]) {
|
||||
return $this->error(lang('wepay.payment_failed_retry'), url('visa/index'));
|
||||
}
|
||||
|
||||
$pay_result = json_decode($response[0], true);
|
||||
if (empty($pay_result)) {
|
||||
return $this->error(lang('wepay.payment_failed_retry'), url('visa/index'));
|
||||
}
|
||||
if (!$pay_result['code']) {
|
||||
return $this->error(lang('wepay.payment_failed_retry'), url('visa/index'));
|
||||
}
|
||||
|
||||
$pay_result = $pay_result['data'];
|
||||
if ($pay_result['pay_status']) {
|
||||
return $this->success(lang('wepay.payment_success'), url('wepay/succ'), ['order_sn' => $order_sn]);
|
||||
}
|
||||
|
||||
return $this->error(lang('wepay.payment_failed_retry'), url('visa/index'));
|
||||
}
|
||||
}
|
||||
185
app/home/controller/Wepay.php
Normal file
185
app/home/controller/Wepay.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use api\Httpcurl;
|
||||
use think\exception\HttpResponseException;
|
||||
use think\facade\Log;
|
||||
use think\facade\Request;
|
||||
use think\facade\View;
|
||||
use think\Response;
|
||||
|
||||
class Wepay extends Base
|
||||
{
|
||||
private $order_sn;
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$order_sn = input('order_sn');
|
||||
if (empty($order_sn)) {
|
||||
$order_sn = input('reference');
|
||||
}
|
||||
if (!$order_sn) {
|
||||
throw new HttpResponseException(Response::create($this->error(lang('wepay.missing_order_sn'), url('visa/index'))));
|
||||
}
|
||||
$this->order_sn = $order_sn;
|
||||
}
|
||||
|
||||
public function wxpay()
|
||||
{
|
||||
$wechaturl = config('app.wechatpay');
|
||||
$wechaturl .= '?order_sn=' . $this->order_sn . '&mark=' . PAY_MARK . '&body=' . urlencode(COUNTRY . lang('wepay.pay_body'));
|
||||
header('location:' . $wechaturl);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function pcpay()
|
||||
{
|
||||
$order_sn = $this->order_sn;
|
||||
$response = Httpcurl::request(config('app.GET_ORDER_DETAIL_URL'), 'post', ['order_sn' => $order_sn, 'model' => MODEL]);
|
||||
if ($response[3]) {
|
||||
return $this->error(lang('wepay.system_error'), url('visa/index'));
|
||||
}
|
||||
|
||||
$pay_result = json_decode($response[0], true);
|
||||
Log::info(json_encode($pay_result));
|
||||
if (empty($pay_result)) {
|
||||
return $this->error(lang('wepay.system_error'), url('visa/index'));
|
||||
}
|
||||
if (!$pay_result['code']) {
|
||||
return $this->error($pay_result['msg'], url('visa/index'));
|
||||
}
|
||||
|
||||
$pay_result = $pay_result['data'];
|
||||
if ($pay_result['pay_status']) {
|
||||
return $this->success(lang('wepay.already_paid'), url('visa/index'));
|
||||
}
|
||||
|
||||
$body = COUNTRY . lang('wepay.pay_body');
|
||||
$wxurl = '';
|
||||
$res = Httpcurl::request(config('app.wechatpcpay'), 'get', ['order_sn' => $order_sn, 'mark' => PAY_MARK, 'body' => $body]);
|
||||
if (!$res[3]) {
|
||||
$result = json_decode($res[0], true);
|
||||
$wxurl = $result['url'] ?? '';
|
||||
}
|
||||
Log::info(json_encode($res));
|
||||
|
||||
$aliurl = '';
|
||||
$res = Httpcurl::request(config('app.alipcpay'), 'get', ['order_sn' => $order_sn, 'mark' => PAY_MARK, 'body' => urlencode($body)]);
|
||||
if (!$res[3]) {
|
||||
$result = json_decode($res[0], true);
|
||||
$aliurl = $result['url'] ?? '';
|
||||
}
|
||||
Log::info(json_encode($res));
|
||||
|
||||
View::assign('url', $wxurl);
|
||||
View::assign('aliurl', $aliurl);
|
||||
View::assign('order_sn', $order_sn);
|
||||
View::assign('total_fee', number_format(($pay_result['total_price'] ?? 0) / 100, 2));
|
||||
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
public function h5pay()
|
||||
{
|
||||
$wechaturl = config('app.wechath5pay');
|
||||
$wechaturl .= '?order_sn=' . $this->order_sn . '&mark=' . PAY_MARK . '&body=' . urlencode(COUNTRY . lang('wepay.pay_body'));
|
||||
header('location:' . $wechaturl);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function succ()
|
||||
{
|
||||
/*判断订单状态*/
|
||||
$order_info = Httpcurl::request(config('app.GET_ORDER_DETAIL_URL'), 'post', ['order_sn' => $this->order_sn, 'model' => MODEL]);
|
||||
$order_info = json_decode($order_info[0], true);
|
||||
if ($order_info['code'] == '0') {
|
||||
return $this->error(lang("controller.order_not_exist"));
|
||||
}
|
||||
$order_info = $order_info['data'];
|
||||
if ($order_info) {
|
||||
if ($order_info['pay_status'] == 0 ) {
|
||||
return $this->success(lang("controller.payment_not_completed"), url('visa/index'));
|
||||
}
|
||||
}
|
||||
/*判断订单状态*/
|
||||
$arrive_date = $order_info['arrive_date'] ?? '2026-05-30';
|
||||
$arrive_timestamp = $arrive_date ? strtotime($arrive_date) : false;
|
||||
$latest_submit_timestamp = strtotime(date('Y-m-d') . ' +' . ARRIVE_DATE_COUNT . ' days 23:59:59');
|
||||
if ($arrive_timestamp === false || $arrive_timestamp < $latest_submit_timestamp) {
|
||||
View::assign('arrive_date_info', '');
|
||||
} else {
|
||||
$arrive_date_info = sprintf(lang("pay.arrive_date_info"), $arrive_date, date('Y-m-d', $arrive_timestamp - ARRIVE_DATE_COUNT * 86400));
|
||||
View::assign('arrive_date_info', $arrive_date_info);
|
||||
}
|
||||
View::assign('payment_confirmed', true);
|
||||
View::assign('poll_status_url', '');
|
||||
View::assign('repay_url', '');
|
||||
View::assign('order_sn', $this->order_sn);
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
public function h5result()
|
||||
{
|
||||
if (!Request::instance()->isAjax()) {
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
return $this->checkPayStatus('h5pay');
|
||||
}
|
||||
|
||||
public function pcresult()
|
||||
{
|
||||
if (!Request::instance()->isAjax()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->checkPayStatus('pcpay');
|
||||
}
|
||||
|
||||
private function checkPayStatus(string $retryAction)
|
||||
{
|
||||
$order_sn = $this->order_sn;
|
||||
$response = Httpcurl::request(config('app.GET_ORDER_DETAIL_URL'), 'post', ['order_sn' => $order_sn, 'model' => MODEL]);
|
||||
if ($response[3]) {
|
||||
return json([
|
||||
'status' => 0,
|
||||
'msg' => lang('wepay.system_error'),
|
||||
'url' => url('wepay/index', ['order_sn' => $order_sn])->build(),
|
||||
]);
|
||||
}
|
||||
|
||||
$pay_result = json_decode($response[0], true);
|
||||
Log::info(json_encode($pay_result));
|
||||
if (empty($pay_result)) {
|
||||
return json([
|
||||
'status' => 0,
|
||||
'msg' => lang('wepay.system_error'),
|
||||
'url' => url('wepay/index', ['order_sn' => $order_sn])->build(),
|
||||
]);
|
||||
}
|
||||
if (!$pay_result['code']) {
|
||||
return json([
|
||||
'status' => 0,
|
||||
'msg' => $pay_result['msg'],
|
||||
'url' => url('wepay/index', ['order_sn' => $order_sn])->build(),
|
||||
]);
|
||||
}
|
||||
|
||||
$pay_result = $pay_result['data'];
|
||||
if ($pay_result['pay_status']) {
|
||||
return json([
|
||||
'status' => 1,
|
||||
'msg' => lang('wepay.payment_success'),
|
||||
'url' => url('wepay/succ', ['order_sn' => $order_sn])->build(),
|
||||
]);
|
||||
}
|
||||
|
||||
return json([
|
||||
'status' => 0,
|
||||
'msg' => lang('wepay.payment_not_completed'),
|
||||
'url' => url('wepay/' . $retryAction, ['order_sn' => $order_sn])->build(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user