Commit c757faf7 authored by hujun's avatar hujun

个人推送所有设备

parent 768f5878
......@@ -23,6 +23,7 @@ use app\model\PushFeed;
class PushMessageService
{
private $push;
public function __construct()
{
$this->push = new GeTuiUntils();
......@@ -38,20 +39,21 @@ class PushMessageService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function pushReportMessage($house_id, $agent_id, $type = 1) {
public function pushReportMessage($house_id, $agent_id, $type = 1)
{
$house_agent = new GHousesToAgents();
$agent = new AAgents();
$house = new GHouses();
$agent = new AAgents();
$house = new GHouses();
$data = $house_agent->getHousesAgents($house_id, 'b.id', ['type'=> $type]);
$agent_name = $agent->getAgentsStoreById(['a.id'=>$agent_id], 'name,store_name');
$house_data = $house->getHouseDetail('internal_title',['id'=>$house_id]);
$data = $house_agent->getHousesAgents($house_id, 'b.id', [ 'type' => $type ]);
$agent_name = $agent->getAgentsStoreById([ 'a.id' => $agent_id ], 'name,store_name');
$house_data = $house->getHouseDetail('internal_title', [ 'id' => $house_id ]);
foreach ($data as $k => $v) {
$content = "【{$agent_name['store_name']}】店【{$agent_name['name']}】约带看【{$house_data['internal_title']}】商铺";
// $this->push->public_push_message_for_one($v['id'], $v['device_id'], '报备', $content);
$this->pushAgentAllDeviceId($v['id'], '报备', $content);
}
return ;
return;
}
/**
......@@ -63,14 +65,15 @@ class PushMessageService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function pushMarchInMessage($report_id = 0, $type = 1) {
$report = new OReportModel();
public function pushMarchInMessage($report_id = 0, $type = 1)
{
$report = new OReportModel();
$field = 'house_title,user_name,report_store_id,report_agent_id';
$report_data = $report->getReportOrder($field, [ 'a.id' => $report_id ]);
$agent = new AAgents();
$agent_data = $agent->getAgentInfo('id', $report_data['report_agent_id']);
$agent = new AAgents();
$agent_data = $agent->getAgentInfo('id', $report_data['report_agent_id']);
if ($type == 1) {
$content = "客户{$report_data['user_name']}进场【{$report_data['house_title']}】商铺";
......@@ -80,16 +83,16 @@ class PushMessageService
$title = '收款';
}
$where['store_id'] = $report_data['report_store_id'];
$where['level'] = 20;
$agent_store = $agent->getAgentInfo('id,device_id', '', $where);
$where['store_id'] = $report_data['report_store_id'];
$where['level'] = 20;
$agent_store = $agent->getAgentInfo('id,device_id', '', $where);
// $this->push->public_push_message_for_one($report_data['report_agent_id'], $agent_data['device_id'], $title, $content);
// $this->push->public_push_message_for_one($agent_store['id'], $agent_store['device_id'], $title, $content);
$this->pushAgentAllDeviceId($report_data['report_agent_id'], $title, $content);
$this->pushAgentAllDeviceId($agent_store['id'], $title, $content);
return ;
return;
}
/**
......@@ -100,31 +103,32 @@ class PushMessageService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function pushBargainMessage($report_id = 0){
$report = new OReportModel();
$feed = new PushFeed();
$agent = new AAgents();
$field = 'house_id,house_title,report_agent_name,user_id,report_agent_id';
public function pushBargainMessage($report_id = 0)
{
$report = new OReportModel();
$feed = new PushFeed();
$agent = new AAgents();
$field = 'house_id,house_title,report_agent_name,user_id,report_agent_id';
$report_data = $report->getReportOrder($field, [ 'a.id' => $report_id ]);
$house_arr = [1,4,3031,3032]; //剔除测试楼盘推送
$house_arr = [ 1, 4, 3031, 3032 ]; //剔除测试楼盘推送
if (in_array($report_data['house_id'], $house_arr)) {
return ;
return;
}
//查询经纪人门店和部门信息
$agent_store = $agent->verifyUser('store_id', '', ['id'=>$report_data['report_agent_id']]);
$store = new AStore();
$store_name = $store->getStoreDistrictName($agent_store['store_id']);
$title = '成交就是这么简单';
$agent_store = $agent->verifyUser('store_id', '', [ 'id' => $report_data['report_agent_id'] ]);
$store = new AStore();
$store_name = $store->getStoreDistrictName($agent_store['store_id']);
$title = '成交就是这么简单';
$feed->editData([
'title' => $title,
'agent_id' => -1,
'agent_id' => -1,
'report_id' => $report_id,
'house_id' => $report_data['house_id'],
'house_id' => $report_data['house_id'],
'content' => $store_name . $report_data['report_agent_name'],
'steel_phone' => 0,
'type' => 0,
......@@ -135,12 +139,12 @@ class PushMessageService
'click_num' => 10 //不要问什么,就是产品要加的。
]);
$content = "恭喜【{$store_name}】店【{$report_data['report_agent_name']}】成交【{$report_data['house_title']}】商铺一套";
$url = $this->push->http_host(). '/app/dist/index.html#/feeds?id='.$feed->id;
$feed->editData(['link'=>$url], $feed->id);
$url = $this->push->http_host() . '/app/dist/index.html#/feeds?id=' . $feed->id;
$feed->editData([ 'link' => $url ], $feed->id);
$this->push->push_message_for_all($title, $content, $url);
return ;
return;
}
/**
......@@ -150,10 +154,11 @@ class PushMessageService
* @param string $content
* @param string $url
*/
public function pushAll(string $title = '', string $content = '', string $url = '') {
$url = $this->push->http_host(). '/'. $url;
public function pushAll(string $title = '', string $content = '', string $url = '')
{
$url = $this->push->http_host() . '/' . $url;
$this->push->push_message_for_all($title, $content, $url);
return ;
return;
}
/**
......@@ -166,7 +171,8 @@ class PushMessageService
* @param string $user_id
* @return array|bool
*/
public function pushMessageById($id, $title,$content, $type = 'other' ,$user_id = '') {
public function pushMessageById($id, $title, $content, $type = 'other', $user_id = '')
{
if (empty($id)) {
return false;
......@@ -175,10 +181,9 @@ class PushMessageService
// $agent = new AAgents();
// $device_id = $agent->getAgentsById($id, 'device_id');
if (!empty($device_id)) {
// $result = $this->push->public_push_message_for_one($id, $device_id, $title, $content, $type, $user_id);
$result = $this->pushAgentAllDeviceId($id, $title, $content, $type, $user_id);
}
$result = $this->pushAgentAllDeviceId($id, $title, $content, $type, $user_id);
return $result;
}
......@@ -193,12 +198,13 @@ class PushMessageService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function pushBargainCommissionMessage($submit_agent_name, $agent_id, $order_id) {
$agent = new AAgents();
$order = new OrderModel();
$house = $order->getHouseInfoByOrderIdOne('internal_title', ['a.id'=>$order_id]);
public function pushBargainCommissionMessage($submit_agent_name, $agent_id, $order_id)
{
$agent = new AAgents();
$order = new OrderModel();
$house = $order->getHouseInfoByOrderIdOne('internal_title', [ 'a.id' => $order_id ]);
$agent_data = $agent->getAgentInfo('id,name', $agent_id);
$content = "{$submit_agent_name}新增成交报告,分佣方:{$agent_data['name']}[{$house['internal_title']}]商铺";
$content = "{$submit_agent_name}新增成交报告,分佣方:{$agent_data['name']}[{$house['internal_title']}]商铺";
// return $this->push->public_push_message_for_one($agent_data['id'], $agent_data['device_id'], '新增分佣', $content);
return $this->pushAgentAllDeviceId($agent_data['id'], '新增分佣', $content);
......@@ -213,9 +219,10 @@ class PushMessageService
* @param null $user_id
* @return bool
*/
public function pushAgentAllDeviceId($id, $title, $content, $type = null, $user_id = null) {
$m_agent_device = new ABindingDevice();
$device_id_array = $m_agent_device->getDeviceByAgentId(['agent_id'=>$id], 'id,push_id');
public function pushAgentAllDeviceId($id, $title, $content, $type = null, $user_id = null)
{
$m_agent_device = new ABindingDevice();
$device_id_array = $m_agent_device->getDeviceByAgentId([ 'agent_id' => $id ], 'id,push_id');
foreach ($device_id_array as $k => $v) {
if (!empty($v['push_id'])) {
......
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