5 Commits

Author SHA1 Message Date
lcc e803408e82 修改客户和订单 2024-09-26 17:48:07 +08:00
小鱼开发 e480d2e43b 923 2024-09-23 11:29:33 +08:00
lcc 4f4a873781 修改后台云信号码分配 2024-09-04 15:13:37 +08:00
lcc a6dc8037bf 增加晓致虚拟电话 2024-09-04 15:13:37 +08:00
lcc 9e0385630c 修改客户品牌 2024-09-02 18:07:15 +08:00
24 changed files with 1154 additions and 45 deletions
+9 -6
View File
@@ -833,6 +833,7 @@ class Common extends CI_Controller
public function bind_mobile()
{
$this->load->model('sys/sys_admin_model');
$this->load->model('sys/sys_yx_mobiles_model');
$params = $this->input->get();
$id = intval($params['id']);
$type = $params['type'];
@@ -851,12 +852,14 @@ class Common extends CI_Controller
return $this->show_json(SYS_CODE_FAIL, '手机不存在!');
}
$mobile = $re['mobile'];
$cache = &load_cache('redis');
$xz_admin_phone = $cache->get('xz_admin_phone');
$middleNumber = '';
if ($xz_admin_phone) {
$middleNumber = $xz_admin_phone['admins'][$this->uid];
}
// $cache = &load_cache('redis');
// $xz_admin_phone = $cache->get('xz_admin_phone');
// $middleNumber = '';
// if ($xz_admin_phone) {
// $middleNumber = $xz_admin_phone['admins'][$this->uid];
// }
$yxMobiles = $this->sys_yx_mobiles_model->get(['admin_id' => $this->uid, 'status' => 1]);
$middleNumber = $yxMobiles['mobile'] ?: '';
if (!$middleNumber) {
return $this->show_json(SYS_CODE_FAIL, '还未分配号码不可使用');
}
+5 -4
View File
@@ -216,10 +216,11 @@ class Login extends CI_Controller
//退出
public function logout()
{
$domain = explode('.', $_SERVER['HTTP_HOST']);
array_shift($domain);
$domain = implode('.', $domain);
// $domain = explode('.', $_SERVER['HTTP_HOST']);
// array_shift($domain);
// $domain = implode('.', $domain);
$http_host = explode(':', $_SERVER['HTTP_HOST']);
$domain = $http_host[0];
$this->input->set_cookie(LOGIN_COOKIE, '', 0, $domain);
return $this->show_json(SYS_CODE_SUCCESS, '注销成功', '/login');
+7 -3
View File
@@ -635,9 +635,13 @@ class Clues extends HD_Controller
//短信通知店长
$this->load->model('app/licheb/app_licheb_users_model');
$where = array('biz_id' => $re['biz_id'], 'status' => 1, 'group_id' => 2);
$res_u = $this->app_licheb_users_model->get($where);
if($re['biz_id'] != 1){
b2m_send_sms($res_u['mobile'], '【理车宝】您好,门店新增了1个客户线索。请及时到小程序"理车宝-待分配客户”分配给销售顾问跟进。祝您生活愉快!');
$res_u = $this->app_licheb_users_model->select($where);
if($res_u){
foreach ($res_u as $v){
if($re['biz_id'] != 1){
b2m_send_sms($v['mobile'], '【理车宝】您好,门店新增了1个客户线索。请及时到小程序"理车宝-待分配客户”分配给销售顾问跟进。祝您生活愉快!');
}
}
}
$msg = '转交成功';
+34 -6
View File
@@ -10,7 +10,7 @@ defined('BASEPATH') or exit('No direct script access allowed');
class Customer extends HD_Controller
{
private $searchTpAry = array('mobile' => '客户手机号', 'cid' => '客户编号');
private $searchTimeAry = array('p_time' => '派单/建档时间', 'cont_time' => '最后联系时间', 'dt_time' => '首次到店时间', 'order_time' => '下定时间', 'def_time' => '战败时间','c_time' => '创建时间', );
private $searchTimeAry = array('p_time' => '派单/建档时间', 'cont_time' => '最后联系时间', 'dt_time' => '首次到店时间', 'order_time' => '下定时间', 'def_time' => '战败时间', 'c_time' => '创建时间',);
protected $log_dir;
@@ -24,10 +24,12 @@ class Customer extends HD_Controller
$this->load->model('receiver/receiver_clues_model', 'clues_model');
$this->load->model('receiver/receiver_clues_cfrom_model', 'clues_cfrom_model');
$this->load->model('receiver/receiver_yx_model');
$this->load->model('receiver/receiver_xz_model');
$this->load->model('app/licheb/app_licheb_users_model');
$this->load->model("biz/biz_model");
$this->load->model('area_model');
$this->load->model('auto/auto_brand_model');
$this->load->model('auto/auto_series_model');
$this->log_dir = 'receiver_' . get_class($this);
}
@@ -598,7 +600,15 @@ class Customer extends HD_Controller
$area = $this->area_model->get(array('province_id' => $row['province_id']));
$poi = "{$area['province_name']}";
}
$brand_detail = '';
if ($row['brand_id']) {
$brand = $this->auto_brand_model->get(['id' => $row['brand_id']]);
$brand && $brand_detail = $brand['name'];
}
if ($row['series_id']) {
$series = $this->auto_series_model->get(['id' => $row['series_id']]);
$series && $brand_detail .= '-' . $series['name'];
}
$info = array(
'id' => $row['id'],
'name' => $row['name'],
@@ -615,6 +625,7 @@ class Customer extends HD_Controller
'poi' => $poi,
'biz' => $row_biz['biz_name'],
'time_name' => $row['clue_id'] ? '派单时间' : '建档时间',
'brand_detail' => $brand_detail,
);
//到店信息
@@ -636,9 +647,16 @@ class Customer extends HD_Controller
foreach ($rows_log as $key => $value) {
$rec_text = $rec_url = '';
if ($value['type'] == 2) {
$rec_row = $this->receiver_yx_model->get(['id' => $value['log']], 'rec_url,duration');
$record = '';
if ($value['sub_type'] == Receiver_customer_oplogs_model::SUB_TYPE_XZ) {
$rec_row = $this->receiver_xz_model->get(['id' => $value['log']], 'rec_url,duration');
$rec_row['rec_url'] && $record = $rec_row['rec_url'];
} else {
$rec_row = $this->receiver_yx_model->get(['id' => $value['log']], 'rec_url,duration');
$rec_row['rec_url'] && $record = get_yx_video($rec_row['rec_url']);
}
if ($rec_row['duration']) {
$rec_row['rec_url'] && $rec_url = get_yx_video($rec_row['rec_url']);
$record && $rec_url = $record;
!$rec_row['rec_url'] && $rec_text = '录音暂未生成';
} else {
$rec_text = '未接通';
@@ -928,6 +946,7 @@ class Customer extends HD_Controller
"biz_name" => "归属门店",
"admin_name" => "归属顾问",
"wxgr_name" => "加个微",
'brand_detail' => '重点关注车型'
];
$count = $this->customers_model->count($where);
@@ -937,10 +956,12 @@ class Customer extends HD_Controller
$status_arr = $this->customers_model->get_status();
unset($status_arr['-1']);
if ($count) {
$fileds = "id, name, mobile, level, status, cs_biz_id, FROM_UNIXTIME(c_time) as c_time, if(dt_time>0, dt_time,'') as dt_time, p_time, if(order_time>0, order_time,'') as order_time, if(cont_time>0, cont_time,'') as cont_time, c_brand, cf_id, of_id, of2_id, (SELECT biz_name FROM `lc_biz` where id = `lc_receiver_customers`.biz_id) as biz_name, (SELECT uname FROM `lc_app_licheb_users` where id = `lc_receiver_customers`.admin_id) as admin_name, biz_id, admin_id, wxqy, wxgr, (select city_name from lc_area where city_id = lc_receiver_customers.city_id limit 1) as city_name, (select county_name from lc_area where county_id = lc_receiver_customers.county_id limit 1) as county_name";
$fileds = "id, name, mobile, level, status, cs_biz_id,brand_id,series_id, FROM_UNIXTIME(c_time) as c_time, if(dt_time>0, dt_time,'') as dt_time, p_time, if(order_time>0, order_time,'') as order_time, if(cont_time>0, cont_time,'') as cont_time, c_brand, cf_id, of_id, of2_id, (SELECT biz_name FROM `lc_biz` where id = `lc_receiver_customers`.biz_id) as biz_name, (SELECT uname FROM `lc_app_licheb_users` where id = `lc_receiver_customers`.admin_id) as admin_name, biz_id, admin_id, wxqy, wxgr, (select city_name from lc_area where city_id = lc_receiver_customers.city_id limit 1) as city_name, (select county_name from lc_area where county_id = lc_receiver_customers.county_id limit 1) as county_name";
$rows = $this->customers_model->select($where, 'id desc', $page, $size, $fileds);
$brands = $this->auto_brand_model->get_map_by_ids(array_column($rows, 'brand_id'));
$series = $this->auto_series_model->get_map_by_ids(array_column($rows, 'series_id'));
foreach ($rows as $key => $val) {
$of_title = '';
$brand_detail = $of_title = '';
$of_title_1 = $of_title_2 = '';
if ($val['of_id']) {
$of_ary = $offlineSources[$val['of_id']];
@@ -949,6 +970,12 @@ class Customer extends HD_Controller
$val['of2_id'] && $of_title .= '-' . $of_ary['list'][$val['of2_id']];
$val['of2_id'] && $of_ary['list'][$val['of2_id']] && $of_title_2 = $of_ary['list'][$val['of2_id']];
}
if ($brands[$val['brand_id']]) {
$brand_detail = $brands[$val['brand_id']][0]['name'];
}
if ($brands[$val['brand_id']]) {
$brand_detail .= '-' . $series[$val['series_id']][0]['name'];
}
$id = $val['id'];
$row = array(
'id' => $id,
@@ -969,6 +996,7 @@ class Customer extends HD_Controller
'biz_name' => $val['biz_name'],
'admin_name' => $val['admin_name'],
'wxgr_name' => $this->customers_model->wxgrAry($val['wxgr']),
'brand_detail' => $brand_detail,
);
if ($params['export_tag']) {
+178
View File
@@ -0,0 +1,178 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Mobile extends HD_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('sys/sys_yx_mobiles_model');
$this->load->model('area_model');
$this->load->model('sys/sys_admin_model');
}
public function index()
{
return $this->lists();
}
public function lists($where = array(), $order = 'id desc', $page = 0, $size = 10)
{
$page = $this->input->post_get('page') ? $this->input->get('page') : 1;
$params = $this->input->get();
$where['status>='] = 0;
if ($params['mobile']) {
$where["mobile like '%{$params['mobile']}%'"] = null;
}
$count = $this->sys_yx_mobiles_model->count($where);
$lists = [];
if ($count) {
$rows = $this->sys_yx_mobiles_model->select($where, $order, $page, $size);
foreach ($rows as $row) {
$tmp = $row;
$city = $this->area_model->get(['city_id' => $row['city_id']]);
$tmp['province_name'] = $city['province_name'];
$tmp['city_name'] = $city['city_name'];
$admin = '';
if ($row['admin_id']) {
$admin = $this->sys_admin_model->get(['id' => $row['admin_id']]);
}
$tmp['admin_name'] = $admin ? $admin['username'] : '未绑定';
$lists[] = $tmp;
}
}
$this->data['pager'] = array('count' => '', 'curr' => $page, 'totle' => $count, 'total' => $count);
$this->data['lists'] = $lists;
$this->data['params'] = $params;
$this->data['_title'] = '云信虚拟号管理';
$this->show_view('sys/yx/lists', true);
}
public function get()
{
$id = $this->input->get('id');
$row = [];
$url = 'add';
if ($id) {
$row = $this->sys_yx_mobiles_model->get(['id' => $id]);
$url = 'edit';
}
$this->data['url'] = $url;
$this->data['row'] = $row;
$this->show_view('sys/yx/edit');
}
public function add()
{
$input = $this->input->post();
if (!$input['mobile'] || !mobile_valid($input['mobile'])) {
return $this->show_json(SYS_CODE_FAIL, '请输入正确手机号');
}
if (!$input['city_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择城市');
}
$add = [
'mobile' => $input['mobile'],
'province_id' => $input['province_id'],
'city_id' => $input['city_id'],
'c_time' => time(),
];
$re = $this->sys_yx_mobiles_model->add($add);
if ($re) {
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '添加失败');
}
}
public function edit()
{
$input = $this->input->post();
$row = $this->sys_yx_mobiles_model->get(['id' => $input['id']]);
if (!$row) {
return $this->show_json(SYS_CODE_FAIL, '参数错误');
}
if (!$input['mobile'] || !mobile_valid($input['mobile'])) {
return $this->show_json(SYS_CODE_FAIL, '请输入正确手机号');
}
if (!$input['city_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择城市');
}
$data = [
'mobile' => $input['mobile'],
'province_id' => $input['province_id'],
'city_id' => $input['city_id'],
];
$re = $this->sys_yx_mobiles_model->update($data, ['id' => $row['id']]);
if ($re) {
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '保存失败');
}
}
public function batch()
{
}
public function export()
{
}
public function del()
{
}
/**
* 修改状态
* @return bool
*/
public function edit_status()
{
$id = $this->input->post('id');
if (!$id) {
return $this->show_json(SYS_CODE_FAIL, '提交失败');
}
$status = $this->input->post('status');
$update['status'] = $status;
$re = $this->sys_yx_mobiles_model->update($update, array('id' => $id));
if ($re) {
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '操作失败');
}
}
public function edit_admin()
{
$id = $this->input->post_get('id');
$row = $this->sys_yx_mobiles_model->get(['id' => $id]);
if (!$row) {
return $this->show_json(SYS_CODE_FAIL, '参数错误');
}
if ($this->input->method() == 'post') {
$admin_id = (int)$this->input->post('admin_id');
$re = $this->sys_yx_mobiles_model->update(['admin_id' => $admin_id], array('id' => $id));
if ($re) {
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '操作失败');
}
} else {
$where = [
'status' => 1,
"id not in (select admin_id from lc_sys_yx_mobiles where status>=0 and admin_id>0 and admin_id!={$row['admin_id']})" => null
];
$adminLists = $this->sys_admin_model->select($where, 'id desc', 0, 0, 'id,username,mobile');
$this->data['adminLists'] = $adminLists;
$this->data['row'] = $row;
$this->show_view('sys/yx/edit_admin');
}
}
}
+1
View File
@@ -61,6 +61,7 @@
<tr>
<td class="table-td"><span class="mr5">{{info.time_name}}:</span>{{info.p_time}}</td>
<td class="table-td"><span class="mr5">微信好友:</span>{{info.wx_name}}</td>
<td class="table-td"><span class="mr5">重点关注车型:</span>{{info.brand_detail}}</td>
</tr>
<tr>
<td>
+2 -2
View File
@@ -135,7 +135,7 @@
</li>
</ul>
</div>
<!--div class="am-form-group clearfix">
<div class="am-form-group clearfix" v-if="parseInt(info.if_equity)">
<p class="am-text-default mb10 ml30 pt15 pb10">
权益确认书:
</p>
@@ -160,7 +160,7 @@
</a>
</li>
</ul>
</div-->
</div>
<div class="am-form-group clearfix">
<p class="am-text-default mb10 ml30 pt15 pb10">
发票:
+10
View File
@@ -92,5 +92,15 @@
</div>
</div>
</div>
<div class="am-form-inline">
<div class="am-form-group am-u-lg-6">
<label class="am-para-label label-width"><span class="span-bold">投保买贵必赔:</span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{parseInt(info.if_equity) ? '是':'否'}}</label>
</div>
</div>
<div class="am-form-group am-u-lg-6">
</div>
</div>
</div>
</div>
+113
View File
@@ -0,0 +1,113 @@
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/yx/mobile/<?= $url ?>" data-auto="true"
method="post" style="width: 90%;padding-top: 10px" onsubmit="return false">
<input type="hidden" v-model="row.id" name="id"/>
<div class="am-form-group">
<label class="am-para-label">手机号:</label>
<div class="am-para-input">
<input type="text" placeholder="输入手机号" v-model="row.mobile" name="mobile"/>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">城市:</label>
<div class="am-form-group am-para-inline w150">
<select name="province_id" v-model="province_id">
<option value="0">省份</option>
<option :value="v.id" v-for="(v,i) in provinceAry">{{v.name}}</option>
</select>
</div>
<div class="am-form-group am-para-inline w150">
<select name="city_id" v-model="city_id">
<option value="0">城市</option>
<option :value="v.id" v-for="(v,i) in cityAry">{{v.name}}</option>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<button class="am-btn ml20 am-btn-sm am-btn-success w100" style="margin-left: 3.5rem" type="submit">保存
</button>
</div>
</form>
<script>
vue_obj = new Vue({
el: '#vue-edit',
data: {
row: <?=$row ? json_encode($row, JSON_UNESCAPED_UNICODE) : '[]'?>,
province_id: <?=$row['province_id'] ? $row['province_id'] : 0?>,
city_id: <?=$row['city_id'] ? $row['city_id'] : 0?>,
provinceAry: [],
cityAry: []
},
mounted: function () {
this.init_provinces();
this.init_citys();
},
methods: {
init_provinces: function () {
var vm = this;
$.get('common/area', {}, function (response) {
if (response.code == 1) {
vm.provinceAry = response.data;
}
});
},
init_citys: function () {
var vm = this;
$.get('common/area', {id: vm.province_id, key: 'city', type: 1}, function (response) {
if (response.code == 1) {
vm.cityAry = response.data;
}
});
}
},
watch: {
'province_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.cityAry = [];
that.city_id = '0';
} else {
$.get('common/area', {id: nv, key: 'city', type: 1}, function (response) {
if (response.code == 1) {
that.cityAry = response.data;
if (that.city_id > 0) {
var city_id = '0';
for (var i in that.cityAry) {
var city = that.cityAry[i];
if (city.id == that.city_id) {
city_id = city.id;
break;
}
}
that.city_id = city_id;
}
}
});
}
},
'city_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.countyAry = [];
that.county_id = '0';
} else {
$.get('common/area', {id: nv, key: 'county', type: 1}, function (response) {
if (response.code == 1) {
that.countyAry = response.data;
if (that.county_id > 0) {
var county_id = '0';
for (var i in that.countyAry) {
var county = that.countyAry[i];
if (county.id == that.county_id) {
county_id = county.id;
break;
}
}
that.county_id = county_id;
}
}
});
}
}
}
});
</script>
+31
View File
@@ -0,0 +1,31 @@
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/yx/mobile/edit_admin" data-auto="true"
method="post" style="width: 90%;padding-top: 10px" onsubmit="return false">
<input type="hidden" v-model="row.id" name="id"/>
<div class="am-form-group">
<label class="am-para-label">管理员:</label>
<div class="am-form-group am-para-inline w300">
<select name="admin_id" v-model="row.admin_id">
<option value="0">选择管理员</option>
<option :value="v.id" v-for="(v,i) in adminLists">{{v.username}}({{v.mobile}})</option>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<button class="am-btn ml20 am-btn-sm am-btn-success w100" style="margin-left: 3.5rem" type="submit">保存
</button>
</div>
</form>
<script>
vue_obj = new Vue({
el: '#vue-edit',
data: {
row: <?=$row ? json_encode($row, JSON_UNESCAPED_UNICODE) : '[]'?>,
adminLists: <?=$adminLists ? json_encode($adminLists, JSON_UNESCAPED_UNICODE) : '[]'?>
},
mounted: function () {
},
methods: {},
watch: {}
});
</script>
+92
View File
@@ -0,0 +1,92 @@
<div class="coms-table-wrap">
<!-- no-border 去掉头部就有边控了-->
<div class="coms-table-hd clearfix no-border">
<form action="/sys/yx/mobile/lists" class="form-search" onsubmit="return false">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label">手机号</label>
<div class="am-para-inline w200">
<input type="text" value="<?= $mobile ?>" name="mobile"/>
</div>
</div>
<div class="am-form-group fl">
<button type="submit" class="am-btn ml20 am-btn-sm am-btn-success w100">搜索</button>
</div>
<div class="am-form-group fl">
<button type="button" data-modal="/sys/yx/mobile/get" data-title="新增"
class="add am-btn ml20 am-btn-sm am-btn-success w100">新增
</button>
</div>
<div class="am-form-group fr" style="font-size: 15px;padding-right: 20px;padding-top: 6px;">
共有<?= $pager['total'] ?>条数据
</div>
</div>
</form>
</div>
<div class="coms-table-bd">
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="8%"><span>ID</span></th>
<th width="20%"><span>手机号</span></th>
<th width="20%"><span>城市</span></th>
<th width="20%"><span>绑定管理员</span></th>
<th width="8%"><span>状态</span></th>
<th><span>操作</span></th>
</tr>
</thead>
<tbody>
<tr v-for="value in lists">
<!-- <td><input type="checkbox" /></td> -->
<td>{{value.id}}</td>
<td>{{value.mobile}}</td>
<td>{{value.province_name}}-{{value.city_name}}</td>
<td>{{value.admin_name}}</td>
<td>{{ value.status==1 ? '正常': '禁用'}}</td>
<td>
<a v-if="value.status == 1" @click="editStatus(value.id,0)"
class="am-btn am-btn-danger am-btn-xs">禁用</a>
<a v-else @click="editStatus(value.id,1)" class="am-btn am-btn-danger am-btn-xs">启用</a>
<a :data-modal="'/sys/yx/mobile/get?id='+value.id"
class="am-btn am-btn-primary am-btn-xs">修改</a>
<a :data-modal="'/sys/yx/mobile/edit_admin?id='+value.id"
class="am-btn am-btn-primary am-btn-xs">{{value.admin_id>0 ? '修改绑定管理员' :'绑定管理员'}}</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="coms-table-ft clearfix">
<div class="coms-pagination fr mr20">
<?php call_user_func_array('page_view', $this->data['pager']); ?>
</div>
</div>
<script type="text/javascript">
var modal = $('#add-new');
$('.add').on('click', function (e) {
var $target = $(e.target);
modal.modal();
});
var vm = new Vue({
el: '.coms-table-bd',
data: {
lists: JSON.parse('<?=json_encode($this->data['lists'])?>'),
},
methods: {
editStatus: function (index, status) {
$.post('sys/yx/mobile/edit_status', {id: index, status: status}, function (data) {
setTimeout(function () {
if (data.code == '1') {
layer.alert(data.msg, {icon: 1});
window.onhashchange.call();
} else {
layer.alert(data.msg, {icon: 2});
}
}, 500)
})
}
}
})
</script>
+3 -9
View File
@@ -7,13 +7,7 @@
* Time: 11:32
*/
$config['app_id'] = 1216;
$config['app_key'] = 'V44SK7UJMUN1SH9FETN8QRT2';
$config['app_id'] = 1428;
$config['app_key'] = 'S3WMWHBGKSDZP5SYYVDV4JZK';
$config['mobile_list'] = array(
'18017420332','18017414423','15317304631','15317106841',
'15317082243','15317373459','15317373449','15317373340',
'15317373147','15317373143','15317372640','15317371423',
'15317371412','15317371405','15317370437','15317368843',
'15317367941','15317367402','15317364837',
);
$config['mobile_list'] = [];
+176
View File
@@ -0,0 +1,176 @@
<?php
/**
* Created by Vim
* User: lcc
* Desc: 晓致拨号回调
* Date: 2021/4/14
* Time: 19:15
*/
require_once COMMPATH . 'third_party/Xcall/Xcall.php';
class Xzcall extends HD_Controller
{
private $log_file;
private $admin_config = [
'app_id' => 1206,
'app_key' => 'WX6HDVZX3AYSZDR1739332ZM'
];
public function __construct()
{
parent::__construct();
$this->log_file = 'call_xz.log';
$this->load->model('receiver/receiver_xz_model');
$this->load->model('receiver/receiver_customers_model', 'customers_model');
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdOplogs');
}
public function index()
{
debug_log("start function:" . __FUNCTION__, $this->log_file);
$data = $this->input->post();
debug_log('data:' . json_encode($data, JSON_UNESCAPED_UNICODE), $this->log_file);
if ($data && $data['seqId']) {
$row = $this->receiver_xz_model->get(array('call_id' => $data['seqId']));
if ($row) {
$jsondata = json_decode($row['json_data'], true);
$data['uname'] = $jsondata['uname'];
$data['brand_id'] = $jsondata['brand_id'];
$up_data['caller_state'] = $data['status'];
$up_data['status'] = 1;
$data['mid'] && $up_data['mid'] = $data['mid'];
$data['to'] && $up_data['called_num'] = $data['to'];
$data['from'] && $up_data['caller_num'] = $data['from'];
if ($data['callAnswer']) {
$up_data['duration'] = $data['callEnd'] - $data['callAnswer'];
$up_data['answer_time'] = $this->getMsecToMescdate($data['callAnswer']);
}
$data['callStart'] && $up_data['start_time'] = $this->getMsecToMescdate($data['callStart']);
$data['callEnd'] && $up_data['end_time'] = $this->getMsecToMescdate($data['callEnd']);
$up_data['json_data'] = json_encode($data, JSON_UNESCAPED_UNICODE);
$this->receiver_xz_model->update($up_data, ['id' => $row['id']]);
if ($row['cf_id'] && $row['cf_platform'] == 'admin') { //后台
$admin_id = $row['cf_uid'];
$this->load->model('sys/sys_admin_model');
$admin = $this->sys_admin_model->get(array('id' => $admin_id));
$addData = array(
'uid' => $admin_id,
'uname' => $admin['username'] ? $admin['username'] : '',
'type' => 2,//类型 0 普通 1短信 2电话
'log' => $row['id'],
'c_time' => time()
);
if ($row['cf_title'] == 'clues') {//线索拨打电话回调
$this->load->model('receiver/receiver_clue_oplogs_model', 'mdOplogs');
$addData['clue_id'] = $row['cf_id'];
} else if ($row['cf_title'] == 'customer') {//客户拨打电话回调
$addData['customer_id'] = $row['cf_id'];
$addData['sub_type'] = Receiver_customer_oplogs_model::SUB_TYPE_XZ;
} else if ($row['cf_title'] == 'owners') {//车主拨打电话回调
$this->load->model('receiver/receiver_owners_oplogs_model', 'mdOplogs');
$addData['own_id'] = $row['cf_id'];
}
$this->mdOplogs->add($addData);
$xcall = new Xcall($this->admin_config);
//解绑
$xcall->SWunbind($data['to'], $data['virtualMobile']);
} elseif ($row['cf_id'] && $row['cf_platform'] == 'api') { //狸车宝
$this->config->load('xcall');
$params = [
'app_id' => $this->config->item('app_id'),
'app_key' => $this->config->item('app_key'),
];
$xcall = new Xcall($params);
//解绑
$result = $xcall->AXBUnbind($data['to'], $data['from'], $data['virtualMobile']);
//删除redis
$cache_key = "XZ_LICHEB_MOBILEA_{$data['from']}_MOBILEB_{$data['to']}_{$row['cf_uid']}";
$redis = &load_cache('redis');
$redis->delete($cache_key);
$cust = $this->customers_model->get(['id' => $row['cf_id']]);
$this->load->library('receiver/customers_entity');
$visit = $row['cf_title'] == 'customer' ? 1 : 0;
$this->customers_entity->add_log_visit($cust['id'], $row['cf_uid'], $data['uname'], $row['id'], 2, $visit, [], 'wxapp', Receiver_customer_oplogs_model::SUB_TYPE_XZ);
}
} else {
// if ($data['virtualMobile'] == '13391247942') { //推送test环境
// $url = "https://api.lc.haodian.cn/plan/xzcall";
// $this->load->library('mycurl');
// $res = $this->mycurl->httpPost($url, $data);
// debug_log('结束,推送test环境:' . json_encode($res, JSON_UNESCAPED_UNICODE), $this->log_file);
// }
debug_log("error: 未找到拨打记录", $this->log_file);
}
}
debug_log("end " . __FUNCTION__, $this->log_file);
echo '{"result":"0","error":""}';
}
//录音推送地址
public function video()
{
$data = $this->input->post();
debug_log("start function:" . __FUNCTION__, $this->log_file);
debug_log('data:' . json_encode($data, JSON_UNESCAPED_UNICODE), $this->log_file);
$row = $this->receiver_xz_model->get(array('mid' => $data['mid']));
if ($row) {
$jsondata = json_decode($row['json_data'], true);
if ($data['getFileUrl']) {
if ($data['id'] == $this->admin_config['app_id']) {
$params = $this->admin_config;
} else {
$this->config->load('xcall');
$params = [
'app_id' => $this->config->item('app_id'),
'app_key' => $this->config->item('app_key'),
];
}
$xcall = new Xcall($params);
$result = $xcall->getFile($data['getFileUrl'], $data['mid'], $data['tag']);
if ($result['code']) { //上传七牛
$this->load->library('qiniu');
$qiniu = new Qiniu(['type' => 'video']);
$filename = $qiniu->getFileName($data['mid'], 'mp3', 'xz_video_');
$q_res = $qiniu->save($filename, $result['data']);
if (!$q_res) {
debug_log('error:文件上传七牛失败', $this->log_file);
} else {
$up_data['rec_url'] = $q_res['url'];
}
} else {
debug_log('error:' . json_encode($result, JSON_UNESCAPED_UNICODE), $this->log_file);
}
}
$jsondata['file_info'] = $data;
$up_data['json_data'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
$this->receiver_xz_model->update($up_data, ['id' => $row['id']]);
} else {
//推送test环境
// $url = "https://api.ss.haodian.cn/plan/xzcall/video";
// $this->load->library('mycurl');
// $res = $this->mycurl->httpPost($url, $data);
// debug_log('结束,推送test环境:' . json_encode($res, JSON_UNESCAPED_UNICODE), $this->log_file);
}
debug_log("end " . __FUNCTION__, $this->log_file);
echo '{"result":"0","error":""}';
}
/**
* 毫秒转日期
*/
private function getMsecToMescdate($msectime)
{
$msectime = $msectime * 0.001;
if (strstr($msectime, '.')) {
sprintf("%01.3f", $msectime);
list($usec, $sec) = explode(".", $msectime);
$sec = str_pad($sec, 3, "0", STR_PAD_RIGHT);
} else {
$usec = $msectime;
$sec = "000";
}
$date = date("Y-m-d H:i:s.x", $usec);
return $mescdate = str_replace('x', $sec, $date);
}
}
+2 -1
View File
@@ -48,6 +48,7 @@ class Yxcall extends HD_Controller
'uname' => $admin['username'] ? $admin['username'] : '',
'type' => 2,//类型 0 普通 1短信 2电话
'log' => $row['id'],
'cf_platform' => 'admin',
'c_time' => time()
);
if ($row['cf_title'] == 'clues') {//线索拨打电话回调
@@ -68,7 +69,7 @@ class Yxcall extends HD_Controller
$result = $ycall->AXBUnbind($data['displayNumber'], $data['calleeNumber'], $data['callerNumber']);
//删除redis
$cache_key = "XZ_LICHEB_MOBILEA_{$data['calleeNumber']}_MOBILEB_{$data['callerNumber']}_{$row['cf_uid']}";
$redis = &load_cache('redis');
$redis = &load_cache();
$redis->delete($cache_key);
$cust = $this->customers_model->get(['id' => $row['cf_id']]);
$visit = $row['cf_title'] == 'customer' ? 1 : 0;
@@ -62,6 +62,7 @@ class Cusorder extends Wxapp
$if_num = $this->input_param('if_num');
$if_insure = $this->input_param('if_insure');
$register_amount = $this->input_param('register_amount'); //上牌费
$if_equity = $this->input_param('if_equity');
//贷款相关参数
$downpayment_type = $this->input_param('downpayment_type');
$loan_amount = $this->input_param('loan_amount');
@@ -99,6 +100,7 @@ class Cusorder extends Wxapp
$in_color && $data['in_color'] = $in_color;
$if_num && $data['if_num'] = 1;
$if_insure && $data['if_insure'] = 1;
$if_equity && $data['if_equity'] = 1;
$money_json = [];
$money_json['confirm_amount'] = $confirm_amount ? $confirm_amount : 0;
$money_json['discount_amount'] = $discount_amount ? $discount_amount : 0;
@@ -143,6 +145,7 @@ class Cusorder extends Wxapp
$delry_time = $this->input_param('delry_time');
$if_num = $this->input_param('if_num');
$if_insure = $this->input_param('if_insure');
$if_equity = $this->input_param('if_equity');
$register_amount = $this->input_param('register_amount'); //上牌费
//贷款相关参数
$downpayment_type = $this->input_param('downpayment_type');
@@ -168,6 +171,7 @@ class Cusorder extends Wxapp
$in_color && $data['in_color'] = $in_color;
$data['if_num'] = $if_num ? 1 : 0;
$data['if_insure'] = $if_insure ? 1 : 0;
$data['if_equity'] = $if_equity ? 1 : 0;
$money_json = json_decode($row['money_json'], true);
$money_json['confirm_amount'] = $confirm_amount ? $confirm_amount : 0;
$money_json['discount_amount'] = $discount_amount ? $discount_amount : 0;
@@ -532,6 +536,7 @@ class Cusorder extends Wxapp
if (!$payway) { // 分期
$car_data['按揭信息'] = '';
}
$car_data['投保买贵必赔'] = $row['if_equity'] ? '是' : '否';
$car_data['是否店内投保'] = $row['if_insure'] ? '是' : '否';
$car_data['是否店内上牌'] = $row['if_num'] ? '是' : '否';
if ($row['if_num']) {
@@ -557,6 +562,7 @@ class Cusorder extends Wxapp
'car_data' => $car_data,
'if_num' => $row['if_num'],
'if_insure' => $row['if_insure'],
'if_equity' => $row['if_equity'],
'delry_time' => date('Y-m-d', strtotime($row['delry_time'])),
'money_json' => json_decode($row['money_json'], true),
'downpayment_type' => $row['downpayment_type'],
+11 -4
View File
@@ -25,6 +25,7 @@ class Customerlogs extends Wxapp
$this->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model');
$this->load->model('receiver/receiver_comments_model', 'mdComments');
$this->load->model('receiver/receiver_yx_model');
$this->load->model('receiver/receiver_xz_model');
}
protected function get()
@@ -40,7 +41,7 @@ class Customerlogs extends Wxapp
$count = $this->customer_oplogs_model->count($where);
$lists = [];
if ($count) {
$rows = $this->customer_oplogs_model->select($where, 'id desc', $page, $size, 'id,log,uname,type,c_time,imgs');
$rows = $this->customer_oplogs_model->select($where, 'id desc', $page, $size, 'id,log,uname,type,c_time,imgs,sub_type');
foreach ($rows as $key => $val) {
$record = '';
$second = 0;
@@ -53,11 +54,17 @@ class Customerlogs extends Wxapp
}
}
if ($val['type'] == 2) {
$rec_row = $this->receiver_yx_model->get(['id' => $val['log']], 'rec_url,duration');
$content = '拨打电话';
if ($val['sub_type'] == Receiver_customer_oplogs_model::SUB_TYPE_XZ) {
$rec_row = $this->receiver_xz_model->get(['id' => $val['log']], 'rec_url,duration');
$rec_row['rec_url'] && $record = $rec_row['rec_url'];
$rec_row['duration'] && $second = intval($rec_row['duration'] / 1000);
} else {
$rec_row = $this->receiver_yx_model->get(['id' => $val['log']], 'rec_url,duration');
$rec_row['rec_url'] && $record = get_yx_video($rec_row['rec_url']);
$rec_row['duration'] && $second = intval($rec_row['duration']);
}
!$rec_row['duration'] && $content .= '(未接通)';
$rec_row['rec_url'] && $record = get_yx_video($rec_row['rec_url']);
$rec_row['duration'] && $second = intval($rec_row['duration']);
}
$comments = [];
$res = $this->mdComments->select(['pid' => $val['id'], 'status' => 1, 'type' => 0], 'id asc', 0, 0
+18 -4
View File
@@ -110,6 +110,7 @@ class Customers extends Wxapp
$cfrom_rows = $this->clues_cfrom_model->get(array('id' => $row['of_id']));
$cfrom_rows['type'] == 1 && $edit_status = true;
}
$brand = $this->auto_brand_model->get(['id' => $row['brand_id']]);
$of_title = $row['of_id'] ? $this->get_cfTitle($row) : '';
$data['baseinfo'] = [
'name' => ['value' => $row['name'], 'cn' => '客户姓名'],
@@ -120,6 +121,8 @@ class Customers extends Wxapp
'wxgr' => $row['wxgr'],
'wxgrimg' => $row['wxgrimg'],
'wxgrimg_url' => $row['wxgrimg'] ? build_qiniu_image_url($row['wxgrimg']) : '',
'brand' => ['id' => $row['brand_id'], 'name' => $brand['name']],
'series_id' => $row['series_id'],
];
return $data;
}
@@ -210,6 +213,8 @@ class Customers extends Wxapp
$county_id = $this->input_param('county_id'); //区id
$wxgr = $this->input_param('wxgr'); //是否加个微
$wxgrimg = $this->input_param('wxgrimg'); //个微截图
$brand_id = (int)$this->input_param('brand_id');
$series_id = (int)$this->input_param('series_id');
$row = $this->customers_model->get(['id' => $id]);
if (!$row) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
@@ -238,6 +243,8 @@ class Customers extends Wxapp
$county_id && $update['county_id'] = $county_id;
$wxgr && $update['wxgr'] = intval($wxgr) ? 1 : 0;
$wxgrimg && $wxgrimg != $row['wxgrimg'] && $update['wxgrimg'] = $wxgrimg;
$brand_id && $update['brand_id'] = $brand_id ?: 0;
$series_id && $update['series_id'] = $series_id ?: 0;
if ($buy_time) {
$update['level'] = $this->customers_entity->cal_level($buy_time);
$update['buy_time'] = $buy_time;
@@ -305,6 +312,9 @@ class Customers extends Wxapp
$county_id = $this->input_param('county_id'); //区id
$wxgr = $this->input_param('wxgr'); //是否加个微
$wxgrimg = $this->input_param('wxgrimg'); //个微截图
$brand_id = $this->input_param('brand_id');
$series_id = $this->input_param('series_id');
$car_id = $this->input_param('car_id');
if (!mobile_valid($mobile)) throw new Exception('请输入正确的手机号码', ERR_PARAMS_ERROR);
if (!$city_id || !$county_id) {
throw new Exception('请选择城市与行政区', API_CODE_FAIL);
@@ -327,7 +337,9 @@ class Customers extends Wxapp
}
return ['code' => API_CODE_FAIL, 'msg' => $msg, 'data' => ['id' => $is_exit['id'], 'owner' => $owner]];
}
if($cf_row['id']==10){ //自然到店直接改成到店客户
$status = 1;
}
$this->load->helper("order");
$biz_row = $this->biz_model->get(['id' => $this->biz_id]);
@@ -361,6 +373,8 @@ class Customers extends Wxapp
$buy_time && $add_data['buy_time'] = $buy_time;
$of_id && $add_data['of_id'] = $of_id;
$of2_id && $add_data['of2_id'] = $of2_id;
$brand_id && $add_data['brand_id'] = $brand_id;
$series_id && $add_data['series_id'] = $series_id;
$id = $this->customers_model->add($add_data);
if ($id) {
//客户标签
@@ -1067,7 +1081,7 @@ class Customers extends Wxapp
}
//发送短信
$num = $re['mobile'] ? substr($re['mobile'], -4) : 0;
b2m_send_sms($admin['mobile'], '【理车宝】您有一个新的客户需要跟进,手机尾号为'.$num.'。请及时到小程序“理车宝-客户”进行操作,祝您成单!');
b2m_send_sms($admin['mobile'], '【理车宝】您有一个新的客户需要跟进,手机尾号为' . $num . '。请及时到小程序“理车宝-客户”进行操作,祝您成单!');
}
}
throw new Exception('分配成功', API_CODE_SUCCESS);
@@ -1354,9 +1368,9 @@ class Customers extends Wxapp
$mobile = $params['mobile'];
if (!$mobile) {
return '';
} elseif ($params['rid']){
} elseif ($params['rid']) {
return mobile_asterisk($mobile);
}else {
} else {
return $mobile;
}
}
+132
View File
@@ -0,0 +1,132 @@
<?php
defined('WXAPP_APP') or exit('No direct script access allowed');
/**
* Created by Vim.
* User: lcc
* Desc: 晓致虚拟号
* Date: 2021/07/26
* Time: 10:17
*/
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
require_once COMMPATH . 'third_party/Xcall/Xcall.php';
class Xz extends Wxapp
{
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = array();//登录白名单
$this->load->model('receiver/receiver_customers_model', 'customers_model');
$this->load->model('receiver/receiver_xz_model');
$this->log_file = 'call.log';
}
protected function get()
{
$id = $this->input_param('id');
$type = intval($this->input_param('type'));
!$type && $type = 0;
$session = $this->session;
$admin_id = $session['uid'];
$cf_title = 'customer';
$cus_id = $id;
$row = $this->customers_model->get(['id' => $cus_id]);
if (!$row || !$row['mobile']) {
throw new Hd_Exception('用户不存在', API_CODE_INVILD_PARAM);
}
$customer_mobile = $row['mobile'];
$user_mobile = $session['mobile'];
$json = $session['jsondata'] ? json_decode($session['jsondata'], true) : array();
if ($json && $json['hdy'] && $json['hdy']['tel']) {
$user_mobile = $json['hdy']['tel'];
}
$redis = &load_cache('redis');
$cache_key = "XZ_LICHEB_MOBILEA_{$user_mobile}_MOBILEB_{$customer_mobile}_{$admin_id}";
$call_mobile = $redis->get($cache_key);
if (!$call_mobile) {
$this->config->load('xcall');
$params = [
'app_id' => $this->config->item('app_id'),
'app_key' => $this->config->item('app_key'),
];
$seq_id = create_order_no();
$xcall = new Xcall($params);
$maxBindingTime = 10;//绑定时间
$result = $xcall->ABXbind($user_mobile, $customer_mobile, $seq_id, $maxBindingTime);
if (!$result['code']) { //绑定失败
debug_log("xz_failed_bind:customer_mobile【{$customer_mobile}", $this->log_file);
debug_log("xz_result:" . json_encode($result, JSON_UNESCAPED_UNICODE), $this->log_file);
throw new Hd_Exception($result['msg'], API_CODE_FAIL);
} else {
$this->data['middlenumber'] = $result['data']['virtualMobile'];
$add_data = [
'call_id' => $seq_id,
'display_number' => $result['data']['virtualMobile'],
'biz_id' => $row['biz_id'],
'cf_id' => $cus_id,
'cf_uid' => $admin_id,
'cf_title' => $cf_title,
'cf_platform' => 'api',
'json_data' => json_encode(['uname' => $session['uname']], JSON_UNESCAPED_UNICODE),
'c_time' => time()
];
$this->receiver_xz_model->add($add_data);
$call_mobile = $result['data']['virtualMobile'];
$redis->save($cache_key, $call_mobile, $maxBindingTime * 60);
}
}
$data['mobile'] = $call_mobile;
return $data;
}
//电话统计
protected function get_stat()
{
$biz_id = $this->input_param('biz_id');
$day = $this->input_param('day');
$admin_id = $this->input_param('admin_id');
if (!$biz_id) {
throw new Hd_Exception('参数错误', API_CODE_INVILD_PARAM);
}
//接通次数
$where1 = [
'cf_title' => 'customer',
'cf_platform' => 'api',
'biz_id' => $biz_id,
'status' => 1,
];
if ($day) {
$s_time = date('Y-m-d 00:00:00', strtotime($day));
$e_time = date('Y-m-t 23:59:59', strtotime($day));
$where1["c_time>="] = strtotime($s_time);
$where1["c_time<="] = strtotime($e_time);
}
$admin_id && $where1['cf_uid'] = $admin_id;
$where2 = [
'duration' => 0
];
$where = array_merge($where1, $where2);
$num = $this->receiver_xz_model->count($where);
$where2 = [
'duration>' => 0
];
$where = array_merge($where1, $where2);
$count_call = $this->receiver_xz_model->count($where); //接通次数
$sum_call = $this->receiver_xz_model->sum('duration', $where); //接通总时长
$call_time = $sum_call['duration'] / 60000;
if ($call_time) {
$avg_time = $call_time / $count_call;
}
$data = [
'call_time' => round($call_time, 2),
'avg_time' => round($avg_time, 2),
'unget_num' => $num
];
return $data;
}
}
+246
View File
@@ -0,0 +1,246 @@
<?php
/**
* 通用curl
* User: bleachin
*/
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Mycurl
{
private $host = '';
private $user_agent = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36';
private $cookie = '';
private $headers = array();
private $post_data = '';
public function __construct()
{
$this->setHeaders();
}
public function setHost($host='')
{
$this->host = $host;
}
public function setUserAgent($user_agent='')
{
$this->user_agent = $user_agent;
}
public function setCookie($cookie='')
{
$this->cookie = $cookie;
}
public function setHeaders($headers='')
{
if($headers&&is_array($headers)){
$_headers = $headers;
}else{
$_headers = array();
$_headers[] = $this->host;
// $_headers[] = 'Accept-Encoding: gzip, deflate, sdch';
$_headers[] = $this->user_agent;
$_headers[] = $this->cookie;
$headers && $_headers[] = $headers;
}
$this->headers = $_headers;
}
public function httpGet($url='', $data=array())
{
$res = false;
if (!$url) return $res;
if ($data)
{
$url = $url.'?'.$this->buildGetQuery($data);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//关闭https验证
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
if($this->headers)
{
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
}
$res = curl_exec($ch);
curl_close($ch);
return $res;
}
/**
* post 通用方法
* @param string $url [description]
* @param [type] $data [description]
* @param string $type post请求的数据类型
* @param string $file_path 文件的绝对路径,类似APPPATH.'public/img/'.$photo_path
* @return [type] [description]
*/
public function httpPost($url='', $data, $type='', $file_path='',$time_out = 60)
{
$res = false;
if (!$url) return $res;
if ($file_path) $file_path = realpath($file_path);
if (!$type || $type=='is_file'|| $type=='xml') {
$this->post_data = $data;
}elseif($data && $type=='is_json'){
$this->post_data = $this->buildJsonQuery($data);
$this->headers[] = 'Content-Type: application/json; charset=UTF-8';
}elseif($data && $type=='is_form')
{
$this->post_data = http_build_query($data);
$this->headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
}elseif($data && $type=='xml'){
$this->headers[] = 'Content-type: text/xml';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_ENCODING, ''); // 重要,否则采集数据时会乱码,乱码检测的编码格式为cp936
//关闭https验证
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
if ($file_path && $type=='is_file')
{
if (class_exists('\CURLFile'))
{
$file_path = new \CURLFile($file_path);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true); // >=5.5.0
}
else
{
if (defined('CURLOPT_SAFE_UPLOAD')) // 非5.6.0,是5.5.0以下手动设置了true
{
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); // <=5.5.0
}
$file_path = "@".$file_path; //@’符号告诉服务器为上传资源
}
}
if($this->headers) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->post_data);
if($time_out){ //超时时间
// 在尝试连接时等待的秒数
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , $time_out);
// 最大执行时间
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
}
$res = curl_exec($ch);
if(curl_errno( $ch )) {
$errno = curl_errno( $ch );
$info = curl_getinfo( $ch );
print_r($errno);
print_r($info);
}
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
return $res;
}
/**
* put 通用方法
* @param string $url [description]
* @param [type] $data [description]
* @param string $type put请求的数据类型
* @return [type] [description]
*/
public function httpPut($url='', $data, $type='',$time_out = 60){
$res = false;
if (!$url) return $res;
if (!$type || $type=='is_file'|| $type=='xml') {
$this->post_data = $data;
}elseif($data && $type=='is_json'){
$this->post_data = $this->buildJsonQuery($data);
$this->headers[] = 'Content-Type: application/json; charset=UTF-8';
}elseif($data && $type=='is_form')
{
$this->post_data = http_build_query($data);
$this->headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
}elseif($data && $type=='xml'){
$this->headers[] = 'Content-type: text/xml';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); //定义请求类型
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->post_data);
if($this->headers) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
}
if($time_out){ //超时时间
// 在尝试连接时等待的秒数
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , $time_out);
// 最大执行时间
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
}
$res = curl_exec($ch);
if(curl_errno( $ch )) {
$errno = curl_errno( $ch );
$info = curl_getinfo( $ch );
print_r($errno);
print_r($info);
}
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
return $res;
}
private function buildGetQuery($data)
{
$querystring = '';
if (is_array($data)) {
foreach ($data as $key => $val) {
if (is_array($val)) {
foreach ($val as $val2) {
$querystring .= urlencode($key).'='.urlencode($val2).'&';
}
} else {
$querystring .= urlencode($key).'='.urlencode($val).'&';
}
}
$querystring = substr($querystring, 0, -1);
} else {
$querystring = $data;
}
return $querystring;
}
private function buildJsonQuery($data)
{
$querystring = '';
if (is_array($data)) {
$querystring=json_encode($data);
}
return $querystring;
}
}
@@ -29,11 +29,11 @@ class Customers_entity
* @param string $cf_platform
* @return mixed
*/
public function add_log_visit($customer_id, $uid, $uname, $content, $type = '', $visit = 0, $imgs = [], $cf_platform = 'wxapp')
public function add_log_visit($customer_id, $uid, $uname, $content, $type = '', $visit = 0, $imgs = [], $cf_platform = 'wxapp', $sub_type = '')
{
$result = '';
if ($content) {
$result = $this->add_log($customer_id, $uid, $uname, $content, $type, $cf_platform, $imgs);
$result = $this->add_log($customer_id, $uid, $uname, $content, $type, $cf_platform, $imgs, '', $sub_type);
}
if ($visit && ($result || !$content)) {//更新客户已跟进
if ($type == 1 || $type == 2) {//1发短信2拨打号码 不算入已跟进
@@ -61,7 +61,7 @@ class Customers_entity
* @param $c_time int 创建日期
* @return string
*/
public function add_log($customer_id, $uid, $uname, $content, $type = '', $cf_platform = 'wxapp', $imgs = [], $c_time = '')
public function add_log($customer_id, $uid, $uname, $content, $type = '', $cf_platform = 'wxapp', $imgs = [], $c_time = '', $sub_type = '')
{
$this->ci->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model');
if ($type == 4 || $type == 5) {//到店或试驾,一天只记录一次
@@ -104,6 +104,7 @@ class Customers_entity
$uname && $add_data['uname'] = $uname;
$type && $add_data['type'] = $type;
$cf_platform && $add_data['cf_platform'] = $cf_platform;
$sub_type && $add_data['sub_type'] = $sub_type;
$imgs && $add_data['imgs'] = json_encode($imgs, JSON_UNESCAPED_UNICODE);
$result = $this->ci->customer_oplogs_model->add($add_data);
if (($type == 2 || $type == 1) && $result) { //更新最后联系时间
@@ -6,12 +6,14 @@
* Time: 13:47
*/
defined('BASEPATH') OR exit('No direct script access allowed');
defined('BASEPATH') or exit('No direct script access allowed');
class Receiver_customer_oplogs_model extends HD_Model
{
private $table_name = 'lc_receiver_customer_oplogs';
const SUB_TYPE_XZ = 'xz';
public function __construct()
{
parent::__construct($this->table_name, 'default');
@@ -0,0 +1,56 @@
<?php
/**
* Notes:晓致虚拟号通话记录
* Created on: 2021/7/26 13:38
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Receiver_xz_model extends HD_Model
{
private $table_name = 'lc_receiver_xz';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
//获取晓致状态
public function get_xz_status($status=''){
$arr = [
-1 => '实时来电通知(是否接听状态未知,非话单记录)',
0 => '正常接听',
1 => '未应答',
2 => '黑名单来电,拒接',
3 => '虚号关机状态,未接听',
4 => '未绑定号码',
5 => '遇忙未接听'
];
if(strlen($status)){
return $arr[$status] ? $arr[$status] : '未知状态';
}else{
return $arr;
}
}
//获取晓致noAnswerReaso对应错误码
public function get_xz_noAnswerReason($noAnswerReason=''){
$arr = [
11 => '主叫挂机',
12 => '被叫挂机',
13 => '被叫正在通话中',
14 => '被叫无人接听',
15 => '被叫无法接通',
16 => '被叫关机',
17 => '被叫空号',
18 => '被叫暂停服务',
19 => '被叫转接失败',
];
if(strlen($noAnswerReason)){
return $arr[$noAnswerReason] ? $arr[$noAnswerReason] : '';
}else{
return $arr;
}
}
}
@@ -0,0 +1,13 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Sys_yx_mobiles_model extends HD_Model
{
private $table_name = 'lc_sys_yx_mobiles';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
+2 -2
View File
@@ -8,8 +8,8 @@
class Xcall{
private $id = '1206';
private $key = 'WX6HDVZX3AYSZDR1739332ZM';
private $id = 1428;
private $key = 'S3WMWHBGKSDZP5SYYVDV4JZK';
private $api_url = 'http://api.teleii.com/';
private $ci;
private $log_file = 'xcall.log';