Commit be066be7 authored by hujun's avatar hujun

Merge branch 'hujun3.8' into test

# Conflicts: # public/resource/js/agentIndex.js
parents 88be2bd5 9122c457
......@@ -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
......@@ -54,7 +56,7 @@ class CellPhone extends Basic
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);
//是否还有未绑定的中间号码
if ($phone_x) {
......@@ -63,19 +65,11 @@ 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,
]);
$aliYunPhone->editStatus($phone_x, $phone_a, $phone_b, $record, $time, $result); //记录绑定
$this->msg = 'Binding success.';
$this->data = ['phone' => $phone_x['phone_x']];
} else {
......@@ -160,7 +154,7 @@ class CellPhone extends Basic
if ($subsId) {
$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';
......
......@@ -24,7 +24,7 @@ return [
'password' => 'Fujuhaofang123022818root',
// 'password' => '123456',
// 端口
'hostport' => '3308',
'hostport' => '3307',
// 'hostport' => '',
// 连接dsn
'dsn' => '',
......
......@@ -18,31 +18,51 @@ class AliYunPhone extends BaseModel
/**
* 获取未绑定的手机号码
*
* @param string $phone
* @param $phone_a
* @param $phone_b
* @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) {
/* //查找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('phone_a='.$phone_a.' or phone_b='.$phone_b)->select();
foreach ($id_arr as $k=>$v) {
$id[$k] = $v['id'];//去除phone_a已经绑定的号码
}
$id = empty($id) ? 0 : implode(',',$id);
$where_phone['status'] = 0;
if (empty($id)) {
$result = Db::table('aliYun_phone')->field('id,phone_x')->where($where_phone)->find();
} else {
$where_phone['id'] = ['NOT IN',$id];
$result = Db::table('aliYun_phone')->field('id,phone_x')->where($where_phone)->find();
}
$result = Db::table('aliYun_phone')->field('id,phone_x')->where($where)->find();
return $result;
}
......@@ -81,4 +101,39 @@ 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 $time
* @param $result
* @throws \think\Exception
*/
public function editStatus($phone_x, $phone_a, $phone_b,$record,$time,$result) {
$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,
'record' => $record,
'aliYun_phone_id' => $phone_x['id'],
'expiry_date' => $time,
]);
return ;
}
}
\ No newline at end of file
......@@ -44,21 +44,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,7 +93,7 @@ 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();
}
......
......@@ -206,7 +206,7 @@ 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元/分
}
......
......@@ -102,7 +102,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,7 +111,6 @@ 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 ;
}
......
/**
* Created by 刘丹 on 2018/3/1.
*/
define (['doT', 'text!temp/agentIndex_template_tpl.html', 'css!style/home.css','ckfinder','ckfinderStart','pagination','bootstrapJs'], function (doT, template) {
agentIndex = {
pageNo: 1, /*第几页*/
pageSize: 10, /*每页显示多少条*/
id : '',
house_id:'',
type:'',
valueCurrent:'',
ajaxObj:'',
stopstatus:true,
boxphoto:'',
init: function () {
//初始化dot
$ ("body").append (template);
agentIndex.getList ();
agentIndex.event ();
},
event: function () {
$("#search").click(function () {
agentIndex.getList(1);
});
$("#reset").click(function () {//重置
document.getElementById("form_search").reset();
});
},
getList: function (pageNo) {
agentIndex.pageNo = pageNo;
var params = {};
params.pageNo = agentIndex.pageNo;
params.pageSize = agentIndex.pageSize;
params.agents_name = $('#industry_type') .val();//经纪人姓名
params.phone = $('#dish') .val();//经纪人手机号
params.start_date = $('#start_date') .val();//时间1
params.end_date = $('#end_date') .val();//时间2
$.ajax ({
url: '/index/callCollectList',//获取列表
type: 'GET',
async: true,
data: params,
dataType: 'json',
success: function (data) {
var temp = document.getElementById ('agentIndex_list_tpl').innerHTML;
var doTtmpl = doT.template (temp);
$ ("#agentIndex_list").html (doTtmpl (data.data.list));
/*分页代码*/
$ ("#pagediv").pagination ({
length: data.data.total,
current: pageNo,
every: agentIndex.pageSize,
onClick: function (el) {
agentIndex.getList (el.num.current);
}
});
}
});
}
};
return agentIndex;
});
\ 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