Commit ba68e571 authored by hujun's avatar hujun

退款列表

parent b930ef6e
...@@ -727,7 +727,7 @@ class Finance extends Basic ...@@ -727,7 +727,7 @@ class Finance extends Basic
//显示视图 //显示视图
if (!$this->request->isAjax()) { if (!$this->request->isAjax()) {
return view('refundList'); // return view('refundList');
} }
$data['code'] = 200; $data['code'] = 200;
...@@ -737,35 +737,97 @@ class Finance extends Basic ...@@ -737,35 +737,97 @@ 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 = [ 0, 1, 2, 3 ]; $refund = new ORefundModel();
$m_house = new GHouses();
$m_store = new AStore();
if (in_array($this->params['check_status'], $check_status)) { $where['a.is_del'] = 0;
switch ($this->params['check_status']) { if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
case 1 : $where['a.create_time'] = ['>', $this->params['start_time']. ' 00:00:00'];
//退款列表-经理审核 }
$where['e.audit_level'] = 0;
break; if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
case 2 : $where['a.create_time'] = ['>', $this->params['end_time']. ' 23:59:59'];
//退款列表-总监审核 }
$where['e.audit_level'] = 1;
break; if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) {
case 3 : $where['a.create_time'] = ['between', [$this->params['start_time']. ' 00:00:00', $this->params['end_time']. ' 23:59:59']];
//退款列表-出纳审核 }
$where['e.audit_level'] = 2;
break; if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) {
default : $where['d.income_time'] = ['>', $this->params['income_start_time']. ' 00:00:00'];
//退款列表-专员审核 }
$where['e.audit_level'] = [ 'NULL' ];
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'])) {
$m_house = new GHouses();
$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'] = implode(',',$this->params['house_id']);
} }
} else {
$where['e.audit_level'] = [ 'NULL' ];
} }
$where['a.status'] = 1; if (!empty($this->params['district_id'])) {
$refund = new ORefundModel(); $where['c.district_id'] = $this->params['district_id'];
}
$fields = 'a.id,a.agent_name,a.name,a.bank,a.card_no,a.create_time,a.refund_money,b.report_agent_name,b.user_name,a.order_id'; if (!empty($this->params['store_id'])) {
$data['data']['list'] = $refund->getCheckRefundList($pageNo, $pageSize, 'a.id DESC', $fields, $where); $where['c.store_id'] = $this->params['store_id'];
}
if (!empty($this->params['agent_id'])) {
$where['a.agent_id'] = $this->params['agent_id'];
}
$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 {
$list[$k]['address'] = $m_house->getHouseValue('internal_address', ['id'=>$v['house_id']]);
}
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); $data['data']['total'] = $refund->getCheckRefundListTotal($where);
return $this->response($data['code'], $data['msg'], $data['data']); return $this->response($data['code'], $data['msg'], $data['data']);
......
...@@ -1634,6 +1634,16 @@ class GHouses extends BaseModel ...@@ -1634,6 +1634,16 @@ class GHouses extends BaseModel
->value($field); ->value($field);
} }
/**
* @param $field
* @param $where
* @return mixed
*/
public function getHouseColumn($field, $where) {
return $this->where($where)
->column($field);
}
/** /**
* @param $field * @param $field
* @param $where_ * @param $where_
......
...@@ -203,11 +203,12 @@ class ORefundModel extends Model{ ...@@ -203,11 +203,12 @@ class ORefundModel extends Model{
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
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 Db::table($this->table) return $this->db_->alias('a')
->alias('a')
->field($field) ->field($field)
->join('o_report b', 'a.report_id = b.id', 'left') ->join('o_order b', 'a.order_id = b.id', 'left')
->join('o_financial_audit c', 'a.order_id=c.order_id', 'left') ->join('a_agents c', 'a.agent_id = c.id', 'left')
->join('o_paylog d', 'a.pay_log_id = d.id', 'left')
->where($params)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
->order($order_) ->order($order_)
...@@ -221,10 +222,20 @@ class ORefundModel extends Model{ ...@@ -221,10 +222,20 @@ class ORefundModel extends Model{
* @return int|string * @return int|string
*/ */
public function getCheckRefundListTotal($params) { public function getCheckRefundListTotal($params) {
return Db::table($this->table) return $this->db_->alias('a')
->alias('a') ->join('o_order b', 'a.order_id = b.id', 'left')
->join('o_report b', 'a.report_id = b.id', 'left') ->join('a_agents c', 'a.agent_id = c.id', 'left')
->join('o_financial_audit c', 'a.order_id=c.order_id', 'left') ->join('o_paylog d', 'a.pay_log_id = d.id', 'left')
->where($params)
->count(); ->count();
} }
public function getSumMoney($params) {
return $this->db_->alias('a')
->join('o_order b', 'a.order_id = b.id', 'left')
->join('a_agents c', 'a.agent_id = c.id', 'left')
->join('o_paylog d', 'a.pay_log_id = d.id', 'left')
->where($params)
->sum('a.refund_money');
}
} }
\ No newline at end of file
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