travel/service/app/admin/controller/OrderBooksController.php

52 lines
1.7 KiB
PHP
Raw Normal View History

2024-10-21 17:14:32 +08:00
<?php
namespace app\admin\controller;
require_once(__DIR__.'/xlsxwriter.class.php');
use app\model\OrderBooks;
use app\model\Orders;
use app\model\Products;
use support\Request;
class OrderBooksController extends base {
/**
* @param Request $request
* @return \support\Response
* @throws \think\db\exception\DbException
*/
public function list(Request $request) {
$query = OrderBooks::where([])->order('id', 'desc');
if($username = $request->get('username')) {
$query->where('username', $username);
}
if($status = $request->get('status')) {
$query->where('status', $status);
}
2024-10-22 15:00:11 +08:00
if($is_order = $request->get('sn')) {
2024-10-21 17:14:32 +08:00
$query->where('is_order', $is_order);
}
$list = $query->with(['orderInfo'])->paginate($request->get('limit',10));
foreach ($list as &$val) {
if ($val['code_pic']) {
$val['code_pic'] = json_decode($val['code_pic'], true);
$val['code_pic_show'] = $val['code_pic'][0];
}
}
return $this->success($list,null,['oss' => array_values(array_map(function ($os, $k) {
return ['id' => $k, 'os' => $os];
}, Orders::OSS, array_keys(Orders::OSS)))]);
}
/**
* @param Request $request
* @return \support\Response
* @throws \think\db\exception\DbException
*/
public function updateStatus(Request $request) {
if (!$request->post('id')) {
return $this->error('请选择预约记录');
}
OrderBooks::where('id', $request->post('id'))->update(['status' => 1]);
return $this->success([]);
}
}