Browse Source

预约单保存

zhangxiaobin 1 year ago
parent
commit
796a25b804

+ 4 - 1
application/api/controller/PreOrder.php

@@ -66,6 +66,7 @@ class PreOrder extends Api
             $carId = $this->request->param('car_id',0);
             $preTime = $this->request->param('pre_time','');
             $userId = $this->auth->id;
+            $companyId = $this->auth->company_id;
             $scene = !empty($id) ? 'edit' : 'add';
             $validate = validate('PreOrder');
             if(!$validate->check($this->request->param(),[],$scene)){
@@ -81,7 +82,7 @@ class PreOrder extends Api
             }
             $time = time();
             $data = [
-                'company_id'     => $this->request->param('company_id', 0),
+                'company_id'     => $companyId,
                 'name'           => $this->request->param('name', ''),
                 'mobile'         => $this->request->param('mobile', ''),
                 'address'         => $this->request->param('address', ''),
@@ -96,6 +97,7 @@ class PreOrder extends Api
                 $data['user_id'] = $userId;
                 $data['createtime'] = $time;
                 $res = $this->model->insertGetId($data);
+                $id = $res;
             } else {
                 $data['updatetime'] = $time;
                 $where['id'] = $id;
@@ -106,6 +108,7 @@ class PreOrder extends Api
                 throw new Exception('操作失败');
             }
             $result = [
+                'pre_order_id' => $id,
                 'template_ids' => config('param.wechat_template_ids'),//微信消息模版ID
             ];
             $this->success('操作成功',$result);

+ 1 - 2
application/common/validate/PreOrder.php

@@ -8,7 +8,7 @@ class PreOrder extends Validate
     // 验证规则
     protected $rule = [
         'id' => 'require|number',
-        'company_id' => 'require|number',
+        'company_id' => 'number',
         'name' => 'require|max:32',
         'mobile' => 'require|max:32',
         'address' => 'max:256',
@@ -23,7 +23,6 @@ class PreOrder extends Validate
     protected $message = [
         'id.require' => '请输入预约单ID',
         'id.number' => '您输入的预约单ID,必须是数字类型',
-        'company_id.require' => '请输入门店',
         'company_id.number' => '您输入的门店,必须是数字类型',
         'name.require' => '请输入联系人',
         'name.max' => '您输入的联系人,必须小于32字符',