Commit b41bc534 authored by hujun's avatar hujun

收款列表

parent 466d8194
......@@ -14,8 +14,8 @@ use app\api_broker\service\VipService;
use app\index\extend\Basic;
use app\index\untils\ExportExcelUntil;
use app\model\AAgents;
use app\model\ADistrict;
use app\model\AStore;
use app\model\GHousesToAgents;
use app\model\OBargainLogModel;
use app\model\OBargainModel;
use app\model\OImg;
......@@ -2283,7 +2283,7 @@ class Finance extends Basic
*/
public function getCollection() {
if (!$this->request->isAjax() && $this->params['excel'] != 1) {
// return view('getCollection');
return view('getCollection');
}
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
......@@ -2296,6 +2296,7 @@ class Finance extends Basic
try {
$order = new OPayLogModel();
/*提交时间 start*/
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['> time', $this->params['start_time'] . ' 00:00:00'];
$is_show = 1;
......@@ -2312,7 +2313,8 @@ class Finance extends Basic
]];
$is_show = 1;
}
/*提交时间 end*/
/*入账日期 start*/
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'];
$is_show = 1;
......@@ -2329,91 +2331,98 @@ class Finance extends Basic
]];
$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'])) {
$where['d.internal_address'] = ['like', '%' . $this->params['internal_address'] . '%'];
$is_show = 1;
}
if (!empty($this->params['user_name'])) {
$where['c.user_name'] = ['like', '%' . $this->params['user_name'] . '%'];
$is_show = 1;
}
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'];
//商铺ID
if (!empty($this->params['house_id'])) {
$where['b.house_id'] = $this->params['house_id'];
$is_show = 1;
}
//提交人所在门店
if (!empty($this->params['store_id'])) {
$where['e.store_id'] = $this->params['store_id'];
$is_show = 1;
}
//提交人所在部门
if (!empty($this->params['district_id'])) {
$where['e.district_id'] = $this->params['district_id'];
$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;
}
//入账方式
if (!empty($this->params['pay_type'])) {
$where['a.pay_type'] = $this->params['pay_type'];
$is_show = 1;
}
//入账类型
if (!empty($this->params['type'])) {
$where['a.type'] = $this->params['type'];
$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;
}
if (!empty($this->params['agent_name'])) {
$where['a.agent_name'] = ['like', '%' . $this->params['agent_name'] . '%'];
$is_show = 1;
if (!empty($this->params['bargain_id'])) {
$order_id = $this->m_bargain->getFieldValue('order_id', $this->params['bargain_id']);
$where[] = ['EXP', 'a.id='.$order_id];
}
if (!empty($this->params['pay_id'])) {
$where['a.id'] = $this->params['pay_id'];
}
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,
c.report_agent_name,a.income_time,e.store_id';
$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,';
$field .= 'e.name,a.income_time,e.store_id,b.house_id';
$list = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$data['total'] = $order->getAddPayLogOrderListLimitTotal($where);
$m_store = new AStore();
$m_pay_adjustment = new OPayLogAdjustment();
$m_march = new OMarchInModel();
$m_agent_house = new GHousesToAgents();
$m_agent = new AAgents();
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']]);
$list[$k]['source_id'] = empty($source_id) ? 0 : $source_id;
$bargain_id = $this->m_bargain->selectBargainByOrderNo('id', ['order_id', $v['order_id']]);
$list[$k]['bargain_id'] = $bargain_id[0]['id'];
switch ($v['type']) {
case 91:
//中介费 对应业务员:约带看的人 即 反签方
break;
case 92:
//案场费 对应业务员:盘方
break;
default :
//意向金/保管金 10/30 对应业务员:约带看的人 即 反签方
$list[$k]['current_agent_name'] = $list[$k]['store_name'] = "";
if ($v['type'] == 92) {
//案场费 对应业务员:盘方
$current_agent_name = $m_agent_house->getHousesAgents($v['house_id'], 'b.name,b.store_id', ['a.type'=>2]);
$list[$k]['current_agent_name'] = $current_agent_name['name'];
$list[$k]['store_name'] = $m_store->getStoreKeyById('store_name', ['id'=>$current_agent_name['store_id']]);
}
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;
......
......@@ -669,21 +669,21 @@ class HouseService
if(!$agent_id){
return 1;
}
$agent_model = new AAgents();
$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__['store_id']=$result[0]['store_id'];
$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__['district_id']=$result[0]['district_id'];
$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)) {
return 0;//可编辑
}else{
......@@ -697,9 +697,8 @@ class HouseService
* @return mixed
*/
public function getShopOnlyAgentId($shop_id){
$m_houses_to_agents = new GHousesToAgents();
$where_houses_to_agents['houses_id']=$shop_id;
$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
}
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
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
->field($field)
->alias("a")
->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('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_district g', 'f.district_id=g.id', 'left')
->limit($pageSize)
......@@ -353,9 +353,9 @@ class OPayLogModel extends Model
->field($field)
->alias("a")
->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('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_district g', 'f.district_id=g.id', 'left')
->limit($pageSize)
......@@ -380,21 +380,21 @@ class OPayLogModel extends Model
if (isset($params['e.name']) || isset($params['f.store_name']) || isset($params['e.phone'])) {
$data = Db::table($this->table)->alias("a")
->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('a_agents e', 'c.report_agent_id=e.id', 'left')
->join('a_store f', 'e.store_id=f.id', 'left')
->join('a_district g', 'f.district_id=g.id', 'left')
// ->join('a_store f', 'e.store_id=f.id', 'left')
// ->join('a_district g', 'f.district_id=g.id', 'left')
->where($params)
->count();
} else {
$data = Db::table($this->table)->alias("a")
->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('a_agents e', 'c.report_agent_id=e.id', 'left')
->join('a_store f', 'e.store_id=f.id', 'left')
->join('a_district g', 'f.district_id=g.id', 'left')
// ->join('a_store f', 'e.store_id=f.id', 'left')
// ->join('a_district g', 'f.district_id=g.id', 'left')
->where($params)
->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