Commit 2f099d8c authored by hujun's avatar hujun

修改盘方推送

parent 49baefb7
......@@ -220,6 +220,30 @@ class PushMessageService
return $this->pushAgentAllDeviceId($agent_data['id'], '新增分佣', $content);
}
/**
* @param $house_id
* @param $operation_id
* @param $agent_id
* @param $push_str
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function pushHouseMessage($house_id, $operation_id, $agent_id, $push_str) {
$agent = new AAgents();
$ccr_agent_data = $agent->getAgentInfo('name,phone', $operation_id);
$house = new GHouses();
$house_data = $house->getHouseInfoById('internal_title',['id'=>$house_id]);
$content = '你的【'.$house_data['internal_title'].'】商铺,盘方被【'.$ccr_agent_data['name'].'-'.$ccr_agent_data['phone'].'】修改为'.$push_str;
foreach ($agent_id as $k=>$v) {
$this->pushAgentAllDeviceId($v, '修改盘方', $content, 'house_info',$house_id);
}
return ;
}
/**
* @param $id
* @param $title
......
......@@ -139,9 +139,9 @@ class Broker extends Basic
$hg = new GHousesToAgents();
switch ($this->params['type']) {
case 1:
$res = $hg->addAgents($this->params['agents_id'], $this->params['houses_id'], $this->params['type']);break;
$res = $hg->addAgents($this->params['agents_id'], $this->params['houses_id'], $this->params['type'], $this->userId);break;
case 2:
$res = $hg->addAgents($this->params['agents_id'], $this->params['houses_id'], $this->params['type']);break;
$res = $hg->addAgents($this->params['agents_id'], $this->params['houses_id'], $this->params['type'], $this->userId);break;
default :
$res = [];
$data['status'] = 101;
......
......@@ -525,17 +525,17 @@ class GHouses extends BaseModel
//权限人
if (isset($params['agent_data'])) {
$agents->addAgents($params['agent_data'], $house_id, 1);
$agents->addAgents($params['agent_data'], $house_id, 1, $agent_id);
}
//盘方
if (isset($params['agent_dish'])) {
$agents->addAgents($params['agent_dish'], $house_id, 2);
$agents->addAgents($params['agent_dish'], $house_id, 2, $agent_id);
}
//独家方
if (isset($params['exclusive_ids'])) {
$agents->addAgents($params['exclusive_ids'], $house_id, 3);
$agents->addAgents($params['exclusive_ids'], $house_id, 3, $agent_id);
}
if ($house_id != NULL) {
......@@ -1130,17 +1130,17 @@ class GHouses extends BaseModel
$agents = new GHousesToAgents();
//权限人
if (isset($params['agent_data'])) {
$agents->addAgents($params['agent_data'], $house_id, 1);
$agents->addAgents($params['agent_data'], $house_id, 1, $agent_id);
}
//盘方
if (isset($params['agent_dish'])) {
$agents->addAgents($params['agent_dish'], $house_id, 2);
$agents->addAgents($params['agent_dish'], $house_id, 2, $agent_id);
}
//独家方
if (isset($params['exclusive_ids'])) {
$agents->addAgents($params['exclusive_ids'], $house_id, 3);
$agents->addAgents($params['exclusive_ids'], $house_id, 3, $agent_id);
}
//1列表页封面图,2详情页轮播图,3楼层平面图,4独家合同
......
......@@ -2,6 +2,7 @@
namespace app\model;
use app\api_broker\service\PushMessageService;
use app\task\controller\ResultsSummaryNewTask;
use Think\Db;
......@@ -13,15 +14,16 @@ class GHousesToAgents extends BaseModel
/**
* @param $agents_id
* @param $houses_id
* @param $type //案场权限人:0,盘方:1,独家:2
* @return array|false
* @throws \Exception
* @param int $type 案场权限人:0,盘方:1,独家:2
* @param $operation_id
* @return array|false|int
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function addAgents($agents_id, $houses_id, $type)
public function addAgents($agents_id, $houses_id, $type, $operation_id)
{
$agent_push_str = '';
$agent_arr = [];
$agents_id = array_unique(explode(',', $agents_id));
$record_agents_id = [];
......@@ -38,6 +40,10 @@ class GHousesToAgents extends BaseModel
$name = [];
foreach ($house_agents as $k2 => $v2) {
$name[] = $agents->where('id', $v2['agents_id'])->value('name');
$agent_id_old[] = $v2;
$agent_push[] = $name;
$agent_push_str = '删除盘方:';
}
$records->record('', 2, '删除盘方' . implode(',', $name), $houses_id);
}
......@@ -77,8 +83,6 @@ class GHousesToAgents extends BaseModel
$agent_arr[$key]['houses_id'] = $houses_id;
$agent_arr[$key]['type'] = $type;
$key++;
}
if (count($record_agents_id) > 0) {
......@@ -90,6 +94,7 @@ class GHousesToAgents extends BaseModel
$where_agent['is_del'] = 0;
$is = $this->where($where_agent)->count();
if ($is) {
$agent_id_old[] = $v2;
continue;
}
$name[] = $agents->where('id', $v2)->value('name');
......@@ -118,15 +123,24 @@ class GHousesToAgents extends BaseModel
foreach ($agent_id as $k=>$v) {
//获取被修改人信息
$m_agent = new AAgents();
$agent_data = $m_agent->agentBragainDetail('a.id,a.store_id,a.district_id,b.create_time', ['a.id'=>$v]);
$agent_data = $m_agent->agentBragainDetail('a.id,a.store_id,a.district_id,b.create_time,a.name', ['a.id'=>$v]);
//更新业绩统计
$sum = new ResultsSummaryNewTask();
$sum->updateTotalByAgentId($agent_data['id'], $agent_data['store_id'], $agent_data['district_id'], $date); //被修改的人
$agent_push[] = $agent_data['name'];
$agent_push_str = '编辑:';
}
}
}
if (!empty($agent_id_old) && !empty($agent_push)) {
$push = new PushMessageService();
$agent_str = $agent_push_str . explode(',', $agent_push);
$push->pushHouseMessage($houses_id, $operation_id, $agent_id_old, $agent_str);
}
return $res;
}
......
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