This commit is contained in:
lcc
2024-06-04 21:11:34 +08:00
parent 38cab97da2
commit 3f7995202d
20 changed files with 901 additions and 56 deletions
+13 -9
View File
@@ -23,9 +23,7 @@ class Customer extends HD_Controller
$this->load->model('receiver/receiver_customer_tagdata_model', 'mdCustomerTagdata');
$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_customer_stat_plan_model', 'statplan');
// $this->load->model('receiver/Receiver_customer_stat_data_model', 'statdata');
// $this->load->model('receiver/Receiver_customer_stat_data_log_model', 'statdatalog');
$this->load->model('receiver/receiver_yx_model');
$this->load->model('app/licheb/app_licheb_users_model');
$this->load->model("biz/biz_model");
$this->load->model('area_model');
@@ -63,7 +61,7 @@ class Customer extends HD_Controller
$biz_id_arr = array_unique(array_column($rows, 'biz_id'));
$biz_id_arr && $biz_rows = $this->biz_model->get_map_by_ids($biz_id_arr, 'id,biz_name,county_id');
foreach ($biz_rows as $v){
foreach ($biz_rows as $v) {
$county_id_arr[] = $v[0]['county_id'];
}
@@ -487,7 +485,7 @@ class Customer extends HD_Controller
$where["biz_id in(select id from lc_biz where county_id={$params['county_id_admin']})"] = null;
} else if ($params['city_id_admin']) {
$where["biz_id in(select id from lc_biz where city_id={$params['city_id_admin']})"] = null;
}else if ($params['province_id_admin']) {
} else if ($params['province_id_admin']) {
$where["biz_id in(select id from lc_biz where province_id={$params['province_id_admin']})"] = null;
}
@@ -575,7 +573,7 @@ class Customer extends HD_Controller
if ($row['of_id']) {
$of = $this->clues_cfrom_model->get(array('id' => $row['of_id']));
$of_title = $of['title'];
if($row['of2_id']){
if ($row['of2_id']) {
$of = $this->clues_cfrom_model->get(array('id' => $row['of2_id']));
$of_title .= '-' . $of['title'];
}
@@ -591,10 +589,10 @@ class Customer extends HD_Controller
if ($row['county_id']) {
$area = $this->area_model->get(array('county_id' => $row['county_id']));
$poi = "{$area['province_name']}-{$area['city_name']}-{$area['county_name']}";
}elseif ($row['city_id']) {
} elseif ($row['city_id']) {
$area = $this->area_model->get(array('city_id' => $row['city_id']));
$poi = "{$area['province_name']}-{$area['city_name']}";
}elseif ($row['province_id']) {
} elseif ($row['province_id']) {
$area = $this->area_model->get(array('province_id' => $row['province_id']));
$poi = "{$area['province_name']}";
}
@@ -634,7 +632,13 @@ class Customer extends HD_Controller
foreach ($rows_log as $key => $value) {
$rec_text = $rec_url = '';
if ($value['type'] == 2) {
$rec_text = '未接通';
$rec_row = $this->receiver_yx_model->get(['id' => $value['log']], 'rec_url,duration');
if ($rec_row['duration']) {
$rec_row['rec_url'] && $rec_url = get_yx_video($rec_row['rec_url']);
!$rec_row['rec_url'] && $rec_text = '录音暂未生成';
} else {
$rec_text = '未接通';
}
}
$imgs = [];
if ($value['imgs']) {
+5
View File
@@ -0,0 +1,5 @@
<?php
$config['mobile_list'] = array(
'13041430150'
);
+6 -5
View File
@@ -1,16 +1,17 @@
<?php
//ini_set("display_errors", "On");//打开错误提示
//ini_set("error_reporting",E_ALL);//显示所有错误
defined('BASEPATH') OR exit('No direct script access allowed');
defined('BASEPATH') or exit('No direct script access allowed');
class Welcome extends CI_Controller {
class Welcome extends CI_Controller
{
public function index()
public function index()
{
$this->load->view('welcome_message');
}
public function test(){
public function test()
{
}
}
+289
View File
@@ -0,0 +1,289 @@
<?php
require_once COMMPATH . 'third_party/Ycall/Ycall.php';
class Yxcall extends HD_Controller
{
private $log_file;
public function __construct()
{
parent::__construct();
$this->log_file = 'call.log';
$this->load->model('receiver/receiver_yx_model');
$this->load->model('receiver/receiver_customers_model', 'customers_model');
$this->load->library('receiver/customers_entity');
}
public function index()
{
debug_log("start", $this->log_file);
$str = file_get_contents('php://input');
debug_log('string:' . $str, $this->log_file);
$data = json_decode($str, true);
if ($data && $data['customerData']) {
$row = $this->receiver_yx_model->get(array('call_id' => $data['customerData']));
if ($row) {
$jsondata = json_decode($row['json_data'], true);
$data['uname'] = $jsondata['uname'];
$up_data['caller_state'] = $data['callerState'];
$up_data['status'] = 1;
$data['displayNumber'] && $up_data['mid'] = $data['displayNumber'];
$data['calleeNumber'] && $up_data['called_num'] = $data['calleeNumber'];
$data['callerNumber'] && $up_data['caller_num'] = $data['callerNumber'];
if ($data['calleeDuration'] > 0) {
$up_data['duration'] = $data['calleeDuration'];
$up_data['answer_time'] = $data['callerAnsweredTime'];
}
$data['startCallTime'] && $up_data['start_time'] = $data['startCallTime'];
$data['recUrl'] && $up_data['rec_url'] = $data['recUrl'];
$data['endTime'] && $up_data['end_time'] = $data['endTime'];
$up_data['json_data'] = json_encode($data, JSON_UNESCAPED_UNICODE);
$this->receiver_yx_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') {//客户拨打电话回调
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdOplogs');
$addData['customer_id'] = $row['cf_id'];
} 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') { //理车宝
$ycall = new Ycall();
//解绑
$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->delete($cache_key);
$cust = $this->customers_model->get(['id' => $row['cf_id']]);
$visit = $row['cf_title'] == 'customer' ? 1 : 0;
$this->customers_entity->add_log_visit($cust['id'], $row['cf_uid'], $data['uname'], $row['id'], 2, $visit);
}
} else {
debug_log("error: 未找到拨打记录", $this->log_file);
}
}
debug_log("end", $this->log_file);
die(json_encode(array('resultCode' => 200)));
}
//未绑定关系用户打入指定手机号
public function axb()
{
$this->config->load('ycall', TRUE);
$mobile_list = $this->config->item('mobile_list', 'ycall');
/**设置为平台分配的account*/
$account = "985437";
/**设置为平台分配的token*/
$token = "5c5ee9cfcb2948a1aadefc445cf96b13";
require_once(COMMPATH . "/third_party/Ycall/sdk/PrivacyUnbindBoody.php");
require_once(COMMPATH . "/third_party/Ycall/sdk/PrivacyAxbBindBody.php");
require_once(COMMPATH . "/third_party/Ycall/sdk/PrivacyAxTransferBody.php");
require_once(COMMPATH . "/third_party/Ycall/sdk/WinnerVoiceSender.php");
foreach ($mobile_list as $key => $value) {
$axTransferBody = new PrivacyAxTransferBody();
$axTransferBody->transferMiddleNumber = $value;
$axTransferBody->transferToNumberA = '19959277910';
$axTransferBody->callRec = 1;
$axTransferBody->callbackUrl = "https://api.haodian.cn/plan/yxcall";
$sender = new WinnerVoiceSender($account, $token, true);
$result = $sender->sendRequest('/voice/1.0.0/axbTransfer', json_encode($axTransferBody));
var_dump($result);
}
}
//后台接单宝添加日志
private function jdb_add_log($admin_id, $rc_id, $log_id, $duration)
{
$this->load->model('app/jdb/receiver_oplogs_model');
$this->load->model('app/jdb/receiver_customers_model');
$this->load->model('sys/sys_admin_model');
$admin = $this->sys_admin_model->get(array('id' => $admin_id));
$data = array(
'rc_id' => $rc_id,
'admin_id' => $admin_id,
'admin_name' => $admin['username'],
'type' => 4,
'log' => $log_id,
'c_time' => time()
);
$res = $this->receiver_oplogs_model->add($data);//增加操作记录
if ($res) {
$updateData = array('last_admin_id' => $admin_id, 'last_op_time' => date('Y-m-d H:i:s'));
$duration && $updateData['call_records = call_records+1'] = null;
$this->receiver_customers_model->update($updateData, array('id' => $rc_id));
}
}
//下载链接到七牛云
public function down_video()
{
$redis = &load_cache('redis');
$key = "RECEIVER_LAST_ID";
$last_id = $redis->get($key);
$where = array(
"rec_url <> ''" => null,
'c_time<' => time() - 50 * 60
);
if ($last_id) {
$where['id>'] = $last_id;
} else {
$where["rec_url like '%winnerlook-voice.oss-cn-hangzhou.aliyuncs.com%'"] = null;
}
$count = $this->receiver_yx_model->count($where);
$failed_num = $success_num = $do_num = 0;
if ($count) {
$rows = $this->receiver_yx_model->select($where, 'id asc', 1, 20, 'id,rec_url');
foreach ($rows as $key => $val) {
$file = $this->upload($val['rec_url']);
if ($file) {
$this->receiver_yx_model->update(array('rec_url' => $file), array('id' => $val['id']));
$success_num++;
} else {
$failed_num++;
}
$do_num++;
$last_id = $val['id'];
}
$redis->save($key, $last_id);
}
echo "do_num:{$do_num},success_num:{$success_num},failed_num:{$failed_num}";
}
private function upload($url, $i = '')
{
$this->load->helper('image');
$arr = explode('?', $url);
$this->load->library('qiniu');
$filename = $this->qiniu->getFileName($arr[0] . $i);
$filename = 'yx/' . $filename;
$info = $this->qiniu->getInfo($filename);
if ($info) {
return $filename;
} else {
$file = $this->qiniu->fetch($url, $filename);
return $file ? $file['file'] : '';
}
}
//检测录音文件为空的数据
public function check_wav()
{
$this->load->model('app/jdb/receiver_yx_model');
$cache = $this->input->get('cache');
$size = $this->input->get('size');
!$size && $size = 20;
$where = array(
"duration>" => 0,
);
$redis = &load_cache('redis');
$save_key = "RECEIVER_CHECK_WAV_LAST_ID";
if (!$cache) {
$last_id = $redis->get($save_key);
$last_id && $where['id>'] = $last_id;
}
$total = $this->receiver_yx_model->count($where);
if ($total) {
$rows = $this->receiver_yx_model->select($where, 'id asc', 1, $size, 'id,call_id,rec_url');
$this->load->library('qiniu');
foreach ($rows as $key => $val) {
$filename = $val['rec_url'];
$info = $this->qiniu->getInfo($filename);
if (!$info['fsize']) {
debug_log(json_encode($val, JSON_UNESCAPED_UNICODE), 'jdb_call_null_rec_url.log');
}
$last_id = $val['id'];
}
$res = $redis->save($save_key, $last_id);
}
$left = $total > count($rows) ? $total - count($rows) : 0;
echo 'total:' . $total . ',left:' . $left;
}
//重新下载空录音文件
public function check_wav_update()
{
$this->load->model('app/jdb/receiver_yx_model');
$id = $this->input->get('id');
$cache = $this->input->get('cache');
$size = $this->input->get('size');
!$size && $size = 20;
$where = array(
"duration>" => 0,
);
$id && $where['id'] = $id;
$redis = &load_cache('redis');
$save_key = "RECEIVER_UPDATE_WAV_LAST_ID";
if (!$cache) {
$last_id = $redis->get($save_key);
$last_id && $where['id>'] = $last_id;
}
$total = $this->receiver_yx_model->count($where);
if ($total) {
$rows = $this->receiver_yx_model->select($where, 'id asc', 1, $size, 'id,call_id,rec_url,json_data');
$this->load->library('qiniu');
foreach ($rows as $key => $val) {
$filename = $val['rec_url'];
if (strpos($filename, 'hdi/yx') !== false) {
echo $val['id'];
$info = $this->qiniu->getInfo($filename);
if (!$info['fsize']) {
$res = $this->qiniu->rm($filename);
$res = $this->qiniu->rm(str_replace('hdi/', '', $filename));
$json_data = json_decode($val['json_data'], true);
$file = $this->upload($json_data['recUrl'], 1);
if ($file) {
$this->receiver_yx_model->update(array('rec_url' => $file), array('id' => $val['id']));
$val['result'] = $file;
debug_log(json_encode($val, JSON_UNESCAPED_UNICODE), 'jdb_call_update_rec_url.log');
}
}
if (!$id) {
$last_id = $val['id'];
}
}
}
$res = $redis->save($save_key, $last_id);
}
$left = $total > count($rows) ? $total - count($rows) : 0;
echo 'total:' . $total . ',left:' . $left;
}
//更新空录音通话记录
public function up_empty()
{
$this->load->model('app/jdb/receiver_yx_model');
$id = $this->input->get('id');
$callid = $this->input->get('callid');
$filename = $this->input->get('filename');
$where = array(
'id' => $id,
'call_id' => $callid
);
$row = $this->receiver_yx_model->get($where);
$filename = base64_decode($filename);
if ($row && $filename) {
$res = $this->receiver_yx_model->update(array('rec_url' => $filename), array('id' => $row['id']));
die(json_encode(array('code' => $res)));
} else {
die(json_encode(array('code' => 0)));
}
}
}
+36 -22
View File
@@ -379,25 +379,38 @@ class Cusorder extends Wxapp
$img_status = $this->order_datas_entity->data_status($order_datas[$val['id']][0]);
$title = "{$brand_name}-{$serie_name}";
$other_data = [
'客户' => ['type' => 'text', 'value' => $val['name'], 'bg_color' => ''],
$o_data_1 = [
'购车主体' => ['type' => 'text', 'value' => $val['main_type'] ? '公司' : '个人', 'bg_color' => ''],
'品牌' => ['type' => 'text', 'value' => $title, 'bg_color' => ''],
'车型' => ['type' => 'text', 'value' => $car_name, 'bg_color' => ''],
'付款方式' => ['type' => 'text', 'value' => $val['payway'] ? '全款' : '按揭', 'bg_color' => ''],
];
$other_data['订单合同'] = ['type' => 'text', 'value' => $img_status['contract_img']['text'], 'bg_color' => $img_status['contract_img']['color']];
$other_data['付款凭证'] = ['type' => 'text', 'value' => $img_status['pay_img']['text'], 'bg_color' => $img_status['pay_img']['color']];
if ($val['main_type']) {//公司
$other_data['营业执照'] = ['type' => 'text', 'value' => $img_status['business_licence']['text'], 'bg_color' => $img_status['business_licence']['color']];
$o_data_1['营业执照'] = ['type' => 'text', 'value' => $img_status['business_licence']['text'], 'bg_color' => $img_status['business_licence']['color']];
} else {
$other_data['客户身份证'] = ['type' => 'text', 'value' => $img_status['cardida']['text'], 'bg_color' => $img_status['cardida']['color']];
$o_data_1['客户身份证'] = ['type' => 'text', 'value' => $img_status['cardida']['text'], 'bg_color' => $img_status['cardida']['color']];
}
$other_data['权益确认书'] = ['type' => 'text', 'value' => $img_status['equity_ck_img']['text'], 'bg_color' => $img_status['equity_ck_img']['color']];
$val['order_time'] != '0000-00-00 00:00:00' && $other_data['下定时间'] = ['type' => 'text', 'value' => date('Y-m-d', strtotime($val['order_time'])), 'bg_color' => ''];
$val['delry_time'] != '0000-00-00 00:00:00' && $other_data['期望交付'] = ['type' => 'text', 'value' => date('Y-m-d', strtotime($val['delry_time'])), 'bg_color' => ''];
$o_data_1['订单合同'] = ['type' => 'text', 'value' => $img_status['contract_img']['text'], 'bg_color' => $img_status['contract_img']['color']];
$o_data_1['付款凭证'] = ['type' => 'text', 'value' => $img_status['pay_img']['text'], 'bg_color' => $img_status['pay_img']['color']];
$o_data_1['权益确认书'] = ['type' => 'text', 'value' => $img_status['equity_ck_img']['text'], 'bg_color' => $img_status['equity_ck_img']['color']];
$o_data_2 = [
'付款方式' => ['type' => 'text', 'value' => $val['payway'] ? '全款' : '按揭', 'bg_color' => ''],
'发票' => ['type' => 'text', 'value' => $img_status['bill_img']['text'], 'bg_color' => $img_status['bill_img']['color']]
];
$o_data_3 = [
'行驶证' => ['type' => 'text', 'value' => $img_status['car_img']['text'], 'bg_color' => $img_status['car_img']['color']],
'保单' => ['type' => 'text', 'value' => $img_status['insurance_img']['text'], 'bg_color' => $img_status['insurance_img']['color']],
'交车合照' => ['type' => 'text', 'value' => $img_status['delivery_ck_img']['text'], 'bg_color' => $img_status['delivery_ck_img']['color']]
];
$o_data_4 = [];
$val['order_time'] != '0000-00-00 00:00:00' && $o_data_4['下定时间'] = ['type' => 'text', 'value' => date('Y-m-d', strtotime($val['order_time'])), 'bg_color' => ''];
$val['delry_time'] != '0000-00-00 00:00:00' && $o_data_4['期望交付'] = ['type' => 'text', 'value' => date('Y-m-d', strtotime($val['delry_time'])), 'bg_color' => ''];
if ($map_users[$val['admin_id']]) {
$other_data['销售顾问'] = ['type' => 'text', 'value' => $map_users[$val['admin_id']], 'bg_color' => ''];
$o_data_4['销售顾问'] = ['type' => 'text', 'value' => $map_users[$val['admin_id']], 'bg_color' => ''];
}
$other_data['o_data_1'] = $o_data_1;
$other_data['o_data_2'] = $o_data_2;
$other_data['o_data_3'] = $o_data_3;
$other_data['o_data_4'] = $o_data_4;
$lists[] = [
'id' => $val['id'],
'cus_id' => $val['customer_id'],
@@ -408,7 +421,6 @@ class Cusorder extends Wxapp
'other_data' => $other_data,
'allot' => $allot,
];
}
}
$data = [
@@ -437,20 +449,22 @@ class Cusorder extends Wxapp
$row['color'] && $car_data['车身颜色'] = $row['color'];
$row['in_color'] && $car_data['内饰颜色'] = $row['in_color'];
$car_data['付款方式'] = $payway ? '全款' : '分期';
$car_data['期望交付时间'] = date('Y-m-d', strtotime($row['delry_time']));
$row['delry_time'] != '0000-00-00 00:00:00' && $car_data['期望交付时间'] = date('Y-m-d', strtotime($row['delry_time']));
if (!$payway) { // 分期
$car_data['首付款方式'] = $this->orders_model->downpayment_type($row['downpayment_type']);
$car_data['贷款额度'] = $money_json['loan_amount'];
$car_data['贷款期数'] = $money_json['loan_periods'];
$car_data['月供'] = $money_json['monthly_payment'];
}
$car_data['是否店内上牌'] = $row['if_num'] ? '是' : '否';
$car_data['是否店内投保'] = $row['if_insure'] ? '是' : '否';
if ($row['if_num']) {
$car_data['上牌费'] = $money_json['register_amount'] ? $money_json['register_amount'] : 0;
$car_data['按揭信息'] = '';
// $car_data['首付款方式'] = $this->orders_model->downpayment_type($row['downpayment_type']);
// $car_data['贷款额度'] = $money_json['loan_amount'];
// $car_data['贷款期数'] = $money_json['loan_periods'];
// $car_data['月供'] = $money_json['monthly_payment'];
}
$money_json['confirm_amount'] && $car_data['定金'] = $money_json['confirm_amount'];
$money_json['discount_amount'] && $car_data['车身优惠'] = $money_json['discount_amount'];
$car_data['是否店内投保'] = $row['if_insure'] ? '是' : '否';
$car_data['是否店内上牌'] = $row['if_num'] ? '是' : '否';
if ($row['if_num']) {
$car_data['上牌费'] = $money_json['register_amount'] ? $money_json['register_amount'] : 0;
}
$bt_cn_array = [0 => '下定信息确认无误', 1 => '发票信息确认无误', 2 => '车辆交付'];
$data = [
'id' => $id,
@@ -1,5 +1,5 @@
<?php
defined('WXAPP_APP') OR exit('No direct script access allowed');
defined('WXAPP_APP') or exit('No direct script access allowed');
/**
* Created by Vim
@@ -24,7 +24,7 @@ class Customerlogs extends Wxapp
$this->load->model('receiver/receiver_customers_model', 'customers_model');
$this->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model');
$this->load->model('receiver/receiver_comments_model', 'mdComments');
// $this->load->model('receiver/receiver_xz_model');
$this->load->model('receiver/receiver_yx_model');
}
protected function get()
@@ -53,11 +53,11 @@ class Customerlogs extends Wxapp
}
}
if ($val['type'] == 2) {
$rec_row = $this->receiver_xz_model->get(['id' => $val['log']], 'rec_url,duration');
$rec_row = $this->receiver_yx_model->get(['id' => $val['log']], 'rec_url,duration');
$content = '拨打电话';
!$rec_row['duration'] && $content .= '(未接通)';
$rec_row['rec_url'] && $record = $rec_row['rec_url'];
$rec_row['duration'] && $second = intval($rec_row['duration'] / 1000);
$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
+61
View File
@@ -0,0 +1,61 @@
<?php
defined('WXAPP_APP') or exit('No direct script access allowed');
/**
* Created by Vim
* User: lcc
* Date: 2021/07/13
* Time: 14:08
*/
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
class Loan extends Wxapp
{
public function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = array();//登录白名单
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg = array();//授权微信信息
$this->load->model('receiver/order/receiver_orders_model', 'orders_model');
}
protected function get()
{
}
protected function post()
{
}
protected function put()
{
$oid = $this->input_param('o_id');
//贷款相关参数
$downpayment_type = $this->input_param('downpayment_type');
$loan_amount = $this->input_param('loan_amount');
$loan_periods = $this->input_param('loan_periods');
$monthly_payment = $this->input_param('monthly_payment');
$row = $this->orders_model->get(['id' => $oid]);
if (!$row) throw new Exception('参数错误', ERR_PARAMS_ERROR);
$money_json = json_decode($row['money_json'], true);
$data['downpayment_type'] = $downpayment_type;
$money_json['loan_amount'] = $loan_amount ? $loan_amount : 0;
$money_json['loan_periods'] = $loan_periods ? $loan_periods : 0;
$money_json['monthly_payment'] = $monthly_payment ? $monthly_payment : 0;
$data['money_json'] = json_encode($money_json, JSON_UNESCAPED_UNICODE);
$result = $this->orders_model->update($data, ['id' => $row['id']]);
if ($result) {
throw new Exception('修改成功', API_CODE_SUCCESS);
} else {
throw new Exception('修改失败', ERR_PARAMS_ERROR);
}
}
}
+72
View File
@@ -0,0 +1,72 @@
<?php
defined('WXAPP_APP') or exit('No direct script access allowed');
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
require_once COMMPATH . 'third_party/Ycall/Ycall.php';
class Yx 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_yx_model');
$this->log_file = 'call.log';
}
protected function get()
{
$id = $this->input_param('id');
$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) {
$seq_id = create_order_no();
$ycall = new Ycall();
$maxBindingTime = 10;//绑定时间
$result = $ycall->ABXbind($user_mobile, $customer_mobile, $seq_id, $maxBindingTime);
if ($result['result'] != '000000') { //绑定失败
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['message'], API_CODE_FAIL);
} else {
$call_mobile = $result['middleNumber'];
$add_data = [
'call_id' => $seq_id,
'display_number' => $call_mobile,
'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_yx_model->add($add_data);
$redis->save($cache_key, $call_mobile, $maxBindingTime * 60);
}
}
$data['mobile'] = $call_mobile;
return $data;
}
}
+17 -2
View File
@@ -962,11 +962,11 @@ if (!function_exists('http_host_com')) {
}
} else { // 正式
if ($type == 'api') {
$url = "";
$url = "https://sapi.liche.cn";
} else if ($type == 'home') {
$url = "";
} else if ($type == 'admin') {
$url = "";
$url = "https://sadmin.liche.cn";
}
}
return $url;
@@ -1198,3 +1198,18 @@ if (!function_exists('isValidLatLng')) {
return preg_match($longitudePattern, $lng) && preg_match($latitudePattern, $lat);
}
}
/**
* 获取云信录音
*/
if (!function_exists('get_yx_video')) {
function get_yx_video($string)
{
if (strpos($string, 'hangzhou.aliyuncs.com') !== false) {
$record = $string;
} else {
$record = build_qiniu_image_url($string);
}
return $record;
}
}
+2 -2
View File
@@ -25,13 +25,13 @@ class Hd_wechat
if (false !== strpos($_SERVER['HTTP_HOST'], 'dev')) { //dev 测试
$this->env = 'd';
} elseif (false !== strpos($_SERVER['HTTP_HOST'], 'api.ss.haodian.cn')) {//test 测试
$this->env = 'p';
$this->env = 't';
} else { // 正式
$this->env = 'p';
}
if ('p' != $this->env) {
$this->url_wechat = http_host_com('api') . 'weixin';
$this->url_wechat = 'https://sapi.liche.cn/weixin';
}
$this->redis = &load_cache('redis');
@@ -1,11 +1,13 @@
<?php
/**
* Created by PhpStorm.
* User: lcc
* Date: 2022/1/10
* Time: 16:11
*/
class Order_datas_entity{
class Order_datas_entity
{
private $ci;
const COLOR_UN_UPLOAD = '#f9394d'; //未传
@@ -14,20 +16,27 @@ class Order_datas_entity{
const COLOR_CHECK = '#36afa2'; //通过
public function __construct(){
$this->ci = & get_instance();
public function __construct()
{
$this->ci = &get_instance();
}
public function data_status($o_data){
public function data_status($o_data)
{
$result = [
'contract_img' => ['text'=>'未传','type'=>1,'color'=>self::COLOR_UN_UPLOAD], //合同图片
'pay_img' => ['text'=>'未传','type'=>1,'color'=>self::COLOR_UN_UPLOAD], //支付凭证
'cardida' => ['text'=>'未传','type'=>2,'color'=>self::COLOR_UN_UPLOAD], //身份证
'business_licence' => ['text'=>'未传','type'=>3,'color'=>self::COLOR_UN_UPLOAD], //营业执照
'equity_ck_img' => ['text'=>'未传','type'=>4,'color'=>self::COLOR_UN_UPLOAD], //权益确认书
'contract_img' => ['text' => '未传', 'type' => 1, 'color' => self::COLOR_UN_UPLOAD], //合同图片
'pay_img' => ['text' => '未传', 'type' => 1, 'color' => self::COLOR_UN_UPLOAD], //支付凭证
'cardida' => ['text' => '未传', 'type' => 2, 'color' => self::COLOR_UN_UPLOAD], //身份证
'business_licence' => ['text' => '未传', 'type' => 3, 'color' => self::COLOR_UN_UPLOAD], //营业执照
'equity_ck_img' => ['text' => '未传', 'type' => 4, 'color' => self::COLOR_UN_UPLOAD], //权益确认书
'bill_img' => ['text' => '未传', 'type' => 5, 'color' => self::COLOR_UN_UPLOAD], //发票
'delivery_ck_img' => ['text' => '未传', 'type' => 5, 'color' => self::COLOR_UN_UPLOAD], //交车确认图片
'car_img' => ['text' => '未传', 'type' => 5, 'color' => self::COLOR_UN_UPLOAD], //行驶证
'car_auth_img' => ['text' => '未传', 'type' => 5, 'color' => self::COLOR_UN_UPLOAD], //车机实名认证
'insurance_img' => ['text' => '未传', 'type' => 5, 'color' => self::COLOR_UN_UPLOAD], //交强险图片
];
foreach ($result as $key=>$item) {
if($o_data[$key]){
foreach ($result as $key => $item) {
if ($o_data[$key]) {
$result[$key]['text'] = '已传';
$result[$key]['color'] = self::COLOR_IS_UPLOAD;
}
@@ -0,0 +1,12 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Receiver_yx_model extends HD_Model
{
private $table_name = 'lc_receiver_yx';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
+125
View File
@@ -0,0 +1,125 @@
<?php
require_once(COMMPATH . "/third_party/Ycall/sdk/PrivacyUnbindBoody.php");
require_once(COMMPATH . "/third_party/Ycall/sdk/PrivacyAxbBindBody.php");
require_once(COMMPATH . "/third_party/Ycall/sdk/PrivacyAxTransferBody.php");
require_once(COMMPATH . "/third_party/Ycall/sdk/WinnerVoiceSender.php");
require_once(COMMPATH . "/third_party/Ycall/sdk/PrivacyAxBindBody.php");
require_once(COMMPATH . "/third_party/Ycall/sdk/VoiceHostUrl.php");
class Ycall
{
private $account = "985437";
private $token = "5c5ee9cfcb2948a1aadefc445cf96b13";
private $mobileList = 'mobile_list';
private $callbackUrl = 'https://api.ss.haodian.cn/plan/yxcall';
private $phones = '';
private $ci;
public function __construct($params = [])
{
$this->ci = &get_instance();
$params['app_id'] && $this->account = $params['app_id'];
$params['app_key'] && $this->token = $params['app_key'];
}
public function ABXPoll($mobileA, $mobileB, $customerData, $callbackUrl, $maxBindingTime = 0, $callRec = 1, $rand = False)
{ //轮询
$ci = &get_instance();
$ci->config->load('ycall', TRUE);
if ($this->phones) {
$mobile_list = $this->phones;
} else {
$mobile_list = $ci->config->item($this->mobileList, 'ycall');
}
if ($rand) { //随机
shuffle($mobile_list);
}
foreach ($mobile_list as $item) {
$middleNumber = $item;
$result = $this->ABXbind($mobileA, $mobileB, $middleNumber, $customerData, $callbackUrl, $maxBindingTime, $callRec);
if ($result['result'] == '000000') {
break;
}
}
return $result;
}
public function ABXbind($mobileA, $mobileB, $customerData, $maxBindingTime = 0, $middleNumber = '', $callbackUrl = '', $callRec = 1)
{
!$callbackUrl && $callbackUrl = $this->callbackUrl;
$axbBody = new PrivacyAxbBindBody();
/**设置为平台分配的隐私号码*/
$middleNumber && $axbBody->middleNumber = $middleNumber;
/**设置为需要绑定的号码A*/
$axbBody->bindNumberA = $mobileA;
/**设置为需要绑定的号码B*/
$axbBody->bindNumberB = $mobileB;
/**用户自定义字段, 呼叫结束后,推送回用户*/
$axbBody->customerData = $customerData;
/**是否需要录音,需要录音设置为1,不需要录音设置为0*/
$axbBody->callRec = $callRec;
/**设置绑定时间,单位秒,当设置为0时,则永久绑定*/
$axbBody->maxBindingTime = $maxBindingTime;
/**设置话单的推送地址*/
$axbBody->callbackUrl = $callbackUrl;
/**设置为平台分配的account*/
$account = $this->account;
/**设置为平台分配的token*/
$token = $this->token;
$sender = new WinnerVoiceSender($account, $token, true);
$result = $sender->sendRequest('/voice/1.0.0/middleNumberAXB', json_encode($axbBody));
$voice_result = json_decode($result, true);
return $voice_result;
}
/** AX,AXB 模式小号解绑 */
function AXBUnbind($middleNumber, $mobileA, $mobileB = '')
{
$unbindBody = new PrivacyUnbindBoody();
$unbindBody->middleNumber = $middleNumber;
$unbindBody->bindNumberA = $mobileA;
$mobileB && $unbindBody->bindNumberB = $mobileB; //AXB 模式时必填
/**设置为平台分配的account*/
$account = $this->account;
/**设置为平台分配的token*/
$token = $this->token;
$sender = new WinnerVoiceSender($account, $token, true);
$result = $sender->sendRequest('/voice/1.0.0/middleNumberUnbind', json_encode($unbindBody));
$voice_result = json_decode($result, true);
return $voice_result;
}
/**
* AXN绑定
* @return void
*/
public function AXbind($middleNumber, $mobileA, $mobileB = '')
{
$axBody = new PrivacyAxBindBody();
$axBody->middleNumber = $middleNumber;
$axBody->bindNumberA = $mobileA;
$mobileB && $axBody->bindNumberB = $mobileB;
$axBody->callbackUrl = $this->callbackUrl;
$axBody->callRec = 1;
$axBody->mode = 1; //1: AXN; 2: AX, 默认为 AXN 模式
/**设置为平台分配的account*/
$account = $this->account;
/**设置为平台分配的token*/
$token = $this->token;
$sender = new WinnerVoiceSender($account, $token, true);
$result = $sender->sendRequest('/voice/1.0.0/middleNumberAX', json_encode($axBody, JSON_UNESCAPED_UNICODE));
$voice_result = json_decode($result, true);
return $voice_result;
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
class PrivacyAxBindBody
{
public $middleNumber;
public $bindNumberA;
public $bindNumberB;
public $callRec;
public $maxBindingTime;
public $callbackUrl;
/*模式: 0: AXB; 1: AXN; 2: AX; 3: AXx 解绑AXB和AXN模式时,默认可以不填 4: AXyb模式 5: XYB模式手工绑定 ; 6 XYB模式自动绑定 */
public $mode;
/**
* PrivacyAxbBindBody constructor.
*/
public function __construct()
{
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
class PrivacyAxTransferBody
{
public $transferMiddleNumber;
public $transferToNumberA;
public $callRec;
public $callbackUrl;
public $isDeleteTransfer;
public $passthroughCallerToA;
/**
* PrivacyAxbBindBody constructor.
*/
public function __construct()
{
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
class PrivacyAxbBindBody
{
public $middleNumber;
public $bindNumberA;
public $bindNumberB;
public $callRec;
public $maxBindingTime;
public $callbackUrl;
public $passthroughCallerToA;
public $passthroughCallerToB;
public $customerData;
/**
* PrivacyAxbBindBody constructor.
*/
public function __construct()
{
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
class PrivacyUnbindBoody
{
/*需要解绑的小号*/
public $middleNumber;
public $bindNumberA;
public $bindNumberB;
/*模式: 0: AXB; 1: AXN; 2: AX; 3: AXx 解绑AXB和AXN模式时,默认可以不填 4: AXyb模式 5: XYB模式手工绑定 ; 6 XYB模式自动绑定 */
public $mode;
/**
* PrivacyUnbindBoody constructor.
*/
public function __construct()
{
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
$HTTPS_VOICE_SERVER='https://101.37.133.245:11008';
$HTTP_VOICE_SERVER='http://101.37.133.245:11108';
$PRIVACY_AX_URL='/voice/1.0.0/middleNumberAX';
$PRIVACY_AXB_URL='/voice/1.0.0/middleNumberAXB';
$PRIVACY_UNBIND_URL='/voice/1.0.0/middleNumberUnbind';
$PRIVACY_AXB_TRANSFER_URL='/voice/1.0.0/axbTransfer';
+19
View File
@@ -0,0 +1,19 @@
<?php
class VoiceResult
{
public $message;
public $bindId;
public $result;
public $middleNumber;
/**
* VoiceResult constructor.
*/
public function __construct()
{
}
}
+112
View File
@@ -0,0 +1,112 @@
<?php
include_once("VoiceHostUrl.php");
class WinnerVoiceSender
{
private $account;
private $token;
private $isHttps;
private $HTTPS_VOICE_SERVER='https://101.37.133.245:11008';
private $HTTP_VOICE_SERVER='http://101.37.133.245:11108';
/**
* PrivacyAxbBindBody constructor.
* @param $accountId
* @param $token
* @param $url
*/
public function __construct($accountId, $token,$isHttps)
{
$this->account = $accountId;
$this->token = $token;
$this->isHttps = $isHttps;
}
/**
*
*返回字符串的毫秒数时间戳
*/
function get_total_millisecond()
{
$time = explode (" ", microtime () );
$time = $time[1] . "000";
return $time;
}
function getAuthorizationHeader($timeStamp)
{
$str = $this->account.":".$timeStamp;
$header = base64_encode($str);
return $header;
}
function getSig($timeStamp)
{
return md5("$this->account$this->token$timeStamp");
}
function sendRequest($voice_url,$body)
{
global $HTTP_VOICE_SERVER,$HTTPS_VOICE_SERVER;
if($this->isHttps)
{
$url=$this->HTTPS_VOICE_SERVER . $voice_url;
}
else {
$url=$this->HTTP_VOICE_SERVER . $voice_url;
}
$timeStamp = $this->get_total_millisecond();
$sig = $this->getSig($timeStamp);
$post_url = "$url/$this->account/$sig";
$auth_header = $this->getAuthorizationHeader($timeStamp);
$header = array("Accept:application/json","Content-Type:application/json;charset=utf-8","Authorization:$auth_header");
$result = $this->curl_post($post_url,$body,$header);
return $result;
}
/**
* 发起HTTPS请求
* @param $url
* @param $data
* @param $header
* @param int $post
* @return bool|string
*/
function curl_post($url,$data,$header,$post=1)
{
//初始化curl
$ch = curl_init();
//参数设置
$res= curl_setopt ($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, $post);
if($post)
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
$result = curl_exec ($ch);
//连接失败
if($result == FALSE){
$result = "{\"result\":\"172001\",\"message\":\"网络错误\"}";
}
curl_close($ch);
return $result;
}
}