Commit 90b541fa authored by hujun's avatar hujun

容联云隐私号码绑定和下载录音修改,

parent 87d356d1
...@@ -125,23 +125,19 @@ class CellPhone extends Basic ...@@ -125,23 +125,19 @@ class CellPhone extends Basic
$Rong = new RongDemo(); $Rong = new RongDemo();
$record2 = empty($this->params['record']) ? 'true' : 'false'; /* 是否录音(容联云规定string类型)*/ $record2 = empty($this->params['record']) ? 'true' : 'false'; /* 是否录音(容联云规定string类型)*/
/*计算有效期*/ $aliYunPhone = new AliYunPhone();
if (empty($day_num)) { $phone_x = $aliYunPhone->getAliYunPhone($phone_a, $phone_b, $is_privacy); //获取未绑定隐号
$yx_time = $day_num * 60 * 60 * 24; $result = $Rong->setNumber($phone_a, $phone_b, $phone_x['phone_x'], $phone_x['area'], $day_num, $record2);
} else {
$yx_time = 604800;
}
$result = $Rong->setNumber($phone_a, $phone_b, $phone_x['phone_x'], $phone_x['area'], $yx_time, $record2);
/*绑定成功*/ /*绑定成功*/
if ($result['statusCode'] == '000000') { if ($result['statusCode'] == '000000') {
$aliYunPhone = new AliYunPhone(); $aliYunPhone = new AliYunPhone();
$aliYunPhone->editStatus($phone_x, $phone_a, $phone_b, $record, $time, 0, $result['data']['mappingId'], $is_privacy); //记录绑定 $aliYunPhone->editStatus($phone_x, $phone_a, $phone_b, $record, $time, 0, $result['data']['mappingId'], $is_privacy); //记录绑定
$this->msg = 'Binding Rong success'; $this->msg = '绑定成功';
$this->data = [ 'phone' => $phone_x['phone_x'] ]; $this->data = [ 'phone' => $phone_x['phone_x'] ];
} else { } else {
$this->code = 101; $this->code = 101;
$this->msg = '操作频繁,请10秒后再操作。'; $this->msg = '拨号失败,15秒再试,再无法拨号请联系请联系运营人员!';
} }
} }
...@@ -206,6 +202,7 @@ class CellPhone extends Basic ...@@ -206,6 +202,7 @@ class CellPhone extends Basic
$redis = RedisExt::getRedis(); $redis = RedisExt::getRedis();
$is_privacy = $redis->get('s_is_privacy'); $is_privacy = $redis->get('s_is_privacy');
$is_privacy = $is_privacy != '0' ? $is_privacy : 0; $is_privacy = $is_privacy != '0' ? $is_privacy : 0;
if ($is_privacy == 1) { if ($is_privacy == 1) {
/*阿里云*/ /*阿里云*/
$subsId = $phone->getSubsId($phone_x, $phone_a, $phone_b, 1, 'subsId'); $subsId = $phone->getSubsId($phone_x, $phone_a, $phone_b, 1, 'subsId');
...@@ -233,12 +230,13 @@ class CellPhone extends Basic ...@@ -233,12 +230,13 @@ class CellPhone extends Basic
$phone->unBind($phone_x, $phone_a, $phone_b); $phone->unBind($phone_x, $phone_a, $phone_b);
} else { } else {
$this->code = 101; $this->code = 101;
$this->msg = 'remove binding error'; $this->msg = '解除绑定关系失败,请联系运营!';
} }
} else { } else {
$this->code = 101; $this->code = 200;
$this->msg = 'dont\'t have about phone_x info'; $this->msg = '没有号码绑定关系,请忽略!。';
} }
} else { } else {
$this->code = 200; $this->code = 200;
$this->msg = '没有号码绑定关系,请忽略!。'; $this->msg = '没有号码绑定关系,请忽略!。';
......
...@@ -22,6 +22,7 @@ define('CK_IMG_URL', CURRENT_URL . 'resource/lib/Attachments/'); //ck 资源文 ...@@ -22,6 +22,7 @@ define('CK_IMG_URL', CURRENT_URL . 'resource/lib/Attachments/'); //ck 资源文
define('_POOLKEY','FC100000022056027');//隐私号码 define('_POOLKEY','FC100000022056027');//隐私号码
define('_TLSYPoolKey','FC100000022056027');//隐私号码池 define('_TLSYPoolKey','FC100000022056027');//隐私号码池
define('WEEK_WORK_IMG', CURRENT_URL . 'static'. DS . 'week_work_img/'); //周报日报目录 define('WEEK_WORK_IMG', CURRENT_URL . 'static'. DS . 'week_work_img/'); //周报日报目录
define('PHONE_VOICE', ROOT_PATH.'public'.DS.'static'.DS.'voice'); //录音绝对路径
return [ return [
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | 应用设置 // | 应用设置
......
...@@ -22,119 +22,6 @@ class CellPhone extends Basic ...@@ -22,119 +22,6 @@ class CellPhone extends Basic
protected $data = []; protected $data = [];
protected $msg = ""; protected $msg = "";
/**
* 绑定手机号
* 解绑之后有延迟
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function bindAXB() {
$params = $this->request->param();
if ($params['phone_a'] || $params['phone_b']) {
$expiration = _EXPIRATION; //过期时间
$phone_a = $this->params['phone_a'];//经纪人手机号
$phone_b = $this->params['phone_b'];//客户手机号
$record = empty($this->params['record'])? true:false; //是否录音
$bind = new AliYunPhone();
$phone_x = $bind->getAliYunPhone($phone_b);
//是否还有未绑定的中间号码
if ($phone_x) {
$result = PlsDemo::bindAxb($phone_a, $phone_b, $expiration, $record, $phone_x['phone_x']);
if ($result->Message == 'OK') {
$bind->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']
]);
$this->msg = 'Binding success.';
$this->data = ['phone'=>$phone_x['phone_x']];
} else {
$this->code = 101;
$this->msg = 'Binding failure.';
}
} else {
$this->code = 102;
$this->msg = 'Number pool run out.';
}
} else {
$this->code = 101;
$this->msg = 'phone_a or phone_b is null';
}
return $this->response($this->code, $this->msg, $this->data);
}
/**
* 更新绑定关系
*
* @return \think\Response
*/
public function updateBindAXB() {
$params = $this->request->param();
if ($params['phone_x'] && ($params['phone_a'] || $params['phone_b'])) {
$bind = new BindingPhone();
if ($params['phone_a']) {
$subId = $bind->getSubsId($params['phone_x'], $params['phone_a'], '',1); //跟换B号码
} else {
$subId = $bind->getSubsId($params['phone_x'], '', $params['phone_b'],1); //更好A号码
}
$resutl = PlsDemo::updateSubscription($params['type'], $subId, $this->params['phone_x'], $this->params['phone_a'], $this->params['phone_b'], $params['date']);
if ($resutl->Message == 'OK') {
$this->msg = 'ok';
} else {
$this->code = 101;
$this->msg = 'update bind is error';
}
} else {
$this->code = 101;
$this->msg = 'phone is null';
}
return $this->response($this->code, $this->msg,$this->data);
}
/**
* 解除绑定关系
*
* @return \think\Response
* @throws \think\exception\DbException
*/
public function agentsUnBind() {
$phone_x = $this->params['phone_x'];
$phone_a = $this->params['phone_a'];
if ($phone_x) {
$phone = new BindingPhone();
$subsId = $phone->getSubsId($phone_x,$phone_a,'',1);
if ($subsId) {
$result = PlsDemo::unbindSubscription($subsId, $phone_x);
if ($result->Message == 'OK') {
$phone->unBind($phone_x);
} 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 is null';
}
$this->params['phone_x'];
return $this->response($this->code, $this->msg);
}
/** /**
* 总记录列表、搜索 * 总记录列表、搜索
* *
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: zfc * User: hu jun
* Date: 2018/3/16 * Date: 2018/6/26
* Time: 14:55 * Time: 11:30
*/ */
namespace app\model; namespace app\model;
class RongBilledInform extends BaseModel class AliYunSecretReport extends BaseModel
{ {
/** // 设置当前模型对应的完整数据表名称
* @param $where protected $table = 'aliYun_secret_report';
* @param $v
* @return mixed
*/
public function getValue($where,$v)
{
$r = $this->where($where)->value($v);
return $r;
}
/** /**
* @param $field * 获取所有的通过回调记录
*
* @param $fields
* @param $where * @param $where
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getArr($field,$where){ public function secretReportAll($fields, $where)
$r =$this->field($field)->where($where)->select(); {
return $r; return $this->field($fields)
->where($where)
->select();
} }
/**
* @param $id
* @param $data
* @return AliYunSecretReport
*/
public function updateDownStatus($id, $data)
{
return $this->where('id', $id)->update($data);
}
} }
\ No newline at end of file
...@@ -23,7 +23,8 @@ class BindingPhone extends BaseModel ...@@ -23,7 +23,8 @@ class BindingPhone extends BaseModel
* @param int $status * @param int $status
* @return bool|mixed * @return bool|mixed
*/ */
public function getSubsId($phone_x, $phone_a, $phone_b = '', $status = 0,$phoneId='subsId') { public function getSubsId($phone_x, $phone_a, $phone_b = '', $status = 0, $phoneId = 'subsId')
{
if ($phone_x && ($phone_a || $phone_b)) { if ($phone_x && ($phone_a || $phone_b)) {
$where['a.status'] = $status; $where['a.status'] = $status;
...@@ -31,7 +32,7 @@ class BindingPhone extends BaseModel ...@@ -31,7 +32,7 @@ class BindingPhone extends BaseModel
$where['a.phone_a'] = $phone_a; $where['a.phone_a'] = $phone_a;
} }
if ($phone_b){ if ($phone_b) {
$where['a.phone_b'] = $phone_b; $where['a.phone_b'] = $phone_b;
} }
...@@ -40,7 +41,7 @@ class BindingPhone extends BaseModel ...@@ -40,7 +41,7 @@ class BindingPhone extends BaseModel
} }
$subsId = $this->alias('a') $subsId = $this->alias('a')
->join('aliYun_phone b','a.aliYun_phone_id=b.id','left') ->join('aliYun_phone b', 'a.aliYun_phone_id=b.id', 'left')
->where($where)->value($phoneId); ->where($where)->value($phoneId);
} else { } else {
$subsId = false; $subsId = false;
...@@ -60,21 +61,22 @@ class BindingPhone extends BaseModel ...@@ -60,21 +61,22 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function unBind($phone_x, $phone_a = '', $phone_b='',$request_id = '') { public function unBind($phone_x, $phone_a = '', $phone_b = '', $request_id = '')
{
if ($phone_x) { if ($phone_x) {
$phone = new AliYunPhone(); $phone = new AliYunPhone();
$phone_data = $phone->where('phone_x',$phone_x)->find(); $phone_data = $phone->where('phone_x', $phone_x)->find();
if ($phone_data['id']) { if ($phone_data['id']) {
$phone_data['bind_num'] -= 1; $phone_data['bind_num'] -= 1;
$phone_data->save(); $phone_data->save();
$result = $this->where([ $result = $this->where([
'aliYun_phone_id'=>$phone_data['id'], 'aliYun_phone_id' => $phone_data['id'],
'status' => 1, 'status' => 1,
'phone_a' => $phone_a, 'phone_a' => $phone_a,
'phone_b' => $phone_b, 'phone_b' => $phone_b,
])->update(['status'=>0,'release_requestId'=>$request_id]); ])->update([ 'status' => 0, 'release_requestId' => $request_id ]);
} else { } else {
$result = false; $result = false;
...@@ -95,10 +97,11 @@ class BindingPhone extends BaseModel ...@@ -95,10 +97,11 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getPhoneX($field = '', $where = []) { public function getPhoneX($field = '', $where = [])
{
return $this->alias('a') return $this->alias('a')
->field($field) ->field($field)
->join('aliYun_phone b','a.aliYun_phone_id=b.id','left') ->join('aliYun_phone b', 'a.aliYun_phone_id=b.id', 'left')
->where($where) ->where($where)
->order('a.id desc') ->order('a.id desc')
->find(); ->find();
...@@ -112,9 +115,10 @@ class BindingPhone extends BaseModel ...@@ -112,9 +115,10 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getBindingPhoneList($field, $where) { public function getBindingPhoneList($field, $where)
{
return $this->field($field)->alias('a') return $this->field($field)->alias('a')
->join('aliYun_phone b','a.aliYun_phone_id = b.id','left') ->join('aliYun_phone b', 'a.aliYun_phone_id = b.id', 'left')
->where($where) ->where($where)
->select(); ->select();
} }
...@@ -128,28 +132,18 @@ class BindingPhone extends BaseModel ...@@ -128,28 +132,18 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function unBindTable($id, $aliYun_phone_id) { public function unBindTable($id, $aliYun_phone_id)
$phone = new AliYunPhone(); {
$phone_data = $phone->field('id,bind_num')->where('id',$aliYun_phone_id)->find(); $phone = new AliYunPhone();
$phone_data = $phone->field('id,bind_num')->where('id', $aliYun_phone_id)->find();
if ($phone_data['id']) { if ($phone_data['id']) {
$phone_data['bind_num'] -= 1; $phone_data['bind_num'] -= 1;
$phone_data->save(); $phone_data->save();
} }
$this->update(['status' => 0, 'id' => $id]); $this->update([ 'status' => 0, 'id' => $id ]);
return ; return;
} }
/**
* @param $phone_x
* @param $phone_a
* @param $phone_b
* @param $record
* @param $time
* @param $result
* @param string $mappingId
* @param int $type
* @return int|string
*/
/** /**
* @param $phone_x * @param $phone_x
* @param $phone_a * @param $phone_a
...@@ -164,22 +158,23 @@ class BindingPhone extends BaseModel ...@@ -164,22 +158,23 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function recordBindPhone($phone_x, $phone_a, $phone_b,$record,$time,$result,$mappingId='',$type=1) { public function recordBindPhone($phone_x, $phone_a, $phone_b, $record, $time, $result, $mappingId = '', $type = 1)
$m_ali_phone = new AliYunPhone(); {
$phone_id = $m_ali_phone->field('id,bind_num')->where('phone_x', $phone_x)->find(); $m_ali_phone = new AliYunPhone();
$phone_id = $m_ali_phone->field('id,bind_num')->where('phone_x', $phone_x)->find();
$phone_id['bind_num'] += 1; $phone_id['bind_num'] += 1;
$m_ali_phone->where('id',$phone_id['id'])->update(['bind_num'=>$phone_id['bind_num']]); $m_ali_phone->where('id', $phone_id['id'])->update([ 'bind_num' => $phone_id['bind_num'] ]);
$insert_data['phone_a'] = $phone_a; $insert_data['phone_a'] = $phone_a;
$insert_data['phone_b'] = $phone_b; $insert_data['phone_b'] = $phone_b;
$insert_data['subsId'] = $result->SecretBindDTO->SubsId; $insert_data['subsId'] = $result->SecretBindDTO->SubsId;
$insert_data['requestId'] = $result->RequestId; $insert_data['requestId'] = $result->RequestId;
$insert_data['mappingId'] = $mappingId; $insert_data['mappingId'] = $mappingId;
$insert_data['record'] = $record; $insert_data['record'] = $record;
$insert_data['aliYun_phone_id'] = $phone_id['id']; $insert_data['aliYun_phone_id'] = $phone_id['id'];
$insert_data['expiry_date'] = $time; $insert_data['expiry_date'] = $time;
$insert_data['type'] = $type; $insert_data['type'] = $type;
$insert_data['status'] = 1; $insert_data['status'] = 1;
return $this->insert($insert_data); return $this->insert($insert_data);
} }
} }
\ No newline at end of file
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