提交
This commit is contained in:
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);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user