Commit 6aa0ec83 authored by zw's avatar zw

Merge branch 'test' into test-hujun1.15

# Conflicts: # application/model/Users.php # application/route.php
parents 4ddabae2 5226a523
......@@ -183,7 +183,7 @@ class Broker extends Basic
$user = new Users();
// 查询数据集
$user_res =$user ->where('user_nick|user_phone','like',"%$phone_or_name%")
->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
//->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
->whereOr('agent_id',$user_id)
->limit($pagesize)
......@@ -193,7 +193,7 @@ class Broker extends Basic
//$user_res =$user->user_search($phone_or_name,$Two_days_ago,$user_id,$pagesize,$pagenum);
$total =$user ->where('user_nick|user_phone','like',"%$phone_or_name%")
->where('create_time','< time',$Two_days_ago)
//->where('create_time','< time',$Two_days_ago)
->whereOr('agent_id',$user_id)
->count();
......
......@@ -10,7 +10,7 @@ namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\untils\PlsDemo;
use app\api_broker\untils\RongDemo;
use app\model\AAgentsPhone;
use app\model\AliYunPhone;
use app\model\BindingPhone;
......@@ -27,7 +27,9 @@ class CellPhone extends Basic
/**
* 绑定手机号
* 解绑之后有延迟
*
* @return \think\Response
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
......@@ -41,20 +43,21 @@ class CellPhone extends Basic
$record = empty($this->params['record']) ? true : false; //是否录音
$setting = Cache::get('Setting'); //获取配置
//var_dump($setting);/*************测试****************/
$aliYunPhone = new AliYunPhone();
$bind = new BindingPhone();
$field = 'phone_x';
$where['a.status'] = 1;
$where['a.phone_a'] = $phone_a;
$where['a.phone_b'] = $phone_b;
$where['a.type'] = $setting['is_privacy'];
if ($setting['is_privacy'] == 1) {
if ($setting['is_privacy'] != 0) {
$phone_x = $bind->getPhoneX($field, $where);
if ($phone_x) {
$this->data = ['phone' => $phone_x['phone_x']];
} else {
$phone_x = $aliYunPhone->getAliYunPhone($phone_b);
$phone_x = $aliYunPhone->getAliYunPhone($phone_a, $phone_b,$setting['is_privacy']);
//是否还有未绑定的中间号码
if ($phone_x) {
......@@ -63,25 +66,43 @@ class CellPhone extends Basic
} else {
$setting['day_num'] += 1;
$time = date('Y-m-d H:i:s',strtotime("+{$setting['day_num']} day"));
// $time = date('Y-m-d H:i:s',time()+300);
}
$result = PlsDemo::bindAxb($phone_a, $phone_b, $time, $record, $phone_x['phone_x']);
if ($result->Message == 'OK') {
$aliYunPhone->where('phone_x', $phone_x['phone_x'])->setField('status', 1);
Db::table('aliYun_binding_phone')->insert([
'phone_a' => $phone_a,
'phone_b' => $phone_b,
'subsId' => $result->SecretBindDTO->SubsId,
'requestId' => $result->RequestId,
'record' => $record,
'aliYun_phone_id' => $phone_x['id'],
'expiry_date' => $time,
]);
$this->msg = 'Binding success.';
$this->data = ['phone' => $phone_x['phone_x']];
} else {
$this->code = 101;
$this->msg = '绑定失败,请重试!';
if($setting['is_privacy']==2) {
/*容联云*/
$Rong = new RongDemo();
$record2 = empty($this->params['record']) ? 'true' : 'false'; /* 是否录音(容联云规定string类型)*/
// var_dump($phone_x);/*************测试****************/
/*计算有效期*/
if(empty($setting['day_num'])){
$yx_time=$setting['day_num']*60*60*24;
}else{
$yx_time=604800;
}
$result = $Rong->setNumber($phone_a, $phone_b, $phone_x['phone_x'], $phone_x['area'],$yx_time,$record2);
/*绑定成功*/
// var_dump($result);/*************测试****************/
if($result['statusCode']=='000000'){
$aliYunPhone->editStatus($phone_x, $phone_a, $phone_b, $record, $time, 0,$result['data']['mappingId'],$setting['is_privacy']); //记录绑定
$this->msg = 'Binding Rong success';
$this->data = ['phone' => $phone_x['phone_x']];
}
}else {
/*阿里云*/
$result = PlsDemo::bindAxb($phone_a, $phone_b, $time, $record, $phone_x['phone_x']);
if ($result->Message == 'OK') {
$aliYunPhone->editStatus($phone_x, $phone_a, $phone_b, $record, $time, $result,'',$setting['is_privacy']); //记录绑定
$this->msg = 'Binding success.';
$this->data = ['phone' => $phone_x['phone_x']];
} else {
$this->code = 101;
$this->msg = '绑定失败,请重试!';
}
}
Log::write(json_encode($result),'AliYunBindAxb'); //记录日志
} else {
$this->code = 102;
......@@ -153,14 +174,17 @@ class CellPhone extends Basic
if ($phone_x && $phone_a && $phone_b) {
$setting = Cache::get('Setting'); //获取配置
if ($setting['is_privacy'] == 1) {
$phone = new BindingPhone();
$subsId = $phone->getSubsId($phone_x,$phone_a,$phone_b,1);
$phone = new BindingPhone();
if ($setting['is_privacy'] == 1) {
/*阿里云*/
$subsId = $phone->getSubsId($phone_x,$phone_a,$phone_b,1,'subsId');
if ($subsId) {
$result = PlsDemo::unbindSubscription($subsId, $phone_x);
$result = PlsDemo::unbindSubscription($subsId, $phone_x);/*解绑*/
if ($result->Message == 'OK') {
$phone->UnBind($phone_x);
$phone->UnBind($phone_x, $phone_a, $phone_b);
} else {
$this->code = 101;
$this->msg = 'remove binding error';
......@@ -169,7 +193,28 @@ class CellPhone extends Basic
$this->code = 101;
$this->msg = 'dont\'t have about phone_x info';
}
}else{
/*容联云*/
$mappingId = $phone->getSubsId($phone_x,$phone_a,$phone_b,1,'mappingId');
$Rong = new RongDemo();
if($mappingId) {
$result = $Rong->releaseNumber($mappingId);/*解绑*/
//var_dump($result);/*************测试****************/
if ($result['statusCode'] == '000000') {
$phone->UnBind($phone_x, $phone_a, $phone_b);
}else{
$this->code = 101;
$this->msg = 'remove binding error';
}
}else{
$this->code = 101;
$this->msg = 'dont\'t have about phone_x info';
}
}
} else {
$this->code = 101;
$this->msg = 'phone_x or phone_a or phone_b is null';
......
......@@ -128,15 +128,19 @@ class Client extends Basic
}
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$type = $params['type']? $params['type'] : 0;
//条件
//time_minute_diff 时间差(分)48小时内增加的【拥有经纪人】的客户为--受保护客户
$field = ['id as user_id','user_nick','user_phone','agent_id','referrer_id','create_time',"TIMESTAMPDIFF(MINUTE,create_time,'{$time}')as time_minute_diff"];
$where = " agent_id in({$params['agent_id']}) ";
$where = " agent_id in({$params['agent_id']}) and user_status={$type}";
if(!empty($params['search'])){
//搜索客户--可以搜索自己的客户and 不在保护期的客户
$where = " (agent_id in(0,{$params['agent_id']}) or agent_id is null or TIMESTAMPDIFF(MINUTE,create_time,'{$time}') > 2880 )
// $where = " (agent_id in(0,{$params['agent_id']}) or agent_id is null or TIMESTAMPDIFF(MINUTE,create_time,'{$time}') > 2880 )
// and ( user_nick like '%{$params['search']}%' or user_phone like '%{$params['search']}%' ) ";
$where = " (agent_id in(0,{$params['agent_id']}) or agent_id is null or TIMESTAMPDIFF(MINUTE,create_time,'{$time}') > 0 )
and ( user_nick like '%{$params['search']}%' or user_phone like '%{$params['search']}%' ) ";
$data['search'] = $params['search'];
}
......@@ -178,7 +182,8 @@ class Client extends Basic
'a.sub_shopname',
"TIMESTAMPDIFF(MINUTE,f.create_time,'{$time}')as time_minute_diff"
];
$where="(u.agent_id in(0,{$params['agent_id']}) or f.user_id is null or TIMESTAMPDIFF(MINUTE,u.create_time,'{$time}') > 2880 ) ";
//$where="(u.agent_id in(0,{$params['agent_id']}) or f.user_id is null or TIMESTAMPDIFF(MINUTE,u.create_time,'{$time}') > 2880 ) ";
$where="(u.agent_id in(0,{$params['agent_id']}) or f.user_id is null or TIMESTAMPDIFF(MINUTE,u.create_time,'{$time}') > 0 ) ";
if(!empty($search)){
$where.=" and f.content like '%$search%' ";
$data['search']=$search;
......@@ -214,4 +219,106 @@ class Client extends Basic
}
/**
* 全部客户
*/
public function all_user() {
header('Access-Control-Allow-Origin:*');
$Two_days_ago = date("Y-m-d h:i:s",strtotime("-2 day"));
//dump($Two_days_ago);
$params = $this->params;
#测试数据
// $params['phone_or_name'] = '666' ;
// $params['pagenum'] = '1' ;
// $params['user_id'] = '10' ;
// $params['type'] = 0 ;
// $params['search_type'] = '2' ;
#测试数据 end
if (!isset($params['user_id'])) {
return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
}
$phone_or_name = trim($params['phone_or_name']);
$pagenum = isset($params['pagenum']) ? $params['pagenum'] : 1;
$pagesize = 15;
$user_id = $params['user_id'];
$type = $params['type'];
$search_type = $params['search_type'];#无:'';客户电话:0;客户姓名:1;跟进:2;
if($search_type == '0')
{//客户电话
$conditions['user_phone'] = ['LIKE', "%$phone_or_name%"];
}elseif ($search_type == '1'){//客户电话
$conditions['user_nick'] = ['LIKE', "%$phone_or_name%"];
}
if ($search_type != '2')
{//全部客户
if($type == '0')
{//求租:0 ;已租:1 数据库0:求租;1:已租;-1:无效
$conditions['user_status'] = 0;
}else{//
$conditions['user_status'] = 1;
}
$user = new Users();
$user_res = $user->all_user($conditions,$pagesize,$pagenum);
$total = $user->all_user_count($conditions);
}else{//跟进
$UPhoneFollowPp = new UPhoneFollowPp();
$user_res = $UPhoneFollowPp->all_user_search($phone_or_name,$pagesize,$pagenum);
$total = $UPhoneFollowPp->all_user_search_count($phone_or_name);
//dump($total);exit;
}
if($search_type!='2')
{//全部客户数据处理
foreach($user_res as $k=>$v)
{
$label=array();
//dump($v);exit;
$user_res[$k]['user_nick'] = $v['user_nick']?$v['user_nick']:'未知';
if($user_id == $v['agent_id'])
{
$label[] = '我的';
}
/*dump($v['create_time']);
$time=strtotime(date("Y-m-d h:i:s"))-strtotime($v['create_time']);
dump(strtotime(date("Y-m-d h:i:s"))-strtotime($v['create_time']));//48时(h)=172800秒(s)
exit;*/
if((strtotime(date("Y-m-d h:i:s")) - strtotime($v['create_time'])) < 172800)
{
$label[] = '保护期内';
}
$user_res[$k]['label'] = implode(',',$label);
}
}else{//跟进数据处理
foreach($user_res as $k=>$v)
{
$user_res[$k]['time']=tranTime($v['create_time']);
$table= new Agents();
$Agents_res = $table->Agents_res($v['agent_id']);
//dump($Agents_res);
$user_res[$k]['agentinfo'] =$Agents_res ? $Agents_res['agentshopname'].'-'.$Agents_res['realname'] : '未知';
$user_res[$k]['agentshopname'] =$Agents_res['agentshopname'] ? $Agents_res['agentshopname'] : '';
$user_res[$k]['realname'] =$Agents_res['realname'] ? $Agents_res['realname'] : '';
$user_res[$k]['user_pic'] =ADMIN_URL_TL.'user_header/'.$Agents_res['head_portrait'];
}
}
/*dump($total);
var_dump($user_res);
exit;*/
$total = intval($total / $pagesize) + (($total % $pagesize == 0) ? 0 : 1);
return $this->response("200", "success!", ['user_date'=>$user_res,'pagenum'=>$pagenum,'total'=>$total,'search_type'=>$search_type]);
}
}
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\untils\RongDemo;
use app\model\BindingPhone;
use app\model\AliYunPhone;
class RongPhone extends Basic
{
protected $code = 200;
protected $data = [];
protected $msg = "";
/**绑定AXB
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function rBindAXB(){
$bind = new BindingPhone();
$params = $this->request->param();
$data=array();
$Rong = new RongDemo();
$aliYunPhone = new AliYunPhone();
$code= $Rong->statusCode;
$phone_a = $params['phone_a'];
$phone_b = $params['phone_b'];
/*查询分配的中间号*/
$where['a.status'] = 1;
$where['a.type'] = 2;
$where['a.phone_a'] = $phone_a;
$where['a.phone_b'] = $phone_b;
$phone_x['phone_x'] = $aliYunPhone->getAliYunPhone($phone_a,$phone_b,$type=2);
var_dump($phone_x);
exit;
if(!$phone_x){
}
$data['data'] = $Rong->setNumber($phone_a,$phone_b,$phone_x['phone_x'],$phone_x['area']);
$data['msg']=$code[$data['data']['statusCode']];
/*绑定成功*/
if($data['data']['statusCode']=='000000'){
}
$data2=json_encode($data);
echo $data2;
}
/**
* 解绑AXB
*/
public function rongReleaseNumber(){
$Rong = new RongDemo();
$params = $this->request->param();
// $mappingId = 'NME201201803141740516611729495567817080219070';
$r = $Rong->releaseNumber($params['mappingId']);
echo $r;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: zfc
* Date: 2018/3/12
* Time: 15:42
*/
namespace app\api_broker\untils;
//use app\api_broker\untils\curlUntils;
use app\chat\utils\CurlUtil;
class RongDemo
{
/**
* 业务url/Accounts/{accountSid}/nme/{type}/{operatorId}/[/{op}]?sig={sigParameter}
* accountSid 账户id
* operatorId 合作运营商标识
* type 号码类型
* op 操作名
* sigParameter 访问签名
* appId 应用id
* authToken 访问授权码
* test_phone 测试中间号
*
*/
public $base_url='https://apppro.cloopen.com:8883/2013-12-26';
public $components=[
'accountSid'=>'8a48b55153eae51101540e763d3b3888',
'appId'=>'8a216da85f5c89b1015f7718e2b90a63',
'appToken'=>'TOKEN3655166d16164b6ef25d6fa2a266acc1',
'authToken'=>'26b220de299d4a56a6f54dd5792a30e4'
];
public $test_phone='17080219070';
public $sign='';
public $statusCode=[
'000000' => '成功',
'300001' => '参数错误',
'300002' =>'验证错误',
'301101' =>'无号码资源',
'301201' =>'内部存储异常',
'301401' =>'无空闲号码',
'301402' =>'分配失败',
'301501' =>'类型号码未配置',
'301633' =>'找不到应用',
'320201' =>'号码已解绑',
'320400' =>'参数异常',
'320402' =>'号码已使用',
'320500' =>'落地异常',
'309000' =>'其它错误',
];
function __construct(){
//$this->sign = $this->sigParameter();
}
/**
* 签名(appId+authToken+时间戳)
* @return array
* @param $time
* @return mixed
*/
public function sigParameter($time)
{
$data=$this->components;
//生成签名
$data['accountSid'].$data['authToken'].$time;
$sign=strtoupper(md5($data['accountSid'].$data['authToken'].$time));
return $sign;
}
/**
* 认证信息
* @param $time
* @return mixed
*/
public function Authorization($time){
$data=$this->components;
$Authorization=base64_encode($data['accountSid'].':'.$time);
return $Authorization;
}
/**
*
* @param $type //号码类型 AXB ,XB
* @param $op //操作名(用于不同请求)
* @param $sign //签名
* @param $operatorId 平台标识
* @return string
*/
public function url($type,$op='',$operatorId,$sign){
$data=$this->components;
$url_c="/Accounts/{$data['accountSid']}/nme/{$type}/{$operatorId}/{$op}?sig={$sign}";
$url=$this->base_url.$url_c;
return $url;
}
public function sendCurl($url,$arr,$Authorization)
{
$data = json_encode($arr);
$curl = new CurlUtil();
$curl->headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json;charset=utf-8',
'Authorization' => $Authorization
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
//echo $url;
$response = $curl->post($url, $data);
return $response;
}
/**
* AXB绑定
* @param $aNumber
* @param $bNumber
* @param $xNumber
* @param $areaCode
* @param $record
* @param $yx_time
* @return string
*/
public function setNumber($aNumber,$bNumber,$xNumber,$areaCode,$yx_time='604800',$record){
$data = $this->components;
$time = date('YmdHis',time());
$sign = $this->sigParameter($time); /*签名*/
$url = $this->url('axb','setnumber','cu01',$sign);/*url*/
$Authorization = $this->Authorization($time);/*认证信息*/
$post_data = [
'appId' => $data['appId'],
'aNumber' => $aNumber,
'bNumber' => $bNumber,
'servingNumber' => $xNumber,
'areaCode' => $areaCode,
'needRecord' =>$record,
'mappingDuratio'=>$yx_time,
'cdrNotifyUrl' =>CURRENT_URL."task/rongBilledInformUrl",
'callStateNotifyUrl'=>CURRENT_URL."task/rongStatusInformUrl",
'recordNotifyUrl'=>CURRENT_URL."task/rongRecordingInformUrl",
// 'cdrNotifyUrl' =>"http://pre.tonglianjituan.com/task/rongBilledInfromUrl",
// 'callStateNotifyUrl'=>"http://pre.tonglianjituan.com/task/rongRecordingInfromUrl",
// 'recordNotifyUrl'=>"http://pre.tonglianjituan.com/task/rongStatusInfromUrl",
];
//var_dump($post_data);/*************测试****************/
$result = json_decode($this->sendCurl($url,$post_data,$Authorization),true);
return $result;
}
/**
* AXB 解绑
* @param $mappingId
* @return string
*/
public function releaseNumber($mappingId){
$data = $this->components;
$time = date('YmdHis',time());
$sign = $this->sigParameter($time); /*签名*/
$url = $this->url('axb','releasenumber','cu01',$sign);/*url*/
$Authorization = $this->Authorization($time);/*认证信息*/
$post_data = [
'appId' => $data['appId'],
'mappingId'=>$mappingId
];
$result = json_decode($this->sendCurl($url,$post_data,$Authorization),true);
return $result;
}
}
\ No newline at end of file
......@@ -121,6 +121,12 @@ function hide_customer_phone($phone)
}
////打印
//function prt($arr){
// echo "<pre/>";
// print_r($arr);
//}
/**^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$
* 验证手机号是否正确
* zhuwei 2017-10-18 17:28:01
......@@ -136,3 +142,36 @@ function checkMobileValidity($phone)
return false;
}
}
/**
* 时间轴 '刚刚' '昨天' '前天'
* 朱伟 2017-10-23 09:56:05
*/
function tranTime($time_inpute) {
$time2=strtotime($time_inpute);
$time = time() - $time2;
$rtime = date("H点i分s秒",$time2);
if ($time < 60) {
$str = '刚刚';
}
elseif ($time < 60 * 60) {
$min = floor($time/60);
$str = $min.'分钟前';
}
// elseif ($time < 60 * 60 * 24) {
// $h = floor($time/(60*60));
// $str = $h.'小时前 ';
// }
// elseif ($time < 60 * 60 * 24 * 3) {
// $d = floor($time/(60*60*24));
// if($d==1)
// $str = '昨天 '.$rtime;
// else
// $str = '前天 '.$rtime;
// }
else {
$str = date("Y-m-d",$time2);
}
return $str;
}
......@@ -14,7 +14,7 @@ define('LOCAL_IMG_HOST','/resource/lib/Attachments/');
define('PAGESIZE', 15); //分页每页条数
define('ADMIN_URL_TL','https://admin.tonglianjituan.com/'); //B端网址
//define('TEST_ADMIN_URL_TL','https://dev.tonglianjituan.com/'); //B端网址
define('CURRENT_URL', 'http://'.$_SERVER['HTTP_HOST'].DS); //取当前域名地址
define('CURRENT_URL', 'http://'.$_SERVER['HTTP_HOST'].'/'); //取当前域名地址
define('HEADERIMGURL', CURRENT_URL . 'static'. DS . 'head_portrait/'); //头像地址
define('AGENTHEADERIMGURL', CURRENT_URL . 'static'. DS . 'agent_head_portrait/'); //头像地址
define('CHAT_IMG_URL', CURRENT_URL . 'static'. DS . 'chat_image/'); //聊天图片地址
......
File mode changed from 100755 to 100644
......@@ -68,7 +68,7 @@ class Auth extends Basic
$data['search']=$search;
}
$data['list'] = $auth_group->getList($pageNo, $pageSize, 'id desc','*', $where);
$data['list'] = $auth_group->getList($pageNo, $pageSize, 'id asc','*', $where);
$data['total'] = $auth_group->getTotal($where);
return $this->response(200, '', $data);
}
......@@ -156,7 +156,7 @@ class Auth extends Basic
if ($table->editData($data,$id)) {
return $this->response(200, '成功');
} else {
return $this->response(101, '失败');
return $this->response(101, '未改动或者角色名重复!');
}
......@@ -300,7 +300,7 @@ class Auth extends Basic
if($table->saveStatus('status',$data['status'],$ids)){
return $this->response(200,'成功',$data);
}else{
return $this->response(100,'未改动或者角色名重复!',$data);
return $this->response(100,'失败',$data);
}
}
//权限表界面
......
......@@ -207,5 +207,59 @@ class Remark extends Basic
}
/**
* 电话跟进列表
*/
public function phone_up_list()
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
// if (!isset($params['user_id'])) {
// return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
// }
$searchdate = $params['searchdate'];
$pagenum = isset($params['pagenum']) ? $params['pagenum'] : 1;
$pagesize = 15;
$user_id = $params['user_id'];
$UPhoneFollowPp = new UPhoneFollowPp();
// 查询电话跟进数据
$UPhoneFollowPp_res=$UPhoneFollowPp->phone_up_list($pagesize,$pagenum);
//dump($UPhoneFollowPp_res);
/*dump($total);
var_dump($user_res);
exit;*/
//dump($UPhoneFollowPp_res);
/*foreach($UPhoneFollowPp_res as $k=>$v){
$table= new Agents();
$Agents_res =$table->Agents_res($v['agent_id']);
//dump($Agents_res);
$UPhoneFollowPp_res[$k]['agentinfo']=$Agents_res?$Agents_res['agentshopname'].'-'.$Agents_res['realname']:'未知';
$UPhoneFollowPp_res[$k]['user_pic']=ADMIN_URL_TL.'user_header/'.$Agents_res['head_portrait'];
$UPhoneFollowPp_res[$k]['label']='';
//dump($v['labels_id']);
//电话跟进标签
if($v['labels_id']){
$table= new ULabels();
$table_res =$table->get_labelsname($v['labels_id']);
//dump($table_res);
//exit;
$UPhoneFollowPp_res[$k]['label']=$table_res[0]['name'];
}
}*/
$UPhoneFollowPp = new UPhoneFollowPp();
$total =$UPhoneFollowPp->phone_up_list_count();
//dump($total);
$total = intval($total / $pagesize) + (($total % $pagesize == 0) ? 0 : 1);
//dump($total);
return $this->response("200", "success!", ['user_date'=>$UPhoneFollowPp_res,'pagenum'=>$pagenum,'total'=>$total]);
}
}
\ No newline at end of file
......@@ -49,6 +49,51 @@ class Agents extends Model
return $data;
}
/**
* 记录总数
*
* @param $params
* @return int|string
*/
public function getTotal2($join,$params)
{
return $this->alias('a')
->join($join)
->where($params)->count();
}
/**分页列表
* @param int $p
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $join
* @param string $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListJoin($p = 1, $pageSize = 15, $order_ = 'id desc', $field = '',$join='', $where = '')
{
$data = $this->field($field)
->alias('a')
->join($join)
->where($where)
->order($order_)
->limit($pageSize)
->page($p)
->select();
//echo $this->getLastSql();
return $data;
}
/**
* 经纪人详情
* @param $id
......
......@@ -18,31 +18,53 @@ class AliYunPhone extends BaseModel
/**
* 获取未绑定的手机号码
*
* @param string $phone
* @param $phone_a
* @param $phone_b
* @param $type
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAliYunPhone($phone = '') {
public function getAliYunPhone($phone_a,$phone_b,$type=1) {
/* //查找phone_x 与 phone_a绑定的号码
$where_a['b.status'] = 1;
$where_a['phone_a'] = $phone_a;
$where_a['bind_num'] = ['<=',200];
$aliYun_phone_id1 = $this->field('a.id,phone_x')->alias('a')
->join('aliYun_binding_phone b','a.id = b.aliYun_phone_id','left')
->where($where_a)->select();
$where['status'] = 0;
if ($phone) {
//查询之前一次绑定关系的号码
$phone_x = Db::table('aliYun_binding_phone')->alias('a')
->join('aliYun_phone b','a.aliYun_phone_id = b.id','left')
->where([
'phone_b' => $phone,
'a.status' => 0,
'b.status' => 0
])->value('phone_x');
//查找phone_x 与 phone_b绑定的号码
$where_b['b.status'] = 1;
$where_b['phone_b'] = $phone_b;
$where_b['bind_num'] = ['<=',200];
$aliYun_phone_id2 = $this->field('a.id,phone_x')->alias('a')
->join('aliYun_binding_phone b','a.id = b.aliYun_phone_id','left')
->where($where_b)->select();
if ($phone_x) {
$where['phone_x'] = $phone_x;
}
$id_arr = array_merge($aliYun_phone_id1,$aliYun_phone_id2); //合并phone_a和phone_b已经绑定的号码*/
$where_a['b.status'] = 1;
$where_a['bind_num'] = ['<=',200];
$id_arr = $this->field('a.id,phone_x')->alias('a')
->join('aliYun_binding_phone b','a.id = b.aliYun_phone_id','left')
->where($where_a)->where("(b.phone_a=$phone_a or b.phone_b=$phone_b) and a.type=$type ")->select();
foreach ($id_arr as $k=>$v) {
$id[$k] = $v['id'];//去除phone_a已经绑定的号码
}
$id = empty($id) ? 0 : implode(',',$id);
$where_phone['status'] = 0;
$where_phone['type'] = $type;
if (empty($id)) {
$result = Db::table('aliYun_phone')->field('id,phone_x,area')->where($where_phone)->find();
} else {
$where_phone['id'] = ['NOT IN',$id];
$result = Db::table('aliYun_phone')->field('id,phone_x,area')->where($where_phone)->find();
}
$result = Db::table('aliYun_phone')->field('id,phone_x')->where($where)->find();
return $result;
}
......@@ -81,4 +103,43 @@ class AliYunPhone extends BaseModel
->where($where)
->count();
}
/**
* 查询绑定数量
*
* @param $phone_x
* @return mixed
*/
public function checkNum($phone_x) {
return $this->where('status',0)->where('phone_x',$phone_x)->value('bind_num');
}
/**
* 修改绑定后的数据
*
* @param $phone_x
* @param $phone_a
* @param $phone_b
* @param $record
* @param $mappingId
* @param $time
* @param $type
* @param $result
* @throws \think\Exception
*/
public function editStatus($phone_x, $phone_a, $phone_b,$record,$time,$result,$mappingId='',$type=1) {
$this->where('phone_x', $phone_x['phone_x'])->setInc('bind_num');
Db::table('aliYun_binding_phone')->insert([
'phone_a' => $phone_a,
'phone_b' => $phone_b,
'subsId' => $result->SecretBindDTO->SubsId,
'requestId' => $result->RequestId,
'mappingId' => $mappingId,
'record' => $record,
'aliYun_phone_id' => $phone_x['id'],
'expiry_date' => $time,
'type' =>$type,
]);
return ;
}
}
\ No newline at end of file
......@@ -19,10 +19,11 @@ class BindingPhone extends BaseModel
* @param $phone_x
* @param $phone_a
* @param $phone_b
* @param $phoneId
* @param int $status
* @return bool|mixed
*/
public function getSubsId($phone_x, $phone_a, $phone_b = '', $status = 0) {
public function getSubsId($phone_x, $phone_a, $phone_b = '', $status = 0,$phoneId='subsId') {
if ($phone_x && ($phone_a || $phone_b)) {
$where['a.status'] = $status;
......@@ -35,7 +36,7 @@ class BindingPhone extends BaseModel
}
$subsId = $this->alias('a')
->join('aliYun_phone b','a.aliYun_phone_id=b.id','left')
->where($where)->value('subsId');
->where($where)->value($phoneId);
} else {
$subsId = false;
......@@ -44,21 +45,33 @@ class BindingPhone extends BaseModel
}
/**
* 释放绑定
*
* @param $phone_x
* @return bool|int
* @param string $phone_a
* @param string $phone_b
* @param string $request_id
* @return $this|bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function UnBind($phone_x) {
public function UnBind($phone_x, $phone_a = '', $phone_b='',$request_id = '') {
if ($phone_x) {
$phone = new AliYunPhone();
$phone_data = $phone->get(['phone_x'=>$phone_x]);
if ($phone_data->id) {
$phone_data->status = 0;
$phone_data = $phone->where('phone_x',$phone_x)->find();
if ($phone_data['id']) {
$phone_data['bind_num'] += 1;
$phone_data->save();
$result = $this->where([
'aliYun_phone_id'=>$phone_data->id,
'status' => 1
])->setField('status',0);
'aliYun_phone_id'=>$phone_data['id'],
'status' => 1,
'phone_a' => $phone_a,
'phone_b' => $phone_b,
])->update(['status'=>0,'release_requestId'=>$request_id]);
} else {
$result = false;
}
......@@ -81,8 +94,9 @@ class BindingPhone extends BaseModel
public function getPhoneX($field, $where) {
return $this->alias('a')
->field($field)
->join('aliYun_phone b','a.aliYun_phone_id=b.id')
->join('aliYun_phone b','a.aliYun_phone_id=b.id','left')
->where($where)
->find();
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: zfc
* Date: 2018/3/16
* Time: 14:55
*/
namespace app\model;
class RongBilledInform extends BaseModel
{
/**
* @param $where
* @param $v
* @return mixed
*/
public function getValue($where,$v)
{
$r = $this->where($where)->value($v);
return $r;
}
/**
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getArr($field,$where){
$r =$this->field($field)->where($where)->select();
return $r;
}
}
\ No newline at end of file
......@@ -206,10 +206,23 @@ class SecretReport extends Model
if ($remainder != 0) {
$time += 1;
}
$time += floor($v->time/60);
$time += ceil($v->time/60);
}
$price += $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分
}
return $price;
}
/**
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getArr($field,$where){
$r =$this->field($field)->where($where)->select();
return $r;
}
}
......@@ -105,4 +105,53 @@ class UPhoneFollowPp extends BaseModel
return $UPhoneFollowPp_res;
}
public function phone_up_list($pagesize,$pagenum)
{
$UPhoneFollowPp_res = db('u_phone_follow_up')
->order('create_time', 'desc')
->limit($pagesize)
->page($pagenum)
->select();
return $UPhoneFollowPp_res;
}
public function phone_up_list_count()
{
$UPhoneFollowPp_res = db('u_phone_follow_up')
->count();
return $UPhoneFollowPp_res;
}
public function all_user_search($searchdate,$pagesize,$pagenum)
{
$UPhoneFollowPp_res = db('u_phone_follow_up')
//->where('user_id',$user_id)
->where('content','like',"%$searchdate%")
->order('create_time', 'desc')
->limit($pagesize)
->page($pagenum)
->select();
/*$total =$UPhoneFollowPp
->where('user_id',$user_id)
->where('content',$searchdate)
->count();*/
return $UPhoneFollowPp_res;
}
public function all_user_search_count($searchdate)
{
$UPhoneFollowPp_res = db('u_phone_follow_up')
//->where('user_id',$user_id)
->where('content','like',"%$searchdate%")
//->limit($pagesize)
//->page($pagenum)
->count();
/*$total =$UPhoneFollowPp
->where('user_id',$user_id)
->where('content',$searchdate)
->count();*/
return $UPhoneFollowPp_res;
}
}
......@@ -324,4 +324,12 @@ class Users extends Model
->group("day")
->select();
}
public function all_user_count($params='')
{
return db('u_users')
->where($params)
->count();
}
}
......@@ -190,6 +190,8 @@ Route::group('index', [
'addBargain' => ['index/Finance/addBargain', [ 'method' => 'post' ] ], //新增成交报告佣金(分佣提成)
'commissionList' => ['index/Finance/commissionList', [ 'method' => 'get' ] ], //分佣提成
'payLogList' => ['index/Finance/payLogList', [ 'method' => 'get' ] ], //收款记录
'phone_up_list' => ['index/remark/phone_up_list', [ 'method' => 'get|post' ] ], //电话跟进列表
]);
......@@ -286,6 +288,9 @@ Route::group('task',[
'totalAgentResults' => [ 'task/ResultsSummaryTask/totalAgentResults', [ 'method' => 'get' ]], //释放号码
'rongBilledInformUrl' => [ 'task/PrivacyNumber/rongBilledInformUrl', [ 'method' => 'post | get' ] ],//隐私号码回调[话单通知]
'rongRecordingInformUrl' => [ 'task/PrivacyNumber/rongRecordingInformUrl', [ 'method' => 'post | get' ] ],//隐私号码回调[录音通知]
'rongStatusInformUrl' => [ 'task/PrivacyNumber/rongStatusInformUrl', [ 'method' => 'post | get' ] ],//隐私号码回调[状态通知]
]);
Route::group('broker', [
......@@ -319,29 +324,12 @@ Route::group('broker', [
'reportList' => ['api_broker/Report/reportList', [ 'method' => 'get' ] ],
'orderDetail' => ['api_broker/OrderLog/orderDetail', [ 'method' => 'get|post' ] ],
'selectReportAll' => ['api_broker/OrderLog/selectReportAll', [ 'method' => 'get|post' ] ],
'searchOrder' => ['api_broker/OrderLog/searchOrder', [ 'method' => 'get|post' ] ],
'bargainList' => ['api_broker/OrderLog/bargainList', [ 'method' => 'get|post' ] ],
'bargainDetail' => ['api_broker/OrderLog/bargainDetail', [ 'method' => 'get|post' ] ],
'token' => ['api_broker/broker/token', [ 'method' => 'get' ] ],
'getAgentsByPhone' => ['api_broker/broker/getAgentsByPhone', [ 'method' => 'get' ] ],
'agentsPhone' => ['api_broker/CellPhone/agentsPhone', [ 'method' => 'get|post' ] ], //获取经纪人拨打界面手机号
'dayStatement' => ['api_broker/Statement/dayStatement', [ 'method' => 'get|post' ] ],
'searchAgents' => ['api_broker/OrderLog/searchAgents', [ 'method' => 'get' ] ],
'center' => ['api_broker/MyCenter/center', [ 'method' => 'get|post' ] ],
'houseEdit' => ['api_broker/shop/edit', ['method' => 'get|post']], //编辑商铺
'getLabelsShopList' => ['api_broker/label/getLabelsShopList', ['method' => 'get']], //编辑商铺
'uploadHouseFile' => ['api_broker/shop/uploadHouseFile', ['method' => 'post']], //商铺上传文件
'delHouseFile' => ['api_broker/shop/delHouseFile', ['method' => 'post']], //商铺文件删除
'getAddress' => ['api_broker/shop/getAddress', ['method' => 'get']], //获取江浙沪城市
]);
//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
......@@ -11,6 +11,7 @@ namespace app\task\controller;
use app\api_broker\untils\PlsDemo;
use app\model\BindingPhone;
use app\model\SecretReport;
use app\model\RongBilledInform;
use think\Db;
use think\Log;
use think\Request;
......@@ -71,6 +72,23 @@ class PrivacyNumber
}
}
}
/*容联云音频下载*/
$rongRecord = new RongBilledInform();
$ids=array();
$field='id,voice_file';
$where='record_down=0';
$down_data2=$rongRecord->getArr($field,$where);
if($down_data2) {
foreach ($down_data2 as $k => $v) {
$ids[] = $v['id'];
$down_url2 = explode('/', $v['voice_file']);
down_file($v['voice_file'], ROOT_PATH . 'public' . DS . 'static' . DS . 'voice', array_pop($down_url2));
}
}
$id_str=implode(',',$ids);
$update['record_down']=1;
$where=" id in($id_str)";
$rongRecord->save($update,$where);
return ;
}
......@@ -102,7 +120,7 @@ class PrivacyNumber
$subsId = $bind->getSubsId($v['phone_x'], $v['phone_a'], $v['phone_b'], 1);
$result = PlsDemo::unbindSubscription($subsId, $v['phone_x']);
if ($result->Message == 'OK') {
$bind->UnBind($v['phone_x'], $v['phone_a'], $v['phone_b']);
$bind->UnBind($v['phone_x'], $v['phone_a'], $v['phone_b'], $result->RequestId);
$binding_phone_id[$k] = $v['id'];
$phone_id[$k] = $v['aliYun_phone_id'];
}
......@@ -111,8 +129,69 @@ class PrivacyNumber
$id['aliYun_binding_phone'] = implode(',',$binding_phone_id);
$id['aliYun_phone'] = implode(',',array_unique($phone_id));
Log::write(json_encode($id),'AliYunReleaseNumber'); //记录日志
return ;
}
/*******************************↓↓↓↓↓↓容联云↓↓↓↓↓***********************************************/
/**话单通知
* @return string
*/
public function rongBilledInformUrl(){
$params = Request::instance()->param();
/*搜索A经纪人agent_id and B客户 user_id */
$date=[
'call_id' => $params['callId'],
'phone_no' => $params['callerNum'],/*A*/
'secret_no' => $params['calleeNum'],/*X*/
'peer_no' => $params['servingNum'],/*B*/
'start_time' => $params['answerTime'],/*被叫接听时间*/
'call_time' => $params['startTime'],/*本次通话开始时间*/
'release_time' => $params['endTime'],/*本次通话结束时间*/
'ring_time' => $params['calleeRingTime'],/*被叫振铃时间*/
'time' => $params['duration'],/*本次通话时间*/
'release_dir' => $params['result'],/*本次通话的结果,0 成功2无应答 9呼叫失败 11*/
'mapping_id' => $params['mappingId'],/*绑定容联云id*/
'type' =>2,
'call_display' => $params['calldisplay'],
];
$phone_a=$params['callerNum'];
if ($phone_a) {
$agents_id = Db::table('agents')->where("phone='{$phone_a}' AND password IS NOT NULL")->value('id');
if (empty($agents_id)) {
$agents_id = Db::table('a_agents_phone')->where('phone',$phone_a)->value('agents_id');
}
$date['agents_id'] = $agents_id;
$date['users_id'] = Db::table('u_users')->where('user_phone',$phone_a)->value('id');
}
$report = new SecretReport();
$report->allowField(true)->save($date);
$str=date('Y-m-d h:i:s').' 容联云话单'.var_export($params,true);
Log::write($str,'rongBilledInformUrl'); //记录日志
return json_encode(["statusCode"=>'000000','msg'=>'接收成功']);
}
//录音通知
public function rongRecordingInformUrl(){
$params = Request::instance()->param();
$report = new SecretReport();
$where['call_id']=$params['callId'];
$update['voice_file']=$params['recordUrl'];
$report->save($update,$where);
$str=date('Y-m-d h:i:s').' 容联云录音'.var_export($params,true);
Log::write($str,'rongRecordingInformUrl'); //记录日志
return json_encode(["statusCode"=>'000000','msg'=>'接收成功']);
}
//状态通知
public function rongStatusInformUrl(){
$params = Request::instance()->param();
$str=date('Y-m-d h:i:s').' 容联云状态通知'.var_export($params,true);
Log::write(json_encode($str),'rongStatusInformUrl'); //记录日志
}
}
\ No newline at end of file
......@@ -28,7 +28,7 @@ define (['doT', 'text!temp/agentIndex_template_tpl.html', 'css!style/home.css','
document.getElementById("form_search").reset();
});
},
},
getList: function (pageNo) {
agentIndex.pageNo = pageNo;
var params = {};
......
......@@ -10,12 +10,18 @@
</div>
<div class="radio" style="display: inline-block">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios2" value="1" [% if(it.is_privacy == 1) { %] checked [% } %]>开启
<input type="radio" name="optionsRadios" id="optionsRadios2" value="1" [% if(it.is_privacy == 1) { %] checked [% } %]>阿里云
</label>
</div>
<div class="radio" style="display: inline-block">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios3" value="2" [% if(it.is_privacy == 2) { %] checked [% } %]>容联云
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" style="text-align: right">隐号绑定有效期(天数):</label>
<div class="col-sm-9">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment