Commit c757faf7 authored by hujun's avatar hujun

个人推送所有设备

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