model = new Order(); $this->refund_order_model = new RefundOrder(); $this->comment_model = new Comment(); $this->admin_info = $this->adminInfo(); if(empty($this->admin_info)){ $this->errorMsg('你还不是代理商'); } } /** * @author chenniang * @DataTime: 2023-04-20 11:44 * @功能说明:获取当前用户的角色权限 */ public function adminInfo(){ $admin_model = new Admin(); $dis = [ 'user_id' => $this->getUserId(), 'status' => 1 ]; $data = $admin_model->dataInfo($dis); if(!empty($data)){ $data['admin_arr'] = $admin_model->getAdminId($data); } return $data; } /** * @author chenniang * @DataTime: 2023-04-20 11:54 * @功能说明:首页各项数据统计 */ public function index(){ //订单管理各类状态 $order_type = [2,3,4,5,6,7]; $dis = [ 'uniacid' => $this->_uniacid, 'is_add' => 0, ]; //订单数据 foreach ($order_type as $value){ $data['order_count'][$value] = $this->model->where($dis)->where('admin_id','in',$this->admin_info['admin_arr'])->where(['pay_type'=>$value])->count(); } //拒单 $data['refuse_order'][8] = $this->model->where($dis)->where('admin_id','in',$this->admin_info['admin_arr'])->where(['pay_type'=>8])->count(); //加钟服务 $dis['is_add'] = 1; $order_type = [2,3,6,7]; //订单数据 foreach ($order_type as $value){ if($value==6){ $data['add_count'][$value] = $this->model->where($dis)->where('admin_id','in',$this->admin_info['admin_arr'])->where('pay_type','in',[4,5,6])->count(); }else{ $data['add_count'][$value] = $this->model->where($dis)->where('admin_id','in',$this->admin_info['admin_arr'])->where(['pay_type'=>$value])->count(); } } $order_type = [1]; //加钟退款 foreach ($order_type as $value){ $data['add_refund_count'][$value] = $this->refund_order_model->where($dis)->where('admin_id','in',$this->admin_info['admin_arr'])->where(['status'=>$value])->count(); } $dis['is_add'] = 0; //退款 foreach ($order_type as $value){ $data['refund_count'][$value] = $this->refund_order_model->where($dis)->where('admin_id','in',$this->admin_info['admin_arr'])->where(['status'=>$value])->count(); } //是否具有邀请业务员的权限 $data['salesman_auth'] = $this->admin_info['salesman_auth']; //是否有邀请渠道商的权限 $data['channel_auth'] = $this->admin_info['channel_auth']; $comm_model = new Commission(); $dis = [ 'admin_id' => $this->admin_info['id'], 'status' => 1, ]; //未入账金额 $data['unrecorded_cash'] = $comm_model->where($dis)->where('admin_id','in',$this->admin_info['admin_arr'])->where('type','in',[2,5,6])->sum('cash'); $dis['status'] = 2; //总金额 $data['total_cash'] = $comm_model->where($dis)->where('admin_id','in',$this->admin_info['admin_arr'])->where('type','in',[2,5,6])->sum('cash'); $data['cash'] = $this->admin_info['cash']; $data['unrecorded_cash'] = round($data['unrecorded_cash'],2); $data['total_cash'] = round($data['total_cash'],2); $data['cash'] = round($data['cash'],2); //通知 $notice_model = new NoticeList(); //列表 $data = $notice_model->indexOrderNotice($data,$this->_uniacid,$this->admin_info['admin_arr']); return $this->success($data); } /** * @author chenniang * @DataTime: 2021-03-15 14:43 * @功能说明:列表 */ public function orderList(){ $input = $this->_param; $is_add = isset($input['is_add'])?$input['is_add']:0; $dis[] = ['uniacid','=',$this->_uniacid]; $dis[] = ['is_add','=',$is_add]; $dis[] = ['admin_id','in',$this->admin_info['admin_arr']]; if(!empty($input['pay_type'])){ $dis[] = ['pay_type','=',$input['pay_type']]; }else{ $dis[] = ['pay_type','>',1]; } //订单号搜索 if(!empty($input['order_code'])){ $dis[] = ['order_code','like','%'.$input['order_code'].'%']; } $data = $this->model->where($dis)->field('id,coach_id,store_id,is_comment,order_code,true_car_price,true_service_price,pay_type,pay_price,start_time,create_time,user_id,end_time,add_pid,is_add')->order('id desc')->paginate(10)->toArray(); if(!empty($data['data'])){ foreach ($data['data'] as &$v){ $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); $v['start_time'] = date('Y-m-d H:i',$v['start_time']); $v['end_time'] = date('Y-m-d H:i',$v['end_time']); } } return $this->success($data); } /** * @author chenniang * @DataTime: 2021-03-15 14:58 * @功能说明:订单详情 */ public function orderInfo(){ $input = $this->_param; $dis = [ 'id' => $input['id'] ]; $data = $this->model->dataInfo($dis); $data['distance'] = distance_text($data['distance']); //加钟订单 if($data['is_add']==0){ $data['add_order_id'] = $this->model->where(['add_pid'=>$data['id']])->where('pay_type','>',1)->field('id,order_code')->select()->toArray(); }else{ $data['add_pid'] = $this->model->where(['id'=>$data['add_pid']])->field('id,order_code')->find(); } $order_model = new OrderData(); //订单附表 $order_data = $order_model->dataInfo(['order_id'=>$input['id'],'uniacid'=>$this->_uniacid]); $data = array_merge($order_data,$data); //订单转派记录 $change_log_model = new CoachChangeLog(); $data['dispatch_record'] = $change_log_model->orderChangeLog($input['id']); $admin_model = new \app\massage\model\Admin(); $data['admin_name'] = $admin_model->where(['id'=>$data['admin_id']])->value('agent_name'); //门店订单 if(!empty($data['store_id'])){ $store_model = new StoreList(); $data['store_info'] = $store_model->where(['id'=>$data['store_id']])->field('title,cover,address,lng,lat,phone')->find(); } $arr = ['create_time','pay_time','serout_time','arrive_time','receiving_time','start_service_time','order_end_time']; foreach ($arr as $value){ $data[$value] = !empty($data[$value])?date('Y-m-d H:i:s',$data[$value]):0; } $data['start_time'] = date('Y-m-d H:i',$data['start_time']).'-'.date('H:i',$data['end_time']); return $this->success($data); } /** * @author chenniang * @DataTime: 2021-03-19 17:50 * @功能说明:退款订单详情 */ public function refundOrderInfo(){ $input = $this->_param; $dis = [ 'id' => $input['id'] ]; $data = $this->refund_order_model->dataInfo($dis); $data['pay_order_code'] = $this->model->where(['id'=>$data['order_id']])->value('order_code'); $data['create_time'] = date('Y-m-d H:i:s',$data['create_time']); $data['refund_time'] = !empty($data['refund_time'])?date('Y-m-d H:i:s',$data['refund_time']):""; $pay_order = $this->model->dataInfo(['id'=>$data['order_id']]); $data['car_type'] = $pay_order['car_type']; $data['distance'] = distance_text($pay_order['distance']); $data['pay_car_price'] = $pay_order['car_price']; $admin_model = new \app\massage\model\Admin(); $data['admin_name'] = $admin_model->where(['id'=>$data['admin_id']])->value('agent_name'); $data['store_id'] = $pay_order['store_id']; //门店订单 if(!empty($pay_order['store_id'])){ $store_model = new StoreList(); $data['store_info'] = $store_model->where(['id'=>$pay_order['store_id']])->field('title,cover,address,lng,lat,phone')->find(); } return $this->success($data); } /** * @author chenniang * @DataTime: 2021-03-17 17:44 * @功能说明:退款订单列表 */ public function refundOrderList(){ $input = $this->_param; $dis[] = ['a.uniacid','=',$this->_uniacid]; //订单状态搜索 if(!empty($input['status'])){ $dis[] = ['a.status','=',$input['status']]; }else{ $dis[] = ['a.status','>',-1]; } $dis[] = ['d.admin_id','in',$this->admin_info['admin_arr']]; if(!empty($input['order_code'])){ $dis[] = ['a.order_code','like','%'.$input['order_code'].'%']; } $is_add = !empty($input['is_add'])?$input['is_add']:0; $dis[] = ['a.is_add','=',$is_add]; $data = $this->refund_order_model->indexAdminDataList($dis); return $this->success($data); } /** * @author chenniang * @DataTime: 2021-03-18 09:21 * @功能说明:拒绝退款 */ public function noPassRefund(){ $input = $this->_input; $res = $this->refund_order_model->noPassRefund($input['id'],$this->getUserId()); if(!empty($res['code'])){ $this->errorMsg($res['msg']); } return $this->success($res); } /**\ * @author chenniang * @DataTime: 2021-03-18 09:28 * @功能说明:同意退款 */ public function passRefund(){ $input = $this->_input; $order = $this->refund_order_model->dataInfo(['id'=>$input['id']]); $is_app= $this->model->where(['id'=>$order['order_id']])->value('app_pay'); $res = $this->refund_order_model->passOrder($input['id'],$input['price'],$this->payConfig($is_app),$this->getUserId(),$input['text']); if(!empty($res['code'])){ $this->errorMsg($res['msg']); } return $this->success($res); } /** * @author chenniang * @DataTime: 2022-12-15 11:34 * @功能说明:订单升级记录 */ public function orderUpRecord(){ $input = $this->_param; $order_model = new UpOrderList(); $data = $order_model->orderUpRecord($input['order_id']); return $this->success($data); } /** * @author chenniang * @DataTime: 2021-07-11 22:34 * @功能说明:技师修改订单信息) */ public function adminUpdateOrder() { $input = $this->_input; $order = $this->model->dataInfo(['id' => $input['order_id']]); $update = $this->model->coachOrdertext($input,1); $refund_model = new RefundOrder(); //判断有无申请中的退款订单 $refund_order = $refund_model->dataInfo(['order_id' => $order['id'], 'status' => 1]); if (!empty($refund_order)) { $this->errorMsg('该订单正在申请退款,请先联系平台处理再进行下一步'); } if($order['pay_type']<1){ $this->errorMsg('订单已被取消'); } Db::startTrans(); if($input['type']==7){ if ($order['pay_type'] != 6&&!empty($order['coach_id'])) { $this->errorMsg('订单状态错误'); } $this->model->hxOrder($order); }elseif ($input['type'] == -1){ if ($order['pay_price'] > 0&&$order['pay_type']>1) { $refund_model = new RefundOrder(); $res = $refund_model->refundCash($this->payConfig($order['app_pay']), $order, $order['pay_price']); if (!empty($res['code'])) { Db::rollback(); $this->errorMsg($res['msg']); } if ($res != true) { Db::rollback(); $this->errorMsg('退款失败,请重试2'); } } //取消订单 $res = $this->model->cancelOrder($order); if (!empty($res['code'])) { Db::rollback(); $this->errorMsg($res['msg']); } } $this->model->dataUpdate(['id' => $input['order_id']], $update); $log_model = new OrderLog(); $log_model->addLog($input['order_id'],$this->_uniacid,$input['type'],$order['pay_type'],1,$this->getUserId()); Db::commit(); return $this->success(true); } /** * @author chenniang * @DataTime: 2023-02-27 14:52 * @功能说明:订单更换技师 */ public function orderChangeCoach(){ $input = $this->_input; $refund_model = new RefundOrder(); //判断有无申请中的退款订单 $refund_order = $refund_model->dataInfo(['order_id' => $input['order_id'], 'status' => 1]); if (!empty($refund_order)) { $this->errorMsg('该订单正在申请退款,请先处理再进行下一步'); } $success_add_order = $this->model->dataInfo(['add_pid'=>$input['order_id'],'pay_type'=>7]); if(!empty($success_add_order)){ $this->errorMsg('该订单加钟订单已经完成,无法转单'); } $order = $this->model->dataInfo(['id'=>$input['order_id']]); $change_model = new CoachChangeLog(); $coach_name = !empty($input['coach_name'])?$input['coach_name']:''; $text = !empty($input['text'])?$input['text']:''; $phone = !empty($input['mobile'])?$input['mobile']:''; $admin_id = !empty($input['admin_id'])?$input['admin_id']:0; $res = $change_model->orderChangeCoach($order,$input['coach_id'],$this->_user['id'],$admin_id,$coach_name,$text,$phone); if (!empty($res['code'])) { $this->errorMsg($res['msg']); } return $this->success($res); } /** * @author chenniang * @DataTime: 2023-02-28 14:21 * @功能说明:订单转派技师列表 */ public function orderChangeCoachList(){ $input = $this->_param; $coach_model = new Coach(); $order = $this->model->dataInfo(['id'=>$input['order_id']]); //获取订单里想关联服务的技师 $coach_id = $coach_model->getOrderServiceCoach($order); $dis[] = ['uniacid','=',$this->_uniacid]; $dis[] = ['status','=',2]; $dis[] = ['id','in',$coach_id]; $dis[] = ['id','<>',$order['coach_id']]; $dis[] = ['is_work','=',1]; $dis[] = ['user_id','>',0]; $dis[] = ['admin_id','in',$this->admin_info['admin_arr']]; if(!empty($input['coach_name'])){ $dis[] = ['coach_name','like','%'.$input['coach_name'].'%']; } //门店订单 只能转同门店的技师 if(!empty($order['store_id'])){ $dis[] = ['store_id','=',$order['store_id']]; } $list = $coach_model->where($dis)->select()->toArray(); $log_model = new CoachChangeLog(); //转派技师时候 获取满足条件的技师 并获取最近的服务时间 $arr = $log_model->getNearTimeCoach($order,$list); $top = !empty($input['type'])&&$input['type']==1?'distance asc,id desc':'near_time asc,id desc'; $lat = $order['address_info']['lat']; $lng = $order['address_info']['lng']; $alh = 'ACOS(SIN(('.$lat.' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS(('.$lat.' * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS(('.$lng.' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6378.137*1000 as distance'; $data = $coach_model->where('id','in',$arr)->field(['*', $alh])->order($top)->paginate(10)->toArray(); if(!empty($data['data'])){ $admin_model = new \app\massage\model\Admin(); $user_model = new User(); foreach ($data['data'] as &$v){ $v['partner_name'] = $user_model->where(['id'=>$v['partner_id']])->value('nickName'); $v['near_time'] = date('m-d H:i',$v['near_time']); $v['admin_info']= $admin_model->where(['id'=>$v['admin_id']])->field('city_type,agent_name as username')->find(); } } return $this->success($data); } /** * @author chenniang * @DataTime: 2021-07-16 10:28 * @功能说明: */ public function noticeUpdate(){ $input = $this->_input; $notice_model = new NoticeList(); $data = $notice_model->dataUpdate(['id'=>$input['id']],$input); return $this->success($data); } /** * @author chenniang * @DataTime: 2021-03-24 13:33 * @功能说明:团长审核提现 */ public function applyWallet(){ $input = $this->_input; if(empty($input['apply_price'])||$input['apply_price']<0.01){ $this->errorMsg('提现费最低一分'); } $admin_model = new Admin(); $admin_user = $admin_model->dataInfo(['id'=>$this->admin_info['id']]); //服务费 if($input['apply_price']>$admin_user['cash']){ $this->errorMsg('余额不足'); } //获取税点 $tax_point = getConfigSetting($this->_uniacid,'tax_point'); $balance = 100-$tax_point; $key = 'cap_wallets'.$this->admin_info['id']; incCache($key,1,$this->_uniacid); $value = getCache($key,$this->_uniacid); if($value!=1){ //减掉 delCache($key,$this->_uniacid); $this->errorMsg('网络错误,请刷新重试'); } Db::startTrans(); //减佣金 $res = $admin_model->dataUpdate(['id'=>$this->admin_info['id'],'lock'=>$admin_user['lock']],['cash'=>$admin_user['cash']-$input['apply_price'],'lock'=>$admin_user['lock']+1]); if($res!=1){ Db::rollback(); //减掉 delCache($key,$this->_uniacid); $this->errorMsg('申请失败'); } $insert = [ 'uniacid' => $this->_uniacid, 'user_id' => $admin_user['id'], 'admin_id' => $admin_user['id'], 'coach_id' => 0, 'total_price' => $input['apply_price'], 'balance' => $balance, 'apply_price' => round($input['apply_price']*$balance/100,2), 'service_price' => round( $input['apply_price'] * $tax_point / 100, 2), 'tax_point' => $tax_point, 'code' => orderCode(), 'text' => !empty($input['text'])?$input['text']:'', 'type' => 3, 'chikaren' => !empty($input['chikaren'])?$input['chikaren']:'', 'kaihuhang' => !empty($input['kaihuhang'])?$input['kaihuhang']:'', 'suoshuzhihang' => !empty($input['suoshuzhihang'])?$input['suoshuzhihang']:'', 'yinhangkahao' => !empty($input['yinhangkahao'])?$input['yinhangkahao']:'', ]; $wallet_model = new Wallet(); //提交审核 $res = $wallet_model->dataAdd($insert); if($res!=1){ Db::rollback(); //减掉 delCache($key,$this->_uniacid); $this->errorMsg('申请失败'); } Db::commit(); //减掉 delCache($key,$this->_uniacid); return $this->success($res); } /** * @author chenniang * @DataTime: 2021-07-07 18:46 * @功能说明:提现列表 */ public function walletList(){ $input = $this->_param; $dis[] = ['a.uniacid','=',$this->_uniacid]; $dis[] = ['a.type','=',3]; $dis[] = ['a.admin_id','=',$this->admin_info['id']]; if(!empty($input['code'])){ $dis[] = ['a.code','like','%'.$input['code'].'%']; } if(!empty($input['status'])){ $dis[] = ['a.status','=',$input['status']]; } $wallet_model = new Wallet(); $data = $wallet_model->adminList($dis); $admin_model = new Admin(); if(!empty($data['data'])){ foreach ($data['data'] as &$v){ $v['create_time']= date('Y-m-d H:i:s',$v['create_time']); $v['coach_name'] = $admin_model->where(['id'=>$v['user_id']])->value('agent_name'); } } //累计提现 $data['extract_total_price'] = $wallet_model->adminCash($this->admin_info['id'],2); return $this->success($data); } /** * @author chenniang * @DataTime: 2022-12-09 15:18 * @功能说明:技师获取客户虚拟电话 */ public function getVirtualPhone(){ $input = $this->_param; $order_model = new Order(); $user_model = new User(); $order = $order_model->dataInfo(['id'=>$input['order_id']]); $called = new \app\virtual\model\Config(); $phone = $user_model->where(['id'=>$this->getUserId()])->value('phone'); if(empty($phone)){ $res = $order['address_info']['mobile']; }else{ $res = $called->getVirtual($order,1,$phone); } return $this->success($res); } /** * @author chenniang * @DataTime: 2021-03-15 14:43 * @功能说明:列表 */ public function coachList(){ $input = $this->_param; $dis[] = ['uniacid','=',$this->_uniacid]; if(!empty($input['status'])){ $dis[] = ['status','=',$input['status']]; }else{ $dis[] = ['status','>',-1]; } $dis[] = ['admin_id','in',$this->admin_info['admin_arr']]; $where = []; if(!empty($input['name'])){ $where[] = ['coach_name','like','%'.$input['name'].'%']; $where[] = ['mobile','like','%'.$input['name'].'%']; } $coach_model = new Coach(); $data = $coach_model->dataList($dis,10,$where,'id,admin_id,user_id,coach_name,work_img,mobile,create_time,status,auth_status'); if(!empty($data['data'])){ $admin_model = new Admin(); $user_model = new User(); foreach ($data['data'] as &$v){ $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); $admin_info = $admin_model->dataInfo(['id'=>$v['admin_id'],'status'=>1],'agent_name,city_type'); $v['admin_name'] = !empty($admin_info)?$admin_info['agent_name']:''; $v['city_type'] = !empty($admin_info)?$admin_info['city_type']:''; $v['nickName'] = $user_model->where(['id'=>$v['user_id']])->value('nickName'); } } $list = [ 1=>'ing', ]; foreach ($list as $k=> $value){ $dis_s = []; $dis_s[] = ['uniacid','=',$this->_uniacid]; $dis_s[] = ['status','=',$k]; $dis_s[] = ['admin_id','in',$this->admin_info['admin_arr']]; $data[$value] = $coach_model->where($dis_s)->count(); } return $this->success($data); } /** * @author chenniang * @DataTime: 2023-04-26 10:21 * @功能说明:佣金信息 */ public function commList(){ $input = $this->_param; $comm_model = new Commission(); //获取所有与自己相关的订单 $order_id = $comm_model->where('status','>',-1)->where('top_id','=',$this->admin_info['id'])->where('type','in',[2,5,6])->column('order_id'); $dis[] = ['uniacid','=',$this->_uniacid]; $dis[] = ['id','in',$order_id]; $dis[] = ['pay_type','>',1]; if(!empty($input['start_time'])){ $dis[] = ['create_time','between',"{$input['start_time']},{$input['end_time']}"]; } if(isset($input['have_tx'])){ $dis[] = ['have_tx','=',$input['have_tx']]; } $order_model = new Order(); $month = !empty($input['month'])?$input['month']:''; $data = $order_model->adminCashList($dis,10,$month); if(!empty($data['data'])){ foreach ($data['data'] as &$v){ $v['month'] = date('Y-m',$v['create_time']); $v['start_time'] = date('Y-m-d H:i',$v['start_time']); $v['create_time'] = date('Y-m-d H:i',$v['create_time']); //查询当前订单的时候 自己属于什么等级的代理商 $v['my_city_type'] = $comm_model->where(['order_id'=>$v['id'],'admin_id'=>$this->admin_info['id']])->where('type','in',[2,5,6])->where('status','>',-1)->value('city_type'); //代理商佣金信息 $v['admin_cash_list'] = $comm_model->where(['order_id'=>$v['id']])->where('admin_id','in',$this->admin_info['admin_arr'])->where('type','in',[2,5,6])->where('status','>',-1)->field('cash,city_type')->select()->toArray(); //获取当前月份所有与自己相关的订单 $order_id = $order_model->where($dis)->whereMonth('create_time',$v['month'])->column('id'); //查询当前月份的佣金 $v['total_cash'] = $comm_model->where('order_id','in',$order_id)->where('type','in',[2,5,6])->where(['admin_id'=>$this->admin_info['id']])->sum('cash'); $v['total_cash'] = round($v['total_cash'],2); } } $data['city_type'] = $this->admin_info['city_type']; return $this->success($data); } /** * @author chenniang * @DataTime: 2022-06-22 21:30 * @功能说明:加盟商下拉框 */ public function adminSelect(){ $input = $this->_param; $dis = [ 'is_admin' => 0, 'status' => 1, 'uniacid' => $this->_uniacid ]; $where[] = ['id','in',$this->admin_info['admin_arr']]; $admin_model = new Admin(); $data = $admin_model->where($dis)->where($where)->field('id,username,agent_name')->select()->toArray(); return $this->success($data); } /** * @author chenniang * @DataTime: 2023-05-04 16:28 * @功能说明:代理商详情 */ public function adminInfoData(){ $data = $this->admin_info; $city_model = new City(); $admin_model= new Admin(); $data['city_name'] = $city_model->where(['id'=>$data['city_id']])->value('title'); $data['sub_data'] = $admin_model->where(['admin_pid'=>$data['id'],'status'=>1])->field('id,username,agent_name,passwd_text,city_id,city_type')->select()->toArray(); if(!empty($data['sub_data'])){ foreach ($data['sub_data'] as &$v){ $v['city_name'] = $city_model->where(['id'=>$v['city_id']])->value('title'); } } $where[] = ['id','=',$data['admin_pid']]; $where[] = ['status','=',1]; //上级 $data['top_data'] = $admin_model->dataInfo($where,'id,username,agent_name,passwd_text,city_id,city_type'); if(!empty($data['top_data'])){ $data['top_data']['city_name'] = $city_model->where(['id'=>$data['top_data']['city_id']])->value('title'); } return $this->success($data); } /** * @author chenniang * @DataTime: 2021-03-22 13:35 * @功能说明:申请技师 */ public function coachApply(){ $input = $this->_input; $coach_model = new Coach(); //后台添加 $input['admin_add'] = 1; $res = $coach_model->coachApply($input,$input['user_id'],$this->_uniacid,$this->admin_info['id']); if(!empty($res['code'])){ $this->errorMsg($res['msg']); } return $this->success($res); } /** * @author chenniang * @DataTime: 2021-09-22 15:19 * @功能说明:团长用户列表 */ public function coachUserList(){ $input = $this->_param; if(empty($input['nickName'])){ $where[] = ['id','=',-1]; } $dis[] = ['uniacid','=',$this->_uniacid]; $dis[] = ['status','in',[0,1,2,3]]; $coach_model = new Coach(); $user_id = $coach_model->where($dis)->column('user_id'); $where1 = []; if(!empty($input['nickName'])){ $where1[] = ['nickName','like','%'.$input['nickName'].'%']; $where1[] = ['phone','like','%'.$input['nickName'].'%']; } $user_model = new User(); $where[] = ['uniacid','=',$this->_uniacid]; $where[] = ['id','not in',$user_id]; $list = $user_model->dataList($where,$input['limit'],$where1,'id,nickName,avatarUrl,phone'); return $this->success($list); } /** * @author chenniang * @DataTime: 2021-03-15 14:58 * @功能说明:订单详情 */ public function coachInfo(){ $input = $this->_param; $dis = [ 'id' => $input['id'] ]; $coach_model = new Coach(); $data = $coach_model->dataInfo($dis); $user_model = new User(); $city_model = new City(); $store_model= new StoreList(); $data['nickName'] = $user_model->where(['id'=>$data['user_id']])->value('nickName'); $data['city'] = $city_model->where(['id'=>$data['city_id']])->value('title'); $data['order_num'] = $coach_model->where(['id' => $data['id']])->value('order_num'); //绑定门店 if(!empty($data['store_id'])){ $data['store_name'] = $store_model->where(['id'=>$data['store_id']])->value('title'); } $record_model= new FddAgreementRecord(); $dis = [ 'user_id' => $data['user_id'], 'status' => 3, 'admin_id'=> $data['admin_id'] ]; //法大大合同 $data['fdd_agreement'] = $record_model->where($dis)->field('id,download_url,viewpdf_url,end_time')->order('id desc')->find(); return $this->success($data); } /** * @author chenniang * @DataTime: 2023-05-05 13:52 * @功能说明:代理商绑定码 */ public function agentInviteQr(){ $input = $this->_param; $key = 'channel_qr'.$this->admin_info['id'].'-'.$this->is_app.'-'.$input['type']; $qr = getCache($key,$this->_uniacid); if(empty($qr)){ //小程序 if($this->is_app==0){ $user_model = new User(); $input['page'] = $input['type']==1?'user/pages/channel/apply':'user/pages/salesman/apply'; $input['admin_id'] = $this->admin_info['id']; //获取二维码 $qr = $user_model->orderQr($input,$this->_uniacid); }else{ if($input['type']==1){ $page = 'https://'.$_SERVER['HTTP_HOST'].'/h5/#/user/pages/channel/apply?admin_id='.$this->admin_info['id']; }else{ $page = 'https://'.$_SERVER['HTTP_HOST'].'/h5/#/user/pages/salesman/apply?admin_id='.$this->admin_info['id']; } $qr = base64ToPng(getCode($this->_uniacid,$page)); } setCache($key,$qr,86400,$this->_uniacid); } $qr = !empty($qr)?$qr:'https://'.$_SERVER['HTTP_HOST'].'/favicon.ico'; return $this->success($qr); } /** * @author chenniang * @DataTime: 2021-07-03 00:15 * @功能说明:编辑技师 */ public function coachDataUpdate(){ $input = $this->_input; $coach_model = new Coach(); if(!empty($input['user_id'])){ $cap_dis[] = ['user_id','=',$input['user_id']]; $cap_dis[] = ['status','>',-1]; if(!empty($input['id'])){ $cap_dis[] = ['id','<>',$input['id']]; } $cap_info = $coach_model->dataInfo($cap_dis); if(empty($input['id'])&&!empty($cap_info)&&in_array($cap_info['status'],[1,2,3])){ $this->errorMsg('已经申请过技师了,'); } }else{ $wehre[] = ['mobile','=',$input['mobile']]; $wehre[] = ['status','>',-1]; if(!empty($input['id'])){ $wehre[] = ['id','<>',$input['id']]; } $find = $coach_model->where($wehre)->find(); if(!empty($find)){ $this->errorMsg('该电话号码已经注册技师'); } } $input['id_card'] = !empty($input['id_card'])?implode(',',$input['id_card']):''; $input['license'] = !empty($input['license'])?implode(',',$input['license']):''; $input['self_img'] = !empty($input['self_img'])?implode(',',$input['self_img']):''; $res = $coach_model->dataUpdate(['id'=>$input['id']],$input); return $this->success($res); } /** * @author chenniang * @DataTime: 2023-03-28 15:48 * @功能说明:门店下拉框 */ public function storeSelect(){ $input = $this->_param; $dis[] = ['uniacid','=',$this->_uniacid]; $dis[] = ['status','=',1]; if(!empty($input['title'])){ $dis[] = ['title','like','%'.$input['title'].'%']; } $dis[] = ['admin_id','=',$this->admin_info['id']]; $store_model = new \app\store\model\StoreList(); $data = $store_model->where($dis)->select()->toArray(); return $this->success($data); } }