Files
evus.acvisa.com/app/home/controller/Update.php

435 lines
23 KiB
PHP

<?php
namespace app\home\controller;
use api\Httpcurl;
use think\facade\Db;
use think\facade\Request;
use think\facade\Session;
use think\facade\View;
class Update extends Base
{
public function index()
{
$id = Request::param('id');
$order_sn = Request::param('order_sn');
if (empty($id) || empty($order_sn)) {
return $this->error('参数错误');
}
//获取数据
$data = Db::name('msg')->where(['id' => $id, 'order_sn' => $order_sn])->find();
if (empty($data)) {
return $this->error('无此数据');
}
$refer_url = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '';
if ($refer_url){
Session::set('update_refer_url',$refer_url);
}
View::assign('data', $data);
View::assign('id', $id);
View::assign('order_sn', $order_sn);
return View::fetch();
}
function do_apply()
{
unset($_REQUEST['s']);
$id = Request::param('id');
$order_sn = Request::param('order_sn');
file_put_contents('/www/newevus/update.log',
"{$order_sn}.'-'.{$id}===" . json_encode($_REQUEST) . "\r\n", FILE_APPEND);
$insert_id = Db::name('msg')->where(['id' => $id, 'order_sn' => $order_sn])->update($_REQUEST);
$refer_url= Session::get('update_refer_url');
if ($insert_id >= 0) {
return $this->success('修改成功',$refer_url);
} else {
return $this->error("提交失败,请联系管理员!",$refer_url);
}
}
public function adminindex()
{
$order_sn = Request::param('order_sn');
if (empty($order_sn)) {
return $this->error('参数错误');
}
$response = Httpcurl::request(config('app.get_evus_detail_url'), 'post', ['order_sn' => $order_sn, 'model' => MODEL]);
if ($response[3]) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
$pay_result = json_decode($response[0], true);
if (empty($pay_result)) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
if (!$pay_result['code']) {
return $this->error($pay_result['msg'], url('detail/index'));
}
$refer_url = Request::param('return_url');
if ($refer_url) {
Session::set('update_refer_url', $refer_url);
}
View::assign('country_list', json_decode(file_get_contents('./json/country.json'), true));
View::assign('phone_prefix', json_decode(file_get_contents('./json/phone_prefix.json'), true));
View::assign('us', json_decode(file_get_contents('./json/us.json'), true));
View::assign('data', $pay_result['data']);
return View::fetch();
}
public function order_apply()
{
$order_sn = Request::param('order_sn');
if (!$order_sn) {
return $this->error(lang('controller.order_not_exist'));
}
$response = Httpcurl::request(config('app.get_evus_detail_url'), 'post', ['order_sn' => $order_sn, 'model' => MODEL]);
if ($response[3]) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
$pay_result = json_decode($response[0], true);
if (empty($pay_result)) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
if (!$pay_result['code']) {
return $this->error($pay_result['msg'], url('detail/index'));
}
unset($_REQUEST['s']);
$_REQUEST['birth_date_day'] = (string)date_parse($_REQUEST['birth_date'])['day'] ?:'0';
$_REQUEST['birth_date_month'] = (string)date_parse($_REQUEST['birth_date'])['month'] ?:'0';
$_REQUEST['birth_date_year'] = (string)date_parse($_REQUEST['birth_date'])['year'] ?:'0';
$_REQUEST['passport_expedition_date_day'] = (string)date_parse($_REQUEST['passport_expedition_date'])['day'] ?:'';
$_REQUEST['passport_expedition_date_month'] = (string)date_parse($_REQUEST['passport_expedition_date'])['month'] ?:'';
$_REQUEST['passport_expedition_date_year'] = (string)date_parse($_REQUEST['passport_expedition_date'])['year'] ?:'';
$_REQUEST['passport_expiration_date_day'] = (string)date_parse($_REQUEST['passport_expiration_date'])['day'] ?:'';
$_REQUEST['passport_expiration_date_month'] = (string)date_parse($_REQUEST['passport_expiration_date'])['month'] ?:'';
$_REQUEST['passport_expiration_date_year'] = (string)date_parse($_REQUEST['passport_expiration_date'])['year'] ?:'';
$_REQUEST['us_visa_passport_issue_date_day'] = (string)date_parse($_REQUEST['us_visa_passport_issue_date'])['day'] ?:'';
$_REQUEST['us_visa_passport_issue_date_month'] = (string)date_parse($_REQUEST['us_visa_passport_issue_date'])['month'] ?:'';
$_REQUEST['us_visa_passport_issue_date_year'] = (string)date_parse($_REQUEST['us_visa_passport_issue_date'])['year'] ?:'';
$_REQUEST['us_visa_passport_expiration_date_day'] = (string)date_parse($_REQUEST['us_visa_passport_expiration_date'])['day'] ?:'';
$_REQUEST['us_visa_passport_expiration_date_month'] = (string)date_parse($_REQUEST['us_visa_passport_expiration_date'])['month'] ?:'';
$_REQUEST['us_visa_passport_expiration_date_year'] = (string)date_parse($_REQUEST['us_visa_passport_expiration_date'])['year'] ?:'';
$_REQUEST['us_visa_birth_date_day'] = (string)date_parse($_REQUEST['us_visa_birth_date'])['day'] ?:'';
$_REQUEST['us_visa_birth_date_month'] = (string)date_parse($_REQUEST['us_visa_birth_date'])['month'] ?:'';
$_REQUEST['us_visa_birth_date_year'] = (string)date_parse($_REQUEST['us_visa_birth_date'])['year'] ?:'';
$_REQUEST = formDataToJson(['vist_country', 'vist_from_date', 'vist_end_date', 'vist_country_des'], $_REQUEST, 'vistitem', 'question_i');
$_REQUEST['other_country_acquired_other'] = isset($_REQUEST['other_country_acquired_other']) ? $_REQUEST['other_country_acquired_other'] : '';
$_REQUEST['model'] = MODEL;
$_REQUEST['token'] = md5(MODEL);
$_REQUEST['order_sn'] = $order_sn;
$_REQUEST['total_price'] = $pay_result['data']['total_price'];
try {
$insert_id = Httpcurl::request(UPDATE_EVUS_ORDER_URL, 'post', $_REQUEST);
$result = json_decode($insert_id[0], true);
$refer_url= Session::get('update_refer_url');
if (empty($result)) {
return $this->error(lang('controller.fail'));
}
if (!$result['code']) {
return $this->error(lang('controller.fail'));
}
return $this->success(lang('controller.success'), $refer_url);
} catch (\Exception $e) {
return $this->error(lang('controller.fail'));
}
}
public function adminesta()
{
$order_sn = Request::param('order_sn');
if (empty($order_sn)) {
return $this->error('参数错误');
}
$response = Httpcurl::request(config('app.get_order_detail_url'), 'post', ['order_sn' => $order_sn, 'model' => ESTA_MODEL]);
if ($response[3]) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
$pay_result = json_decode($response[0], true);
if (empty($pay_result)) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
if (!$pay_result['code']) {
return $this->error($pay_result['msg'], url('detail/index'));
}
$refer_url = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '';
if ($refer_url) {
Session::set('update_refer_url', $refer_url);
}
View::assign('country_list', json_decode(file_get_contents('./json/country.json'), true));
View::assign('phone_prefix', json_decode(file_get_contents('./json/phone_prefix.json'), true));
View::assign('us', json_decode(file_get_contents('./json/us.json'), true));
View::assign('goods', config('app.ESTA_GOODS'));
View::assign('ismobile', isMobile() ? 1 : 0);
View::assign('ppt_sample_url', '/new/assets/images/shili.jpg');
View::assign('per_sample_url', '/new/assets/images/persion2.png');
View::assign('data', $pay_result['data']);
View::assign('id', $pay_result['data']['id']);
return View::fetch();
}
public function detail()
{
$order_sn = Request::param('id');
if (empty($order_sn)) {
return $this->error('参数错误');
}
$response = Httpcurl::request(config('app.get_evus_detail_url'), 'post', ['order_sn' => $order_sn, 'model' => MODEL]);
if ($response[3]) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
$pay_result = json_decode($response[0], true);
if (empty($pay_result)) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
if (!$pay_result['code']) {
return $this->error($pay_result['msg'], url('detail/index'));
}
View::assign('country_list', json_decode(file_get_contents('./json/country.json'), true));
View::assign('phone_prefix', json_decode(file_get_contents('./json/phone_prefix.json'), true));
View::assign('us', json_decode(file_get_contents('./json/us.json'), true));
View::assign('data', $pay_result['data']);
return View::fetch();
}
/**
* 未支付订单去支付
*/
public function do_unpay()
{
$order_sn = Request::param('order_sn');
if (empty($order_sn)) {
return $this->error('参数错误');
}
$response = Httpcurl::request(config('app.get_evus_detail_url'), 'post', ['order_sn' => $order_sn, 'model' => MODEL]);
if ($response[3]) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
$pay_result = json_decode($response[0], true);
if (empty($pay_result)) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
if (!$pay_result['code']) {
return $this->error($pay_result['msg'], url('detail/index'));
}
$order_sn = $_REQUEST['order_sn'] = getOrderNumber();
$total_price =$pay_result['data']['total_price'];
/*判断价格是否正确*/
$config_price = array_map(function($item) {
return $item['value'];
}, config('app.EVUS_GOODS'));
if (!in_array($total_price, $config_price)) {
return $this->error('价格错误');
}
/*判断价格是否正确*/
$_REQUEST['birth_date_day'] = (string)date_parse($_REQUEST['birth_date'])['day'] ?:'0';
$_REQUEST['birth_date_month'] = (string)date_parse($_REQUEST['birth_date'])['month'] ?:'0';
$_REQUEST['birth_date_year'] = (string)date_parse($_REQUEST['birth_date'])['year'] ?:'0';
$_REQUEST['passport_expedition_date_day'] = (string)date_parse($_REQUEST['passport_expedition_date'])['day'] ?:'';
$_REQUEST['passport_expedition_date_month'] = (string)date_parse($_REQUEST['passport_expedition_date'])['month'] ?:'';
$_REQUEST['passport_expedition_date_year'] = (string)date_parse($_REQUEST['passport_expedition_date'])['year'] ?:'';
$_REQUEST['passport_expiration_date_day'] = (string)date_parse($_REQUEST['passport_expiration_date'])['day'] ?:'';
$_REQUEST['passport_expiration_date_month'] = (string)date_parse($_REQUEST['passport_expiration_date'])['month'] ?:'';
$_REQUEST['passport_expiration_date_year'] = (string)date_parse($_REQUEST['passport_expiration_date'])['year'] ?:'';
$_REQUEST['us_visa_passport_issue_date_day'] = (string)date_parse($_REQUEST['us_visa_passport_issue_date'])['day'] ?:'';
$_REQUEST['us_visa_passport_issue_date_month'] = (string)date_parse($_REQUEST['us_visa_passport_issue_date'])['month'] ?:'';
$_REQUEST['us_visa_passport_issue_date_year'] = (string)date_parse($_REQUEST['us_visa_passport_issue_date'])['year'] ?:'';
$_REQUEST['us_visa_passport_expiration_date_day'] = (string)date_parse($_REQUEST['us_visa_passport_expiration_date'])['day'] ?:'';
$_REQUEST['us_visa_passport_expiration_date_month'] = (string)date_parse($_REQUEST['us_visa_passport_expiration_date'])['month'] ?:'';
$_REQUEST['us_visa_passport_expiration_date_year'] = (string)date_parse($_REQUEST['us_visa_passport_expiration_date'])['year'] ?:'';
$_REQUEST['us_visa_birth_date_day'] = (string)date_parse($_REQUEST['us_visa_birth_date'])['day'] ?:'';
$_REQUEST['us_visa_birth_date_month'] = (string)date_parse($_REQUEST['us_visa_birth_date'])['month'] ?:'';
$_REQUEST['us_visa_birth_date_year'] = (string)date_parse($_REQUEST['us_visa_birth_date'])['year'] ?:'';
$_REQUEST = formDataToJson(['vist_country', 'vist_from_date', 'vist_end_date', 'vist_country_des'], $_REQUEST, 'vistitem', 'question_i');
$_REQUEST['other_country_acquired_other'] = isset($_REQUEST['other_country_acquired_other']) ? $_REQUEST['other_country_acquired_other'] : '';
$_REQUEST['source'] = Session::get('source' );
$_REQUEST['is_mobile'] = isMobile() ? 1 : 0;
$_REQUEST['total_price'] = $total_price;
$_REQUEST['origin_price'] = $total_price;
$_REQUEST['ip'] = getIP();
$_REQUEST['coupon_code'] = isset($_REQUEST['coupon_code']) ? $_REQUEST['coupon_code']: '';
$_REQUEST['model'] = MODEL;
$_REQUEST['token'] = md5(MODEL);
$_REQUEST['user_id'] = $this->_userId;
$order_res = Httpcurl::request(CREATE_EVUS_ORDER_URL, 'post', $_REQUEST);
$order = json_decode($order_res[0], true);
if (!$order['code']) {
return $this->error("提交失败,请联系管理员!");
}
if ($order['is_pay'] == 1) {
return $this->success('操作成功', url('home/pay/succ', ['order_sn' => $order_sn])->build());
}
return $this->success('操作成功', url('home/pay/index', ['order_sn' => $order_sn])->build());
}
public function upevus()
{
$id = Request::param('id');
if (empty($id)) {
return $this->error('参数错误');
}
$order_sn = base64_decode($id);
$response = Httpcurl::request(config('app.get_evus_detail_url'), 'post', ['order_sn' => $order_sn, 'model' => MODEL]);
if ($response[3]) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
$pay_result = json_decode($response[0], true);
if (empty($pay_result)) {
return $this->error("订单不存在,请重新提交", url('detail/index'));
}
if (!$pay_result['code']) {
return $this->error($pay_result['msg'], url('detail/index'));
}
View::assign('country_list', json_decode(file_get_contents('./json/country.json'), true));
View::assign('phone_prefix', json_decode(file_get_contents('./json/phone_prefix.json'), true));
View::assign('us', json_decode(file_get_contents('./json/us.json'), true));
View::assign('goods', config('app.EVUS_GOODS'));
View::assign('data', $pay_result['data']);
return View::fetch();
}
public function do_update()
{
unset($_REQUEST['s']);
$order_sn = $_REQUEST['order_sn'] = getOrderNumber();
$total_price = $_REQUEST['total_price'];
/*判断价格是否正确*/
$config_price = array_map(function($item) {
return $item['value'];
}, config('app.EVUS_GOODS'));
if (!in_array($total_price, $config_price)) {
return $this->error('价格错误');
}
/*判断价格是否正确*/
$_REQUEST['birth_date_day'] = (string)date_parse($_REQUEST['birth_date'])['day'] ?:'0';
$_REQUEST['birth_date_month'] = (string)date_parse($_REQUEST['birth_date'])['month'] ?:'0';
$_REQUEST['birth_date_year'] = (string)date_parse($_REQUEST['birth_date'])['year'] ?:'0';
$_REQUEST['passport_expedition_date_day'] = (string)date_parse($_REQUEST['passport_expedition_date'])['day'] ?:'';
$_REQUEST['passport_expedition_date_month'] = (string)date_parse($_REQUEST['passport_expedition_date'])['month'] ?:'';
$_REQUEST['passport_expedition_date_year'] = (string)date_parse($_REQUEST['passport_expedition_date'])['year'] ?:'';
$_REQUEST['passport_expiration_date_day'] = (string)date_parse($_REQUEST['passport_expiration_date'])['day'] ?:'';
$_REQUEST['passport_expiration_date_month'] = (string)date_parse($_REQUEST['passport_expiration_date'])['month'] ?:'';
$_REQUEST['passport_expiration_date_year'] = (string)date_parse($_REQUEST['passport_expiration_date'])['year'] ?:'';
$_REQUEST['us_visa_passport_issue_date_day'] = (string)date_parse($_REQUEST['us_visa_passport_issue_date'])['day'] ?:'';
$_REQUEST['us_visa_passport_issue_date_month'] = (string)date_parse($_REQUEST['us_visa_passport_issue_date'])['month'] ?:'';
$_REQUEST['us_visa_passport_issue_date_year'] = (string)date_parse($_REQUEST['us_visa_passport_issue_date'])['year'] ?:'';
$_REQUEST['us_visa_passport_expiration_date_day'] = (string)date_parse($_REQUEST['us_visa_passport_expiration_date'])['day'] ?:'';
$_REQUEST['us_visa_passport_expiration_date_month'] = (string)date_parse($_REQUEST['us_visa_passport_expiration_date'])['month'] ?:'';
$_REQUEST['us_visa_passport_expiration_date_year'] = (string)date_parse($_REQUEST['us_visa_passport_expiration_date'])['year'] ?:'';
$_REQUEST['us_visa_birth_date_day'] = (string)date_parse($_REQUEST['us_visa_birth_date'])['day'] ?:'';
$_REQUEST['us_visa_birth_date_month'] = (string)date_parse($_REQUEST['us_visa_birth_date'])['month'] ?:'';
$_REQUEST['us_visa_birth_date_year'] = (string)date_parse($_REQUEST['us_visa_birth_date'])['year'] ?:'';
$_REQUEST = formDataToJson(['vist_country', 'vist_from_date', 'vist_end_date', 'vist_country_des'], $_REQUEST, 'vistitem', 'question_i');
$_REQUEST['other_country_acquired_other'] = isset($_REQUEST['other_country_acquired_other']) ? $_REQUEST['other_country_acquired_other'] : '';
$_REQUEST['source'] = Session::get('source' );
$_REQUEST['is_mobile'] = isMobile() ? 1 : 0;
$_REQUEST['total_price'] = $total_price;
$_REQUEST['origin_price'] = $total_price;
$_REQUEST['ip'] = getIP();
$_REQUEST['coupon_code'] = isset($_REQUEST['coupon_code']) ? $_REQUEST['coupon_code']: '';
$_REQUEST['model'] = MODEL;
$_REQUEST['token'] = md5(MODEL);
$_REQUEST['user_id'] = $this->_userId;
$order_res = Httpcurl::request(CREATE_EVUS_ORDER_URL, 'post', $_REQUEST);
$order = json_decode($order_res[0], true);
if (!$order['code']) {
return $this->error("提交失败,请联系管理员!");
}
if ($order['is_pay'] == 1) {
return $this->success('操作成功', url('home/pay/succ', ['order_sn' => $order_sn])->build());
}
return $this->success('操作成功', url('home/pay/index', ['order_sn' => $order_sn])->build());
}
function do_esta_apply()
{
unset($_REQUEST['s']);
unset($_REQUEST['file']);
/*判断价格是否正确*/
$_REQUEST['birth_date_day'] = (string)date_parse($_REQUEST['birth_date'])['day'] ?:'0';
$_REQUEST['birth_date_month'] = (string)date_parse($_REQUEST['birth_date'])['month'] ?:'0';
$_REQUEST['birth_date_year'] = (string)date_parse($_REQUEST['birth_date'])['year'] ?:'0';
$_REQUEST['passport_expedition_date_day'] = (string)date_parse($_REQUEST['passport_expedition_date'])['day'] ?:'';
$_REQUEST['passport_expedition_date_month'] = (string)date_parse($_REQUEST['passport_expedition_date'])['month'] ?:'';
$_REQUEST['passport_expedition_date_year'] = (string)date_parse($_REQUEST['passport_expedition_date'])['year'] ?:'';
$_REQUEST['passport_expiration_date_day'] = (string)date_parse($_REQUEST['passport_expiration_date'])['day'] ?:'';
$_REQUEST['passport_expiration_date_month'] = (string)date_parse($_REQUEST['passport_expiration_date'])['month'] ?:'';
$_REQUEST['passport_expiration_date_year'] = (string)date_parse($_REQUEST['passport_expiration_date'])['year'] ?:'';
$_REQUEST['other_country_date_day'] = (string)date_parse($_REQUEST['other_country_date'])['day'] ?:'';
$_REQUEST['other_country_date_month'] = (string)date_parse($_REQUEST['other_country_date'])['month'] ?:'';
$_REQUEST['other_country_date_year'] = (string)date_parse($_REQUEST['other_country_date'])['year'] ?:'';
unset($_REQUEST['other_country_date']);
$_REQUEST['other_country_edate_day'] = (string)date_parse($_REQUEST['other_country_edate'])['day'] ?:'';
$_REQUEST['other_country_edate_month'] = (string)date_parse($_REQUEST['other_country_edate'])['month'] ?:'';
$_REQUEST['other_country_edate_year'] = (string)date_parse($_REQUEST['other_country_edate'])['year'] ?:'';
unset($_REQUEST['other_country_edate']);
$_REQUEST['model'] = ESTA_MODEL;
$_REQUEST['token'] = md5(ESTA_MODEL);
$_REQUEST['other_country_acquired_other'] = isset($_REQUEST['other_country_acquired_other']) ? $_REQUEST['other_country_acquired_other'] : '';
$refer_url= Session::get('update_refer_url');
$order_res = Httpcurl::request(config('app.update_order_url'), 'post', $_REQUEST);
$order = json_decode($order_res[0], true);
if (!$order['code']) {
return $this->error("提交失败,请联系管理员!");
}
// python($order_sn);
return $this->success('修改成功', $refer_url);
}
function do_admin_apply()
{
unset($_REQUEST['s'],$_REQUEST['id']);
$id = Request::param('id');
$order_sn = think_decrypt($id);
if (empty($_REQUEST['family_name_alias']) || empty($_REQUEST['given_name_alias'])){
$_REQUEST['have_alias'] = 2;
}
$data = Db::name('msg')->where(['order_sn' => $order_sn])->find();
$insert_id = Db::name('msg')->where(['order_sn' => $order_sn])->update($_REQUEST);
// $url = "http://manage.evus.cn/index.php?s=/Immigrant/index.html";
$url='https://manage.evus.cn/index.php?s=/Immigrant/detail/id/'.$data['id'];
Db::name('msg_format')->where(['order_sn' => $order_sn])->delete();
if ($insert_id >= 0) {
// python($order_sn);
return $this->success('修改成功', $url);
// $this->redirect($url);
} else {
return $this->error("提交失败,请联系管理员!", $url);
}
}
}