request()->employee->root_id, 'type' => 'yhuatong'])->find(); View::assign('data', $setting); return View::fetch(); } /** * 云话统余额 * * @return String */ public function balence() { // 获取配置 $setting = OutCallSetting::where(['root_id' => request()->employee->root_id, 'type' => 'yhuatong'])->find(); if (empty($setting)) return json(['code' => 0, 'data' => '暂无']); $outCall = new CallYhuatong($setting->config['appid'], $setting->config['secretKey']); $rs = $outCall->balance(); if ($rs['code'] != 10000) return json(['code' => 0, 'data' => $rs['msg']]); return json(['code' => 0, 'data' => $rs['data']['balance']]); } /** * 云话统配置 * * @return String */ public function settingSave() { // 单个企业只能设置一种外呼系统 $setting = OutCallSetting::where(['root_id' => request()->employee->root_id])->findOrEmpty(); if ($setting->isEmpty()) { $setting = new OutCallSetting; } elseif ($setting->type != 'yhuatong') { $setting->delete(); $setting = new OutCallSetting; } $param = request()->only(['appid', 'secretKey', 'tel_x']); // 行业获取 $outCall = new CallYhuatong($param['appid'], $param['secretKey']); $industryData = $outCall->comIndustryList(); $param['industry'] = $industryData['data']; $data = [ 'config' => $param, 'root_id' => request()->employee->root_id, 'type' => 'yhuatong' ]; $rs = $setting->save($data); if (!$rs) return json(['code' => 1, 'msg' => '保存失败']); return json(['code' => 0, 'msg' => '保存成功']); } }