Commit 1888d8e2 authored by hujun's avatar hujun

收款总计

parent 7589b6bd
...@@ -32,78 +32,94 @@ class Collection extends Basic ...@@ -32,78 +32,94 @@ class Collection extends Basic
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$where = []; $where = [];
$is_show = 0;
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) { if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['> time',$this->params['start_time'] . ' 00:00:00']; $where['a.create_time'] = ['> time',$this->params['start_time'] . ' 00:00:00'];
$is_show = 1;
} }
if (!empty($this->params['end_time']) && empty($this->params['start_time'])) { if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
$where['a.create_time'] = ['< time',$this->params['end_time'] . ' 23:59:59']; $where['a.create_time'] = ['< time',$this->params['end_time'] . ' 23:59:59'];
$is_show = 1;
} }
if (!empty($this->params['end_time']) && !empty($this->params['start_time'])) { if (!empty($this->params['end_time']) && !empty($this->params['start_time'])) {
$where['a.create_time'] = ['between time', [ $where['a.create_time'] = ['between time', [
$this->params['start_time']. ' 00:00:00',$this->params['end_time']. ' 23:59:59' $this->params['start_time']. ' 00:00:00',$this->params['end_time']. ' 23:59:59'
]]; ]];
$is_show = 1;
} }
if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) { if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) {
$where['a.income_time'] = ['> time',$this->params['income_start_time'] . ' 00:00:00']; $where['a.income_time'] = ['> time',$this->params['income_start_time'] . ' 00:00:00'];
$is_show = 1;
} }
if (!empty($this->params['income_end_time']) && empty($this->params['income_start_time'])) { if (!empty($this->params['income_end_time']) && empty($this->params['income_start_time'])) {
$where['a.income_time'] = ['< time',$this->params['end_time'] . ' 23:59:59']; $where['a.income_time'] = ['< time',$this->params['end_time'] . ' 23:59:59'];
$is_show = 1;
} }
if (!empty($this->params['income_end_time']) && !empty($this->params['income_start_time'])) { if (!empty($this->params['income_end_time']) && !empty($this->params['income_start_time'])) {
$where['a.income_time'] = ['between time', [ $where['a.income_time'] = ['between time', [
$this->params['income_start_time']. ' 00:00:00',$this->params['income_end_time']. ' 23:59:59' $this->params['income_start_time']. ' 00:00:00',$this->params['income_end_time']. ' 23:59:59'
]]; ]];
$is_show = 1;
} }
if (!empty($this->params['internal_title'])) { if (!empty($this->params['internal_title'])) {
$where['d.internal_title'] = ['like', '%'.$this->params['internal_title'].'%']; $where['d.internal_title'] = ['like', '%'.$this->params['internal_title'].'%'];
$is_show = 1;
} }
if (!empty($this->params['internal_address'])) { if (!empty($this->params['internal_address'])) {
$where['d.internal_address'] = ['like', '%'.$this->params['internal_address'].'%']; $where['d.internal_address'] = ['like', '%'.$this->params['internal_address'].'%'];
$is_show = 1;
} }
if (!empty($this->params['user_name'])) { if (!empty($this->params['user_name'])) {
$where['c.user_name'] = ['like','%'.$this->params['user_name'].'%']; $where['c.user_name'] = ['like','%'.$this->params['user_name'].'%'];
$is_show = 1;
} }
if (!empty($this->params['user_phone'])) { if (!empty($this->params['user_phone'])) {
$where['c.user_phone'] = ['like','%'.$this->params['user_phone'].'%']; $where['c.user_phone'] = ['like','%'.$this->params['user_phone'].'%'];
$is_show = 1;
} }
if (!empty($this->params['id'])) { if (!empty($this->params['id'])) {
$where['a.house_number'] = $this->params['id']; $where['a.house_number'] = $this->params['id'];
$is_show = 1;
} }
if (!empty($this->params['store_id'])) { if (!empty($this->params['store_id'])) {
$where['e.store_id'] = $this->params['store_id']; $where['e.store_id'] = $this->params['store_id'];
$is_show = 1;
} }
if (!empty($this->params['district_id'])) { if (!empty($this->params['district_id'])) {
$where['e.district_id'] = $this->params['district_id']; $where['e.district_id'] = $this->params['district_id'];
$is_show = 1;
} }
if (!empty($this->params['report_phone'])) { if (!empty($this->params['report_phone'])) {
$where['e.phone'] = ['like','%'.$this->params['report_phone'].'%']; $where['e.phone'] = ['like','%'.$this->params['report_phone'].'%'];
$is_show = 1;
} }
if (!empty($this->params['pay_type'])) { if (!empty($this->params['pay_type'])) {
$where['a.pay_type'] = $this->params['pay_type']; $where['a.pay_type'] = $this->params['pay_type'];
$is_show = 1;
} }
if (!empty($this->params['type'])) { if (!empty($this->params['type'])) {
$where['a.type'] = $this->params['type']; $where['a.type'] = $this->params['type'];
$is_show = 1;
} }
if (!empty($this->params['report_name'])) { if (!empty($this->params['report_name'])) {
$where['e.name'] = ['like','%'.$this->params['report_name'].'%']; $where['e.name'] = ['like','%'.$this->params['report_name'].'%'];
$is_show = 1;
} }
if (empty($this->params['excel'])) { if (empty($this->params['excel'])) {
...@@ -114,36 +130,8 @@ class Collection extends Basic ...@@ -114,36 +130,8 @@ class Collection extends Basic
$data['data']['total'] = $order->getAddPayLogOrderListLmitTotal($where); $data['data']['total'] = $order->getAddPayLogOrderListLmitTotal($where);
//加时间条件 //加时间条件
if ($where['a.income_time'] || $where['a.create_time']) { if ($is_show) {
if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) { $data['data']['money_total'] = $order->getMoneyTotal($where, 'a.money'); //总额
$pay_where['income_time'] = ['> time',$this->params['start_time'] . ' 00:00:00'];
}
if (!empty($this->params['income_end_time']) && empty($this->params['income_start_time'])) {
$pay_where['income_time'] = ['< time',$this->params['income_end_time'] . ' 23:59:59'];
}
if (!empty($this->params['income_end_time']) && !empty($this->params['income_start_time'])) {
$pay_where['income_time'] = ['between time', [
$this->params['income_start_time']. ' 00:00:00',$this->params['income_end_time']. ' 23:59:59'
]];
}
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$pay_where['create_time'] = ['> time',$this->params['start_time'] . ' 00:00:00'];
}
if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
$pay_where['create_time'] = ['< time',$this->params['end_time'] . ' 23:59:59'];
}
if (!empty($this->params['end_time']) && !empty($this->params['start_time'])) {
$pay_where['create_time'] = ['between time', [
$this->params['start_time']. ' 00:00:00',$this->params['end_time']. ' 23:59:59'
]];
}
$data['data']['money_total'] = $order->getMoneyTotal($pay_where); //总额
} else { } else {
$data['data']['money_total'] = ''; $data['data']['money_total'] = '';
} }
......
...@@ -402,12 +402,38 @@ class OPayLogModel extends Model ...@@ -402,12 +402,38 @@ class OPayLogModel extends Model
* 订单总额 * 订单总额
* *
* @param $where * @param $where
* @param $field
* @return float|int * @return float|int
*/ */
public function getMoneyTotal($where) public function getMoneyTotal($where, $field)
{ {
$where["is_del"] = 0; $params["a.is_del"] = 0;
return $this->where($where)->sum('money'); if (isset($params['e.name']) || isset($params['f.store_name']) || isset($params['e.phone'])) {
$data = Db::table($this->table)
->alias("a")
->join("o_order b", "a.order_id = b.id", "left")
->join("o_report c", "b.f_id = c.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left')
->join('a_agents e', 'c.report_agent_id=e.id', 'left')
->join('a_store f', 'e.store_id=f.id', 'left')
->join('a_district g', 'f.district_id=g.id', 'left')
->where($where)
->sum($field);
} else {
$data = Db::table($this->table)
->alias("a")
->join("o_order b", "a.order_id = b.id", "left")
->join("o_report c", "b.f_id = c.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left')
->join('a_agents e', 'c.report_agent_id=e.id', 'left')
->join('a_store f', 'e.store_id=f.id', 'left')
->join('a_district g', 'f.district_id=g.id', 'left')
->where($where)
->sum($field);
}
return $data;
} }
/** /**
......
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