You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.8 KiB
PHP
93 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\H5;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\ConfigService;
|
|
use DateTime;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class OrderController extends Controller
|
|
{
|
|
public function list(Request $request)
|
|
{
|
|
// status 1-待支付 2-已预约 3-交易关闭 4-已完成 5-已退款
|
|
$openid = $request->post('openid');
|
|
$user=DB::table('web_users')->where(['openid'=>$openid,'is_del'=>0])->first();
|
|
if(!$user) return \Yz::echoError1("openid对应用户不存在");
|
|
$OrderList=DB::table('orders')
|
|
->select('id','title','status','name','appointment_time as time','order_number as order',
|
|
DB::raw("CASE WHEN type = 1 THEN '个检' WHEN type = 2 THEN '团检' ELSE 'unknown' END as type"),
|
|
'price','true_price','pay_time','refund_time','created_at')
|
|
->where(['web_user_id'=>$user->id])->get();
|
|
$WaitingPaymentTime=config('app.globals.WaitingPaymentTime');//支付等待時間
|
|
foreach ($OrderList as $key=>$list){
|
|
if($list->status==1){
|
|
$datetime = new DateTime($list->created_at);
|
|
$timestamp = $datetime->getTimestamp();
|
|
$list->end_time=$timestamp + (60 * $WaitingPaymentTime);
|
|
}
|
|
}
|
|
$list = [[
|
|
'id' => 1,
|
|
'title' => '测试套餐1',
|
|
'status' => 1,
|
|
'name' => '陆予',
|
|
'time' => '2024-08-05 08:00:00',
|
|
'order' => '1234567890987654321',
|
|
'type' => '个检',
|
|
'price' => '4999.99',
|
|
'true_price' => '4999.99',
|
|
'end_time' => time() + (60 * 20)
|
|
], [
|
|
'id' => 1,
|
|
'title' => '测试套餐2',
|
|
'status' => 2,
|
|
'name' => '陆予',
|
|
'time' => '2024-08-05 08:00:00',
|
|
'order' => '1234567890987654321',
|
|
'type' => '个检',
|
|
'price' => '4999.99',
|
|
'true_price' => '4999.99',
|
|
'pay_time' => '2024-08-06 08:00:00'
|
|
], [
|
|
'id' => 1,
|
|
'title' => '测试套餐2',
|
|
'status' => 3,
|
|
'name' => '陆予',
|
|
'time' => '2024-08-05 08:00:00',
|
|
'order' => '1234567890987654321',
|
|
'type' => '个检'
|
|
], [
|
|
'id' => 1,
|
|
'title' => '测试套餐2',
|
|
'status' => 4,
|
|
'name' => '陆予',
|
|
'time' => '2024-08-05 08:00:00',
|
|
'order' => '1234567890987654321',
|
|
'type' => '团检',
|
|
'price' => '4999.99',
|
|
'true_price' => '0.01',
|
|
'pay_time' => '2024-08-06 08:00:00',
|
|
'report' => true,
|
|
'decode' => 0,
|
|
], [
|
|
'id' => 1,
|
|
'title' => '测试套餐2',
|
|
'status' => 5,
|
|
'name' => '陆予',
|
|
'time' => '2024-08-05 08:00:00',
|
|
'order' => '1234567890987654321',
|
|
'type' => '团检',
|
|
'price' => '4999.99',
|
|
'true_price' => '0.01',
|
|
'refund_time' => '2024-08-06 08:00:00'
|
|
]];
|
|
|
|
return \Yz::Return(true, '获取成功', [
|
|
'list' => $OrderList
|
|
]);
|
|
}
|
|
}
|