|
@@ -53,6 +53,37 @@ class Preorder extends Apic
|
|
|
$this->success(1,$info);
|
|
|
}
|
|
|
|
|
|
+ //车牌号或手机号搜用户
|
|
|
+ public function searchuser(){
|
|
|
+ $keyword = input('keyword','');
|
|
|
+
|
|
|
+ //先搜手机
|
|
|
+ $where = [
|
|
|
+ 'mobile' => ['LIKE','%'.$keyword.'%']
|
|
|
+ ];
|
|
|
+ $user_ids = Db::name('user')->where($where)->column('id');
|
|
|
+
|
|
|
+ //再搜车牌
|
|
|
+ $where = [
|
|
|
+ 'car_number' => ['LIKE','%'.$keyword.'%']
|
|
|
+ ];
|
|
|
+ $car_user_ids = Db::name('user_car')->where($where)->column('user_id');
|
|
|
+
|
|
|
+ //合并用户ids
|
|
|
+ $new_user_ids = array_merge($user_ids,$car_user_ids);
|
|
|
+ $new_user_ids = array_flip(array_flip($new_user_ids));
|
|
|
+
|
|
|
+ //搜用户
|
|
|
+ $user_list = Db::name('user')->field('id,mobile,nickname')->where('id','IN',$new_user_ids)->autopage()->select();
|
|
|
+ foreach($user_list as $key => &$val){
|
|
|
+ $user_car = Db::name('user_car')->where('user_id',$val['id'])->select();
|
|
|
+ $val['car_list'] = $user_car;
|
|
|
+ $val['address'] = Db::name('user_wallet')->where('user_id',$val['id'])->where('company_id',$this->auth->company_id)->value('address');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success(1,$user_list);
|
|
|
+ }
|
|
|
+
|
|
|
//预约开单 在线开单
|
|
|
public function submit_order(){
|
|
|
$pre_order_id = input('pre_order_id',0); //预约单id
|
|
@@ -62,16 +93,17 @@ class Preorder extends Apic
|
|
|
'servicetype_id','server_time','server_info','server_images','pay_fee'
|
|
|
]);
|
|
|
|
|
|
- //检查用户
|
|
|
- $user_info = Db::name('user')->where('mobile',$data['user_mobile'])->find();
|
|
|
- if(empty($user_info)){
|
|
|
- $this->error('不存在的用户');
|
|
|
- }
|
|
|
- $data['user_id'] = $user_info['id'];
|
|
|
-
|
|
|
//预约单
|
|
|
$pre_order = [];
|
|
|
if($pre_order_id > 0){
|
|
|
+ //检查用户
|
|
|
+ $user_info = Db::name('user')->where('mobile',$data['user_mobile'])->find();
|
|
|
+ if(empty($user_info)){
|
|
|
+ $this->error('不存在的用户');
|
|
|
+ }
|
|
|
+ $data['user_id'] = $user_info['id'];
|
|
|
+
|
|
|
+ //检查预约单
|
|
|
$map = ['id'=>$pre_order_id,'company_id'=>$this->auth->company_id,'pre_order_status'=>1];
|
|
|
$pre_order = Db::name('pre_order')->where($map)->find();
|
|
|
if(empty($pre_order)){
|
|
@@ -92,6 +124,15 @@ class Preorder extends Apic
|
|
|
Db::name('pre_order')->where('id',$pre_order_id)->update($update);
|
|
|
}else{
|
|
|
$data['pre_order_id'] = 0;
|
|
|
+
|
|
|
+ //检查用户
|
|
|
+ $user_info = Db::name('user')->where('mobile',$data['user_mobile'])->find();
|
|
|
+ if(empty($user_info)){
|
|
|
+ //注册用户,并添加新车,并加为我的客户
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $data['user_id'] = $user_info['id'];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//检索car_id,没必要了
|