Commit bdfaf336 authored by hujun's avatar hujun

退款列表

parent 50d355f2
...@@ -1775,4 +1775,336 @@ class OfficePayLog extends Basic ...@@ -1775,4 +1775,336 @@ class OfficePayLog extends Basic
return $this->response($code, $msg, $data); return $this->response($code, $msg, $data);
} }
/**
* 退款列表
*
* @return \think\Response|\think\response\View
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function refundList()
{
//显示视图
if (!$this->request->isAjax()) {
return view('refundList');
}
$data['code'] = 200;
$data['msg'] = "";
$data['data'] = [];
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$refund = new OfficeORefundModel();
$m_house = new OfficeGRoom();
$m_store = new AStore();
$where['a.is_del'] = 0;
if (isset($this->params['status']) && $this->params['status'] != -1) {
if ($this->params['status'] == 1) {
$where['a.status'] = ['in', '0,1'];
} else {
$where['a.status'] = $this->params['status'];
}
}
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['>', $this->params['start_time']. ' 00:00:00'];
}
if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
$where['a.create_time'] = ['>', $this->params['end_time']. ' 23:59:59'];
}
if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) {
$where['a.create_time'] = ['between', [$this->params['start_time']. ' 00:00:00', $this->params['end_time']. ' 23:59:59']];
}
if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) {
$where['d.income_time'] = ['>', $this->params['income_start_time']. ' 00:00:00'];
}
if (!empty($this->params['income_end_time']) && empty($this->params['income_start_time'])) {
$where['d.income_time'] = ['>', $this->params['income_end_time']. ' 23:59:59'];
}
if (!empty($this->params['income_start_time']) && !empty($this->params['income_end_time'])) {
$where['d.income_time'] = ['between', [$this->params['income_start_time']. ' 00:00:00', $this->params['income_end_time']. ' 23:59:59']];
}
if (isset($this->params['type']) && $this->params['type'] != -1) {
$where['a.type'] = $this->params['type'];
}
if (!empty($this->params['order_id'])) {
$where['a.order_id'] = $this->params['order_id'];
}
if (!empty($this->params['id'])) {
$where['a.id'] = $this->params['id'];
}
if (!empty($this->params['house_id'])) {
$where['b.house_id'] = $this->params['house_id'];
}
if (!empty($this->params['address'])) {
$house_id = $m_house->getHouseColumn('id', ['internal_address'=> ['LIKE', '%'.trim($this->params['address']).'%']]);
if (isset($where['b.house_id'])) {
$house_id[] = $where['b.house_id'];
}
if (!empty($house_id)) {
$where['b.house_id'] = ['in', $house_id];
}
}
if (!empty($this->params['district_id'])) {
$where['c.district_id'] = $this->params['district_id'];
}
if (!empty($this->params['store_id'])) {
$where['c.store_id'] = $this->params['store_id'];
}
if (!empty($this->params['agent_id'])) {
$where['a.agent_id'] = $this->params['agent_id'];
}
if (!empty($this->params['pay_log_id'])) {
$where['a.pay_log_id'] = $this->params['pay_log_id'];
}
if (isset($this->params['is_self']) && $this->params['is_self'] != -1) {
if ($this->params['is_self']) {
$where['e.operation_id'] = $this->userId;
} else {
$where[] = ['EXP', 'a.id NOT IN (SELECT refund_id FROM o_refund_log WHERE operation_id ='.$this->userId.')'];
}
}
//案场费和中介费是否开业
if (isset($this->params['is_open'])) {
if ($this->params['is_open'] == 1) {
$where['d.is_open'] = 1;
} else {
$where['d.is_open'] = 0;
}
if (!isset($where['a.type'])) {
$where['a.type'] = ['in', '4,5'];
}
}
$fields = 'a.create_time,a.id,a.order_id,a.pay_log_id,a.refund_money,a.type,a.agent_id,a.agent_name,b.house_id,a.status,';
$fields .= 'd.income_time,a.type,c.store_id';
$list = $refund->getCheckRefundList($pageNo, $pageSize, 'a.id DESC', $fields, $where);
foreach ($list as $k=>$v) {
if (empty($v['house_id'])) {
$list[$k]['address'] = '';
} else {
$address = $m_house->getHouseDetail('address', ['a.id'=>$v['house_id']]);
$list[$k]['address'] = empty($address) ? '': $address;
}
if (empty($v['store_id'])) {
$list[$k]['store_name'] = '';
} else {
$list[$k]['store_name'] = $m_store->getStoreKeyById('store_name', ['id'=> $v['store_id']]);
}
}
$data['data']['list'] = $list;
$data['data']['total_money'] = $refund->getSumMoney($where);
$data['data']['total'] = $refund->getCheckRefundListTotal($where);
return $this->response($data['code'], $data['msg'], $data['data']);
}
/**
* 退款列表-导出excel
* @return string
*/
public function refundListExcel()
{
$data['code'] = 200;
$data['msg'] = "";
$data['data'] = [];
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$refund = new OfficeORefundModel();
$m_house = new OfficeGRoom();
$m_store = new AStore();
$where['a.is_del'] = 0;
if (isset($this->params['status']) && $this->params['status'] != -1) {
if ($this->params['status'] == 1) {
$where['a.status'] = ['in', '0,1'];
} else {
$where['a.status'] = $this->params['status'];
}
}
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['>', $this->params['start_time']. ' 00:00:00'];
}
if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
$where['a.create_time'] = ['>', $this->params['end_time']. ' 23:59:59'];
}
if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) {
$where['a.create_time'] = ['between', [$this->params['start_time']. ' 00:00:00', $this->params['end_time']. ' 23:59:59']];
}
if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) {
$where['d.income_time'] = ['>', $this->params['income_start_time']. ' 00:00:00'];
}
if (!empty($this->params['income_end_time']) && empty($this->params['income_start_time'])) {
$where['d.income_time'] = ['>', $this->params['income_end_time']. ' 23:59:59'];
}
if (!empty($this->params['income_start_time']) && !empty($this->params['income_end_time'])) {
$where['d.income_time'] = ['between', [$this->params['income_start_time']. ' 00:00:00', $this->params['income_end_time']. ' 23:59:59']];
}
if (is_numeric($this->params['type']) && $this->params['type'] != -1) {
$where['a.type'] = $this->params['type'];
}
if (!empty($this->params['order_id'])) {
$where['a.order_id'] = $this->params['order_id'];
}
if (!empty($this->params['id'])) {
$where['a.id'] = $this->params['id'];
}
if (!empty($this->params['house_id'])) {
$where['b.house_id'] = $this->params['house_id'];
}
if (!empty($this->params['address'])) {
$house_id = $m_house->getHouseColumn('id', ['internal_address'=> ['LIKE', '%'.trim($this->params['address']).'%']]);
if (isset($where['b.house_id'])) {
$house_id[] = $where['b.house_id'];
}
if (!empty($house_id)) {
$where['b.house_id'] = ['in', $house_id];
}
}
if (!empty($this->params['district_id'])) {
$where['c.district_id'] = $this->params['district_id'];
}
if (!empty($this->params['store_id'])) {
$where['c.store_id'] = $this->params['store_id'];
}
if (!empty($this->params['agent_id'])) {
$where['a.agent_id'] = $this->params['agent_id'];
}
if (!empty($this->params['pay_log_id'])) {
$where['a.pay_log_id'] = $this->params['pay_log_id'];
}
if (is_numeric($this->params['is_self']) && $this->params['is_self'] != -1) {
if ($this->params['is_self']) {
$where['e.operation_id'] = $this->userId;
} else {
$where[] = ['EXP', 'a.id NOT IN (SELECT refund_id FROM o_refund_log WHERE operation_id ='.$this->userId.')'];
}
}
$fields = 'a.create_time,a.id,a.type,a.order_id,a.pay_log_id,a.refund_money,';
$fields .= 'd.income_time,a.status,c.store_id,a.agent_name,b.house_id';
$list = $refund->getCheckRefundListForExcel( 'a.id DESC', $fields, $where);
foreach ($list as $k=>$v) {
if (($v['status'] == 0)or($v['status'] == 1) ) {
$v['status'] = '审核中';
} elseif ($v['status'] == 2) {
$v['status'] = '退款成功';
}elseif ($v['status'] == 3) {
$v['status'] = '已审核';
}elseif ($v['status'] == 4) {
$v['status'] = '驳回';
}else{
$v['status'] = '';
}
if ($v['type'] == 1 ) {
$v['type'] = '意向金转定';
} elseif ($v['type'] == 2) {
$v['type'] = '退保管金';
}elseif ($v['type'] == 3) {
$v['type'] = '保管金转定';
}elseif ($v['type'] == 4) {
$v['type'] = '退中介费';
}elseif ($v['type'] == 5) {
$v['type'] = '退案场费';
}elseif ($v['type'] == 0) {
$v['type'] = '退意向金';
}else{
$v['type'] = '';
}
if (empty($v['house_id'])) {
$v['address'] = '';
} else {
$address = $m_house->getHouseDetail('address', ['a.id'=>$v['house_id']]);
$v['address'] = empty($address) ? '': $address;
}
if (empty($v['store_id'])) {
$v['store_name'] = '';
} else {
$v['store_name'] = $m_store->getStoreKeyById('store_name', ['id'=> $v['store_id']]);
}
$excel_data_ = [];
$excel_data_[] = $v['create_time'];
$excel_data_[] = $v['id'];
$excel_data_[] = $v['status'];
$excel_data_[] = $v['order_id'];
$excel_data_[] = $v['pay_log_id'];
$excel_data_[] = $v['refund_money'];
$excel_data_[] = $v['income_time'];
$excel_data_[] = $v['type'];
$excel_data_[] = $v['agent_name'];
$excel_data_[] = $v['store_name'];
$excel_data_[] = $v['house_id'];
$excel_data_[] = $v['address'];
$excel_data[] = $excel_data_;
}
$total_money = $refund->getSumMoney($where);
if(!$excel_data){
return '<script>alert("导出失败");window.close();</script>';
}
$export = new ExportExcelUntil();
$title = [ '提交时间','退款ID','状态','订单ID','收款ID','退款金额','入账日期','退款类型','提交人','所属门店','商铺ID','商铺地址'];
$export->exportTable('退款审核明细表', $excel_data, 11, '退款审核明细表 (退款总计:'.$total_money.')', $title);
return '';
}
} }
\ No newline at end of file
...@@ -507,4 +507,18 @@ class OfficeGRoom extends BaseModel ...@@ -507,4 +507,18 @@ class OfficeGRoom extends BaseModel
public function updateData($data, $where) { public function updateData($data, $where) {
return $this->db_->where($where)->update($data); return $this->db_->where($where)->update($data);
} }
/**
* @param $field
* @param $params
* @return array
*/
public function getHouseColumn($field, $params)
{
return $this->db_->alias("a")
->join("office_g_building b","a.building_id=b.id","left")
->where($params)
->column($field);
}
} }
...@@ -228,11 +228,11 @@ class OfficeORefundModel extends Model{ ...@@ -228,11 +228,11 @@ class OfficeORefundModel extends Model{
public function getCheckRefundList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') { public function getCheckRefundList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->db_->alias('a') return $this->db_->alias('a')
->field($field) ->field($field)
->join('o_order b', 'a.order_id = b.id', 'left') ->join('office_o_order b', 'a.order_id = b.id', 'left')
->join('a_agents c', 'a.agent_id = c.id', 'left') ->join('office_a_agents c', 'a.agent_id = c.id', 'left')
->join('o_paylog d', 'a.pay_log_id = d.id', 'left') ->join('office_o_paylog d', 'a.pay_log_id = d.id', 'left')
->join('o_refund_log e', 'a.id = e.refund_id', 'left') ->join('office_o_refund_log e', 'a.id = e.refund_id', 'left')
->join('o_bargain f', 'd.bargain_id = f.id', 'left') ->join('office_o_bargain f', 'd.bargain_id = f.id', 'left')
->where($params) ->where($params)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
...@@ -263,11 +263,11 @@ class OfficeORefundModel extends Model{ ...@@ -263,11 +263,11 @@ class OfficeORefundModel extends Model{
*/ */
public function getCheckRefundListTotal($params) { public function getCheckRefundListTotal($params) {
return $this->db_->alias('a') return $this->db_->alias('a')
->join('o_order b', 'a.order_id = b.id', 'left') ->join('office_o_order b', 'a.order_id = b.id', 'left')
->join('a_agents c', 'a.agent_id = c.id', 'left') ->join('office_a_agents c', 'a.agent_id = c.id', 'left')
->join('o_paylog d', 'a.pay_log_id = d.id', 'left') ->join('office_o_paylog d', 'a.pay_log_id = d.id', 'left')
->join('o_refund_log e', 'a.id = e.refund_id', 'left') ->join('office_o_refund_log e', 'a.id = e.refund_id', 'left')
->join('o_bargain f', 'd.bargain_id = f.id', 'left') ->join('office_o_bargain f', 'd.bargain_id = f.id', 'left')
->where($params) ->where($params)
->group('a.id') ->group('a.id')
->count(); ->count();
...@@ -305,11 +305,11 @@ class OfficeORefundModel extends Model{ ...@@ -305,11 +305,11 @@ class OfficeORefundModel extends Model{
public function getSumMoney($params) { public function getSumMoney($params) {
$refund_money = $this->db_->alias('a') $refund_money = $this->db_->alias('a')
->field('a.refund_money') ->field('a.refund_money')
->join('o_order b', 'a.order_id = b.id', 'left') ->join('office_o_order b', 'a.order_id = b.id', 'left')
->join('a_agents c', 'a.agent_id = c.id', 'left') ->join('office_a_agents c', 'a.agent_id = c.id', 'left')
->join('o_paylog d', 'a.pay_log_id = d.id', 'left') ->join('office_o_paylog d', 'a.pay_log_id = d.id', 'left')
->join('o_refund_log e', 'a.id = e.refund_id', 'left') ->join('office_o_refund_log e', 'a.id = e.refund_id', 'left')
->join('o_bargain f', 'd.bargain_id = f.id', 'left') ->join('office_o_bargain f', 'd.bargain_id = f.id', 'left')
->where($params) ->where($params)
->group('a.id') ->group('a.id')
->select(); ->select();
......
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