Commit b6440ce8 authored by hujun's avatar hujun

成交报告撤销

parent cc620f10
...@@ -126,31 +126,47 @@ class Finance extends Basic ...@@ -126,31 +126,47 @@ class Finance extends Basic
switch ($check_status) { switch ($check_status) {
case 2 : case 2 :
//成交报告列表-第二级审核 //成交报告列表-第二级审核
$audit_level = 0; $where['a.audit_level'] = 1;
break; break;
case 3 : case 3 :
//成交报告列表-第三级审核 //成交报告列表-第三级审核
$audit_level = 1; $where['a.audit_level'] = 2;
break; break;
case 4 : case 4 :
//成交报告列表-已结单 //成交报告列表-已结单
$where['a.account_statement'] = 1; $where['a.account_statement'] = 1;
$where['a.status'] = 13; $where['a.status'] = 13;
$audit_level = 2; $where['a.audit_level'] = 3;
break; break;
/* case 5 : case 5 :
//成交报告列表-待撤销 //成交报告列表-待撤销
$where['a.status'] = 20; $where['a.status'] = 20;
$where['a.audit_level'] = 0;
break; break;
case 6 : case 6 :
//成交报告列表-已撤销 //成交报告列表-已撤销
$where['a.status'] = 21; $where['a.status'] = 21;
break;*/ break;
case 7 :
//成交报告列表-待撤销-第一级审核
$where['a.status'] = 20;
$where['a.audit_level'] = 1;
break;
case 8 :
//成交报告列表-待撤销-第二级审核
$where['a.status'] = 20;
$where['a.audit_level'] = 2;
break;
case 9 :
//成交报告列表-待撤销-第三级审核
$where['a.status'] = 20;
$where['a.audit_level'] = 3;
break;
default : default :
//成交报告列表-第一级审核 //成交报告列表-第一级审核
$order = 'a.id DESC'; $order = 'a.id DESC';
$where['a.status'] = 10; $where['a.status'] = 10;
$audit_level = -1; $where['a.audit_level'] = 0;
} }
if (!empty($this->params['status'])) { if (!empty($this->params['status'])) {
...@@ -159,8 +175,8 @@ class Finance extends Basic ...@@ -159,8 +175,8 @@ class Finance extends Basic
$bargain = new OBargainModel(); $bargain = new OBargainModel();
try { try {
$data['data']['list'] = $bargain->getBargainList($pageNo, $pageSize, $order, $fields, $where, $audit_level); $data['data']['list'] = $bargain->getBargainList($pageNo, $pageSize, $order, $fields, $where);
$data['data']['total'] = $bargain->getBargainTotal($where, $audit_level); $data['data']['total'] = $bargain->getBargainTotal($where);
$data['data']['step'] = $check_status; $data['data']['step'] = $check_status;
} catch (\Exception $e) { } catch (\Exception $e) {
return $this->response(101, '内部错误,获取列表失败!请联系运营。'.$e->getMessage()); return $this->response(101, '内部错误,获取列表失败!请联系运营。'.$e->getMessage());
...@@ -1488,4 +1504,37 @@ class Finance extends Basic ...@@ -1488,4 +1504,37 @@ class Finance extends Basic
/*记录日志 end*/ /*记录日志 end*/
return $this->response(200, '修改成功', $data); return $this->response(200, '修改成功', $data);
} }
/**
* 撤销成交报告
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function backOutOne() {
if (empty($this->params['bargain_id'])) {
return $this->response(101, '参数错误');
}
$m_bargain = new OBargainModel();
$insert_data['audit_id'] = $this->userId;
$insert_data['audit_name'] = $this->userName;
$insert_data['audit_level'] = 1;
$insert_data['is_del'] = 1;
$data = $m_bargain->addCheckBargain($this->params['bargain_id'], $insert_data, 3, 20);
$code = 200;
$msg = "";
if ($data) {
$this->editRecordLog($this->params['bargain_id'], '[撤销成交报告]', 3); //日志记录
} else {
$code = 101;
$msg = '参数错误撤销失败!';
}
return $this->response($code, $msg);
}
} }
...@@ -302,34 +302,6 @@ class OBargainModel extends Model ...@@ -302,34 +302,6 @@ 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();
// }
/** /**
* 成交报告列表 * 成交报告列表
* *
...@@ -338,108 +310,44 @@ class OBargainModel extends Model ...@@ -338,108 +310,44 @@ class OBargainModel extends Model
* @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 getBargainList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '', int $audit_level = 0) public function getBargainList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '')
{ {
return $this->field($field)->alias('a')
if ($audit_level != -1) { ->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')
$sql_string = '((SELECT * FROM o_financial_audit WHERE audit_level = ' . $audit_level . ' AND is_del = 0) ->join('a_agents f', 'b.report_agent_id=f.id', 'left')
UNION ALL (SELECT * FROM o_financial_audit WHERE audit_level > ' . $audit_level . ' AND is_del = 0)) as e'; ->join('a_agents g', 'a.agent_id=g.id', 'left')
->where($params)
$data = $this->table($sql_string) ->group('a.id')
->field($field) ->order($order_)
->join('o_bargain a', 'e.bargain_id = a.id', 'left') ->limit($pageSize)
->join('o_report b', 'a.report_id = b.id', 'left') ->page($pageNo)
->join('o_order c', 'a.order_id = c.id', 'left') ->select();
->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)
->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')
->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_)
->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 array $params * @param array $params
* @param int $audit_level
* @return int * @return int
*/ */
public function getBargainTotal(array $params = [], int $audit_level = 0): int public function getBargainTotal(array $params = []): int
{ {
$total = 0; return $this->alias('a')
if ($audit_level != -1) { ->join('o_report b', 'a.report_id = b.id', 'left')
$total = $this->table('((SELECT * FROM o_financial_audit WHERE audit_level = ' . $audit_level . ' AND is_del = 0) ->join('o_order c', 'a.order_id = c.id', 'left')
UNION ALL (SELECT * FROM o_financial_audit WHERE audit_level > ' . $audit_level . ' AND is_del = 0)) as e') ->join('g_houses d', 'c.house_id = d.id', 'left')
->join('o_bargain a', 'e.bargain_id = a.id', 'left') ->join('a_agents f', 'b.report_agent_id=f.id', 'left')
->join('o_report b', 'a.report_id = b.id', 'left') ->join('a_agents g', 'a.agent_id=g.id', 'left')
->join('o_order c', 'a.order_id = c.id', 'left') ->where($params)
->join('g_houses d', 'c.house_id = d.id', 'left') ->group('a.id')
->join('a_agents f', 'b.report_agent_id=f.id', 'left') ->count();
->join('a_agents g', 'a.agent_id=g.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')
->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();
}
return $total;
} }
/** /**
...@@ -500,7 +408,6 @@ class OBargainModel extends Model ...@@ -500,7 +408,6 @@ class OBargainModel extends Model
$update_data['account_statement'] = 1; $update_data['account_statement'] = 1;
$update_data['account_time'] = date('Y-m-d H:i:s'); $update_data['account_time'] = date('Y-m-d H:i:s');
$this->where('id', $bargain_data['id'])->whereOr('father_id', $bargain_data['id'])->update($update_data); $this->where('id', $bargain_data['id'])->whereOr('father_id', $bargain_data['id'])->update($update_data);
$this->save($update_data, [ 'id' => $bargain_data['id'] ]);
} else { } else {
$update_data['status'] = 11; $update_data['status'] = 11;
$this->save($update_data, [ 'id' => $bargain_data['id'] ]); $this->save($update_data, [ 'id' => $bargain_data['id'] ]);
......
...@@ -198,7 +198,9 @@ Route::group('index', [ ...@@ -198,7 +198,9 @@ Route::group('index', [
'reportListTwo/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 2 ] ], //财务 成交报告-未结单-第二级审核 'reportListTwo/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 2 ] ], //财务 成交报告-未结单-第二级审核
'reportListThree/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 3 ] ], //财务 成交报告-未结单-第三级审核 'reportListThree/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 3 ] ], //财务 成交报告-未结单-第三级审核
'reportListStatement/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 4 ] ], //财务 成交报告-已结单 'reportListStatement/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 4 ] ], //财务 成交报告-已结单
'reportListBackout/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 5 ] ], //财务 成交报告-待撤销 'backOutOne/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 5 ] ], //财务 成交报告-待撤销-第一级数据
'backOutTwo/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 7 ] ], //财务 成交报告-待撤销-第二级数据
'backOutThree/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 8 ] ], //财务 成交报告-待撤销-第三级数据
'reportListUndone/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 6 ] ], //财务 成交报告-已撤销 'reportListUndone/:check_status' => [ 'index/Finance/reportList', [ 'method' => 'get' ], [ 'check_status' => 6 ] ], //财务 成交报告-已撤销
'refundListAttache/:check_status' => [ 'index/Finance/refundList', [ 'method' => 'get|post' ], [ 'check_status' => 0 ] ], //退款列表-专员审核 'refundListAttache/:check_status' => [ 'index/Finance/refundList', [ 'method' => 'get|post' ], [ 'check_status' => 0 ] ], //退款列表-专员审核
'refundListManager/:check_status' => [ 'index/Finance/refundList', [ 'method' => 'get|post' ], [ 'check_status' => 1 ] ], //退款列表-财务经理 'refundListManager/:check_status' => [ 'index/Finance/refundList', [ 'method' => 'get|post' ], [ 'check_status' => 1 ] ], //退款列表-财务经理
......
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