Commit 4c5c3265 authored by hujun's avatar hujun

新增成交报告推送

parent 0c8ec517
......@@ -546,7 +546,7 @@ class OrderLog extends Basic
$insert_data['scale'] = empty($this->params['scale']) ? 0 : $this->params['scale'];
$data['data']['id'] = $bargain->insertBargain($insert_data);
if ($data['data'] == 0) {
if ($data['data']['id'] == 0) {
$data['code'] = 101;
$data['msg'] = 'Add the failure.';
}
......
......@@ -12,7 +12,9 @@ namespace app\api_broker\service;
use app\api\untils\GeTuiUntils;
use app\model\AAgents;
use app\model\AStore;
use app\model\GHouses;
use app\model\GHousesToAgents;
use app\model\OrderModel;
use app\model\OReportModel;
use app\model\Users;
......@@ -28,19 +30,23 @@ class PushMessageService
* 报备推送
*
* @param $house_id
* @param $agent_id
* @param int $type
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function pushReportMessage($house_id, $type = 1) {
$house = new GHousesToAgents();
$ge_tui = new GeTuiUntils();
$data = $house->getAgentList($house_id, $type);
public function pushReportMessage($house_id, $agent_id, $type = 1) {
$house_agent = new GHousesToAgents();
$agent = new AAgents();
$house = new GHouses();
$data = $house_agent->getHousesAgents($house_id, 'b.id,device_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 = "【{$v['store_name']}】店【{$v['name']}】约带看【{$v['internal_title']}】商铺";
$ge_tui->public_push_message_for_one($v['id'], $v['device_id'], '报备', $content);
$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);
}
return ;
}
......@@ -55,7 +61,6 @@ class PushMessageService
* @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';
......@@ -66,16 +71,18 @@ class PushMessageService
if ($type == 1) {
$content = "客户{$report_data['user_name']}进场【{$report_data['house_title']}】商铺";
$title = '进场';
} else {
$content = "【{$report_data['house_title']}】商铺收款";
$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);
$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);
return ;
}
......@@ -89,7 +96,6 @@ class PushMessageService
*/
public function pushBargainMessage($report_id = 0){
$agent = new AAgents();
$ge_tui = new GeTuiUntils();
$agent_house = new GHousesToAgents();
$user = new Users();
$field = 'house_id,house_title,report_agent_name,report_store_id,user_id';
......@@ -134,7 +140,7 @@ class PushMessageService
$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);
$this->push->public_push_message_for_one($v['id'], $v['device_id'], '成交就是这么简单', $content);
}
return ;
......@@ -154,10 +160,29 @@ class PushMessageService
return false;
}
$ge_tui = new GeTuiUntils();
$agent = new AAgents();
$device_id = $agent->getAgentsById($id, 'device_id');
$result = $ge_tui->public_push_message_for_one($id, $device_id, $title, $content);
$result = $this->push->public_push_message_for_one($id, $device_id, $title, $content);
return $result;
}
/**
* 店长新增成交报告
*
* @param $submit_agent_name
* @param $agent_id
* @param $order_id
* @return array|void
* @throws \think\db\exception\DataNotFoundException
* @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]);
$agent_data = $agent->getAgentInfo('id,device_id,name', $agent_id);
$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);
}
}
\ No newline at end of file
......@@ -88,7 +88,7 @@ class ReportService
//todo 批量插入到数据库
$order_no = $this->createOrderNumber();
array_push($order_arr, $this->orderBin($order_no, $id, $v));
$push->pushReportMessage($v); //推送报备信息
$push->pushReportMessage($v, $agent_id); //推送报备信息
}
//todo 保存order表 订单返回成功返回报备id
return ($this->orderModel->insertOrderByAll($order_arr) > 0) ? $id:0;
......
......@@ -128,7 +128,7 @@ class WatchShop extends Basic
],$appoint_data['id']);
$push = new PushMessageService();
$push->pushReportMessage($appoint_data["house_id"]);
$push->pushReportMessage($appoint_data["house_id"], $agent_id);
$data['msg'] = '报备成功并通知经纪人';
$appoint_watch->commit(); //提交事务
......
......@@ -228,11 +228,9 @@ class GHousesToAgents extends BaseModel
*/
public function getAgentList($house_id, $type = 1)
{
return $this->field('b.id,device_id,store_name,d.internal_title,b.name,b.phone')
return $this->field('b.id,device_id,b.name,b.phone')
->alias('a')
->join('a_agents b', 'a.agents_id = b.id', 'left')
->join('a_store c', 'b.store_id = c.id', 'left')
->join('g_houses d', 'd.id = a.houses_id', 'left')
->where('houses_id', $house_id)
->where('type', $type)
->select();
......
......@@ -176,9 +176,13 @@ class OrderModel extends Model
/**
* 根据订单id获取楼盘info
*
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseInfoByOrderId($field,$params){
return $this->db_
......@@ -188,4 +192,23 @@ class OrderModel extends Model
->where($params)
->select();
}
/**
* 根据订单id获取楼盘info
*
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseInfoByOrderIdOne($field, $params) {
return $this->db_
->field($field)
->alias("a")
->join("g_houses b","a.house_id = b.id","left")
->where($params)
->find();
}
}
\ No newline at end of file
......@@ -229,6 +229,7 @@ Route::group('api', [
//get broker
'getBroker' => [ 'api/broker/index', [ 'method' => 'get' ] ], //获取当前商铺或街铺的经纪人评论信息列表
'test' => [ 'api/broker/testtest', [ 'method' => 'get' ] ], //获取当前商铺或街铺的经纪人评论信息列表
'commentAndDeal' => [ 'api/broker/commentAndDeal', [ 'method' => 'get' ] ], //获取当前经纪人的评价和交易列表
'brokerDetail' => [ 'api/broker/brokerDetail', [ 'method' => 'get' ] ], //经纪人详情
//post broker
......
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