Commit b41bc534 authored by hujun's avatar hujun

收款列表

parent 466d8194
...@@ -14,8 +14,8 @@ use app\api_broker\service\VipService; ...@@ -14,8 +14,8 @@ use app\api_broker\service\VipService;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\index\untils\ExportExcelUntil; use app\index\untils\ExportExcelUntil;
use app\model\AAgents; use app\model\AAgents;
use app\model\ADistrict;
use app\model\AStore; use app\model\AStore;
use app\model\GHousesToAgents;
use app\model\OBargainLogModel; use app\model\OBargainLogModel;
use app\model\OBargainModel; use app\model\OBargainModel;
use app\model\OImg; use app\model\OImg;
...@@ -2283,7 +2283,7 @@ class Finance extends Basic ...@@ -2283,7 +2283,7 @@ class Finance extends Basic
*/ */
public function getCollection() { public function getCollection() {
if (!$this->request->isAjax() && $this->params['excel'] != 1) { if (!$this->request->isAjax() && $this->params['excel'] != 1) {
// return view('getCollection'); return view('getCollection');
} }
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo']; $pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
...@@ -2296,6 +2296,7 @@ class Finance extends Basic ...@@ -2296,6 +2296,7 @@ class Finance extends Basic
try { try {
$order = new OPayLogModel(); $order = new OPayLogModel();
/*提交时间 start*/
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) { if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['> time', $this->params['start_time'] . ' 00:00:00']; $where['a.create_time'] = ['> time', $this->params['start_time'] . ' 00:00:00'];
$is_show = 1; $is_show = 1;
...@@ -2312,7 +2313,8 @@ class Finance extends Basic ...@@ -2312,7 +2313,8 @@ class Finance extends Basic
]]; ]];
$is_show = 1; $is_show = 1;
} }
/*提交时间 end*/
/*入账日期 start*/
if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) { if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) {
$where['a.income_time'] = ['> time', $this->params['income_start_time'] . ' 00:00:00']; $where['a.income_time'] = ['> time', $this->params['income_start_time'] . ' 00:00:00'];
$is_show = 1; $is_show = 1;
...@@ -2329,91 +2331,98 @@ class Finance extends Basic ...@@ -2329,91 +2331,98 @@ class Finance extends Basic
]]; ]];
$is_show = 1; $is_show = 1;
} }
/*入账日期 end*/
if (!empty($this->params['internal_title'])) { //商铺地址
$where['d.internal_title'] = ['like', '%' . $this->params['internal_title'] . '%'];
$is_show = 1;
}
if (!empty($this->params['internal_address'])) { if (!empty($this->params['internal_address'])) {
$where['d.internal_address'] = ['like', '%' . $this->params['internal_address'] . '%']; $where['d.internal_address'] = ['like', '%' . $this->params['internal_address'] . '%'];
$is_show = 1; $is_show = 1;
} }
if (!empty($this->params['user_name'])) { //商铺ID
$where['c.user_name'] = ['like', '%' . $this->params['user_name'] . '%']; if (!empty($this->params['house_id'])) {
$is_show = 1; $where['b.house_id'] = $this->params['house_id'];
}
if (!empty($this->params['user_phone'])) {
$where['c.user_phone'] = ['like', '%' . $this->params['user_phone'] . '%'];
$is_show = 1;
}
if (!empty($this->params['id'])) {
$where['a.house_number'] = $this->params['id'];
$is_show = 1; $is_show = 1;
} }
//提交人所在门店
if (!empty($this->params['store_id'])) { if (!empty($this->params['store_id'])) {
$where['e.store_id'] = $this->params['store_id']; $where['e.store_id'] = $this->params['store_id'];
$is_show = 1; $is_show = 1;
} }
//提交人所在部门
if (!empty($this->params['district_id'])) { if (!empty($this->params['district_id'])) {
$where['e.district_id'] = $this->params['district_id']; $where['e.district_id'] = $this->params['district_id'];
$is_show = 1; $is_show = 1;
} }
if (!empty($this->params['report_phone'])) { //提交人姓名
$where['e.phone'] = ['like', '%' . $this->params['report_phone'] . '%']; if (!empty($this->params['agent_name'])) {
$where['a.agent_name'] = ['like', '%' . $this->params['agent_name'] . '%'];
$is_show = 1; $is_show = 1;
} }
//入账方式
if (!empty($this->params['pay_type'])) { if (!empty($this->params['pay_type'])) {
$where['a.pay_type'] = $this->params['pay_type']; $where['a.pay_type'] = $this->params['pay_type'];
$is_show = 1; $is_show = 1;
} }
//入账类型
if (!empty($this->params['type'])) { if (!empty($this->params['type'])) {
$where['a.type'] = $this->params['type']; $where['a.type'] = $this->params['type'];
$is_show = 1; $is_show = 1;
} }
if (!empty($this->params['report_name'])) { //来源
$where['e.name'] = ['like', '%' . $this->params['report_name'] . '%']; if (!empty($this->params['source'])) {
$where['a.source'] = $this->params['source'];
$is_show = 1; $is_show = 1;
} }
if (!empty($this->params['agent_name'])) { if (!empty($this->params['bargain_id'])) {
$where['a.agent_name'] = ['like', '%' . $this->params['agent_name'] . '%']; $order_id = $this->m_bargain->getFieldValue('order_id', $this->params['bargain_id']);
$is_show = 1; $where[] = ['EXP', 'a.id='.$order_id];
}
if (!empty($this->params['pay_id'])) {
$where['a.id'] = $this->params['pay_id'];
} }
if (empty($this->params['excel'])) { if (empty($this->params['excel'])) {
$field = 'a.id,a.create_time,a.order_id,a.father_id,a.money,a.real_money,a.pay_type,a.type,a.source,a.transaction_fee,c.report_agent_phone, $field = 'a.id,a.create_time,a.order_id,a.father_id,a.money,a.real_money,a.pay_type,a.type,a.source,a.transaction_fee,';
c.report_agent_name,a.income_time,e.store_id'; $field .= 'e.name,a.income_time,e.store_id,b.house_id';
$list = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where); $list = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$data['total'] = $order->getAddPayLogOrderListLimitTotal($where); $data['total'] = $order->getAddPayLogOrderListLimitTotal($where);
$m_store = new AStore(); $m_store = new AStore();
$m_pay_adjustment = new OPayLogAdjustment(); $m_pay_adjustment = new OPayLogAdjustment();
$m_march = new OMarchInModel();
$m_agent_house = new GHousesToAgents();
$m_agent = new AAgents();
foreach ($list as $k=>$v) { foreach ($list as $k=>$v) {
$list[$k]['store_name'] = $m_store->getStoreKeyById('store_name', ['id'=>$v['store_id']]);
$source_id = $m_pay_adjustment->getFieldValue('id', ['paylog_id'=> $v['id']]); $source_id = $m_pay_adjustment->getFieldValue('id', ['paylog_id'=> $v['id']]);
$list[$k]['source_id'] = empty($source_id) ? 0 : $source_id; $list[$k]['source_id'] = empty($source_id) ? 0 : $source_id;
$bargain_id = $this->m_bargain->selectBargainByOrderNo('id', ['order_id', $v['order_id']]); $bargain_id = $this->m_bargain->selectBargainByOrderNo('id', ['order_id', $v['order_id']]);
$list[$k]['bargain_id'] = $bargain_id[0]['id']; $list[$k]['bargain_id'] = $bargain_id[0]['id'];
switch ($v['type']) { $list[$k]['current_agent_name'] = $list[$k]['store_name'] = "";
case 91: if ($v['type'] == 92) {
//中介费 对应业务员:约带看的人 即 反签方 //案场费 对应业务员:盘方
break; $current_agent_name = $m_agent_house->getHousesAgents($v['house_id'], 'b.name,b.store_id', ['a.type'=>2]);
case 92: $list[$k]['current_agent_name'] = $current_agent_name['name'];
//案场费 对应业务员:盘方 $list[$k]['store_name'] = $m_store->getStoreKeyById('store_name', ['id'=>$current_agent_name['store_id']]);
break; }
default :
//意向金/保管金 10/30 对应业务员:约带看的人 即 反签方 if ($v['type'] == 10 || $v['type'] == 30 || $v['type'] == 91) {
//意向金/保管金 10/30 对应业务员:约带看的人 即 反签方
//中介费 对应业务员:约带看的人 即 反签方
$current_agent_name = $m_march->getInfo('reception_name,reception_id', ['order_id'=>$v['order_id']]);
if (!empty($current_agent_name['reception_id'])) {
$list[$k]['store_name'] = $m_agent->getAgentByIdV2('b.store_name', ['a.id'=>$current_agent_name['reception_id']]);
}
$list[$k]['current_agent_name'] = empty($current_agent_name['reception_name']) ? "" : $current_agent_name['reception_name'];
} }
} }
$data['list'] = $list; $data['list'] = $list;
......
...@@ -669,21 +669,21 @@ class HouseService ...@@ -669,21 +669,21 @@ class HouseService
if(!$agent_id){ if(!$agent_id){
return 1; return 1;
} }
$agent_model = new AAgents();
$params_["id"] = $shop_agent_id; $params_["id"] = $shop_agent_id;
$result = $agent_model->searchAgentsByKeyword("id,store_id,district_id,level", $params_); $result = $this->agent->searchAgentsByKeyword("id,store_id,district_id,level", $params_);
//店长 //店长
$params__=[]; $params__=[];
$params__['store_id']=$result[0]['store_id']; $params__['store_id']=$result[0]['store_id'];
$params__['level']=20; $params__['level']=20;
$result_dz = $agent_model->searchAgentsByKeyword("id,store_id,district_id,level", $params__); $result_dz = $this->agent->searchAgentsByKeyword("id,store_id,district_id,level", $params__);
//总监 //总监
$params__=[]; $params__=[];
$params__['district_id']=$result[0]['district_id']; $params__['district_id']=$result[0]['district_id'];
$params__['level']=30; $params__['level']=30;
$result_zj = $agent_model->searchAgentsByKeyword("id,store_id,district_id,level", $params__); $result_zj = $this->agent->searchAgentsByKeyword("id,store_id,district_id,level", $params__);
if (($shop_agent_id == $agent_id)or($result_dz[0]['store_id'] == $agent_id)or($result_zj[0]['district_id'] == $agent_id)) { if (($shop_agent_id == $agent_id)or($result_dz[0]['store_id'] == $agent_id)or($result_zj[0]['district_id'] == $agent_id)) {
return 0;//可编辑 return 0;//可编辑
}else{ }else{
...@@ -697,9 +697,8 @@ class HouseService ...@@ -697,9 +697,8 @@ class HouseService
* @return mixed * @return mixed
*/ */
public function getShopOnlyAgentId($shop_id){ public function getShopOnlyAgentId($shop_id){
$m_houses_to_agents = new GHousesToAgents();
$where_houses_to_agents['houses_id']=$shop_id; $where_houses_to_agents['houses_id']=$shop_id;
$where_houses_to_agents['type']=3; $where_houses_to_agents['type']=3;
return $m_houses_to_agents->getAgentHouseValue('agents_id', $where_houses_to_agents); return $this->agent_house->getAgentHouseValue('agents_id', $where_houses_to_agents);
} }
} }
\ No newline at end of file
...@@ -1563,4 +1563,13 @@ class OBargainModel extends Model ...@@ -1563,4 +1563,13 @@ class OBargainModel extends Model
} }
return $data; return $data;
} }
/**
* @param $field
* @param $where
* @return mixed
*/
public function getFieldValue($field, $where) {
return $this->where($where)->value($field);
}
} }
\ No newline at end of file
...@@ -469,4 +469,20 @@ class OMarchInModel extends Model ...@@ -469,4 +469,20 @@ class OMarchInModel extends Model
return $data; return $data;
} }
/**
* @param $field
* @param $where
* @param string $order
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getInfo($field, $where, $order = 'id desc') {
return $this->field($field)
->where($where)
->order($order)
->find();
}
} }
\ No newline at end of file
...@@ -338,9 +338,9 @@ class OPayLogModel extends Model ...@@ -338,9 +338,9 @@ class OPayLogModel extends Model
->field($field) ->field($field)
->alias("a") ->alias("a")
->join("o_order b", "a.order_id = b.id", "left") ->join("o_order b", "a.order_id = b.id", "left")
->join("o_report c", "b.f_id = c.id", "left") // ->join("o_report c", "b.f_id = c.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left') ->join('g_houses d', 'b.house_id = d.id', 'left')
->join('a_agents e', 'c.report_agent_id=e.id', 'left') ->join('a_agents e', 'a.agent_id=e.id', 'left')
// ->join('a_store f', 'e.store_id=f.id', 'left') // ->join('a_store f', 'e.store_id=f.id', 'left')
// ->join('a_district g', 'f.district_id=g.id', 'left') // ->join('a_district g', 'f.district_id=g.id', 'left')
->limit($pageSize) ->limit($pageSize)
...@@ -353,9 +353,9 @@ class OPayLogModel extends Model ...@@ -353,9 +353,9 @@ class OPayLogModel extends Model
->field($field) ->field($field)
->alias("a") ->alias("a")
->join("o_order b", "a.order_id = b.id", "left") ->join("o_order b", "a.order_id = b.id", "left")
->join("o_report c", "b.f_id = c.id", "left") // ->join("o_report c", "b.f_id = c.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left') ->join('g_houses d', 'b.house_id = d.id', 'left')
->join('a_agents e', 'c.report_agent_id=e.id', 'left') ->join('a_agents e', 'a.agent_id=e.id', 'left')
// ->join('a_store f', 'e.store_id=f.id', 'left') // ->join('a_store f', 'e.store_id=f.id', 'left')
// ->join('a_district g', 'f.district_id=g.id', 'left') // ->join('a_district g', 'f.district_id=g.id', 'left')
->limit($pageSize) ->limit($pageSize)
...@@ -380,21 +380,21 @@ class OPayLogModel extends Model ...@@ -380,21 +380,21 @@ class OPayLogModel extends Model
if (isset($params['e.name']) || isset($params['f.store_name']) || isset($params['e.phone'])) { if (isset($params['e.name']) || isset($params['f.store_name']) || isset($params['e.phone'])) {
$data = Db::table($this->table)->alias("a") $data = Db::table($this->table)->alias("a")
->join("o_order b", "a.order_id = b.id", "left") ->join("o_order b", "a.order_id = b.id", "left")
->join("o_report c", "b.f_id = c.id", "left") // ->join("o_report c", "b.f_id = c.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left') ->join('g_houses d', 'b.house_id = d.id', 'left')
->join('a_agents e', 'c.report_agent_id=e.id', 'left') ->join('a_agents e', 'c.report_agent_id=e.id', 'left')
->join('a_store f', 'e.store_id=f.id', 'left') // ->join('a_store f', 'e.store_id=f.id', 'left')
->join('a_district g', 'f.district_id=g.id', 'left') // ->join('a_district g', 'f.district_id=g.id', 'left')
->where($params) ->where($params)
->count(); ->count();
} else { } else {
$data = Db::table($this->table)->alias("a") $data = Db::table($this->table)->alias("a")
->join("o_order b", "a.order_id = b.id", "left") ->join("o_order b", "a.order_id = b.id", "left")
->join("o_report c", "b.f_id = c.id", "left") // ->join("o_report c", "b.f_id = c.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left') ->join('g_houses d', 'b.house_id = d.id', 'left')
->join('a_agents e', 'c.report_agent_id=e.id', 'left') ->join('a_agents e', 'c.report_agent_id=e.id', 'left')
->join('a_store f', 'e.store_id=f.id', 'left') // ->join('a_store f', 'e.store_id=f.id', 'left')
->join('a_district g', 'f.district_id=g.id', 'left') // ->join('a_district g', 'f.district_id=g.id', 'left')
->where($params) ->where($params)
->count(); ->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