作者 王智

预约大小汽修

@@ -5,6 +5,7 @@ namespace app\api\controller; @@ -5,6 +5,7 @@ namespace app\api\controller;
5 5
6 6
7 use app\common\controller\Api; 7 use app\common\controller\Api;
  8 +use app\common\model\Car;
8 use app\common\model\Hotel; 9 use app\common\model\Hotel;
9 use app\common\model\House; 10 use app\common\model\House;
10 use app\common\model\SellerAvatar; 11 use app\common\model\SellerAvatar;
@@ -280,4 +281,45 @@ class Seller extends Api @@ -280,4 +281,45 @@ class Seller extends Api
280 $this->error('添加数据失败!'); 281 $this->error('添加数据失败!');
281 } 282 }
282 } 283 }
  284 +
  285 +
  286 + /**
  287 + * @ApiTitle (商家接口-预约大小汽修)
  288 + * @ApiSummary (预约大小汽修)
  289 + * @ApiMethod (POST)
  290 + * @ApiRoute (/api/seller/car_yy)
  291 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  292 + * @ApiParams (name="seller_id", type="int", required=true, description="店铺ID")
  293 + * @ApiParams (name="time", type="string", required=true, description="预约时间")
  294 + * @ApiParams (name="car", type="string", required=true, description="车型")
  295 + * @ApiParams (name="car_num", type="string", required=true, description="车牌号")
  296 + * @ApiParams (name="only_num", type="string", required=true, description="17位编码")
  297 + * @ApiReturnParams (name="code", type="integer", required=true, sample="0")
  298 + * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
  299 + * @ApiReturn ({
  300 + 'code':'1',
  301 + 'msg':'返回成功'
  302 + })
  303 + */
  304 + public function car_yy()
  305 + {
  306 + $token = $this->request->header();
  307 + if (empty($token['token'])) {
  308 + $this->error('请登陆后再操作!', '', '9');
  309 + }
  310 + $token_model = new UserToken();
  311 + $user_id = $token_model:: get(['token' => $token['token']]);
  312 + if (!$user_id) {
  313 + $this->error('Token不存在', '', '8');
  314 + }
  315 + $param = $this->request->param();
  316 + $model = new Car();
  317 + $time = strtotime($param['time']);
  318 + $res = $model->save(['time' => $time, 'car' => $param['car'], 'car_num' => $param['car_num'], 'only_num' => $param['only_num'], 'user_id' => $user_id['id'], 'seller_id' => $param['seller_id']]);
  319 + if ($res) {
  320 + $this->success('成功');
  321 + } else {
  322 + $this->error('添加数据失败!');
  323 + }
  324 + }
283 } 325 }
  1 +<?php
  2 +
  3 +
  4 +namespace app\common\model;
  5 +
  6 +
  7 +use think\Model;
  8 +
  9 +class Car extends Model
  10 +{
  11 + //表名
  12 + protected $name = 'car';
  13 + // 开启自动写入时间戳字段
  14 + protected $autoWriteTimestamp = 'int';
  15 + // 定义时间戳字段名
  16 + protected $createTime = 'createtime';
  17 + protected $updateTime = 'updatetime';
  18 +}