Commit 96de6af2 authored by hujun's avatar hujun

新增分佣方order_id查询经纪人接口

parent c9c639d6
......@@ -990,6 +990,87 @@ class OrderLogService
return $list;
}
/**
* 1盘方,2客方,3反签,4独家,5合作方
*
* @param $bargain_id
* @param string $field
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function searchBargainAllAgents($order_id) {
$orderModel = new OrderModel();
$field = "a.id,a.order_no,a.house_id,a.house_title,b.id as report_id,b.user_id,c.user_nick,c.user_phone,
c.user_pic,c.sex";
$where_["order_id"] = $order_id;
$result = $orderModel->selectOrderDetail($field, $where_);
if (count($result) <= 0 || $result[0]["house_id"] <= 0 || $result[0]["user_id"] <= 0) {
return null;
}
$houseAgents = new GHousesToAgents();
$field = "b.id,b.phone,b.name";
$where_house["a.houses_id"] = $result[0]["house_id"];
$where_house["a.type"] = ['in','2,3'];
$where_house["a.is_del"] = 0;
$where_house["b.status"] = 0;
$agent_house = $houseAgents->getAgentsByHouseId($field.',a.type', $where_house);
$list = [];
$key = 0;
//盘方和独家
foreach ($agent_house as $v) {
$list[$key]['id'] = $v['id'];
$list[$key]['phone'] = $v['phone'];
$list[$key]['name'] = $v['name'];
if ($v['type'] == 2) {
$list[$key]['role'] = 1;
$list[$key]['role_name'] = '盘方';
} else {
$list[$key]['role'] = 4;
$list[$key]['role_name'] = '独家';
}
$key++;
}
$userModel = new Users();
$where_user["a.id"] = $result[0]["user_id"];
$where_user["b.status"] = 0;
$user_data = $userModel->getAgentByUserId($field, $where_user);
//客方
if (isset($user_data['id'])) {
$list[$key]['id'] = $user_data['id'];
$list[$key]['phone'] = $user_data['phone'];
$list[$key]['name'] = $user_data['name'];
$list[$key]['role'] = 2;
$list[$key]['role_name'] = '客方';
$key++;
}
$reportModel = new OReportModel();
$params["a.id"] = $result[0]["report_id"];
$params["b.status"] = 0;
$report_data = $reportModel->getAgentByOrderId($field, $params);
//反签
if (isset($report_data['id'])) {
$list[$key]['id'] = $report_data['id'];
$list[$key]['phone'] = $report_data['phone'];
$list[$key]['name'] = $report_data['name'];
$list[$key]['role'] = 3;
$list[$key]['role_name'] = '反签';
}
return $list;
}
/**
* @param $order_id
* @return false|\PDOStatement|string|\think\Collection
......
......@@ -817,25 +817,45 @@ class Finance extends Basic
}
/**
* 成交报告经纪人查询
* 根据成交报告id查询经纪人
* 1盘方,2客方,3反签,4独家,5合作方
*
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function searchBargainAgents()
{
if (empty($this->params['bargain_id'])) {
return $this->response(101, '请求参数错误!');
}
$bargain = new OBargainModel();
$data = $bargain->getAgentTypeByBargainId($this->params['bargain_id']);
return $this->response(200, "", $data);
}
/**
* 根据成交报告order_id查询经纪人
* 1盘方,2客方,3反签,4独家,5合作方
*
* @return \think\Response
*/
public function searchOrderAgents() {
$params = $this->params;
/* $params = array(
"type" => 1,//1盘方,2客方,3反签,4独家,5合作方
"order_id" => 36,
);*/
if (!isset($params["type"]) || !isset($params["order_id"])) {
if (!isset($params["order_id"])) {
return $this->response("101", "请求参数错误");
}
try {
$order_service = new OrderLogService();
$list = $order_service->searchBargainAgents($params["type"], $params["order_id"]);
$list = $order_service->searchBargainAllAgents($params["order_id"]);
if (count($list) > 0) {
return $this->response("200", "request success", $list);
} else {
......@@ -844,8 +864,6 @@ class Finance extends Basic
} catch (Exception $e) {
return $this->response("101", "request error,msg:" . $e);
}
}
/**
......@@ -961,41 +979,44 @@ class Finance extends Basic
/**收佣日期 start**/
if (!empty($this->params['income_start_date']) && empty($this->params['income_end_date'])) {
$where['f.income_time'] = [ '> time', $this->params['income_start_date'] ];
$month_start = $this->params['income_start_date'];
$month_start = date('Y.m.d', strtotime($this->params['income_start_date']));
$month_end = "";
}
if (!empty($this->params['income_end_date']) && empty($this->params['income_start_date'])) {
$where['f.income_time'] = [ '< time', $this->params['income_end_date'] ];
$month_end = $this->params['income_end_date'];
$month_end = date('Y.m.d', strtotime($this->params['income_end_date']));
$month_start = "";
}
if (empty($this->params['income_start_date']) && empty($this->params['income_end_date'])) {
$where['f.income_time'] = [ 'between time', [ $month_start, $month_end]]; //默认收佣时间
$month_start = date('Y.m.d', strtotime($month_start));
$month_end = date('Y.m.d', strtotime($month_end));
}
if (!empty($this->params['income_start_date']) && !empty($this->params['income_end_date'])){
$where['f.income_time'] = [ 'between time', [ $this->params['income_start_date'], $this->params['income_end_date']]];
$month_start = $this->params['income_start_date'];
$month_end = $this->params['income_end_date'];
$month_start = date('Y.m.d', strtotime($this->params['income_start_date']));
$month_end = date('Y.m.d', strtotime($this->params['income_end_date']));
}
/**收佣日期 end**/
// /**提交成交报告日期 start**/
// if (!empty($this->params['deal_start_date']) && empty($this->params['deal_end_date'])) {
// $where['a.create_time'] = [ '> time', $this->params['deal_start_date'] ] . ' 00:00:00';
// }
//
// if (!empty($this->params['deal_end_date']) && empty($this->params['deal_start_date'])) {
// $where['a.create_time'] = [ '< time', $this->params['deal_end_date'] ] . '23:59:59';
// }
//
// if (!empty($this->params['deal_start_date']) && !empty($this->params['deal_end_date'])) {
// $where['a.create_time'] = [ 'between time', [ $this->params['deal_start_date'] . ' 00:00:00', $this->params['deal_end_date'] . '23:59:59' ] ];
// }
// /**提交成交报告日期 end**/
/**提交成交报告日期 start**/
if (!empty($this->params['bargain_start_date']) && empty($this->params['bargain_end_date'])) {
$where['a.create_time'] = [ '> time', $this->params['bargain_start_date'] ] . ' 00:00:00';
// $bargain_start_date =
}
if (!empty($this->params['bargain_end_date']) && empty($this->params['bargain_start_date'])) {
$where['a.create_time'] = [ '< time', $this->params['bargain_end_date'] ] . '23:59:59';
}
if (!empty($this->params['bargain_start_date']) && !empty($this->params['bargain_end_date'])) {
$where['a.create_time'] = [ 'between time', [ $this->params['bargain_start_date'] . ' 00:00:00', $this->params['bargain_end_date'] . '23:59:59' ] ];
}
/**提交成交报告日期 end**/
//
// /**开票日期 start**/
// if (!empty($this->params['operation_start_date']) && empty($this->params['operation_end_date'])) {
......@@ -1043,7 +1064,7 @@ class Finance extends Basic
$data['data']['list'] = $m_bargain->getCommissionTotalList($pageNo, $pageSize, 'a.id desc', $fields, $where, $whereOr);
foreach ($data['data']['list'] as $k=>$v) {
$data['data']['list'][$k]['month_income'] = date('Y.m.d', strtotime($month_start)) . '-' . date('Y.m.d', strtotime($month_end));
$data['data']['list'][$k]['month_income'] = $month_start . '-' . $month_end;
}
$data['data']['total'] = $m_bargain->getCommissionTotalListTotal($where, $whereOr);
......
......@@ -218,7 +218,8 @@ Route::group('index', [
'addRealIncome' => [ 'index/Finance/addRealIncome', [ 'method' => 'POST' ] ], //增加和编辑实收佣金
'getTallAge' => [ 'index/Finance/getTallAge', [ 'method' => 'GET' ] ], //开票税费查询
'addTallAge' => [ 'index/Finance/addTallAge', [ 'method' => 'POST' ] ], //新增和编辑开票税费
'searchBargainAgents' => [ 'index/Finance/searchBargainAgents', [ 'method' => 'GET' ] ], //获取盘方,客方,反签,独家,合作方
'searchBargainAgents' => [ 'index/Finance/searchBargainAgents', [ 'method' => 'GET' ] ], //成交报告id获取盘方,客方,反签,独家,合作方
'searchOrderAgents' => [ 'index/Finance/searchOrderAgents', [ 'method' => 'GET' ] ], //order_id获取盘方,客方,反签,独家,合作方
'getTallAgeList' => [ 'index/Finance/getTalllAgeList', [ 'method' => 'GET' ] ], //税费承担明细表
'getCommissionTotalList' => [ 'index/Finance/getCommissionTotalList', [ 'method' => 'GET' ] ], //分佣提成汇总表
'test123' => [ 'index/WatchShop/test123', [ 'method' => 'get|post' ] ], //时间轴
......
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