Commit a8da17ee authored by hujun's avatar hujun

约带看,报备推送

parent 52cfe3c8
...@@ -144,9 +144,11 @@ class GeTuiUntils { ...@@ -144,9 +144,11 @@ class GeTuiUntils {
* @param $content * @param $content
* @param string $type * @param string $type
* @param $user_id * @param $user_id
* @param $house_id
* @param $order_id
* @return array * @return array
*/ */
function public_push_message_for_one($id, $device_id, $title, $content, $type = 'other', $user_id) function public_push_message_for_one($id, $device_id, $title, $content, $type = 'other', $user_id, $house_id, $order_id)
{ {
$home_url = $this->http_host(); $home_url = $this->http_host();
$data['agent_id'] = $id; $data['agent_id'] = $id;
...@@ -160,6 +162,8 @@ class GeTuiUntils { ...@@ -160,6 +162,8 @@ class GeTuiUntils {
'url' => '', 'url' => '',
'name' => $title, 'name' => $title,
'id' => $user_id, 'id' => $user_id,
'house_id' => $house_id,
'order_id' => $order_id,
'imageUrl' => $home_url .'notice_android_logo.png')); 'imageUrl' => $home_url .'notice_android_logo.png'));
return $this->push_message_for_one($data); return $this->push_message_for_one($data);
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace app\api_broker\controller; namespace app\api_broker\controller;
use app\api_broker\extend\Basic; use app\api_broker\extend\Basic;
use app\api_broker\service\PushMessageService;
use app\api_broker\service\ReportService; use app\api_broker\service\ReportService;
use app\index\service\UserService; use app\index\service\UserService;
use app\model\AAgents; use app\model\AAgents;
...@@ -78,6 +79,16 @@ class Report extends Basic ...@@ -78,6 +79,16 @@ class Report extends Basic
$userArr["user_name"], $house_ids, $vehicle, $intro, $predict_see_time); $userArr["user_name"], $house_ids, $vehicle, $intro, $predict_see_time);
if ($is_ok > 0) { if ($is_ok > 0) {
$this->userService->setUserSites($user_id, $this->siteId);//设置用户站点 朱伟 2018-10-22 $this->userService->setUserSites($user_id, $this->siteId);//设置用户站点 朱伟 2018-10-22
/*记录推送*/
$push = new PushMessageService();
$house_ids_arr = explode(',', $house_ids);
if (is_array($house_ids)) {
foreach ($house_ids_arr as $k=>$v) {
$push->pushReportMessage($v, $agent_id, 1, $this->agentId); //推送报备信息
}
}
/*记录推送*/
return $this->response("200", "request success", []); return $this->response("200", "request success", []);
} else { } else {
return $this->response("101", "save exception"); return $this->response("101", "save exception");
......
...@@ -36,25 +36,36 @@ class PushMessageService ...@@ -36,25 +36,36 @@ class PushMessageService
* *
* @param $house_id * @param $house_id
* @param $agent_id * @param $agent_id
* @param int $type * @param $type
* @throws \think\db\exception\DataNotFoundException * @param $operation_id
* @throws \think\db\exception\ModelNotFoundException * @return bool
* @throws \think\exception\DbException
*/ */
public function pushReportMessage($house_id, $agent_id, $type = 1) public function pushReportMessage($house_id, $agent_id, $type, $operation_id)
{ {
$house_agent = new GHousesToAgents(); try {
$agent = new AAgents(); $house_agent = new GHousesToAgents();
$house = new GHouses(); $agent = new AAgents();
$house = new GHouses();
$data = $house_agent->getHousesAgents($house_id, 'b.id', [ 'type' => $type ]); $m_report = new OReportModel();
$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 ]);
foreach ($data as $k => $v) { $agent_name = $agent->getAgentsStoreById([ 'a.id' => $agent_id ], 'name,store_name');
$content = "【{$agent_name['store_name']}】店【{$agent_name['name']}】约带看【{$house_data['internal_title']}】商铺"; $house_data = $house->getHouseDetail('internal_title', [ 'id' => $house_id ]);
$this->pushAgentAllDeviceId($v['id'], '报备', $content); $order_id = $m_report->getReportOrder('b.order_id',['a.report_agent_id'=>$agent_id]);
foreach ($data as $k => $v) {
$content = "【{$agent_name['store_name']}】店【{$agent_name['name']}】约带看【{$house_data['internal_title']}】商铺";
// $this->pushAgentAllDeviceId($v['id'], '报备', $content);
$data['content'] = $content;
$data['order_id'] = $order_id;
$data['house_id'] = $house_id;
$this->record(6, 0, $agent_id, $operation_id, $data);
}
$result = true;
} catch (\Exception $e) {
$result = false;
} }
return;
return $result;
} }
/** /**
...@@ -230,20 +241,22 @@ class PushMessageService ...@@ -230,20 +241,22 @@ class PushMessageService
$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']}]商铺";
$this->pushAgentAllDeviceId($agent_data['id'], '新增分佣', $content);
return $this->pushAgentAllDeviceId($agent_data['id'], '新增分佣', $content); return ;
} }
/** /**
* @param $id * @param $id
* @param $title * @param $title
* @param $content * @param $content
* @param null $type * @param int $type
* @param null $user_id * @param int $user_id
* @param int $is_forbidden * @param int $is_forbidden
* @param int $house_id
* @param int $order_id
* @return array|bool * @return array|bool
*/ */
public function pushAgentAllDeviceId($id, $title, $content, $type = null, $user_id = null, $is_forbidden = 0) public function pushAgentAllDeviceId($id, $title, $content, $type = 0, $user_id = 0, $is_forbidden = 0, $house_id = 0, $order_id = 0)
{ {
if (empty($id)) { if (empty($id)) {
return false; return false;
...@@ -255,7 +268,7 @@ class PushMessageService ...@@ -255,7 +268,7 @@ class PushMessageService
if (!empty($device_id_array)) { if (!empty($device_id_array)) {
foreach ($device_id_array as $k => $v) { foreach ($device_id_array as $k => $v) {
if (!empty($v['push_id'])) { if (!empty($v['push_id'])) {
$result[] = $this->push->public_push_message_for_one($id, $v['push_id'], $title, $content, $type, $user_id); $result[] = $this->push->public_push_message_for_one($id, $v['push_id'], $title, $content, $type, $user_id, $house_id, $order_id);
} }
} }
} }
...@@ -292,24 +305,12 @@ class PushMessageService ...@@ -292,24 +305,12 @@ class PushMessageService
case 1 : case 1 :
$result = $m_push->addHouseIdArray($house_id, $operation_id, $type, $data); $result = $m_push->addHouseIdArray($house_id, $operation_id, $type, $data);
break; break;
case 2 :
$result = $m_push->addAgentIdArray($agent_id, $operation_id, $type, $data);
break;
case 3 : case 3 :
$data['house_id'] = $house_id; $data['house_id'] = $house_id;
$result = $m_push->addAgentIdArray($agent_id, $operation_id, $type, $data); $result = $m_push->addAgentIdArray($agent_id, $operation_id, $type, $data);
break; break;
case 4 :
$result = $m_push->addAgentIdArray($agent_id, $operation_id, $type, $data);
break;
case 5 :
$result = $m_push->addAgentIdArray($agent_id, $operation_id, $type, $data);
break;
case 6 :
$result = $m_push->addAgentIdArray($agent_id, $operation_id, $type, $data);
break;
default : default :
$result = $m_push->addData($data, $operation_id, $type); $result = $m_push->addAgentIdArray($agent_id, $operation_id, $type, $data);
} }
return $result; return $result;
} }
...@@ -321,7 +322,7 @@ class PushMessageService ...@@ -321,7 +322,7 @@ class PushMessageService
{ {
$title = $type = ''; $title = $type = '';
$m_push = new MPushMessage(); $m_push = new MPushMessage();
$field = 'id,addressee_id,type,message,house_id,user_id'; $field = 'id,addressee_id,type,message,house_id,user_id,order_id';
$where['status'] = $id = $is_forbidden = 0; $where['status'] = $id = $is_forbidden = 0;
$push_data = $m_push->getDateLimit($field, $where, 100); $push_data = $m_push->getDateLimit($field, $where, 100);
...@@ -354,13 +355,19 @@ class PushMessageService ...@@ -354,13 +355,19 @@ class PushMessageService
break; break;
case 5: case 5:
$title = '进场'; $title = '进场';
$type = 'timer_shaft';
break; break;
case 6: case 6:
$title = '收款'; $title = '收款';
$type = 'timer_shaft';
break;
case 6:
$title = '报备';
$type = 'timer_shaft';
break; break;
} }
$result = $this->pushAgentAllDeviceId($v['addressee_id'], $title, $v['message'], $type, $id, $is_forbidden); $this->pushAgentAllDeviceId($v['addressee_id'], $title, $v['message'], $type, $id, $is_forbidden);
$update_data['status'] = 1; $update_data['status'] = 1;
$update_data['send_time'] = date('Y-m-d H:i:s'); $update_data['send_time'] = date('Y-m-d H:i:s');
...@@ -368,6 +375,6 @@ class PushMessageService ...@@ -368,6 +375,6 @@ class PushMessageService
} }
} }
return; return ;
} }
} }
\ No newline at end of file
...@@ -87,12 +87,10 @@ class ReportService ...@@ -87,12 +87,10 @@ class ReportService
$house_arr = explode(",", $house_ids); $house_arr = explode(",", $house_ids);
$order_arr = []; $order_arr = [];
$push = new PushMessageService();
foreach ($house_arr as $k => $v) { foreach ($house_arr as $k => $v) {
//todo 批量插入到数据库 //todo 批量插入到数据库
$order_no = $this->createOrderNumber(); $order_no = $this->createOrderNumber();
array_push($order_arr, $this->orderBin($order_no, $id, $v)); array_push($order_arr, $this->orderBin($order_no, $id, $v));
$push->pushReportMessage($v, $agent_id); //推送报备信息
} }
//todo 保存order表 订单返回成功返回报备id //todo 保存order表 订单返回成功返回报备id
return ($this->orderModel->insertOrderByAll($order_arr) > 0) ? $id : 0; return ($this->orderModel->insertOrderByAll($order_arr) > 0) ? $id : 0;
......
...@@ -157,7 +157,7 @@ class WatchShop extends Basic ...@@ -157,7 +157,7 @@ class WatchShop extends Basic
$appoint_watch->commit(); //提交事务 $appoint_watch->commit(); //提交事务
$push = new PushMessageService(); $push = new PushMessageService();
$push->pushReportMessage($appoint_data["house_id"], $agent_id); $push->pushReportMessage($appoint_data["house_id"], $agent_id, 1, $this->userId);
return $this->response("200", $data['msg']); return $this->response("200", $data['msg']);
} else { } else {
$appoint_watch->rollback(); //回滚事务 $appoint_watch->rollback(); //回滚事务
......
...@@ -136,6 +136,10 @@ class MPushMessage ...@@ -136,6 +136,10 @@ class MPushMessage
$insert_data[$k]['house_id'] = $data['house_id']; $insert_data[$k]['house_id'] = $data['house_id'];
} }
if (isset($data['order_id'])) {
$insert_data[$k]['order_id'] = $data['order_id'];
}
$insert_data[$k]['type'] = $type; $insert_data[$k]['type'] = $type;
$insert_data[$k]['status'] = 0; $insert_data[$k]['status'] = 0;
$insert_data[$k]['operation_id'] = $operation_id; $insert_data[$k]['operation_id'] = $operation_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