getUserId(); $JsModel = new JsModel(); $js_info = $JsModel::where('user_id', $user_id)->find(); if ($js_info['id']) { $this->js_id = $js_info['id']; if ($js_info['js_status'] == 1) { $this->js_status = true; } } parent::initialize(); // TODO: Change the autogenerated stub } /** * 注销技师账户 * * @param [type] $mobile * @param [type] $product * @return void */ public function destroy() { $info = JsModel::get($this->js_id); $res = $info->delete(); $this->success('注销成功', $res); } /** * 向用户发送短信通知 * * @param [type] $mobile * @param [type] $product * @return void */ protected function sendMsg($mobile, $product) { $helper = new SignatureHelper(); $alisms = cmf_get_option('alisms'); $security = false; $accessKeyId = $alisms['access_key_id']; $accessKeySecret = $alisms['access_key_secret']; $js_mobile = $mobile; $params["PhoneNumbers"] = $js_mobile; $params["SignName"] = '嘀咚点到'; $params["TemplateCode"] = 'SMS_247620502'; $params['TemplateParam'] = array( "product" => $product, ); if (!empty($params["TemplateParam"]) && is_array($params["TemplateParam"])) { $params["TemplateParam"] = json_encode($params["TemplateParam"], JSON_UNESCAPED_UNICODE); } $content = $helper->request( $accessKeyId, $accessKeySecret, "dysmsapi.aliyuncs.com", array_merge($params, array( "RegionId" => "cn-hangzhou", "Action" => "SendSms", "Version" => "2017-05-25", )), $security ); } /** * 技师用户个人中心 */ public function getInfo() { if (!$this->js_id) { $this->error('认证信息不存在!'); } $info = JsModel::get($this->js_id); $info->score = get_js_score($this->js_id); $info->distributor_status = DistributorLogModel::where('user_id', $this->userId)->value('chuli_status'); $info->fenxiaoshang = DistributorModel::get(UserModel::get($this->userId)['agency_id'])['name']; $info = $info->toarray(); $info['js']['name'] = $info['name']; $info['js']['avatar'] = $info['avatar']; $this->success('ok', $info); } /** * 加载我的时间 */ public function getTime() { $user_id = $this->getUserId(); $JsModel = new JsModel(); $jsId = $JsModel::where('user_id', $user_id)->value('id'); $JsTimeModel = new JsTimeModel(); $list = $JsTimeModel::where('js_id', $jsId)->select(); $this->success('ok', $list); } /** * 添加我的时间 */ public function addTimePost() { $user_id = $this->getUserId(); $JsModel = new JsModel(); $data['js_id'] = $JsModel::where('user_id', $user_id)->value('id'); $data['times'] = $this->request->param('times/a'); $data['weeks'] = $this->request->param('week/a'); Db::name('js_time')->where('js_id', $data['js_id'])->delete(); $JsTimeModel = new JsTimeModel(); $JsTimeModel->allowField(true)->isUpdate(false)->save($data); $this->success('添加成功'); } /** * 更改上下钟 * @return void */ public function setWorkTime() { $user_id = $this->getUserId(); $is_work = $this->request->post('is_work'); $data['times'] = [0 => ['js_start_time' => '00:00', 'js_end_time' => '23:59']]; $data['weeks'] = ['1', '2', '3', '4', '5', '6', '0']; if (!$is_work) $data['times'] = []; $JsModel = new JsModel(); $js_id = $JsModel::where('user_id', $user_id)->value('id'); $JsTimeModel = new JsTimeModel(); $ret = $JsTimeModel->allowField(true)->isUpdate(true)->save($data, ['js_id' => $js_id]); $this->success($is_work ? '上钟成功' : '下钟成功', $ret); } /** * 获取技师地点 * @throws \think\Exception * @throws \think\exception\PDOException */ public function getPostSite() { $user_id = $this->getUserId(); $JsModel = new JsModel(); $jsId = $JsModel::where('user_id', $user_id)->value('id'); $res = ''; if ($jsId) { $id = Db::name('js_site')->where('js_id', $jsId)->value('id'); $res = Db::name('js_site')->where('id', $id)->find(); } $this->success('ok', $res); } /** * 更新技师地点 * @throws \think\Exception * @throws \think\exception\PDOException */ public function addPostSite() { $user_id = $this->getUserId(); $JsModel = new JsModel(); $jsId = $JsModel::where('user_id', $user_id)->value('id'); $lng = $this->request->param('long'); $lat = $this->request->param('lat'); $id = 0; $ret = 0; if ($jsId) { $id = Db::name('js_site')->where('js_id', $jsId)->value('id'); if ($id) { $ret = Db::name('js_site')->where('id', $id)->update(['lng' => $lng, 'lat' => $lat]); } else { $ret = Db::name('js_site')->where('id', $id)->insert(['lng' => $lng, 'lat' => $lat, 'js_id' => $jsId]); } } $this->success('定位成功', $ret); } /** * 技师申请项目 */ public function postProject() { if (!$this->js_status) { $this->error('您还没有认证技师!'); } $data['js_id'] = $this->js_id; $data['project_id'] = $this->request->param('project_id'); $info = Db::name('js_project_relevancy')->where($data)->field('id,status')->find(); if ($info) { if ($info['status'] == 0) { $this->error('您已申请该项目!'); } elseif ($info['status'] == 2) { $data['add_time'] = time(); Db::name('js_project_relevancy')->update(['status' => 0, 'id' => $info['id']]); $this->success('申请成功'); } } else { $data['add_time'] = time(); Db::name('js_project_relevancy')->insert($data); $this->success('申请成功'); } } /** * 技师编辑个人信息 */ public function editInfo() { $js_id = $this->js_id; $UserModel = new UserModel(); $mobile = $UserModel->where('id', $this->getUserId())->value('mobile'); // if (!$this->js_status) { // $this->error('认证暂未通过不可修改!'); // } $JsModel = new JsModel(); $serviceData = $JsModel->where('id', $js_id)->find(); $data['avatar'] = $this->request->param('avatar'); $data['name'] = $this->request->param('name'); $data['is_make'] = $this->request->param('is_make'); $data['is_real_time'] = $this->request->param('is_real_time'); $data['phone'] = $this->request->param('phone'); $data['phone'] = $data['phone'] ?: $mobile; $data['jianjie'] = $this->request->param('jianjie'); $sex = $this->request->param('sex'); if (isset($sex)) $data['sex'] = $sex; if ($serviceData['avatar'] != $data['avatar'] || $serviceData['name'] != $data['name'] || $serviceData['jianjie'] != $data['jianjie']) $data['js_status'] = 0; UserModel::where('id', $this->getUserId())->update(['avatar' => $data['avatar']]); $JsModel->allowField(true)->isUpdate(true)->save($data, ['id' => $js_id]); $this->success('修改成功'); } public function editPicture() { $js_id = $this->js_id; if (!$js_id) { $this->error('您还没有认证技师!'); } $data['work'] = $this->request->param('work/a'); // $data['massage'] = $this->request->param('massage/a'); $data['pictures'] = $this->request->param('pictures/a'); $data['js_status'] = 0; $JsModel = new JsModel(); $JsModel->allowField(true)->isUpdate(true)->save($data, ['id' => $js_id]); $this->success('修改成功'); } public function getPicture() { $JsModel = new JsModel(); $info = $JsModel::get($this->js_id); $res['work'] = $info->work; $res['pictures'] = $info->pictures; $this->success('ok', $res); } /** * 视频课程列表 */ public function getCourseList() { $name = $this->request->param('name'); $page = $this->request->param('page', 1); $JsProjectModel = new JsProjectModel(); $jsCourseModel = new JsCourseOrderModel(); $list = $JsProjectModel::with('tag')->where(function ($query) use ($name) { if ($name) { $query->where('name', 'like', '%' . $name . '%'); } })->field('id,name,brief,course_price,video_sl,video')->order('list_order', 'asc')->page($page, 20)->select()->each(function ($list) use ($jsCourseModel) { $list->video = cmf_get_image_preview_url($list->video); $list->video_sl = cmf_get_image_preview_url($list->video_sl); $course_order_status = $jsCourseModel::where(['user_id' => $this->getUserId(), 'project_id' => $list->id])->value('status'); $list->purchase = isset($course_order_status) ? $course_order_status : 0; }); $this->success('ok', $list); } /** *获取详情 */ public function getCourseInfo() { $id = $this->request->param('project_id'); $jsCourseModel = new JsCourseOrderModel(); $course_order_status = $jsCourseModel::where(['user_id' => $this->getUserId(), 'project_id' => $id])->value('status'); $JsProjectModel = new JsProjectModel(); $info = $JsProjectModel::where('id', $id)->field('id,try_minute,video,course_price')->find(); $info->purchase = isset($course_order_status) ? $course_order_status : 0; $info->video = cmf_get_image_preview_url($info->video); $this->success('ok', $info); } /** * 创建订单 */ public function addCourseOrder() { $id = $this->request->param('project_id'); $pay_price = $this->request->param('pay_price'); $jsCourseModel = new JsCourseOrderModel(); $data['project_id'] = $id; $data['pay_price'] = $pay_price; $data['order_sn'] = cmf_get_order_sn(); $data['user_id'] = $this->getUserId(); $jsCourseModel->allowField(true)->isUpdate(false)->save($data); $this->success('创建订单成功', $jsCourseModel->id); } /** * 支付订单 */ public function pay() { $id = $this->request->param('order_id'); $pay_type = $this->request->param('pay_type'); // 1视频支付 2 上传支付 switch ($pay_type) { case 'alipay'; $res = aly_pay($id, 1); if (!empty($res['return_code'])) { $this->error($res['return_msg']); } else { $this->success('ok', $res); } break; case 'wxpay'; $res = wx_pay($id, 1); if (!empty($res['return_code'])) { $this->error($res['return_msg']); } else { $this->success('ok', $res); } break; case 'balance'; $bool = balance_pay($id, 1); if ($bool === true) { $this->success('支付成功'); } else { $this->error($bool); } break; } } /** * 技师服务接单列表 */ public function getProjectOrderList() { $js_id = $this->js_id; if (!$js_id) { $this->error('您还没有认证技师!'); } $type = $this->request->param('type', 1); $page = $this->request->param('page', 1); $category_id = $this->request->param('category_id'); $js_order_ids = get_js_order_ids($js_id, $type, $page, $category_id, false); $js_site_info = Db::name('js_site')->where('js_id', $js_id)->find(); $JsOrderModel = new JsOrderModel(); $list = $JsOrderModel::with('project.tag')->where('id', 'in', $js_order_ids) ->order('id', 'desc')->select()->each(function ($list) use ($js_site_info) { $list->project->icon = cmf_get_image_preview_url($list->project->icon); $list->project->service = Db::name('js_project_service_relevancy')->where('id', $list['service_id'])->find(); $list['distance'] = GetDistance($js_site_info['lat'], $js_site_info['lng'], $list['lat'], $list['lng'], 2, 2);; return $list; }); $this->success('ok', $list); } /** * 技师服务抢单列表 */ public function getFastOrderList() { $js_id = $this->js_id; if (!$js_id) { $this->error('您还没有认证技师!'); } $type = $this->request->param('type', 1); $page = $this->request->param('page', 1); $category_id = $this->request->param('category_id'); $js_order_ids = get_js_order_ids($js_id, $type, $page, $category_id); $distance = cmf_get_option('distance')['distance']; $js_site_info = Db::name('js_site')->where('js_id', $js_id)->find(); $offset = $distance / 111; $lng_offset = [$js_site_info['lng'] - $offset, $js_site_info['lng'] + $offset]; $lat_offset = [$js_site_info['lat'] - $offset, $js_site_info['lat'] + $offset]; $JsOrderModel = new JsOrderModel(); $list = $JsOrderModel::with('project.tag')->where('id', 'in', $js_order_ids) ->whereBetween('lat', $lat_offset) ->whereBetween('lng', $lng_offset) ->order('id', 'desc')->select()->each(function ($list) use ($js_site_info) { $list->project->icon = cmf_get_image_preview_url($list->project->icon); $list->project->service = Db::name('js_project_service_relevancy')->where('id', $list['service_id'])->find(); $list['distance'] = GetDistance($js_site_info['lat'], $js_site_info['lng'], $list['lat'], $list['lng'], 2, 2);; return $list; }); $this->success('ok', $list); } /** * 技师屏蔽订单操作 */ public function addShield() { $id = $this->request->param('order_id'); if (!$this->js_id) { $this->error('您没有认证技师!'); } Db::name('js_shield_log')->insert(['order_id' => $id, 'js_id' => $this->js_id]); $this->success('操作成功'); } // /** // * 技师抢单列表 // */ // public function jsOrderList() // { // // $JsOrderModel = new JsOrderModel(); // $page = $this->request->param('page'); // $js_order_ids = get_js_order_ids($this->js_id,1,$page); // // $list = $JsOrderModel::with('project')->where('id','in',$js_order_ids)->select()->each(function ($list){ // $list->project->service = Db::name('js_project_service_relevancy')->where('id',$list['service_id'])->find(); // return $list; // }); // $this->success('ok',$list); // // } /** * 技师接单操作 */ public function jeidanPost() { $id = $this->request->param('order_id'); $js_id = $this->js_id; if (!$this->js_status) { $this->error('您技师认证暂未通过,不可抢单!'); } $JsOrderGrab = new JsOrderGrabModel(); $JsOrderModel = new JsOrderModel(); $js_order_id = $JsOrderModel::where('jiedan_js_id', $js_id)->where('status', 6)->value('id'); if ($js_order_id) { $this->error('您有订单未完成,请合理安排时间'); } $msg = '订单未支付!'; $info = $JsOrderGrab::where(['order_id' => $id, 'js_id' => $js_id])->find(); if ($info) { $msg = '您已报名参加抢单!'; $this->error($msg); } $order_info = $JsOrderModel::get($id); switch ($order_info['status']) { case 2: $msg = '订单已被抢!'; break; case 6: $msg = '服务中!'; break; case 3: $msg = '订单已完成!'; break; case 4: $msg = '订单已评价!'; break; case 5: $msg = '订单已取消!'; break; } if ($order_info['status'] != 1) { $this->error($msg); } else { if ($order_info['status'] == 1 && $order_info['jiedan_js_id']) { $result = $JsOrderModel->allowField(true)->isUpdate(true)->save(['jiedan_time' => time(), 'status' => 2], ['id' => $order_info['id']]); if ($result) { $mobile = $order_info->mobile; $order_sn = $order_info->order_sn; $this->sendMsg($mobile, $order_sn); } $this->success('接单成功'); } else { $JsOrderGrab->allowField(true)->isUpdate(false)->save(['js_id' => $js_id, 'order_id' => $id]); $this->success('抢单报名成功,等待客户选择'); } } } /** * 获取抢单数量 */ public function getJsOrdernum() { $js_id = $this->js_id; if (!$this->js_status) { $this->error('您还没有认证技师!'); } $category_id = $this->request->param('category_id'); $project_new_ids = []; $js_project_relevancy_where['js_id'] = $js_id; $js_project_relevancy_where['status'] = 1; if ($category_id) { $project_ids1 = Db::name('js_project_category_relevancy')->where('category_id', $category_id)->field('project_id')->select(); $project_ids2 = []; foreach ($project_ids1 as $vo) { $project_ids2[] = $vo['project_id']; } $js_project_relevancy_where['project_id'] = $project_ids2; } $project_ids = Db::name('js_project_relevancy')->where($js_project_relevancy_where)->field('project_id')->select(); $order_new_ids = []; $order_ids = Db::name('js_shield_log')->where('js_id', $js_id)->field('order_id')->select(); foreach ($order_ids as $vo) { $order_new_ids[] = $vo['order_id']; } foreach ($project_ids as $vo) { $project_new_ids[] = $vo['project_id']; } $distance = cmf_get_option('distance')['distance']; $js_site_info = Db::name('js_site')->where('js_id', $js_id)->find(); $offset = $distance / 111; $lng_offset = [$js_site_info['lng'] - $offset, $js_site_info['lng'] + $offset]; $lat_offset = [$js_site_info['lat'] - $offset, $js_site_info['lat'] + $offset]; $JsOrderModel = new JsOrderModel(); $order_coun = $JsOrderModel::where('project_id', 'in', $project_new_ids)->where(['jiedan_js_id' => 0, 'status' => 1]) ->where('id', 'not in', $order_new_ids) ->whereBetween('lat', $lat_offset) ->whereBetween('lng', $lng_offset) ->field('id,lat,lng')->count('id'); $this->success('ok', $order_coun); } /** * 获取接单数量 */ public function getOrdernum() { $js_id = $this->js_id; if (!$this->js_status) { $this->error('您还没有认证技师!'); } $order_refuse_ids = []; $order_ids = Db::name('js_shield_log')->where('js_id', $js_id)->field('order_id')->select(); foreach ($order_ids as $vo) { $order_refuse_ids[] = $vo['order_id']; } $JsOrderModel = new JsOrderModel(); $order_coun = $JsOrderModel->where(['jiedan_js_id' => $js_id])->where('status', [['eq', 1], ['eq', 2]], 'or')->where('id', 'not in', $order_refuse_ids)->count(); $this->success('ok', $order_coun); } /** * 技师开始服务 */ public function start() { $id = $this->request->param('order_id'); $JsOrderModel = new JsOrderModel(); $order_info = $JsOrderModel::where('order_sole', $id)->find(); if (!$order_info) { $this->error('订单不存在!'); } $js_id = $this->js_id; if ($order_info['jiedan_js_id'] != $js_id) { $this->error('接单人不是您,不可操作!'); } if ($order_info['status'] != 2) { $this->error('订单异常'); } else { $JsOrderModel->allowField(true)->isUpdate(true)->save(['start_time' => time(), 'status' => 6], ['id' => $order_info['id']]); $this->success('开始服务'); } } /** * 新增地址 */ public function addressPost() { $data['user_id'] = $this->getUserId(); $data['province'] = $this->request->param('province'); $data['city'] = $this->request->param('city'); $data['district'] = $this->request->param('district'); $data['address'] = $this->request->param('address'); $data['moren'] = $this->request->param('moren'); $data['name'] = $this->request->param('name'); $data['mobile'] = $this->request->param('mobile'); $id = $this->request->param('id'); if ($id) { if ($data['moren'] == 1) { Db::name('user_address')->where('user_id', $data['user_id'])->update(['moren' => 2]); } Db::name('user_address')->where('id', $id)->update($data); } else { if ($data['moren'] == 1) { Db::name('user_address')->where('user_id', $data['user_id'])->update(['moren' => 2]); } Db::name('user_address')->insert($data); } // $address_id = Db::name('user_address')->where(['user_id'=>$data['user_id'],'moren' =>1])->value('id'); // if(!$address_id){ // $data['moren'] = 1; // } $this->success('操作成功'); } public function getaddresslist() { $user_id = $this->getUserId(); $list = Db::name('user_address')->where('user_id', $user_id)->select(); $this->success('ok', $list); } public function getaddressinfo() { $id = $this->request->param('id'); $info = Db::name('user_address')->where('id', $id)->find(); $this->success('ok', $info); } public function addressDelete() { $id = $this->request->param('id'); Db::name('user_address')->where('id', $id)->delete(); $this->success('删除成功'); } /** * 技师报警 */ public function callPost() { $js_id = $this->js_id; if (!$this->js_status) { $this->error('您还没有认证技师!'); } $order_id = JsOrderModel::where('jiedan_js_id', $js_id)->where(function ($query) { $query->where('status', 2); $query->whereor('status', 6); })->value('id'); if ($order_id) { $order_sn = JsOrderModel::where('id', $order_id)->value('order_sn'); } if (!$order_id) { $order_id = JsOrderModel::where(['jiedan_js_id' => $js_id, 'status' => 3])->order('finish_time', 'desc')->value('id'); $order_sn = JsOrderModel::where('id', $order_id)->value('order_sn'); $finish_time = JsOrderModel::where(['jiedan_js_id' => $js_id, 'status' => 3, 'id' => $order_id])->value('finish_time'); $alarm_delay = $duration = cmf_get_option('duration')['alarm_delay']; if (($finish_time + $alarm_delay * 60) < time()) { $this->error('警报发送失败,没有服务中订单!'); } } if (!$order_id) { $this->error('警报发送失败,没有服务中订单!'); } $data['user_id'] = $this->getUserId(); $data['order_id'] = $order_id; $UserModel = new UserModel(); $user_city_id = $UserModel::get($this->getUserId())['city_id']; $user_district_id = $UserModel::get($this->getUserId())['district_id']; $city_agency_id = Db::name('agency')->where(['city_id' => $user_city_id, 'renk_id' => 1])->value('id'); $district_agency_id = Db::name('agency')->where(['district_id' => $user_district_id, 'renk_id' => 2])->value('id'); $JsCallModel = new JsCallModel(); $info = cmf_get_option('jspus'); $city_agency_user = $UserModel::where('agency_id', $city_agency_id)->field('id,user_type')->find(); $client = new Client($info['app_key'], $info['master_secret']); if ($city_agency_user) { if ($city_agency_user['user_type'] == 3) { $client = new Client($info['js_app_key'], $info['js_master_secret']); } $extras = [ 'id' => $this->getUserId(), 'flag' => '技师报警', ]; $array = [ 'extras' => $extras, ]; $alias = $city_agency_user['id'] . 'js'; $text = '订单号:' . $order_sn . '报警'; $platform = array('ios', 'android'); $client->push() ->setPlatform($platform) ->setNotificationAlert($text) ->iosNotification($text, $array) ->androidNotification($text, $array) ->addAlias("{$alias}") ->send(); } $district_agency_user = $UserModel::where('agency_id', $district_agency_id)->field('id,user_type')->find(); if ($district_agency_user) { if ($city_agency_user['user_type'] == 3) { $client = new Client($info['js_app_key'], $info['js_master_secret']); } $extras = [ 'id' => $this->getUserId(), 'flag' => '技师报警', ]; $array = [ 'extras' => $extras, ]; $alias = $district_agency_user['id'] . 'js'; $text = '订单号:' . $order_sn . '报警'; $platform = array('ios', 'android'); $client->push() ->setPlatform($platform) ->setNotificationAlert($text) ->iosNotification($text, $array) ->androidNotification($text, $array) ->addAlias("{$alias}") ->send(); } $JsCallModel->allowField(true)->isUpdate(false)->save($data); $this->success('警报发送成功'); } /** * @throws \think\Exception * @throws \think\exception\PDOException * 播放语音 */ public function play() { $js_id = $this->js_id; $id = JsOrderGrabModel::where(['js_id' => $js_id, 'status' => 1])->value('id'); if ($id) { JsOrderGrabModel::where('id', $id)->update(['status' => 2]); $this->success('播放'); } else { $this->error('已通知'); } } /** * @throws \think\Exception * @throws \think\exception\PDOException * 播放语音取消订单 */ public function cancelplay() { $js_id = $this->js_id; $id = JsOrderModel::where(['jiedan_js_id' => $js_id, 'status' => 5, 'order_status' => 2])->value('id'); if ($id) { JsOrderModel::where('id', $id)->update(['order_status' => 3]); $this->success('播放'); } else { $this->error('已通知'); } } /** * 技师删除i订单 */ public function deleteOrder() { $order_id = $this->request->param('order_id'); $JsOrderModel = new JsOrderModel(); $JsOrderModel::where('id', $order_id)->update(['js_delete' => 2]); $this->success('删除成功'); } /** * 项目分类下的订单数量 */ public function getClassifyOrderNum() { $js_id = $this->js_id; $js_site_info = Db::name('js_site')->where('js_id', $js_id)->find(); $distance = cmf_get_option('distance')['distance']; $JsProjectCategoryModel = new JsProjectCategoryModel(); //项目分类 $list = $JsProjectCategoryModel::where('is_show', 1)->order('list_order', 'desc')->field('id')->select()->each(function ($list) use ($js_id, $js_site_info, $distance) { $list['order_num'] = 0; $project_ids = Db::name('js_project_category_relevancy')->where('category_id', $list['id'])->field('project_id')->select(); $project_ids_new = []; foreach ($project_ids as $v) { $js_project_relevancy_id = Db::name('js_project_relevancy')->where(['project_id' => $v['project_id'], 'js_id' => $js_id, 'status' => 1])->value('id'); if ($js_project_relevancy_id) { if (!in_array($v['project_id'], $project_ids_new)) { array_push($project_ids_new, $v['project_id']); } } } if ($project_ids_new) { $offset = $distance / 111; $lng_offset = [$js_site_info['lng'] - $offset, $js_site_info['lng'] + $offset]; $lat_offset = [$js_site_info['lat'] - $offset, $js_site_info['lat'] + $offset]; $order_list = JsOrderModel::where('project_id', 'in', $project_ids_new)->where('status', 1) ->whereBetween('lat', $lat_offset) ->whereBetween('lng', $lng_offset) ->where('jiedan_js_id', 0)->field('id,lat,lng') ->count(); // ->select(); $list['order_num'] = $order_list; // foreach ($order_list as $value) { // $distance1 = GetDistance($value['lat'], $value['lng'], $js_site_info['lat'], $js_site_info['lng'], 2, 2);//value['lat'],/$value['lng'],$js_site_info['lat'],$js_site_info['lng'],2,2); // if ($distance >= $distance1) { // $list['order_num'] += 1; // } // } // $list['order_num'] = JsOrderModel::where('project_id', 'in', $project_ids_new)->where('status', 1)->where('jiedan_js_id', 0)->count(); } return $list; }); $this->success('ok', $list); } /** * 技师带接单数量 */ public function getOrdeNum() { $js_id = $this->js_id; $order_ids = Db::name('js_shield_log')->where('js_id', $js_id)->field('order_id')->select(); $order_new_ids = []; foreach ($order_ids as $vo) { $order_new_ids[] = $vo['order_id']; } $num = JsOrderModel::where(['status' => 1, 'jiedan_js_id' => $js_id])->where('id', 'not in', $order_new_ids)->count(); $this->success('ok', $num); } }