Commit c889d6c8 authored by hujun's avatar hujun

成交报告搜索

parent 204e46ba
......@@ -806,7 +806,7 @@ class OrderLog extends Basic
if (!empty($where)) {
//获取被修改人信息
$m_agent = new AAgents();
$agent_data = $m_agent->agentBragainDetail('a.id,a.store_id,a.district_id,b.create_time', ['b.id'=>$bargain_id]);
$agent_data = $m_agent->agentBargainDetail('a.id,a.store_id,a.district_id,b.create_time', ['b.id'=>$bargain_id]);
//更新业绩统计
$sum = new ResultsSummaryNewTask();
......
......@@ -67,7 +67,8 @@ class Finance extends Basic
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$check_status = $this->params['check_status'];
$fields = 'a.id,a.create_time,a.trade_type,b.user_phone,b.user_name,d.internal_title,d.internal_address,
a.commission,a.practical_fee,a.scale_fee,a.order_no,a.order_id,content,house_number,a.is_open,a.agent_id';
a.commission,a.practical_fee,a.scale_fee,a.order_no,a.order_id,content,house_number,a.is_open,a.agent_id,
a.submit_agent_name,a.price';
$where['a.father_id'] = 0;
$where['a.status'] = 11;
$order = 'a.id desc';
......@@ -102,24 +103,50 @@ class Finance extends Basic
}
if (!empty($this->params['district_id'])) {
$where['f.district_id'] = $this->params['district_id'];
$agent_where['a.district_id'] = $this->params['district_id'];
}
if (!empty($this->params['store_id'])) {
$where['f.store_id'] = $this->params['store_id'];
$agent_where['a.store_id'] = $this->params['store_id'];
}
if (!empty($this->params['agent_phone'])) {
$where['f.phone'] = ['LIKE', '%'.$this->params['agent_phone'].'%'];
$agent_where['a.phone'] = ['LIKE', '%'.$this->params['agent_phone'].'%'];
}
if (!empty($this->params['agent_name'])) {
$where['f.name'] = ['LIKE', '%'.$this->params['agent_name'].'%'];
$agent_where['a.name'] = ['LIKE', '%'.$this->params['agent_name'].'%'];
}
if (!empty($agent_where)) {
$m_agent = new AAgents();
$where_bargain_id = $m_agent->agentBargainAll('b.id', $agent_where);
if (empty($where_bargain_id)) {
return $this->response(200, '');
} else {
$where_id = [];
foreach ($where_bargain_id as $k=>$v) {
$where_id[] = $v['id'];
}
$where['a.id'] = ['in', $where_id];
}
}
//分佣方姓名
if (!empty($this->params['partial_name'])) {
$where['g.name'] = ['LIKE', '%'.$this->params['partial_name'].'%'];
if (!empty($this->params['partial_id'])) {
$m_agent = new AAgents();
$where_bargain_id = $m_agent->agentBargainAll('b.id', ['a.id' =>$this->params['partial_id']]);
if (empty($where_bargain_id)) {
return $this->response(200, '');
} else {
$where_id = [];
foreach ($where_bargain_id as $k=>$v) {
$where_id[] = $v['id'];
}
$where['a.id'] = ['in', $where_id];
}
}
if (!empty($this->params['bargain_id'])) {
......@@ -1585,7 +1612,7 @@ class Finance extends Basic
if (!empty($where)) {
//获取被修改人信息
$m_agent = new AAgents();
$agent_data = $m_agent->agentBragainDetail('a.id,a.store_id,a.district_id,b.create_time', ['b.id'=>$bargain_id]);
$agent_data = $m_agent->agentBargainDetail('a.id,a.store_id,a.district_id,b.create_time', ['b.id'=>$bargain_id]);
//更新业绩统计
$sum = new ResultsSummaryNewTask();
......
......@@ -1114,7 +1114,7 @@ class AAgents extends BaseModel
* @param $where
* @return array|false|\PDOStatement|string|\think\Model
*/
public function agentBragainDetail($field, $where) {
public function agentBargainDetail($field, $where) {
try {
$data = $this->alias('a')
->field($field)
......@@ -1127,6 +1127,24 @@ class AAgents extends BaseModel
return $data;
}
/**
* @param $field
* @param $where
* @return array|false|\PDOStatement|string|\think\Collection
*/
public function agentBargainAll($field, $where) {
try {
$data = $this->alias('a')
->field($field)
->join('o_bargain b', 'a.id = b.agent_id', 'left')
->where($where)
->select();
} catch (\Exception $e) {
$data = [];
}
return $data;
}
/**
* 获取绑定号码
*
......
......@@ -123,7 +123,7 @@ class GHousesToAgents extends BaseModel
foreach ($agent_id as $k=>$v) {
//获取被修改人信息
$m_agent = new AAgents();
$agent_data = $m_agent->agentBragainDetail('a.id,a.store_id,a.district_id,b.create_time,a.name', ['a.id'=>$v]);
$agent_data = $m_agent->agentBargainDetail('a.id,a.store_id,a.district_id,b.create_time,a.name', ['a.id'=>$v]);
//更新业绩统计
$sum = new ResultsSummaryNewTask();
......
......@@ -361,8 +361,6 @@ class OBargainModel extends Model
->join('o_report b', 'a.report_id = b.id', 'left')
->join('o_order c', 'a.order_id = c.id', 'left')
->join('g_houses d', 'c.house_id = d.id', 'left')
->join('a_agents f', 'b.report_agent_id=f.id', 'left')
->join('a_agents g', 'a.agent_id=g.id', 'left')
->where($params)
->group('a.id')
->order($order_)
......@@ -383,8 +381,6 @@ class OBargainModel extends Model
->join('o_report b', 'a.report_id = b.id', 'left')
->join('o_order c', 'a.order_id = c.id', 'left')
->join('g_houses d', 'c.house_id = d.id', 'left')
->join('a_agents f', 'b.report_agent_id=f.id', 'left')
->join('a_agents g', 'a.agent_id=g.id', 'left')
->where($params)
->group('a.id')
->count();
......
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