Commit a5ec5c52 authored by hujun's avatar hujun

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

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