|
@@ -5,6 +5,7 @@ namespace app\api\controller;
|
|
|
use addons\epay\library\Service;
|
|
|
use app\common\controller\Api;
|
|
|
use app\common\model\HotelModel;
|
|
|
+use app\common\model\HotelOrderModel;
|
|
|
use app\common\model\HotelRoomModel;
|
|
|
use app\common\model\PayOrderModel;
|
|
|
use app\common\model\UniversityEventModel;
|
|
@@ -20,6 +21,12 @@ class Hotel extends Api
|
|
|
{
|
|
|
protected $noNeedLogin = [''];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
+ protected $status = [
|
|
|
+ 0 => '全部',
|
|
|
+ 1 => '待入住',
|
|
|
+ 2 => '已入住',
|
|
|
+ 3 => '已取消',
|
|
|
+ ];
|
|
|
|
|
|
// 活动列表
|
|
|
public function list()
|
|
@@ -108,11 +115,11 @@ class Hotel extends Api
|
|
|
'hotel'=>function ($query) {
|
|
|
$query->field(['id','name','image','images','price','original_price']);
|
|
|
}
|
|
|
- ])->where('id',$params['id'])->where('status',1)->find();
|
|
|
+ ])->where('id',$params['room_id'])->where('status',1)->find();
|
|
|
if (!$info) {
|
|
|
return $this->error('房间不存在');
|
|
|
}
|
|
|
- if (!empty($info['hotel'])) {
|
|
|
+ if (empty($info['hotel'])) {
|
|
|
return $this->error('酒店信息有误');
|
|
|
}
|
|
|
|
|
@@ -138,10 +145,59 @@ class Hotel extends Api
|
|
|
return $this->success('提交成功');
|
|
|
}
|
|
|
|
|
|
- public function applyList()
|
|
|
+ // 订单列表
|
|
|
+ public function myApply()
|
|
|
{
|
|
|
+ $params = $this->request->param();
|
|
|
+ $user_id = $this->auth->id;
|
|
|
+
|
|
|
+ $query = HotelOrderModel::with([
|
|
|
+ 'room'=>function ($query) {
|
|
|
+ $query->field(['id','name','image']);
|
|
|
+ }
|
|
|
+ ])->where('user_id',$user_id);
|
|
|
+
|
|
|
+ switch ($params['status']){
|
|
|
+ case 1:
|
|
|
+ $query->where('start_date','<',date('Y-m-d'))->where('status',1);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ $query->where('start_date','>=',date('Y-m-d'))->where('status',1);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ $query->where('status',0);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ $list = $query->order('id','desc')->autopage()->select();
|
|
|
+ foreach ($list as $key=>$val){
|
|
|
+ if ($val['status'] == 1){
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $list[$key]['status_txt'] = '已取消';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $this->success('获取成功',$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 订单取消
|
|
|
+ public function applyCancel()
|
|
|
+ {
|
|
|
+ $params = $this->request->param();
|
|
|
$user_id = $this->auth->id;
|
|
|
- $query = Db::name('university_event_apply')->where('user_id',$user_id);
|
|
|
|
|
|
+ $order = HotelOrderModel::where('user_id',$user_id)->where('id',$params['order_id'])->where('status',1)->find();
|
|
|
+ if (!$order){
|
|
|
+ return $this->error('订单不存在或已取消');
|
|
|
+ }
|
|
|
+ if (date('Y-m-d H:i:s') > ($order['start_date'] . ' 12:00:00')){
|
|
|
+ return $this->error('订单已入住,无法取消');
|
|
|
+ }
|
|
|
+ if (!HotelOrderModel::where('user_id',$user_id)->where('id',$params['order_id'])->where('status',1)->update(['status'=>0])){
|
|
|
+ return $this->error('操作失败');
|
|
|
+ }
|
|
|
+ return $this->success('操作成功');
|
|
|
}
|
|
|
}
|