Commit d3813b9b authored by hujun's avatar hujun

推送

parent 397c7687
...@@ -2,16 +2,14 @@ ...@@ -2,16 +2,14 @@
namespace app\api_broker\controller; namespace app\api_broker\controller;
use app\api\untils\GeTuiUntils;
use app\api_broker\extend\Basic; use app\api_broker\extend\Basic;
use app\api_broker\service\HouseNumUpdateService; use app\api_broker\service\HouseNumUpdateService;
use app\api_broker\service\OrderLogService; use app\api_broker\service\OrderLogService;
use app\api_broker\service\PushMessageService;
use app\model\AAgents; use app\model\AAgents;
use app\model\Agents;
use app\model\OBargainModel; use app\model\OBargainModel;
use app\model\OMarchInModel; use app\model\OMarchInModel;
use app\model\ORefundModel; use app\model\ORefundModel;
use app\model\OReportModel;
use think\Exception; use think\Exception;
/** /**
...@@ -65,20 +63,8 @@ class OrderLog extends Basic ...@@ -65,20 +63,8 @@ class OrderLog extends Basic
$is_ok = $this->o_march_in_model->addMarchIn($params); $is_ok = $this->o_march_in_model->addMarchIn($params);
if ($is_ok > 0) { if ($is_ok > 0) {
$ge_tui = new GeTuiUntils(); $pushMarchIn = new PushMessageService();
$report = new OReportModel(); $pushMarchIn->pushMarchInMessage($params["report_id"]); //推送
$field = 'house_title,user_name';
$report_data = $report->getReportOrder($field, [ 'a.id' => $params["report_id"] ]);
$agent = new AAgents();
$agent_data = $agent->getAgentInfo('device_id,store_id', $params['reception_id']);
$content = "客户{$report_data['user_name']}进场【{$report_data['house_title']}】商铺";
$where['store_id'] = $agent_data['store_id'];
$where['level'] = 20;
$agent_store = $agent->getAgentInfo('id,device_id', '', $where);
$ge_tui->public_push_message_for_one($params['reception_id'], $agent_data['device_id'], '进场', $content);
$ge_tui->public_push_message_for_one($agent_store['id'], $agent_store['device_id'], '进场', $content);
return $this->response("200", "request success", []); return $this->response("200", "request success", []);
} else { } else {
return $this->response("101", "request faild"); return $this->response("101", "request faild");
......
...@@ -68,6 +68,8 @@ class OrderLogService ...@@ -68,6 +68,8 @@ class OrderLogService
} }
//todo if bill_arr not null, save database table //todo if bill_arr not null, save database table
if (!empty($bill_arr)) { if (!empty($bill_arr)) {
$pushMarchIn = new PushMessageService($params["report_id"], 2);
$pushMarchIn->pushMarchInMessage($params["report_id"], 2); //推送
/*推送 客方,盘方,独家方,店长 start*/ /*推送 客方,盘方,独家方,店长 start*/
$ge_tui = new GeTuiUntils(); $ge_tui = new GeTuiUntils();
...@@ -135,6 +137,8 @@ class OrderLogService ...@@ -135,6 +137,8 @@ class OrderLogService
{ {
$bargain_arr = []; $bargain_arr = [];
$father_id = 0; $father_id = 0;
$agent_arr = [];
array_push($agent_arr,[$submit_agent_id]);
foreach ($commission_arr as $commission_val) { foreach ($commission_arr as $commission_val) {
if (isset($commission_val["role"]) && isset($commission_val["agent_id"]) && isset($commission_val["scale"]) if (isset($commission_val["role"]) && isset($commission_val["agent_id"]) && isset($commission_val["scale"])
&& isset($commission_val["scale_fee"])) { && isset($commission_val["scale_fee"])) {
...@@ -146,10 +150,13 @@ class OrderLogService ...@@ -146,10 +150,13 @@ class OrderLogService
array_push($bargain_arr, $this->bargainBin($father_id, $commission_val, $submit_agent_id, $submit_agent_name, $report_id, array_push($bargain_arr, $this->bargainBin($father_id, $commission_val, $submit_agent_id, $submit_agent_name, $report_id,
$order_id, $order_no, $trade_type, $price, $commission)); $order_id, $order_no, $trade_type, $price, $commission));
} }
} }
array_push($agent_arr,[$commission_val["agent_id"]]);
} }
if ($father_id > 0) { //修改楼盘 if ($father_id > 0) { //修改楼盘
$push_message = new PushMessageService();
$push_message->pushBargainMessage($agent_arr, $report_id); //推送
$houseNumUpdateService = new HouseNumUpdateService(); $houseNumUpdateService = new HouseNumUpdateService();
$houseNumUpdateService->updateHouseNumByBargain($order_id); $houseNumUpdateService->updateHouseNumByBargain($order_id);
} }
......
...@@ -10,7 +10,10 @@ namespace app\api_broker\service; ...@@ -10,7 +10,10 @@ namespace app\api_broker\service;
use app\api\untils\GeTuiUntils; use app\api\untils\GeTuiUntils;
use app\model\AAgents;
use app\model\AStore;
use app\model\GHousesToAgents; use app\model\GHousesToAgents;
use app\model\OReportModel;
class PushMessageService class PushMessageService
{ {
...@@ -21,6 +24,8 @@ class PushMessageService ...@@ -21,6 +24,8 @@ class PushMessageService
} }
/** /**
* 报备推送
*
* @param $house_id * @param $house_id
* @param int $type * @param int $type
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
...@@ -38,4 +43,73 @@ class PushMessageService ...@@ -38,4 +43,73 @@ class PushMessageService
} }
return ; return ;
} }
/**
* 1.进场推送 2.收款推送
*
* @param int $report_id
* @param int $type
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function pushMarchInMessage($report_id = 0, $type = 1) {
$ge_tui = new GeTuiUntils();
$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,device_id', $report_data['report_agent_id']);
if ($type == 1) {
$content = "客户{$report_data['user_name']}进场【{$report_data['house_title']}】商铺";
} else {
$content = "【{$report_data['house_title']}】商铺收款";
}
$where['store_id'] = $report_data['report_store_id'];
$where['level'] = 20;
$agent_store = $agent->getAgentInfo('id,device_id', '', $where);
$ge_tui->public_push_message_for_one($report_data['report_agent_id'], $agent_data['device_id'], '进场', $content);
$ge_tui->public_push_message_for_one($agent_store['id'], $agent_store['device_id'], '进场', $content);
return ;
}
/**
* 成交报告推送
*
* @param array $agent_id
* @param int $report_id
* @return bool|void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function pushBargainMessage($agent_id = [], $report_id = 0){
if (!is_array($agent_id)) {
return false;
}
$agent = new AAgents();
$ge_tui = new GeTuiUntils();
$agent_data = $agent->getAgentAllById($agent_id, 'id,device_id');
$field = 'house_title,report_agent_name,report_store_id';
$report = new OReportModel();
$report_data = $report->getReportOrder($field, [ 'a.id' => $report_id ]);
$store = new AStore();
$store_name = $store->getStoreKeyById('store_name');
$content = "恭喜【{$store_name}】店【{$report_data['report_agent_name']}】成交【{$report_data['house_title']}】商铺一套";
foreach ($agent_data as $k => $v) {
$ge_tui->public_push_message_for_one($v['id'], $v['device_id'], '成交', $content);
}
return ;
}
} }
\ No newline at end of file
...@@ -182,4 +182,16 @@ class AStore extends BaseModel ...@@ -182,4 +182,16 @@ class AStore extends BaseModel
return $name; return $name;
} }
/**
* 查询门店单个字段信息
*
* @param $field
* @param $where
* @return mixed
*/
public function getStoreKeyById($field, $where) {
return $this->where($where)
->value($field);
}
} }
\ 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