commit 0b165153c6ae4bf5e54c64f6af9a21dbb23e5115 Author: gaofeng <1212121@qq.com> Date: Wed May 13 10:44:29 2026 +0800 提交 diff --git a/.env b/.env new file mode 100644 index 0000000..1920062 --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +APP_DEBUG = true +TCP_LOG_URL="tcp://112.124.15.204" +TCP_LOG_PORT=18001 +PROJECT_NAME="tha_tyatjyzx_cn" \ No newline at end of file diff --git a/.example.env b/.example.env new file mode 100644 index 0000000..c457fe5 --- /dev/null +++ b/.example.env @@ -0,0 +1,11 @@ +APP_DEBUG = true + +DB_TYPE = mysql +DB_HOST = 127.0.0.1 +DB_NAME = test +DB_USER = username +DB_PASS = password +DB_PORT = 3306 +DB_CHARSET = utf8 + +DEFAULT_LANG = zh-cn diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..515457f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.idea +/runtime +/data diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..36f7b6f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +sudo: false + +language: php + +branches: + only: + - stable + +cache: + directories: + - $HOME/.composer/cache + +before_install: + - composer self-update + +install: + - composer install --no-dev --no-interaction --ignore-platform-reqs + - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip . + - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0" + - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0" + - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip . + +script: + - php think unit + +deploy: + provider: releases + api_key: + secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw= + file: + - ThinkPHP_Core.zip + - ThinkPHP_Full.zip + skip_cleanup: true + on: + tags: true diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..8d94897 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,32 @@ + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 +版权所有Copyright © 2006-2025 by ThinkPHP (http://thinkphp.cn) +All rights reserved。 +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +Apache Licence是著名的非盈利开源组织Apache采用的协议。 +该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, +允许代码修改,再作为开源或商业软件发布。需要满足 +的条件: +1. 需要给代码的用户一份Apache Licence ; +2. 如果你修改了代码,需要在被修改的文件中说明; +3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 +带有原来代码中的协议,商标,专利声明和其他原来作者规 +定需要包含的说明; +4. 如果再发布的产品中包含一个Notice文件,则在Notice文 +件中需要带有本协议内容。你可以在Notice中增加自己的 +许可,但不可以表现为对Apache Licence构成更改。 +具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..05c7b83 --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ + + +ThinkPHP 8 +=============== + +## 特性 + +* 基于PHP`8.0+`重构 +* 升级`PSR`依赖 +* 依赖`think-orm`3.0+版本 +* 全新的`think-dumper`服务,支持远程调试 +* 支持`6.0`/`6.1`无缝升级 + +> ThinkPHP8的运行环境要求PHP8.0+ + +现在开始,你可以使用官方提供的[ThinkChat](https://chat.topthink.com/),让你在学习ThinkPHP的旅途中享受私人AI助理服务! + + + +ThinkPHP生态服务由[顶想云](https://www.topthink.com)(TOPThink Cloud)提供,为生态提供专业的开发者服务和价值之选。 + +## 文档 + +[完全开发手册](https://doc.thinkphp.cn) + + +## 赞助 + +全新的[赞助计划](https://www.thinkphp.cn/sponsor)可以让你通过我们的网站、手册、欢迎页及GIT仓库获得巨大曝光,同时提升企业的品牌声誉,也更好保障ThinkPHP的可持续发展。 + +[](https://www.thinkphp.cn/sponsor/special) + +[](https://www.thinkphp.cn/sponsor) + +## 安装 + +~~~ +composer create-project topthink/think tp +~~~ + +启动服务 + +~~~ +cd tp +php think run +~~~ + +然后就可以在浏览器中访问 + +~~~ +http://localhost:8000 +~~~ + +如果需要更新框架使用 +~~~ +composer update topthink/framework +~~~ + +## 命名规范 + +`ThinkPHP`遵循PSR-2命名规范和PSR-4自动加载规范。 + +## 参与开发 + +直接提交PR或者Issue即可 + +## 版权信息 + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 + +本项目包含的第三方源码和二进制文件之版权信息另行标注。 + +版权所有Copyright © 2006-2024 by ThinkPHP (http://thinkphp.cn) All rights reserved。 + +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +更多细节参阅 [LICENSE.txt](LICENSE.txt) diff --git a/app/.htaccess b/app/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/app/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/app/AppService.php b/app/AppService.php new file mode 100644 index 0000000..96556e8 --- /dev/null +++ b/app/AppService.php @@ -0,0 +1,22 @@ +app = $app; + $this->request = $this->app->request; + + // 控制器初始化 + $this->initialize(); + } + + // 初始化 + protected function initialize() + {} + + /** + * 验证数据 + * @access protected + * @param array $data 数据 + * @param string|array $validate 验证器名或者验证规则数组 + * @param array $message 提示信息 + * @param bool $batch 是否批量验证 + * @return array|string|true + * @throws ValidateException + */ + protected function validate(array $data, string|array $validate, array $message = [], bool $batch = false) + { + if (is_array($validate)) { + $v = new Validate(); + $v->rule($validate); + } else { + if (strpos($validate, '.')) { + // 支持场景 + [$validate, $scene] = explode('.', $validate); + } + $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); + $v = new $class(); + if (!empty($scene)) { + $v->scene($scene); + } + } + + $v->message($message); + + // 是否批量验证 + if ($batch || $this->batchValidate) { + $v->batch(true); + } + + return $v->failException(true)->check($data); + } + +} diff --git a/app/ExceptionHandle.php b/app/ExceptionHandle.php new file mode 100644 index 0000000..453d126 --- /dev/null +++ b/app/ExceptionHandle.php @@ -0,0 +1,58 @@ + [ + ], + + 'listen' => [ + 'AppInit' => [], + 'HttpRun' => [], + 'HttpEnd' => [], + 'LogLevel' => [], + 'LogWrite' => [], + ], + + 'subscribe' => [ + ], +]; diff --git a/app/home/common.php b/app/home/common.php new file mode 100644 index 0000000..9e624ec --- /dev/null +++ b/app/home/common.php @@ -0,0 +1,859 @@ + 'wechatpay', '2' => 'alipay']; +const INCOICETYPE = '22'; +const CONFIG_JSON_NATION = './json/nation.json'; +const CONFIG_JSON_NATION_EN = './json/nation_en.json'; +const CONFIG_JSON_COUNTRY = './json/country.json'; +const CONFIG_JSON_COUNTRY_EN = './json/country_en.json'; +const CONFIG_JSON_TH_CITY = './json/th_city.json'; +const CONFIG_JSON_TH_DISTRICT = './json/th_district.json'; +const CONFIG_JSON_TH_PROVINCE = './json/th_province.json'; + +const CONFIG_JSON_VISA_NATIONALITY = './json/visa_nationality.json'; +const CONFIG_JSON_NATIONALITY_MAP = './json/visa_nationality_map.json'; +const ARRIVE_DATE_COUNT = '3'; +const BASE_PATH = '/tha'; +const CONTACT_REASON = [ + '我需要解决付款问题', + '我需要协助填写申请表格', + '我需要关于旅行证件的信息', + '我需要更正我的旅行证件或已提交申请的信息', + '我想检查已提交的申请的状态', + '我想申请退款', + '我有其他未列明的原因' +]; +const CONTACT_REASON_EN = [ + 'I need to resolve a payment issue', + 'I need assistance with filling out the application form', + 'I need information about travel documents', + 'I need to correct information on my travel document or submitted application', + 'I want to check the status of my submitted application', + 'I want to request a refund', + 'I have other reasons not listed' +]; + +// 公共函数 +function build_ocr_signature(string $appId, string $secret, ?int $timestamp = null): array +{ + $timestamp = $timestamp ?? time(); + $signString = $appId . "\n" . (string)$timestamp; + $signature = hash_hmac('sha256', $signString, $secret); + + return [ + 'app_id' => $appId, + 'timestamp' => (string)$timestamp, + 'signature' => $signature, + 'base_url' => config('app.OCR_BASE_URL'), + ]; +} +function isDateTodayTomorrowOrDayAfter($dateString, $country = '') { + // 将输入日期转换为 DateTime 对象 + $inputDate = new DateTime($dateString); + $inputDate->setTime(0, 0, 0); // 忽略时间部分,只比较日期 + + // 获取今天的日期(午夜时间) + $today = new DateTime('today'); + + if ($inputDate < $today) { + return true; + } + // 获取明天和后天的日期 + $tomorrow = new DateTime('tomorrow'); + if ($country == 'thailand') { + $dayAfterTomorrow = new DateTime('tomorrow +1 day'); + $dayAfterTomorrow1 = new DateTime('tomorrow +2 day'); + return $inputDate == $today || $inputDate == $tomorrow || $inputDate == $dayAfterTomorrow || $inputDate == $dayAfterTomorrow1; + } else if ($country == 'indonesia') { + $yeasterday = new DateTime('yesterday'); + $dayAfterTomorrow = new DateTime('tomorrow +1 day'); + return $inputDate == $yeasterday || $inputDate == $today || $inputDate == $tomorrow || $inputDate == $dayAfterTomorrow; + } else { + $dayAfterTomorrow = new DateTime('tomorrow +1 day'); + return $inputDate == $today || $inputDate == $tomorrow || $inputDate == $dayAfterTomorrow; + } +} +function find_json($json_name, $field, $field_value) +{ + $data = file_get_contents($json_name); + $data_arr = json_decode($data, true); + $found = array_filter($data_arr, function ($item) use ($field, $field_value) { + return $item[$field] === $field_value; + }); + // 输出结果 + if ($found) { + $found = array_values($found); // 获取过滤后的第一个元素 + return $found; + } else { + return false; + } +} + +function getNameById($json_name, $id) +{ + $data = file_get_contents($json_name); + $data_arr = json_decode($data, true); + foreach ($data_arr as $item) { + if (array_key_exists('data', $item['data'])) { + foreach ($item['data']['data'] as $dataItem) { + if ($dataItem['id'] === $id) { + return $dataItem['name']; + } + } + } + } + return null; +} + +function getIdByName($json_name, $id) +{ + $data = file_get_contents($json_name); + $data_arr = json_decode($data, true); + foreach ($data_arr as $item) { + if (array_key_exists('data', $item['data'])) { + foreach ($item['data']['data'] as $dataItem) { + if ($dataItem['name'] === $id) { + return $dataItem['id']; + } + } + } + } + return null; +} + +function isMobile() +{ + $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : ''; + + if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)/i', + strtolower($_SERVER['HTTP_USER_AGENT']))) { + return true; + } + if ((isset($_SERVER['HTTP_ACCEPT'])) and (strpos(strtolower($_SERVER['HTTP_ACCEPT']), + 'application/vnd.wap.xhtml+xml') !== false)) { + return true; + } + if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) { + return true; + } + if (isset($_SERVER['HTTP_PROFILE'])) { + return true; + } + $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4)); + $mobile_agents = array( + 'w3c ', + 'acs-', + 'alav', + 'alca', + 'amoi', + 'audi', + 'avan', + 'benq', + 'bird', + 'blac', + 'blaz', + 'brew', + 'cell', + 'cldc', + 'cmd-', + 'dang', + 'doco', + 'eric', + 'hipt', + 'inno', + 'ipaq', + 'java', + 'jigs', + 'kddi', + 'keji', + 'leno', + 'lg-c', + 'lg-d', + 'lg-g', + 'lge-', + 'maui', + 'maxo', + 'midp', + 'mits', + 'mmef', + 'mobi', + 'mot-', + 'moto', + 'mwbp', + 'nec-', + 'newt', + 'noki', + 'oper', + 'palm', + 'pana', + 'pant', + 'phil', + 'play', + 'port', + 'prox', + 'qwap', + 'sage', + 'sams', + 'sany', + 'sch-', + 'sec-', + 'send', + 'seri', + 'sgh-', + 'shar', + 'sie-', + 'siem', + 'smal', + 'smar', + 'sony', + 'sph-', + 'symb', + 't-mo', + 'teli', + 'tim-', + 'tosh', + 'tsm-', + 'upg1', + 'upsi', + 'vk-v', + 'voda', + 'wap-', + 'wapa', + 'wapi', + 'wapp', + 'wapr', + 'webc', + 'winw', + 'winw', + 'xda', + 'xda-' + ); + if (in_array($mobile_ua, $mobile_agents)) { + return true; + } + if (strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) { + return true; + } + // Pre-final check to reset everything if the user is on Windows + if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows') !== false) { + return false; + } + // But WP7 is also Windows, with a slightly different characteristic + if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows phone') !== false) { + return true; + } + return false; +} + +function getOrderNumber() +{ + return '1003' . date('YmdHis') . mt_rand(10, 99); +} + +function cmf_get_current_user_id() +{ + $sessionUserId = session('user.id'); + if (empty($sessionUserId)) { + return 0; + } + return $sessionUserId; + +} + +/** + * 身份证信息 + * @param array $data + * @return void + */ +function parseIdentification(array $data) +{ + $res = [ + 'national_identification_number' => '', + 'provice' => '', + 'city' => '', + 'address' => '' + ]; + if (!is_array($data) || empty($data)) { + return $res; + } + $res['national_identification_number'] = $data['words_result']['公民身份号码']['words'] ?? ''; + $address = paresAddress($data['words_result']['住址']['words'] ?? ''); + $res['provice'] = $address['provice']; + $res['city'] = $address['city']; + $res['address'] = $address['address']; + return $res; + +} +function getprovince($city) +{ + if (empty($city)){ + return ''; + } +// 构建市与省份的对应关系数组 + $cityProvinceMap = [ + // 华北地区 + "北京市" => "北京市", + "天津市" => "天津市", + "石家庄市" => "河北省", + "唐山市" => "河北省", + "秦皇岛市" => "河北省", + "邯郸市" => "河北省", + "邢台市" => "河北省", + "保定市" => "河北省", + "张家口市" => "河北省", + "承德市" => "河北省", + "沧州市" => "河北省", + "廊坊市" => "河北省", + "衡水市" => "河北省", + "太原市" => "山西省", + "大同市" => "山西省", + "阳泉市" => "山西省", + "长治市" => "山西省", + "晋城市" => "山西省", + "朔州市" => "山西省", + "晋中市" => "山西省", + "运城市" => "山西省", + "忻州市" => "山西省", + "临汾市" => "山西省", + "吕梁市" => "山西省", + "呼和浩特市" => "内蒙古自治区", + "包头市" => "内蒙古自治区", + "乌海市" => "内蒙古自治区", + "赤峰市" => "内蒙古自治区", + "通辽市" => "内蒙古自治区", + "鄂尔多斯市" => "内蒙古自治区", + "呼伦贝尔市" => "内蒙古自治区", + "巴彦淖尔市" => "内蒙古自治区", + "乌兰察布市" => "内蒙古自治区", + // 东北地区 + "沈阳市" => "辽宁省", + "大连市" => "辽宁省", + "鞍山市" => "辽宁省", + "抚顺市" => "辽宁省", + "本溪市" => "辽宁省", + "丹东市" => "辽宁省", + "锦州市" => "辽宁省", + "营口市" => "辽宁省", + "阜新市" => "辽宁省", + "辽阳市" => "辽宁省", + "盘锦市" => "辽宁省", + "铁岭市" => "辽宁省", + "朝阳市" => "辽宁省", + "葫芦岛市" => "辽宁省", + "长春市" => "吉林省", + "吉林市" => "吉林省", + "四平市" => "吉林省", + "辽源市" => "吉林省", + "通化市" => "吉林省", + "白山市" => "吉林省", + "松原市" => "吉林省", + "白城市" => "吉林省", + "延边朝鲜族自治州" => "吉林省", + "哈尔滨市" => "黑龙江省", + "齐齐哈尔市" => "黑龙江省", + "鸡西市" => "黑龙江省", + "鹤岗市" => "黑龙江省", + "双鸭山市" => "黑龙江省", + "大庆市" => "黑龙江省", + "伊春市" => "黑龙江省", + "佳木斯市" => "黑龙江省", + "七台河市" => "黑龙江省", + "牡丹江市" => "黑龙江省", + "黑河市" => "黑龙江省", + "绥化市" => "黑龙江省", + "大兴安岭地区" => "黑龙江省", + // 华东地区 + "上海市" => "上海市", + "南京市" => "江苏省", + "无锡市" => "江苏省", + "徐州市" => "江苏省", + "常州市" => "江苏省", + "苏州市" => "江苏省", + "南通市" => "江苏省", + "连云港市" => "江苏省", + "淮安市" => "江苏省", + "盐城市" => "江苏省", + "扬州市" => "江苏省", + "镇江市" => "江苏省", + "泰州市" => "江苏省", + "宿迁市" => "江苏省", + "杭州市" => "浙江省", + "宁波市" => "浙江省", + "温州市" => "浙江省", + "嘉兴市" => "浙江省", + "湖州市" => "浙江省", + "绍兴市" => "浙江省", + "金华市" => "浙江省", + "衢州市" => "浙江省", + "舟山市" => "浙江省", + "台州市" => "浙江省", + "丽水市" => "浙江省", + "合肥市" => "安徽省", + "芜湖市" => "安徽省", + "蚌埠市" => "安徽省", + "淮南市" => "安徽省", + "马鞍山市" => "安徽省", + "淮北市" => "安徽省", + "铜陵市" => "安徽省", + "安庆市" => "安徽省", + "黄山市" => "安徽省", + "滁州市" => "安徽省", + "阜阳市" => "安徽省", + "宿州市" => "安徽省", + "六安市" => "安徽省", + "亳州市" => "安徽省", + "池州市" => "安徽省", + "宣城市" => "安徽省", + "福州市" => "福建省", + "厦门市" => "福建省", + "莆田市" => "福建省", + "三明市" => "福建省", + "泉州市" => "福建省", + "漳州市" => "福建省", + "南平市" => "福建省", + "龙岩市" => "福建省", + "宁德市" => "福建省", + "南昌市" => "江西省", + "景德镇市" => "江西省", + "萍乡市" => "江西省", + "九江市" => "江西省", + "新余市" => "江西省", + "鹰潭市" => "江西省", + "赣州市" => "江西省", + "吉安市" => "江西省", + "宜春市" => "江西省", + "抚州市" => "江西省", + "上饶市" => "江西省", + "济南市" => "山东省", + "青岛市" => "山东省", + "淄博市" => "山东省", + "枣庄市" => "山东省", + "东营市" => "山东省", + "烟台市" => "山东省", + "潍坊市" => "山东省", + "济宁市" => "山东省", + "泰安市" => "山东省", + "威海市" => "山东省", + "日照市" => "山东省", + "临沂市" => "山东省", + "德州市" => "山东省", + "聊城市" => "山东省", + "滨州市" => "山东省", + "菏泽市" => "山东省", + // 中南地区 + "郑州市" => "河南省", + "开封市" => "河南省", + "洛阳市" => "河南省", + "平顶山市" => "河南省", + "安阳市" => "河南省", + "鹤壁市" => "河南省", + "新乡市" => "河南省", + "焦作市" => "河南省", + "濮阳市" => "河南省", + "许昌市" => "河南省", + "漯河市" => "河南省", + "三门峡市" => "河南省", + "南阳市" => "河南省", + "商丘市" => "河南省", + "信阳市" => "河南省", + "周口市" => "河南省", + "驻马店市" => "河南省", + "武汉市" => "湖北省", + "黄石市" => "湖北省", + "十堰市" => "湖北省", + "宜昌市" => "湖北省", + "襄阳市" => "湖北省", + "鄂州市" => "湖北省", + "荆门市" => "湖北省", + "孝感市" => "湖北省", + "荆州市" => "湖北省", + "黄冈市" => "湖北省", + "咸宁市" => "湖北省", + "随州市" => "湖北省", + "恩施土家族苗族自治州" => "湖北省", + "长沙市" => "湖南省", + "株洲市" => "湖南省", + "湘潭市" => "湖南省", + "衡阳市" => "湖南省", + "邵阳市" => "湖南省", + "岳阳市" => "湖南省", + "常德市" => "湖南省", + "张家界市" => "湖南省", + "益阳市" => "湖南省", + "郴州市" => "湖南省", + "永州市" => "湖南省", + "怀化市" => "湖南省", + "娄底市" => "湖南省", + "湘西土家族苗族自治州" => "湖南省", + "广州市" => "广东省", + "韶关市" => "广东省", + "深圳市" => "广东省", + "珠海市" => "广东省", + "汕头市" => "广东省", + "佛山市" => "广东省", + "江门市" => "广东省", + "湛江市" => "广东省", + "茂名市" => "广东省", + "肇庆市" => "广东省", + "惠州市" => "广东省", + "梅州市" => "广东省", + "汕尾市" => "广东省", + "河源市" => "广东省", + "阳江市" => "广东省", + "清远市" => "广东省", + "东莞市" => "广东省", + "中山市" => "广东省", + "潮州市" => "广东省", + "揭阳市" => "广东省", + "云浮市" => "广东省", + "南宁市" => "广西壮族自治区", + "柳州市" => "广西壮族自治区", + "桂林市" => "广西壮族自治区", + "梧州市" => "广西壮族自治区", + "北海市" => "广西壮族自治区", + "防城港市" => "广西壮族自治区", + "钦州市" => "广西壮族自治区", + "贵港市" => "广西壮族自治区", + "玉林市" => "广西壮族自治区", + "百色市" => "广西壮族自治区", + "贺州市" => "广西壮族自治区", + "河池市" => "广西壮族自治区", + "来宾市" => "广西壮族自治区", + "崇左市" => "广西壮族自治区", + "海口市" => "海南省", + "三亚市" => "海南省", + "三沙市" => "海南省", + "儋州市" => "海南省", + // 西南地区 + "重庆市" => "重庆市", + "成都市" => "四川省", + "自贡市" => "四川省", + "攀枝花市" => "四川省", + "泸州市" => "四川省", + "德阳市" => "四川省", + "绵阳市" => "四川省", + "广元市" => "四川省", + "遂宁市" => "四川省", + "内江市" => "四川省", + "乐山市" => "四川省", + "南充市" => "四川省", + "眉山市" => "四川省", + "宜宾市" => "四川省", + "广安市" => "四川省", + "达州市" => "四川省", + "雅安市" => "四川省", + "巴中市" => "四川省", + "资阳市" => "四川省", + "阿坝藏族羌族自治州" => "四川省", + "甘孜藏族自治州" => "四川省", + "凉山彝族自治州" => "四川省", + "贵阳市" => "贵州省", + "六盘水市" => "贵州省", + "遵义市" => "贵州省", + "安顺市" => "贵州省", + "毕节市" => "贵州省", + "铜仁市" => "贵州省", + "黔西南布依族苗族自治州" => "贵州省", + "黔东南苗族侗族自治州" => "贵州省", + "黔南布依族苗族自治州" => "贵州省", + "昆明市" => "云南省", + "曲靖市" => "云南省", + "玉溪市" => "云南省", + "保山市" => "云南省", + "昭通市" => "云南省", + "丽江市" => "云南省", + "普洱市" => "云南省", + "临沧市" => "云南省", + "楚雄彝族自治州" => "云南省", + "红河哈尼族彝族自治州" => "云南省", + "文山壮族苗族自治州" => "云南省", + "西双版纳傣族自治州" => "云南省", + "大理白族自治州" => "云南省", + "德宏傣族景颇族自治州" => "云南省", + "怒江傈僳族自治州" => "云南省", + "迪庆藏族自治州" => "云南省", + "拉萨市" => "西藏自治区", + "日喀则市" => "西藏自治区", + "昌都市" => "西藏自治区", + "林芝市" => "西藏自治区", + "山南市" => "西藏自治区", + "那曲市" => "西藏自治区", + "阿里地区" => "西藏自治区", + // 西北地区 + "西安市" => "陕西省", + "铜川市" => "陕西省", + "宝鸡市" => "陕西省", + "咸阳市" => "陕西省", + "渭南市" => "陕西省", + "延安市" => "陕西省", + "汉中市" => "陕西省", + "榆林市" => "陕西省", + "安康市" => "陕西省", + "商洛市" => "陕西省", + "兰州市" => "甘肃省", + "嘉峪关市" => "甘肃省", + "金昌市" => "甘肃省", + "白银市" => "甘肃省", + "天水市" => "甘肃省", + "武威市" => "甘肃省", + "张掖市" => "甘肃省", + "平凉市" => "甘肃省", + "酒泉市" => "甘肃省", + "庆阳市" => "甘肃省", + "定西市" => "甘肃省", + "陇南市" => "甘肃省", + "临夏回族自治州" => "甘肃省", + "甘南藏族自治州" => "甘肃省", + "西宁市" => "青海省", + "海东市" => "青海省", + "海北藏族自治州" => "青海省", + "黄南藏族自治州" => "青海省", + "海南藏族自治州" => "青海省", + "果洛藏族自治州" => "青海省", + "玉树藏族自治州" => "青海省", + "海西蒙古族藏族自治州" => "青海省", + "银川市" => "宁夏回族自治区", + "石嘴山市" => "宁夏回族自治区", + "吴忠市" => "宁夏回族自治区", + "固原市" => "宁夏回族自治区", + "中卫市" => "宁夏回族自治区", + "乌鲁木齐市" => "新疆维吾尔自治区", + "克拉玛依市" => "新疆维吾尔自治区", + "吐鲁番市" => "新疆维吾尔自治区", + "哈密市" => "新疆维吾尔自治区", + "昌吉回族自治州" => "新疆维吾尔自治区", + "博尔塔拉蒙古自治州" => "新疆维吾尔自治区", + "巴音郭楞蒙古自治州" => "新疆维吾尔自治区", + "阿克苏地区" => "新疆维吾尔自治区", + "克孜勒苏柯尔克孜自治州" => "新疆维吾尔自治区", + "喀什地区" => "新疆维吾尔自治区", + "和田地区" => "新疆维吾尔自治区", + "伊犁哈萨克自治州" => "新疆维吾尔自治区", + "塔城地区" => "新疆维吾尔自治区", + "阿勒泰地区" => "新疆维吾尔自治区", + // 港澳台地区 + "台北市" => "台湾省", + "新北市" => "台湾省", + "桃园市" => "台湾省", + "台中市" => "台湾省", + "台南市" => "台湾省", + "高雄市" => "台湾省", + "基隆市" => "台湾省", + "新竹市" => "台湾省", + "嘉义市" => "台湾省" + ]; + + +// 检查市名是否存在于数组中 + if (array_key_exists($city, $cityProvinceMap)) { + return $cityProvinceMap[$city]; + } else { + return ''; + } + +} +function paresAddress($address){ + preg_match('/(.*?(省|自治区|北京|天津|上海|重庆))/', $address, $matches); + if (count($matches) > 1) { + $province = $matches[count($matches) - 2]; + $address = preg_replace('/(.*?(省|自治区|北京|天津|上海|重庆))/','', $address, 1); + } + preg_match('/(.*?(市|自治州|地区|区划|县))/', $address, $matches); + if (count($matches) > 1) { + $city = $matches[count($matches) - 2]; + $address = str_replace($city, '', $address); + } + preg_match('/(.*?(区|县|镇|乡|街道))/', $address, $matches); + if (count($matches) > 1) { + $area = $matches[count($matches) - 2]; + $address = str_replace($area, '', $address); + } + $city = isset($city) ? $city : ''; + if (empty($province)){ + $province = getprovince($city); + } + $area = isset($area) ? $area : ''; + return [ + + 'provice' => isset($province) ? $province : '', + 'city' => $city, + "address" => $area.$address + ]; +} + + +/** + * 护照信息 + * @param array $data + * @return string[] + */ +function parsePassport(array $data) +{ + $res = [ + 'last_name' => '', + 'first_name' => '', + 'last_zh_name' => '', + 'first_zh_name' => '', + 'city_birth' => '', + 'birth_date_day' => '', + 'birth_date_month' => '', + 'birth_date_year' => '', + 'birth_date' => '', + 'gender' => '', + 'passport_number' => '', + 'passport_expedition_date_day' => '', + 'passport_expedition_date_month' => '', + 'passport_expedition_date_year' => '', + 'passport_expedition_date' => '', + 'passport_expiration_date_day' => '', + 'passport_expiration_date_month' => '', + 'passport_expiration_date_year' => '', + 'passport_expiration_date' => '', + 'country_code'=>'', + 'place_issue' => '', + 'nationality' =>'' + ]; + if (!is_array($data) || empty($data)) { + return $res; + } + if (!empty($data['words_result']['姓名拼音']['words'])) { + $names = explode(',', $data['words_result']['姓名拼音']['words']); + $res['last_name'] = $names[0] ?? ''; + $res['first_name'] = $names[1] ?? ''; + } + if (!empty($data['words_result']['姓名']['words'])) { + $zhnames = parseChineseName($data['words_result']['姓名']['words']); + + $res['last_zh_name'] = $zhnames['surname'] ?? ''; + $res['first_zh_name'] = $zhnames['givenName'] ?? ''; + } + if (!empty($data['words_result']['国家码']['words'])) { + $res['country_code'] = $data['words_result']['国家码']['words']; + } + if (!empty($data['words_result']['护照签发地点']['words'])) { + $citys = explode('/', $data['words_result']['护照签发地点']['words']); + $res['place_issue'] = $citys[1] ?? ''; + } + if (!empty($data['words_result']['国籍']['words'])) { + $citys = explode('/', $data['words_result']['国籍']['words']); + $res['nationality'] = $citys[1] ?? ''; + } + if (!empty($data['words_result']['出生地点']['words'])) { + $citys = explode('/', $data['words_result']['出生地点']['words']); + $res['city_birth'] = $citys[1] ?? ''; + } + if (!empty($data['words_result']['护照号码']['words'])) { + $res['passport_number'] = $data['words_result']['护照号码']['words']; + } + if (!empty($data['words_result']['签发日期']['words'])) { + $res['passport_expedition_date_year'] = substr($data['words_result']['签发日期']['words'], 0, 4); + $res['passport_expedition_date_month'] = intval(substr($data['words_result']['签发日期']['words'], 4, 2)); + $res['passport_expedition_date_day'] = intval(substr($data['words_result']['签发日期']['words'], -2)); + $res['passport_expedition_date'] = $res['passport_expedition_date_year'] . '-' . $res['passport_expedition_date_month'] . '-' . $res['passport_expedition_date_day']; + + } + if (!empty($data['words_result']['有效期至']['words'])) { + $res['passport_expiration_date_year'] = substr($data['words_result']['有效期至']['words'], 0, 4); + $res['passport_expiration_date_month'] = intval(substr($data['words_result']['有效期至']['words'], 4, 2)); + $res['passport_expiration_date_day'] = intval(substr($data['words_result']['有效期至']['words'], -2)); + $res['passport_expiration_date'] = $res['passport_expiration_date_year'] . '-' . $res['passport_expiration_date_month'] . '-' . $res['passport_expiration_date_day']; + + } + if (!empty($data['words_result']['生日']['words'])) { + $res['birth_date_year'] = substr($data['words_result']['生日']['words'], 0, 4); + $res['birth_date_month'] = intval(substr($data['words_result']['生日']['words'], 4, 2)); + $res['birth_date_day'] = intval(substr($data['words_result']['生日']['words'], -2)); + $res['birth_date'] = $res['birth_date_year'] . '-' . $res['birth_date_month'] . '-' . $res['birth_date_day']; + } + if (!empty($data['words_result']['性别']['words'])) { + $names = explode('/', $data['words_result']['性别']['words']); + $res['gender'] = ($names[0] == '男') ? 'male' : 'female'; + + } + return $res; + +} +/** + * 解析中文姓名为姓和名 + * + * @param string $name 中文姓名 + * @return array 包含姓和名的数组 ['surname' => '姓', 'givenName' => '名'] + */ +function parseChineseName($name) { + // 移除姓名前后的空格 + $name = trim($name); + + // 如果姓名长度小于2,无法合理分割,返回原姓名作为姓氏 + if (mb_strlen($name, 'UTF-8') < 2) { + return ['surname' => $name, 'givenName' => '']; + } + + // 常见复姓列表(可根据需要扩展) + $compoundSurnames = [ + '欧阳', '太史', '端木', '上官', '司马', '东方', '独孤', '南宫', '万俟', + '闻人', '夏侯', '诸葛', '尉迟', '公羊', '赫连', '澹台', '皇甫', '宗政', + '濮阳', '公冶', '太叔', '申屠', '公孙', '慕容', '仲孙', '钟离', '长孙', + '宇文', '司徒', '鲜于', '司空', '闾丘', '子车', '亓官', '司寇', '巫马', + '公西', '颛孙', '壤驷', '公良', '漆雕', '乐正', '宰父', '谷梁', '拓跋', + '夹谷', '轩辕', '令狐', '段干', '百里', '呼延', '东郭', '南门', '羊舌', + '微生', '公户', '公玉', '公仪', '梁丘', '公仲', '公上', '公门', '公山', + '公坚', '左丘', '公伯', '西门', '公祖', '第五', '公乘', '贯丘', '公皙', + '南荣', '东里', '东宫', '仲长', '子书', '子桑', '即墨', '达奚', '褚师' + ]; + + // 检查是否是复姓 + $firstTwoChars = mb_substr($name, 0, 2, 'UTF-8'); + if (in_array($firstTwoChars, $compoundSurnames)) { + return [ + 'surname' => $firstTwoChars, + 'givenName' => mb_substr($name, 2, null, 'UTF-8') + ]; + } + // 默认情况:第一个字符为姓,其余为名 + return [ + 'surname' => mb_substr($name, 0, 1, 'UTF-8'), + 'givenName' => mb_substr($name, 1, null, 'UTF-8') + ]; +} +/** + * 签证信息 + * @param array $data + * @return string[] + */ +function parseVisa(array $data) +{ + $res = [ + 'visa_foil_number' => '', + 'passport_number' => '', + ]; + if (!is_array($data) || empty($data)) { + return $res; + } + foreach ($data['words_result'] as $arr) { + + $str = preg_replace('/\s/i', '', $arr['words']); + if (preg_match('/^[G|E|P]([a-zA-Z0-9]{8})$/i', $str)) { + $res['passport_number'] = $str; + } elseif (preg_match('/^(P|H|J|K|L|M|N)\d{7}$/i', $str)) { + $res['visa_foil_number'] = $str; + } + + } + + return $res; + +} + +// 这是系统自动生成的公共文件 diff --git a/app/home/controller/Base.php b/app/home/controller/Base.php new file mode 100644 index 0000000..830cff0 --- /dev/null +++ b/app/home/controller/Base.php @@ -0,0 +1,157 @@ +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']['TH_GOODS_EN']); + View::assign('country', COUNTRY_EN); + } else { + View::assign('country', COUNTRY); + View::assign('footer', $config_result['data']['footer']); + View::assign('goods', $config_result['data']['TH_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', + ]); + } + } +} diff --git a/app/home/controller/Contact.php b/app/home/controller/Contact.php new file mode 100644 index 0000000..4e76cca --- /dev/null +++ b/app/home/controller/Contact.php @@ -0,0 +1,49 @@ +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('contact.success')); + } catch (\Exception $e) { + return $this->error(lang('contact.fail')); + } + } + +} \ No newline at end of file diff --git a/app/home/controller/Index.php b/app/home/controller/Index.php new file mode 100644 index 0000000..34bc5e7 --- /dev/null +++ b/app/home/controller/Index.php @@ -0,0 +1,24 @@ + 1, + 'msg' => lang('controller.success'), + ]); + } +} diff --git a/app/home/controller/Invoice.php b/app/home/controller/Invoice.php new file mode 100644 index 0000000..8cdae34 --- /dev/null +++ b/app/home/controller/Invoice.php @@ -0,0 +1,92 @@ +_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); + } + +} + diff --git a/app/home/controller/Login.php b/app/home/controller/Login.php new file mode 100644 index 0000000..317b568 --- /dev/null +++ b/app/home/controller/Login.php @@ -0,0 +1,92 @@ +request->post(); + try { + $this->validate($param, ['mobile' => 'require'], ['mobile.require' => '手机号不能为空']); + } catch (ValidateException $e) { + return $this->error($e->getError()); + } + $code = mt_rand(1001, 9999); + //进行发送验证 走接口 + $res = Httpcurl::request(config('app.YZM_URL'), 'post', [ + 'mobile' => $param['mobile'], + 'code' => $code, + ]); + $result = json_decode($res[0], true); + Log::info(json_encode($result)); + if (!$result['code']) { + return $this->error('发送验证码失败'); + } + //进行记录 + if ($result['code'] == 1) { + //把内容存入session + Session::set($param['mobile'] . '_code', $code); + Session::set($param['mobile'] . '_' . $code, time()); + return $this->success('发送成功'); + } else { + return $this->error('发送失败'); + } + + } + + // 登录 + public function login() + { + $param = $this->request->post(); + try { + $this->validate($param, ['phone' => 'require', 'vercode' => 'require'], ['phone.require' => '手机号不能为空', 'vercode.require' => '验证码不能为空']); + } catch (ValidateException $e) { + return $this->error($e->getError()); + } + $mobile = $param['phone']; + $code = $param['vercode']; + $res = 0; + $sms = Session::get($mobile . '_code'); + if (empty($sms)) { + return $this->error('登录失败'); + } + if ($sms != $code) { + return $this->error('验证码不正确'); + } + $time = time(); + $code_time = Session::get($mobile . '_' . $code); + //判断是否已经超时5分钟 + if (($time - $code_time) > 300) { + Session::delete($mobile . '_code'); + Session::delete($mobile . '_' . $code); + return $this->error('验证码超时,请重新发送'); + } + //查询账号 + $user_url = config('app.user_url'); + $res = Httpcurl::request($user_url, 'post', [ + 'model' => MODEL, + 'mobile' => $mobile, + ]); + $result = json_decode($res[0], true); + Log::info(json_encode($result)); + if (!$result['code']) { + return $this->error('账号不存在'); + } + Session::set('user', $result['data']); + return $this->success('登录成功', url('user/index')); + + } + + public function logout() + { + Session::delete('user'); + return redirect('/home/index'); + } +} diff --git a/app/home/controller/Lookup.php b/app/home/controller/Lookup.php new file mode 100644 index 0000000..4934966 --- /dev/null +++ b/app/home/controller/Lookup.php @@ -0,0 +1,36 @@ +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']]); + } +} \ No newline at end of file diff --git a/app/home/controller/News.php b/app/home/controller/News.php new file mode 100644 index 0000000..75559ab --- /dev/null +++ b/app/home/controller/News.php @@ -0,0 +1,56 @@ + MODEL, + 'company'=>COMPANY_TITLE, + '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'); + } +} diff --git a/app/home/controller/Pay.php b/app/home/controller/Pay.php new file mode 100644 index 0000000..521269a --- /dev/null +++ b/app/home/controller/Pay.php @@ -0,0 +1,123 @@ +error(lang("controller.missing_order_sn"), url('visa/index')))); + } + $this->order_sn = $order_sn; + } + public function pay() + { + /*查询订单*/ + $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"), url('visa/index')); + } + $order_info = $order_info['data']; + if (empty($order_info)) { + return $this->error(lang("controller.order_not_exist"), url('visa/index')); + } + /*判断订单状态*/ + if ($order_info['pay_status'] == 1 ) { + return $this->success(lang("controller.payment_success"), url('visa/index')); + } + /*判断订单状态*/ + $params = [ + 'amount' => $order_info['total_price'], + 'terminal' => $order_info['is_mobile'] == '1' ? 'WAP' : 'PC', + 'order_sn' => $order_info['order_sn'], + 'vendor' => PAY_TYPE[$order_info['pay_type']], + 'note' => PAYMODEL, + ]; + $response = HttpCurl::request(config('app.NI_HAO_PAY_URL'), 'post', $params); + Log::info(json_encode($response)); + $response = json_decode($response[0], true); + if ($response['code'] != 1) { + return $this->error($response['msg']); + } + echo $response['data'];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'] ?? ''; + $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('success'); + } + public function h5result() + { + if (Request::instance()->isAjax()) { + /*查询订单*/ + $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 json([ + 'status' => 0, + 'msg' => lang("controller.order_not_exist_retry"), + 'url' => url('visa/index')->build() + ]); + } + $order_info = $order_info['data']; + /*判断订单状态*/ + if ($order_info['pay_status'] == 1) { + return json([ + 'status' => 1, + 'msg' => lang("controller.payment_success"), + 'url' => url('pay/succ', ['reference' => $this->order_sn])->build() + ]); + } + return json([ + 'status' => 0, + 'msg' => lang("controller.payment_not_completed_retry"), + 'url' => url('pay/pay', ['order_sn' => $this->order_sn])->build() + ]); + } + View::assign('order_sn', $this->order_sn); + return View::fetch(); + } +} \ No newline at end of file diff --git a/app/home/controller/Policy.php b/app/home/controller/Policy.php new file mode 100644 index 0000000..54242e6 --- /dev/null +++ b/app/home/controller/Policy.php @@ -0,0 +1,34 @@ +error(lang("controller.missing_order_sn"), url('visa/index')))); + } + $this->order_sn = input('order_sn'); + } + + public function pay() + { + $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 json([ + 'status' => 0, + 'msg' => lang("controller.order_not_exist"), + 'url' => url('visa/index')->build() + ]); + } + $order_info = $order_info['data']; + if (empty($order_info)) { + return $this->error(lang("controller.order_not_exist"), url('visa/index')); + } + /*判断订单状态*/ + if ($order_info['pay_status'] == 1 ) { + return $this->success(lang("controller.payment_success"), url('visa/index')); + } + /*判断订单状态*/ + View::assign('order_sn', $order_info['order_sn']); + View::assign('total_fee', number_format($order_info['total_price'] / 100, 2)); + View::assign('total_price', $order_info['total_price']); + View::assign('order_info', $order_info); + View::assign('applicationId', config('app.SQ_CONIG')['app_id']); + View::assign('locationId', config('app.SQ_CONIG')['location_id']); + View::assign('pay_country', config('app.SQ_COUNTRY')); + View::assign('currency', config('app.SQ_CURRENCY')); + View::assign('uid', uniqid()); + return View::fetch(); + } + public function paySquare() + { + $request_body = file_get_contents('php://input'); + $data = json_decode($request_body, true); + $data['note'] = MODEL; + $response = HttpCurl::request(config('app.SQ_PAY_URL'), 'post', $data); + if ($response[3]) { + return json(['code' => 0, 'msg' => lang("controller.payment_not_completed")]); + } + $pay_result = json_decode($response[0], true); + + if ($pay_result) { + if ($pay_result['code'] == 1) { + return json(['code' => 1, 'msg' => lang("controller.payment_success"), 'data' => $pay_result['msg'], 'url' => url('sqpay/succ',['order_sn'=>$this->order_sn])->build()]); + } else { + return json(['code' => 0, 'msg' => lang("controller.payment_not_completed")]); + } + } + } + + private function getOrderDetail() + { + $order_info = Httpcurl::request(config('app.GET_ORDER_DETAIL_URL'), 'post', ['order_sn' => $this->order_sn, 'model' => MODEL]); + + return json_decode($order_info[0], true); + } + public function payStatus() + { + $order_info = $this->getOrderDetail(); + if (($order_info['code'] ?? '0') == '0') { + return json([ + 'status' => -1, + 'msg' => lang("controller.order_not_exist"), + 'url' => url('visa/index')->build() + ]); + } + + $order_data = $order_info['data'] ?? []; + $is_paid = ($order_data['pay_status'] ?? 0) == 1 ; + + return json([ + 'status' => $is_paid ? 1 : 0, + 'msg' => $is_paid ? lang("controller.payment_success") : lang("sqpay.notice_text"), + 'url' => $is_paid ? url('sqpay/succ', ['order_sn' => $this->order_sn])->build() : url('sqpay/pay', ['order_sn' => $this->order_sn])->build() + ]); + } + public function succ() + { + $order_info = $this->getOrderDetail(); + if (($order_info['code'] ?? '0') == '0') { + return $this->error(lang("controller.order_not_exist")); + } + + $order_info = $order_info['data'] ?? []; + $payment_confirmed = ($order_info['pay_status'] ?? 0) == 1 ; + $arrive_date = $order_info['arrive_date'] ?? ''; + $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', $payment_confirmed); + View::assign('poll_status_url', url('sqpay/payStatus', ['order_sn' => $this->order_sn])->build()); + View::assign('repay_url', url('sqpay/pay', ['order_sn' => $this->order_sn])->build()); + View::assign('order_sn', $this->order_sn); + return View::fetch('pay/success'); + } +} \ No newline at end of file diff --git a/app/home/controller/Upload.php b/app/home/controller/Upload.php new file mode 100644 index 0000000..74a9a34 --- /dev/null +++ b/app/home/controller/Upload.php @@ -0,0 +1,199 @@ +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' => '', + ]); + } + } +} diff --git a/app/home/controller/User.php b/app/home/controller/User.php new file mode 100644 index 0000000..cd919c8 --- /dev/null +++ b/app/home/controller/User.php @@ -0,0 +1,200 @@ +_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); + + } +} diff --git a/app/home/controller/Visa.php b/app/home/controller/Visa.php new file mode 100644 index 0000000..4e7d284 --- /dev/null +++ b/app/home/controller/Visa.php @@ -0,0 +1,160 @@ + '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'); + }*/ + } + +} \ No newline at end of file diff --git a/app/home/controller/Wechatpay.php b/app/home/controller/Wechatpay.php new file mode 100644 index 0000000..85616dd --- /dev/null +++ b/app/home/controller/Wechatpay.php @@ -0,0 +1,37 @@ +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')); + } +} diff --git a/app/home/controller/Wepay.php b/app/home/controller/Wepay.php new file mode 100644 index 0000000..d3e83c0 --- /dev/null +++ b/app/home/controller/Wepay.php @@ -0,0 +1,185 @@ +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(), + ]); + } +} diff --git a/app/home/event.php b/app/home/event.php new file mode 100644 index 0000000..4eff890 --- /dev/null +++ b/app/home/event.php @@ -0,0 +1,5 @@ + + + +
++ {:lang('contact.info')} +
+ + + + ++ {:str_replace('%country%', $country ?? '', lang('index.welcome_message'))}
+ {:lang('index.online_application')} ++ {:lang('index.notice')} + {:lang('index.notice_text')} +
+{:lang('index.step1_desc')}
+{:lang('index.step2_desc')}
+{:lang('index.step3_desc')}
++ {:str_replace('%country%', $country ?? '', lang('index.application_description1'))} +
+ +{:lang('index.convenient_desc')}
+{:lang('index.secure_desc')}
+{:lang('index.approval_desc')}
+{:lang('index.support_desc')}
+