Commit 18646874 authored by hujun's avatar hujun

成交报告推送

parent 91fb5896
...@@ -115,8 +115,7 @@ class OrderLogService ...@@ -115,8 +115,7 @@ 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"])) {
...@@ -136,7 +135,7 @@ class OrderLogService ...@@ -136,7 +135,7 @@ class OrderLogService
$houseNumUpdateService->updateHouseNumByBargain($order_id); $houseNumUpdateService->updateHouseNumByBargain($order_id);
$push_message = new PushMessageService(); $push_message = new PushMessageService();
$push_message->pushBargainMessage($agent_arr, $report_id); //推送 $push_message->pushBargainMessage($report_id); //推送
} }
//todo if bill_arr not null, save database table //todo if bill_arr not null, save database table
......
...@@ -14,6 +14,7 @@ use app\model\AAgents; ...@@ -14,6 +14,7 @@ use app\model\AAgents;
use app\model\AStore; use app\model\AStore;
use app\model\GHousesToAgents; use app\model\GHousesToAgents;
use app\model\OReportModel; use app\model\OReportModel;
use app\model\Users;
class PushMessageService class PushMessageService
{ {
...@@ -81,33 +82,60 @@ class PushMessageService ...@@ -81,33 +82,60 @@ class PushMessageService
/** /**
* 成交报告推送 * 成交报告推送
* *
* @param array $agent_id
* @param int $report_id * @param int $report_id
* @return bool|void
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function pushBargainMessage($agent_id = [], $report_id = 0){ public function pushBargainMessage($report_id = 0){
if (!is_array($agent_id)) {
return false;
}
$agent = new AAgents(); $agent = new AAgents();
$ge_tui = new GeTuiUntils(); $ge_tui = new GeTuiUntils();
$agent_data = $agent->getAgentAllById($agent_id, 'id,device_id'); $agent_house = new GHousesToAgents();
$user = new Users();
$field = 'house_title,report_agent_name,report_store_id'; $field = 'house_id,house_title,report_agent_name,report_store_id,user_id';
$report = new OReportModel(); $report = new OReportModel();
$report_data = $report->getReportOrder($field, [ 'a.id' => $report_id ]); $report_data = $report->getReportOrder($field, [ 'a.id' => $report_id ]);
$user_agent_id = $user->getUserById('agent_id',$report_data['user_id']);
$key = 0;
//客方
if (!empty($user_agent_id['agent_id'])) {
$agent_data[$key]['id'] = $user_agent_id['agent_id'];
$device_id = $agent->getAgentsById($user_agent_id['agent_id'],'device_id');
$agent_data[$key]['device_id'] = $device_id['device_id'];
$key++;
}
$device_id = $agent->getAgentInfo('id,device_id','', [
'store_id'=>$report_data['report_store_id'],'level'=>['in','20,40']
]);
//店长
if ($device_id['device_id']) {
$agent_data[$key]['id'] = $device_id['id'];
$agent_data[$key]['device_id'] = $device_id['device_id'];
$key++;
}
//独家方和盘方
$agent_houser_data = $agent_house->getHousesAgents($report_data['house_id'], 'b.id,b.device_id',['type'=>['in','2,3']]);
foreach ($agent_houser_data as $v) {
if (!empty($v['device_id'])) {
$agent_data[$key]['id'] = $v['id'];
$agent_data[$key]['device_id'] = $v['device_id'];
$key++;
}
}
$store = new AStore(); $store = new AStore();
$store_name = $store->getStoreKeyById('store_name',$report_data['report_store_id']); $store_name = $store->getStoreKeyById('store_name',$report_data['report_store_id']);
$content = "恭喜【{$store_name}】店【{$report_data['report_agent_name']}】成交【{$report_data['house_title']}】商铺一套"; $content = "恭喜【{$store_name}】店【{$report_data['report_agent_name']}】成交【{$report_data['house_title']}】商铺一套";
foreach ($agent_data as $k => $v) { foreach ($agent_data as $k => $v) {
$ge_tui->public_push_message_for_one($v['id'], $v['device_id'], '成交', $content); dump($ge_tui->public_push_message_for_one($v['id'], $v['device_id'], '成交就是这么简单', $content));
} }
return ; return ;
......
...@@ -181,19 +181,23 @@ class GHousesToAgents extends BaseModel ...@@ -181,19 +181,23 @@ class GHousesToAgents extends BaseModel
* 楼盘对应的经纪人信息 * 楼盘对应的经纪人信息
* *
* @param $houses_id * @param $houses_id
* @param string $feild
* @param string $where
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getHousesAgents($houses_id) public function getHousesAgents($houses_id, $feild = 'b.id,name,a.type,b.phone', $where = '')
{ {
$select_data = $this->field('b.id,name,a.type,b.phone')->alias('a') $select_data = $this->field($feild)->alias('a')
->join('a_agents b', 'a.agents_id = b.id', 'LEFT') ->join('a_agents b', 'a.agents_id = b.id', 'LEFT')
->where([ ->where([
'houses_id' => $houses_id, 'houses_id' => $houses_id,
'is_del' => 0 'is_del' => 0
])->select(); ])
->where($where)
->select();
return $select_data; return $select_data;
} }
......
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