Commit a5ec5c52 authored by hujun's avatar hujun

成交报告列表修改,税费承担明细表增加字段

parent 939b4f0e
......@@ -66,10 +66,11 @@ class Finance extends Basic
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$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';
$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';
$where['a.father_id'] = 0;
$where['c.is_del'] = 0;
// $where['c.is_del'] = 0;
$where['a.status'] = 10;
$order = 'e.id desc';
......@@ -97,25 +98,20 @@ class Finance extends Basic
$where['a.house_number'] = [ 'like', '%' . $this->params['house_number'] . '%' ];
}
switch ($this->params['check_status']) {
switch ($check_status) {
case 2 :
//成交报告列表-第二级审核
$where['e.audit_level'] = 0;
$where[]= ['EXP','e.id in (SELECT MAX(id) FROM o_financial_audit WHERE is_del = 0 and `status`<>3 GROUP BY bargain_id)'];
$where['e.is_del'] = 0;
$audit_level = 0;
break;
case 3 :
//成交报告列表-第三级审核
$where['e.audit_level'] = 1;
$where['e.is_del'] = 0;
$where[]= ['EXP','e.id in (SELECT MAX(id) FROM o_financial_audit WHERE is_del = 0 and `status`<>3 GROUP BY bargain_id)'];
$audit_level = 1;
break;
case 4 :
//成交报告列表-已结单
$where['a.account_statement'] = 1;
$where['a.status'] = 11;
$where['e.audit_level'] = 2;
$audit_level = 2;
break;
/* case 5 :
//成交报告列表-待撤销
......@@ -128,7 +124,8 @@ class Finance extends Basic
default :
//成交报告列表-第一级审核
$order = 'a.id DESC';
$where[]= ['EXP','e.audit_level IS NULL or e.id not in (SELECT MAX(id) FROM o_financial_audit WHERE is_del = 0 GROUP BY bargain_id)'];
$where['a.status'] = 10;
$audit_level = -1;
}
if (!empty($this->params['status'])) {
......@@ -136,9 +133,9 @@ class Finance extends Basic
}
$bargain = new OBargainModel();
$data['data']['list'] = $bargain->getBargain($pageNo, $pageSize, $order, $fields, $where);
$data['data']['total'] = $bargain->getBargainTotal($where);
$data['data']['step'] = $this->params['check_status'];
$data['data']['list'] = $bargain->getBargainList($pageNo, $pageSize, $order, $fields, $where, $audit_level);
$data['data']['total'] = $bargain->getBargainTotal($where, $audit_level);
$data['data']['step'] = $check_status;
return $this->response($data['code'], $data['msg'], $data['data']);
}
......@@ -913,7 +910,7 @@ class Finance extends Basic
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$fields = 'a.id,a.create_time,e.name,e.phone,a.fee,b.house_number,d.internal_address,b.agent_id';
$fields = 'a.id,a.create_time,e.name,e.phone,a.fee,b.house_number,d.internal_address,b.agent_id,b.father_id,b.order_id';
$where['c.is_del'] = 0;
$where['b.status'] = [ 'in', 10, 11 ]; //10已提交 11审核成功
......
......@@ -233,50 +233,136 @@ class OBargainModel extends Model
return $result;
}
// /**
// * 成交报告
// *
// * @param int $pageNo
// * @param int $pageSize
// * @param string $order_
// * @param string $field
// * @param string $params
// * @return false|\PDOStatement|string|\think\Collection
// * @throws \think\db\exception\DataNotFoundException
// * @throws \think\db\exception\ModelNotFoundException
// * @throws \think\exception\DbException
// */
// public function getBargain($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '')
// {
// return $this->field($field)->alias('a')
// ->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('o_financial_audit e', 'e.bargain_id = a.id', 'left')
// ->where($params)
// ->group('a.id')
// ->order($order_)
// ->limit($pageSize)
// ->page($pageNo)
// ->select();
// }
/**
* 成交报告
* 成交报告列表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @param int $audit_level
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getBargain($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '')
public function getBargainList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '', int $audit_level = 0)
{
return $this->field($field)->alias('a')
->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('o_financial_audit e', 'e.bargain_id = a.id', 'left')
->where($params)
->group('a.id')
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
if ($audit_level != -1) {
$sql_string = '((SELECT * FROM o_financial_audit WHERE audit_level = '.$audit_level .' AND is_del = 0)
UNION ALL (SELECT * FROM o_financial_audit WHERE audit_level > '.$audit_level .' AND is_del = 0)) as e';
$data = $this->table($sql_string)
->field($field)
->join('o_bargain a', 'e.bargain_id = a.id', 'left')
->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')
->where($params)
->having('count(e.order_id) = 1')
->order($order_)
->group('e.order_id')
->limit($pageSize)
->page($pageNo)
->select();
} else {
$data = $this->field($field)->alias('a')
->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')
->where($params)
->group('a.id')
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
return $data;
}
// /**
// * 成交报告总数
// *
// * @param string $params
// * @return int|string
// */
// public function getBargainTotal($params = '')
// {
// return $this->alias('a')
// ->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('o_financial_audit e', 'e.bargain_id = a.id', 'left')
// ->where($params)
// ->group('a.id')
// ->count();
// }
/**
* 成交报告总数
*
* @param string $params
* @return int|string
* @param array $params
* @param int $audit_level
* @return int
*/
public function getBargainTotal($params = '')
public function getBargainTotal(array $params = [], int $audit_level = 0) : int
{
return $this->alias('a')
->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('o_financial_audit e', 'e.bargain_id = a.id', 'left')
->where($params)
->group('a.id')
->count();
$total = 0;
if ($audit_level != -1) {
$total = $this->table('((SELECT * FROM o_financial_audit WHERE audit_level = '.$audit_level .' AND is_del = 0)
UNION ALL (SELECT * FROM o_financial_audit WHERE audit_level > '.$audit_level .' AND is_del = 0)) as e')
->join('o_bargain a', 'e.bargain_id = a.id', 'left')
->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')
->where($params)
->having('count(e.order_id) = 1')
->group('e.order_id')
->count();
} else {
$total = $this->alias('a')
->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')
->where($params)
->group('a.id')
->count();
}
return $total;
}
/**
......@@ -334,10 +420,13 @@ class OBargainModel extends Model
if ($return) {
if ($data['audit_level'] == 2 && $status == 10) {
$update_data['status'] = 11;
$update_data['status'] = 13;
$update_data['account_statement'] = 1;
$update_data['account_time'] = time();
$this->save($update_data, [ 'id' => $bargain_data['id'] ]);
} else {
$update_data['status'] = 11;
$this->save($update_data, [ 'id' => $bargain_data['id'] ]);
}
if ($data['audit_level'] == 2 && $status == 20) {
......
......@@ -112,12 +112,15 @@ class OTaxes extends BaseModel
return $result;
}
/**
* 根据id 查询详情 zw
*
* @param int $taxesId
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getTaxesId(int $taxesId, string $field)
{
......
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