Commit f3da2361 authored by hujun's avatar hujun

拨打房东手机默认跟进

parent 9285e8af
...@@ -33,7 +33,9 @@ class CellPhone extends Basic ...@@ -33,7 +33,9 @@ class CellPhone extends Basic
$call = new CallPhoneService(); $call = new CallPhoneService();
$record = true; //是否录音 $record = true; //是否录音
$user_id = empty($this->params['user_id']) ? 0:(int)$this->params['user_id']; $user_id = empty($this->params['user_id']) ? 0:(int)$this->params['user_id'];
$result = $call->bindAXB($this->params['phone_a'], $this->params['phone_b'], $record, $user_id, $this->agentId); $house_id = empty($this->params['house_id']) ? 0:(int)$this->params['house_id'];
$landlord = empty($this->params['landlord']) ? 0: (int)$this->params['landlord'];
$result = $call->bindAXB($this->params['phone_a'], $this->params['phone_b'], $record, $user_id, $this->agentId, $this->agentName, $landlord, $house_id);
if ($result['status'] == 'success') { if ($result['status'] == 'success') {
$this->msg = $result['msg']; $this->msg = $result['msg'];
......
...@@ -14,6 +14,7 @@ use app\api_broker\untils\RongDemo; ...@@ -14,6 +14,7 @@ use app\api_broker\untils\RongDemo;
use app\extra\RedisExt; use app\extra\RedisExt;
use app\model\AliYunPhone; use app\model\AliYunPhone;
use app\model\BindingPhone; use app\model\BindingPhone;
use app\model\GHousesFollowUp;
use app\model\SecretReport; use app\model\SecretReport;
use app\model\UPhoneFollowPp; use app\model\UPhoneFollowPp;
use app\model\Users; use app\model\Users;
...@@ -26,6 +27,7 @@ class CallPhoneService ...@@ -26,6 +27,7 @@ class CallPhoneService
private $phone_x = ''; //中间号 private $phone_x = ''; //中间号
private $user_id; private $user_id;
private $agent_id; private $agent_id;
private $agent_name;
private $expiry_date = ''; private $expiry_date = '';
private $record = true; private $record = true;
private $release = 1; //是否释放 private $release = 1; //是否释放
...@@ -53,9 +55,12 @@ class CallPhoneService ...@@ -53,9 +55,12 @@ class CallPhoneService
* @param bool $record * @param bool $record
* @param int $user_id * @param int $user_id
* @param int $agent_id * @param int $agent_id
* @param string $agent_name
* @param int $landlord
* @param int $house_id
* @return mixed * @return mixed
*/ */
public function bindAXB($phone_a, $phone_b, $record = true, int $user_id, int $agent_id) public function bindAXB($phone_a, $phone_b, $record = true, int $user_id, int $agent_id, string $agent_name, int $landlord, int $house_id)
{ {
$result['status'] = 'failed'; $result['status'] = 'failed';
...@@ -94,13 +99,22 @@ class CallPhoneService ...@@ -94,13 +99,22 @@ class CallPhoneService
$this->phone_b = $phone_b;//客户手机号 $this->phone_b = $phone_b;//客户手机号
$this->record = $record; //是否录音 $this->record = $record; //是否录音
$this->agent_id = $agent_id; $this->agent_id = $agent_id;
$this->agent_name = $agent_name;
try { try {
//0不使用隐私号码 1阿里云 2容联云 //0不使用隐私号码 1阿里云 2容联云
if ($this->is_privacy == 0) { if ($this->is_privacy == 0) {
$this->originalPhone(); $this->originalPhone();
$result['status'] = 'success'; $result['status'] = 'success';
$result['phone'] = $phone_b; $result['phone'] = $phone_b;
$result['follow_id'] = $this->addPhoneFollow(); //打默认跟进
if ($landlord) {
$result['follow_id'] = $this->addPhoneFollow(); //打默认跟进(客源)
} else {
if ($house_id) {
$result['follow_id'] = $this->addPhoneFollow(false, $house_id); //打默认跟进(房源)
}
}
return $result; return $result;
} }
...@@ -123,14 +137,14 @@ class CallPhoneService ...@@ -123,14 +137,14 @@ class CallPhoneService
if (empty($this->day_num)) { if (empty($this->day_num)) {
$this->expiry_date = _EXPIRATION; $this->expiry_date = _EXPIRATION;
} else { } else {
if (empty($this->params['landlord'])) { if ($landlord) {
$this->expiry_date = date('Y-m-d H:i:s', strtotime("+{$this->day_num} day")); $this->expiry_date = date('Y-m-d H:i:s', strtotime("+{$this->day_num} day"));
} else { } else {
if ($this->day_num == 0) { if ($this->day_num == 0) {
$this->expiry_date = date('Y-m-d H:i:s', time() + 5); $this->expiry_date = date('Y-m-d H:i:s', time() + 5);
$this->release = 0; $this->release = 0;
} else { } else {
$this->expiry_date = date('Y-m-d H:i:s', strtotime("+{$this->day_num} day")); $this->expiry_date = date('Y-m-d H:i:s', strtotime("+{$this->landlord_phone_day} day"));
} }
} }
} }
...@@ -143,7 +157,6 @@ class CallPhoneService ...@@ -143,7 +157,6 @@ class CallPhoneService
$result['status'] = 'success'; $result['status'] = 'success';
$result['phone'] = $call_phone['phone']; $result['phone'] = $call_phone['phone'];
$result['msg'] = $call_phone['msg']; $result['msg'] = $call_phone['msg'];
$result['follow_id'] = $this->addPhoneFollow(); //打默认跟进
$type = 'AliYunBindAxb'; $type = 'AliYunBindAxb';
} else { } else {
$result['msg'] = $call_phone['msg']; $result['msg'] = $call_phone['msg'];
...@@ -155,16 +168,24 @@ class CallPhoneService ...@@ -155,16 +168,24 @@ class CallPhoneService
$result['status'] = 'success'; $result['status'] = 'success';
$result['phone'] = $call_phone['phone']; $result['phone'] = $call_phone['phone'];
$result['msg'] = $call_phone['msg']; $result['msg'] = $call_phone['msg'];
$result['follow_id'] = $this->addPhoneFollow(); //打默认跟进
$type = 'YunTongXunBindAxb'; $type = 'YunTongXunBindAxb';
} else { } else {
$result['msg'] = $call_phone['msg']; $result['msg'] = $call_phone['msg'];
} }
} }
if ($result['status'] == 'success') if ($result['status'] == 'success') {
$bind->recordBindPhone($call_phone['phone'], $phone_a, $phone_b, $record, $this->expiry_date, $this->subs_id, $this->request_id, $this->mapping_id, $this->is_privacy, $this->release); $bind->recordBindPhone($call_phone['phone'], $phone_a, $phone_b, $record, $this->expiry_date, $this->subs_id, $this->request_id, $this->mapping_id, $this->is_privacy, $this->release);
if ($landlord) {
$result['follow_id'] = $this->addPhoneFollow(); //打默认跟进(客源)
} else {
if ($house_id) {
$result['follow_id'] = $this->addPhoneFollow(false, $house_id); //打默认跟进(客源)
}
}
}
Log::write(json_encode($result), $type); //记录日志 Log::write(json_encode($result), $type); //记录日志
} catch (\Exception $e) { } catch (\Exception $e) {
$data['status'] = 'failed'; $data['status'] = 'failed';
...@@ -400,12 +421,20 @@ class CallPhoneService ...@@ -400,12 +421,20 @@ class CallPhoneService
/** /**
* 打默认跟进 * 打默认跟进
* *
* @param bool $is_Client true客源跟进 false 商铺跟进
* @param int $house_id
* @return int|string * @return int|string
*/ */
private function addPhoneFollow() { private function addPhoneFollow($is_Client = true, $house_id = 0) {
$follow = new UPhoneFollowPp();
$content = '拨打电话,未打跟进。'; $content = '拨打电话,未打跟进。';
if ($is_Client) {
$follow = new UPhoneFollowPp();
$id = $follow->insertDefaultFollow($this->agent_id, $this->user_id, $content, 3, $this->city); $id = $follow->insertDefaultFollow($this->agent_id, $this->user_id, $content, 3, $this->city);
} else {
$follow = new GHousesFollowUp();
$id = $follow->insertDefaultFollow($this->agent_id, $house_id, $content, $this->city, $this->phone_b, $this->phone_a, $this->agent_name);
}
return $id; return $id;
} }
} }
\ No newline at end of file
...@@ -154,9 +154,11 @@ class CellPhone extends Basic ...@@ -154,9 +154,11 @@ class CellPhone extends Basic
} else { } else {
$phone_b = $this->params['phone_b']; $phone_b = $this->params['phone_b'];
} }
$house_id = empty($this->params['house_id']) ? 0:(int)$this->params['house_id'];
$record = true; //录音 $record = true; //录音
$call_phone = new CallPhoneService(); $call_phone = new CallPhoneService();
$data = $call_phone->bindAXB($this->params['phone_a'], $phone_b, $record, $user_id, $this->userId); $data = $call_phone->bindAXB($this->params['phone_a'], $phone_b, $record, $user_id, $this->userId, $this->userName, $house_id);
$result['msg'] = ''; $result['msg'] = '';
if ($data['status'] == 'success') { if ($data['status'] == 'success') {
$push = new PushMessageService(); $push = new PushMessageService();
......
...@@ -61,13 +61,18 @@ class GHousesFollowUp extends BaseModel ...@@ -61,13 +61,18 @@ class GHousesFollowUp extends BaseModel
$where_["disc"] = $params["disc"]; $where_["disc"] = $params["disc"];
} }
$where_["create_time"] = date("Y-m-d H:i:s", time()); $where_["create_time"] = date("Y-m-d H:i:s", time());
$where_["update_time"] = date("Y-m-d H:i:s", time()); $where_["update_time"] = date("Y-m-d H:i:s", time());
Db::startTrans(); Db::startTrans();
try { try {
if (empty($params['id'])) {
$id = $this->db_->insertGetId($where_); $id = $this->db_->insertGetId($where_);
} else {
$this->db_->where('id',$params['id'])->update($where_);
$id = $params['id'];
}
Db::commit(); Db::commit();
return $id; return $id;
} catch (\Exception $e) { } catch (\Exception $e) {
...@@ -168,4 +173,38 @@ class GHousesFollowUp extends BaseModel ...@@ -168,4 +173,38 @@ class GHousesFollowUp extends BaseModel
} }
return false; return false;
} }
/**
* 插入默认跟进
*
* @param $agent_id
* @param $house_id
* @param $content
* @param $city
* @param $landlord_phone
* @param $agent_phone
* @param $agent_name
* @return int|string
*/
public function insertDefaultFollow($agent_id, $house_id, $content, $city, $landlord_phone, $agent_phone, $agent_name) {
$data['agent_id'] = $agent_id;
$data['house_id'] = $house_id;
$data['follow_up_info'] = $content;
$data['city'] = $city;
if ($city == '上海市') {
$data['province'] = '上海市';
$data['disc'] = '黄浦区';
}
if ($city == '杭州市') {
$data['province'] = '浙江省';
$data['disc'] = '西湖区';
}
$data['landlord_phone'] = $landlord_phone;
$data['agent_name'] = $agent_name;
$data['agent_phone'] = $agent_phone;
return $this->addHousesFollowUp($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