Commit f4b58679 authored by hujun's avatar hujun

实收汇总

parent 15b8d43c
...@@ -1417,7 +1417,7 @@ class Finance extends Basic ...@@ -1417,7 +1417,7 @@ class Finance extends Basic
public function getCommissionTotalList() public function getCommissionTotalList()
{ {
if (!$this->request->isAjax() && $this->params['excel'] != 1) { if (!$this->request->isAjax() && $this->params['excel'] != 1) {
// return view('commission_total'); return view('commission_total');
} }
$data['code'] = 200; $data['code'] = 200;
...@@ -1425,27 +1425,30 @@ class Finance extends Basic ...@@ -1425,27 +1425,30 @@ class Finance extends Basic
$data['data'] = $excel_data = []; $data['data'] = $excel_data = [];
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$pageNo = $this->params['pageNo'] == 1? 0 : ($this->params['pageNo'] - 1) * $pageSize; if (empty($this->params['pageNo']) || $this->params['pageNo'] == 1) {
$pageNo = 0;
$where = ' AND e.status in (10,11,13) AND a.confirm_status = 1 '; } else {
$pageNo = ($this->params['pageNo'] - 1) * $pageSize;
}
$where = ' e.status in (10,11,13) AND a.confirm_status = 1 ';
$operation_start_data = $operation_end_data = $income_date = $operation_date = ''; $operation_start_data = $operation_end_data = $income_date = $operation_date = '';
/**收佣日期 start**/ /**收佣日期 start**/
if (!empty($this->params['income_start_date']) && empty($this->params['income_end_date'])) { if (!empty($this->params['income_start_date']) && empty($this->params['income_end_date'])) {
$where .= " AND a.income_time > {$this->params['income_start_date']} AND c.operation_date > {$this->params['income_start_date']}"; $where .= " AND b.income_time > '{$this->params['income_start_date']}' AND c.operation_date > '{$this->params['income_start_date']}'";
$income_date = date('Y.m.d', strtotime($this->params['income_start_date'])); $income_date = date('Y.m.d', strtotime($this->params['income_start_date']));
$operation_start_data = $this->params['income_start_date'] . ' 00:00:00'; $operation_start_data = $this->params['income_start_date'] . ' 00:00:00';
} }
if (!empty($this->params['income_end_date']) && empty($this->params['income_start_date'])) { if (!empty($this->params['income_end_date']) && empty($this->params['income_start_date'])) {
$where .= " AND a.income_time < {$this->params['income_end_date']} AND c.operation_date < {$this->params['income_end_date']}"; $where .= " AND b.income_time < '{$this->params['income_end_date']}' AND c.operation_date < '{$this->params['income_end_date']}'";
$income_date = '-' . date('Y.m.d', strtotime($this->params['income_end_date'])); $income_date = '-' . date('Y.m.d', strtotime($this->params['income_end_date']));
$operation_end_data = $this->params['income_end_date'] . ' 23:59:59'; $operation_end_data = $this->params['income_end_date'] . ' 23:59:59';
} }
if (!empty($this->params['income_start_date']) && !empty($this->params['income_end_date'])) { if (!empty($this->params['income_start_date']) && !empty($this->params['income_end_date'])) {
$where .= " AND a.income_time BETWEEN {$this->params['income_start_date']} AND {$this->params['income_end_date']} "; $where .= " AND b.income_time BETWEEN '{$this->params['income_start_date']}' AND '{$this->params['income_end_date']}' ";
$where .= " AND c.operation_date BETWEEN {$this->params['income_start_date']} AND {$this->params['income_end_date']}"; $where .= " AND c.operation_date BETWEEN '{$this->params['income_start_date']}' AND '{$this->params['income_end_date']}'";
$income_date = date('Y.m.d', strtotime($this->params['income_start_date'])) . '-' . date('Y.m.d', strtotime($this->params['income_end_date'])); $income_date = date('Y.m.d', strtotime($this->params['income_start_date'])) . '-' . date('Y.m.d', strtotime($this->params['income_end_date']));
$operation_start_data = $this->params['income_start_date'] . ' 00:00:00'; $operation_start_data = $this->params['income_start_date'] . ' 00:00:00';
...@@ -1468,19 +1471,27 @@ class Finance extends Basic ...@@ -1468,19 +1471,27 @@ class Finance extends Basic
$where .= " AND a.agent_id={$this->params['agent_id']}"; $where .= " AND a.agent_id={$this->params['agent_id']}";
} }
$fields = ' d.store_id,d.district_id,a.agent_id,sum( a.practical_fee ),sum( c.fee ),sum( a.real_fee ),sum( a.service_charge ),sum( a.charity_fund ) '; $fields = ' d.store_id,d.district_id,a.agent_id,sum( a.practical_fee ) as practical_fee,sum( c.fee ) as fee,';
$m_bargain = new OPartialCommission(); $fields .= 'sum( a.real_fee ) as real_fee,sum( a.service_charge ) as service_charge,sum( a.charity_fund ) as charity_fund';
$m_partial = new OPartialCommission();
if (empty($this->params['excel']) && $this->params['excel'] != 1) { if (empty($this->params['excel']) && $this->params['excel'] != 1) {
$list = $m_bargain->getCommissionTotalList($pageNo, $pageSize, $fields, $where, $operation_start_data, $operation_end_data); $list = $m_partial->getCommissionTotalList($pageNo, $pageSize, $fields, $where, $operation_start_data, $operation_end_data);
foreach ($data['data']['list'] as $k => $v) { $m_store = new AStore();
$m_agent = new AAgents();
foreach ($list as $k => $v) {
$list[$k]['income_date'] = $income_date; $list[$k]['income_date'] = $income_date;
$list[$k]['operation_date'] = $operation_date; $list[$k]['operation_date'] = $operation_date;
$list[$k]['over_fee'] = $v['practical_fee'] - $v['fee']; $list[$k]['district_store'] = $m_store->getStoreDistrictName($v['store_id']);
$list[$k]['fee'] = empty($v['fee']) ? 0 : $v['fee'];
$list[$k]['name'] = $m_agent->getAgentsById($v['agent_id'], 'name');
} }
$data['data']['list'] = $list; $data['data']['list'] = $list;
// $data['data']['total'] = $m_bargain->getCommissionTotalListTotal($where); $data['data']['total'] = $m_partial->getCommissionTotalListTotal($where);
$data['data']['total_money'] = $m_partial->getCommissionTotalInfo('a.practical_fee', $where);
$data['data']['total_taxes'] = $m_partial->getCommissionTotalInfo('c.fee', $where);
} }
return $this->response($data['code'], $data['msg'], $data['data']); return $this->response($data['code'], $data['msg'], $data['data']);
} }
......
...@@ -149,6 +149,12 @@ ...@@ -149,6 +149,12 @@
<span style="margin-left: 5px;font-size: 16px;font-weight: 600;"> <span style="margin-left: 5px;font-size: 16px;font-weight: 600;">
最终实收总计:<span class="total-money"></span> 最终实收总计:<span class="total-money"></span>
</span> </span>
<span style="margin-left: 5px;font-size: 16px;font-weight: 600;">
税费总计:<span class="total-taxes"></span>
</span>
<span style="margin-left: 5px;font-size: 16px;font-weight: 600;">
最终实收总计:<span class="total-all"></span>
</span>
</form> </form>
</td> </td>
</tr> </tr>
......
...@@ -226,9 +226,9 @@ class OPartialCommission extends BaseModel ...@@ -226,9 +226,9 @@ class OPartialCommission extends BaseModel
LEFT JOIN a_agents d ON a.agent_id = d.id LEFT JOIN a_agents d ON a.agent_id = d.id
LEFT JOIN o_bargain e ON a.bargain_id = e.id LEFT JOIN o_bargain e ON a.bargain_id = e.id
WHERE WHERE
a.practical_fee IS NOT NULL {$params}
AND c.fee IS NOT NULL AND a.practical_fee > 0
{$params} AND c.fee > 0
GROUP BY GROUP BY
a.agent_id a.agent_id
) UNION ALL ) UNION ALL
...@@ -242,9 +242,9 @@ class OPartialCommission extends BaseModel ...@@ -242,9 +242,9 @@ class OPartialCommission extends BaseModel
LEFT JOIN a_agents d ON a.agent_id = d.id LEFT JOIN a_agents d ON a.agent_id = d.id
LEFT JOIN o_bargain e ON a.bargain_id = e.id LEFT JOIN o_bargain e ON a.bargain_id = e.id
WHERE WHERE
a.practical_fee IS NULL
AND c.fee IS NOT NULL
{$params} {$params}
AND a.practical_fee IS NULL
AND c.fee > 0
GROUP BY GROUP BY
a.agent_id a.agent_id
) UNION ALL ) UNION ALL
...@@ -258,15 +258,30 @@ class OPartialCommission extends BaseModel ...@@ -258,15 +258,30 @@ class OPartialCommission extends BaseModel
LEFT JOIN a_agents d ON a.agent_id = d.id LEFT JOIN a_agents d ON a.agent_id = d.id
LEFT JOIN o_bargain e ON a.bargain_id = e.id LEFT JOIN o_bargain e ON a.bargain_id = e.id
WHERE WHERE
a.practical_fee IS NOT NULL
AND c.fee IS NULL
{$params} {$params}
AND a.practical_fee > 0
AND c.fee IS NULL
GROUP BY GROUP BY
a.agent_id a.agent_id
) limit {$pageNo},{$pageSize}"; ) limit {$pageNo},{$pageSize}";
return $this->query($sql); return $this->query($sql);
} }
/**
* @param $field
* @param $where
* @return float|int
*/
public function getCommissionTotalInfo($field, $where) {
return $this->alias('a')
->join('o_real_income b', 'a.real_income_id = b.id', 'left')
->join('o_taxes c', 'a.agent_id = c.agent_id', 'left')
->join('a_agents d', 'a.agent_id = d.id', 'left')
->join('o_bargain e', 'a.bargain_id = e.id', 'left')
->where($where)
->sum($field);
}
/** /**
* 分佣提成汇总表 * 分佣提成汇总表
* *
...@@ -342,15 +357,68 @@ class OPartialCommission extends BaseModel ...@@ -342,15 +357,68 @@ class OPartialCommission extends BaseModel
* @param $params * @param $params
* @return int|string * @return int|string
*/ */
/**
* @param $params
* @return mixed
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/
public function getCommissionTotalListTotal($params) public function getCommissionTotalListTotal($params)
{ {
return $this->alias('a') $sql = "SELECT
->join('o_bargain b', 'a.bargain_id = b.id', 'left') COUNT( * ) AS count
->join('o_real_income f', 'b.id = f.bargain_id', 'left') FROM
->join('a_agents d', 'a.agent_id = d.id', 'left') (
->where($params)
->group('a.agent_id') ( SELECT
->count(); count(a.id) as num
FROM
o_partial_commission a
LEFT JOIN o_real_income b ON a.real_income_id = b.id
LEFT JOIN o_taxes c ON a.agent_id = c.agent_id
LEFT JOIN a_agents d ON a.agent_id = d.id
LEFT JOIN o_bargain e ON a.bargain_id = e.id
WHERE
{$params}
AND a.practical_fee > 0
AND c.fee > 0
GROUP BY
a.agent_id
) UNION ALL
(
SELECT
count(a.id)
FROM
o_partial_commission a
LEFT JOIN o_real_income b ON a.real_income_id = b.id
LEFT JOIN o_taxes c ON a.agent_id = c.agent_id
LEFT JOIN a_agents d ON a.agent_id = d.id
LEFT JOIN o_bargain e ON a.bargain_id = e.id
WHERE
{$params}
AND a.practical_fee IS NULL
AND c.fee > 0
GROUP BY
a.agent_id
) UNION ALL
(
SELECT
count(a.id)
FROM
o_partial_commission a
LEFT JOIN o_real_income b ON a.real_income_id = b.id
LEFT JOIN o_taxes c ON a.agent_id = c.agent_id
LEFT JOIN a_agents d ON a.agent_id = d.id
LEFT JOIN o_bargain e ON a.bargain_id = e.id
WHERE
{$params}
AND a.practical_fee > 0
AND c.fee IS NULL
GROUP BY
a.agent_id
) ) as _group_count_";
$num = $this->query($sql);
return $num[0]['count'];
} }
/** /**
......
...@@ -258,8 +258,7 @@ Route::group('index', [ ...@@ -258,8 +258,7 @@ Route::group('index', [
'searchBargainAgents' => ['index/Finance/searchBargainAgents', ['method' => 'GET']], //成交报告id获取盘方,客方,反签,独家,合作方 'searchBargainAgents' => ['index/Finance/searchBargainAgents', ['method' => 'GET']], //成交报告id获取盘方,客方,反签,独家,合作方
'searchOrderAgents' => ['index/Finance/searchOrderAgents', ['method' => 'GET']], //order_id获取盘方,客方,反签,独家,合作方 'searchOrderAgents' => ['index/Finance/searchOrderAgents', ['method' => 'GET']], //order_id获取盘方,客方,反签,独家,合作方
'getTallAgeList' => ['index/Finance/getTallAgeList', ['method' => 'GET']], //税费承担明细表 'getTallAgeList' => ['index/Finance/getTallAgeList', ['method' => 'GET']], //税费承担明细表
'getCommissionTotalList' => ['index/Finance/getCommissionTotalListV2', ['method' => 'GET']], //分佣提成汇总表 'getCommissionTotalList' => ['index/Finance/getCommissionTotalList', ['method' => 'GET']], //分佣提成汇总表
'getCommissionTotalListV2' => ['index/Finance/getCommissionTotalList', ['method' => 'GET']], //分佣提成汇总表
'getCollection' => ['index/Finance/getCollection', ['method' => 'post|get']],//收款记录 'getCollection' => ['index/Finance/getCollection', ['method' => 'post|get']],//收款记录
'addRealMoney' => ['index/Finance/addRealMoney', ['method' => 'post|get']],//新增实收 'addRealMoney' => ['index/Finance/addRealMoney', ['method' => 'post|get']],//新增实收
'visitShop' => ['index/Supervise/visitShop', ['method' => 'get']],//门店拜访 'visitShop' => ['index/Supervise/visitShop', ['method' => 'get']],//门店拜访
......
...@@ -55,7 +55,7 @@ define(['doT', 'text!temp/commissionTotal_template_tpl.html', 'css!style/home.cs ...@@ -55,7 +55,7 @@ define(['doT', 'text!temp/commissionTotal_template_tpl.html', 'css!style/home.cs
$('#confirm_commission').val(day_end); $('#confirm_commission').val(day_end);
//初始化收佣日期 //初始化收佣日期
business.getList(); business.getList(1);
business.event(); business.event();
business.getDistrict(); business.getDistrict();
}, },
...@@ -432,6 +432,7 @@ define(['doT', 'text!temp/commissionTotal_template_tpl.html', 'css!style/home.cs ...@@ -432,6 +432,7 @@ define(['doT', 'text!temp/commissionTotal_template_tpl.html', 'css!style/home.cs
params.confirm_date = $('#confirm_commission').val(); params.confirm_date = $('#confirm_commission').val();
params.district_id = $("#district_id").val(); //部门id 添加字段 params.district_id = $("#district_id").val(); //部门id 添加字段
params.store_id = $('#guest_stores').val(); params.store_id = $('#guest_stores').val();
console.log(params)
$.ajax({ $.ajax({
url: '/index/getCommissionTotalList', //获取列表 url: '/index/getCommissionTotalList', //获取列表
type: 'GET', type: 'GET',
...@@ -445,6 +446,8 @@ define(['doT', 'text!temp/commissionTotal_template_tpl.html', 'css!style/home.cs ...@@ -445,6 +446,8 @@ define(['doT', 'text!temp/commissionTotal_template_tpl.html', 'css!style/home.cs
$("#business_list").html(doTtmpl(data.data.list)); $("#business_list").html(doTtmpl(data.data.list));
//汇总总计 //汇总总计
$('.total-money').html(data.data.total_money); $('.total-money').html(data.data.total_money);
$('.total-taxes').html(data.data.total_taxes);
$('.total-all').html(data.data.total_money - data.data.total_taxes);
/*分页代码*/ /*分页代码*/
add_page(data.data.total, pageNo, business.pageSize, business.getList); add_page(data.data.total, pageNo, business.pageSize, business.getList);
} else { } else {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
[% } %] [% } %]
</td> </td>
<td> <td>
[%= it[item]['over_fee'] %] [%= it[item]['practical_fee'] - it[item]['fee'] %]
</td> </td>
</tr> </tr>
[% } %] [% } %]
......
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