Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
4257bc04
Commit
4257bc04
authored
Dec 23, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实收汇总
parent
29139406
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
127 deletions
+111
-127
Finance.php
application/index/controller/Finance.php
+39
-22
OPartialCommission.php
application/model/OPartialCommission.php
+52
-104
OTaxes.php
application/model/OTaxes.php
+20
-1
No files found.
application/index/controller/Finance.php
View file @
4257bc04
...
...
@@ -1425,30 +1425,36 @@ class Finance extends Basic
$data
[
'data'
]
=
$excel_data
=
[];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
10
:
$this
->
params
[
'pageSize'
];
if
(
empty
(
$this
->
params
[
'pageNo'
])
||
$this
->
params
[
'pageNo'
]
==
1
)
{
$pageNo
=
0
;
}
else
{
$pageNo
=
(
$this
->
params
[
'pageNo'
]
-
1
)
*
$pageSize
;
}
$where
=
' e.status in (10,11,13) '
;
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
// if (empty($this->params['pageNo']) || $this->params['pageNo'] == 1) {
// $pageNo = 0;
// } else {
// $pageNo = ($this->params['pageNo'] - 1) * $pageSize;
// }
// $where = ' e.status in (10,11,13) ';
$where
[
'e.status'
]
=
[
'in'
,
'10,11,13'
];
$operation_start_data
=
$operation_end_data
=
$income_date
=
$operation_date
=
''
;
/**收佣日期 start**/
if
(
!
empty
(
$this
->
params
[
'income_start_date'
])
&&
empty
(
$this
->
params
[
'income_end_date'
]))
{
$where
.=
" AND b.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']}'";
$where
[
0
]
=
[
'EXP'
,
"b.income_time > '
{
$this
->
params
[
'income_start_date'
]
}
' OR c.operation_date > '
{
$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'
;
}
if
(
!
empty
(
$this
->
params
[
'income_end_date'
])
&&
empty
(
$this
->
params
[
'income_start_date'
]))
{
$where
.=
" AND b.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']}'";
$where
[
0
]
=
[
'EXP'
,
"b.income_time < '
{
$this
->
params
[
'income_end_date'
]
}
' OR c.operation_date < '
{
$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'
;
}
if
(
!
empty
(
$this
->
params
[
'income_start_date'
])
&&
!
empty
(
$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 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
[
0
]
=
[
'EXP'
,
"b.income_time BETWEEN '
{
$this
->
params
[
'income_start_date'
]
}
' AND '
{
$this
->
params
[
'income_end_date'
]
}
'
OR 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'
]));
$operation_start_data
=
$this
->
params
[
'income_start_date'
]
.
' 00:00:00'
;
...
...
@@ -1458,22 +1464,22 @@ class Finance extends Basic
/**收佣日期 end**/
if
(
!
empty
(
$this
->
params
[
'bargain_start_date'
])
&&
empty
(
$this
->
params
[
'bargain_end_date'
]))
{
$where
.=
" AND e.create_time > '
{
$this
->
params
[
'bargain_start_date'
]
}
00:00:00' AND c.operation_date > '
{
$this
->
params
[
'bargain_start_date'
]
}
'"
;
//
$where .= " AND e.create_time > '{$this->params['bargain_start_date']} 00:00:00' AND c.operation_date > '{$this->params['bargain_start_date']}'";
$operation_date
=
date
(
'Y.m.d'
,
strtotime
(
$this
->
params
[
'bargain_start_date'
]));
$operation_start_data
=
$this
->
params
[
'bargain_start_date'
]
.
' 00:00:00'
;
}
if
(
!
empty
(
$this
->
params
[
'bargain_end_date'
])
&&
empty
(
$this
->
params
[
'bargain_start_date'
]))
{
$where
.=
" AND e.create_time < '
{
$this
->
params
[
'bargain_end_date'
]
}
23:59:59' AND c.operation_date > '
{
$this
->
params
[
'bargain_end_date'
]
}
'"
;
//
$where .= " AND e.create_time < '{$this->params['bargain_end_date']} 23:59:59' AND c.operation_date > '{$this->params['bargain_end_date']}'";
$operation_date
=
date
(
'Y.m.d'
,
strtotime
(
$this
->
params
[
'bargain_end_date'
]));
$operation_end_data
=
$this
->
params
[
'bargain_end_date'
]
.
' 23:59:59'
;
}
if
(
!
empty
(
$this
->
params
[
'bargain_start_date'
])
&&
!
empty
(
$this
->
params
[
'bargain_end_date'
]))
{
$where
.=
" AND e.create_time BETWEEN '
{
$this
->
params
[
'bargain_start_date'
]
}
00:00:00' AND '
{
$this
->
params
[
'bargain_end_date'
]
}
23:59:59' "
;
$where
.=
" AND c.operation_date BETWEEN '
{
$this
->
params
[
'bargain_start_date'
]
}
' AND '
{
$this
->
params
[
'bargain_end_date'
]
}
'"
;
//
$where .= " AND e.create_time BETWEEN '{$this->params['bargain_start_date']} 00:00:00' AND '{$this->params['bargain_end_date']} 23:59:59' ";
//
$where .= " AND c.operation_date BETWEEN '{$this->params['bargain_start_date']}' AND '{$this->params['bargain_end_date']}'";
$operation_date
=
date
(
'Y.m.d'
,
strtotime
(
$this
->
params
[
'bargain_start_date'
]))
.
'-'
.
date
(
'Y.m.d'
,
strtotime
(
$this
->
params
[
'bargain_end_date'
]));
$operation_start_data
=
$this
->
params
[
'bargain_start_date'
]
.
' 00:00:00'
;
...
...
@@ -1482,30 +1488,39 @@ class Finance extends Basic
/**部门id**/
if
(
!
empty
(
$this
->
params
[
'district_id'
]))
{
$where
.=
" AND d.district_id=
{
$this
->
params
[
'district_id'
]
}
"
;
// $where .= " AND d.district_id={$this->params['district_id']}";
$where
[
'd.district_id'
]
=
$this
->
params
[
'district_id'
];
}
/**门店名**/
if
(
!
empty
(
$this
->
params
[
'store_id'
]))
{
$where
.=
" AND d.store_id=
{
$this
->
params
[
'store_id'
]
}
"
;
// $where .= " AND d.store_id={$this->params['store_id']}";
$where
[
'd.store_id'
]
=
$this
->
params
[
'store_id'
];
}
/**经纪人手机号**/
if
(
!
empty
(
$this
->
params
[
'agent_id'
]))
{
$where
.=
" AND a.agent_id=
{
$this
->
params
[
'agent_id'
]
}
"
;
$where
[
'a.agent_id'
]
=
$this
->
params
[
'agent_id'
]
;
}
$fields
=
'
d.store_id,d.district_id,a.agent_id,sum( a.practical_fee ) as practical_fee,sum( c.fee ) as
fee,'
;
$fields
=
'
sum( a.practical_fee ) as practical_
fee,'
;
$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
();
$m_store
=
new
AStore
();
$m_agent
=
new
AAgents
();
if
(
empty
(
$this
->
params
[
'excel'
])
&&
$this
->
params
[
'excel'
]
!=
1
)
{
$data
[
'data'
][
'total_taxes'
]
=
$m_partial
->
getCommissionTotalInfo
(
'c.fee'
,
$where
);
$m_tax
=
new
OTaxes
();
$taxes_where
[
'a.father_id'
]
=
[
'>'
,
0
];
$taxes_where
[
'is_del'
]
=
0
;
$taxes_where
[
'b.status'
]
=
[
'IN'
,
'10,11,13'
];
$taxes_where
[
'a.operation_date'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
$data
[
'data'
][
'total_taxes'
]
=
$m_tax
->
sumBargainFee
(
'a.fee'
,
$taxes_where
);;
if
(
!
empty
(
$this
->
params
[
'confirm_date'
]))
{
$where
.=
' AND a.confirm_date <= "'
.
$this
->
params
[
'confirm_date'
]
.
' 23:59:59" AND a.confirm_status = 1 '
;
// $where .= ' AND a.confirm_date <= "'.$this->params['confirm_date'].' 23:59:59" AND a.confirm_status = 1 ';
$where
[
'a.confirm_date'
]
=
[
'<='
,
$this
->
params
[
'confirm_date'
]
.
' 23:59:59'
];
$where
[
'a.confirm_status'
]
=
1
;
}
$list
=
$m_partial
->
getCommissionTotalList
(
$pageNo
,
$pageSize
,
$fields
,
$where
,
$operation_start_data
,
$operation_end_data
);
...
...
@@ -1514,11 +1529,11 @@ class Finance extends Basic
$list
[
$k
][
'operation_date'
]
=
$operation_date
;
$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'
][
'total'
]
=
$m_partial
->
getCommissionTotalListTotal
(
$where
);
$where
[
0
]
=
[
'EXP'
,
"b.income_time BETWEEN '
{
$this
->
params
[
'income_start_date'
]
}
' AND '
{
$this
->
params
[
'income_end_date'
]
}
'"
];
$data
[
'data'
][
'total_money'
]
=
$m_partial
->
getCommissionTotalInfo
(
'a.practical_fee'
,
$where
);
}
else
{
...
...
@@ -1526,7 +1541,9 @@ class Finance extends Basic
$pageSize
=
25000
;
$fields
.=
',sum(a.should_commission) as should_commission,sum(a.cash) as cash'
;
if
(
!
empty
(
$this
->
params
[
'confirm_date'
]))
{
$where
.=
' AND a.confirm_date <= "'
.
$this
->
params
[
'confirm_date'
]
.
' 23:59:59" AND a.confirm_status = 1 '
;
// $where .= ' AND a.confirm_date <= "'.$this->params['confirm_date'].' 23:59:59" AND a.confirm_status = 1 ';
$where
[
'a.confirm_date'
]
=
[
'<='
,
$this
->
params
[
'confirm_date'
]
.
' 23:59:59'
];
$where
[
'a.confirm_status'
]
=
1
;
}
$result_data
=
$m_partial
->
getCommissionTotalList
(
$pageNo
,
$pageSize
,
$fields
,
$where
,
$operation_start_data
,
$operation_end_data
);
...
...
application/model/OPartialCommission.php
View file @
4257bc04
...
...
@@ -215,56 +215,49 @@ class OPartialCommission extends BaseModel
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/
public
function
getCommissionTotalList
(
$pageNo
=
1
,
$pageSize
=
15
,
$field
=
''
,
$params
=
''
)
public
function
getCommissionTotalList
(
$pageNo
=
1
,
$pageSize
=
15
,
$field
=
''
,
$params
=
''
,
$operation_start_data
,
$operation_end_data
)
{
$sql
=
"( SELECT
{
$field
}
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
{
$field
}
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
{
$field
}
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
) limit
{
$pageNo
}
,
{
$pageSize
}
"
;
return
$this
->
query
(
$sql
);
$agent_id
=
$this
->
alias
(
'a'
)
->
field
(
'a.agent_id,d.name,d.store_id,d.district_id'
)
->
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
(
$params
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
group
(
'a.agent_id'
)
->
select
();
$partial_where
[
'a.confirm_status'
]
=
1
;
$partial_where
[
'b.status'
]
=
$taxes_where
[
'b.status'
]
=
[
'IN'
,
'10,11,13'
];
$partial_where
[
'a.is_del'
]
=
$taxes_where
[
'is_del'
]
=
0
;
$taxes_where
[
'a.father_id'
]
=
[
'>'
,
0
];
$m_tax
=
new
OTaxes
();
$result
=
[];
foreach
(
$agent_id
as
$k
=>
$v
)
{
$partial_where
[
'a.agent_id'
]
=
$v
[
'agent_id'
];
$partial_where
[
'c.income_time'
]
=
$taxes_where
[
'a.operation_date'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
$result
[
$k
]
=
$this
->
getSumMoney
(
$field
,
$partial_where
);
$taxes_where
[
'a.agent_id'
]
=
$v
[
'agent_id'
];
$result
[
$k
][
'fee'
]
=
$m_tax
->
sumBargainFee
(
'a.fee'
,
$taxes_where
);
$result
[
$k
][
'agent_id'
]
=
$v
[
'agent_id'
];
$result
[
$k
][
'name'
]
=
$v
[
'name'
];
$result
[
$k
][
'store_id'
]
=
$v
[
'store_id'
];
$result
[
$k
][
'district_id'
]
=
$v
[
'district_id'
];
}
return
$result
;
}
public
function
getSumMoney
(
$field
,
$where
)
{
return
$this
->
alias
(
'a'
)
->
field
(
$field
)
->
join
(
'o_bargain b'
,
'a.bargain_id = b.id'
,
'left'
)
->
join
(
'o_real_income c'
,
' a.real_income_id = c.id'
,
'left'
)
->
where
(
$where
)
->
find
();
}
/**
...
...
@@ -274,8 +267,9 @@ class OPartialCommission extends BaseModel
*/
public
function
getCommissionTotalInfo
(
$field
,
$where
)
{
return
$this
->
alias
(
'a'
)
->
field
(
'distinct a.id'
)
->
join
(
'o_real_income b'
,
'a.real_income_id = b.id'
,
'left'
)
->
join
(
'o_taxes c'
,
'a.agent_id = c.agent_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
)
...
...
@@ -365,60 +359,14 @@ class OPartialCommission extends BaseModel
*/
public
function
getCommissionTotalListTotal
(
$params
)
{
$sql
=
"SELECT
COUNT( * ) AS count
FROM
(
( SELECT
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'
];
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
(
$params
)
->
group
(
'a.agent_id'
)
->
count
();
}
/**
...
...
application/model/OTaxes.php
View file @
4257bc04
...
...
@@ -236,7 +236,7 @@ class OTaxes extends BaseModel
->
join
(
'o_bargain b'
,
'a.bargain_id = b.id'
,
'left'
)
->
join
(
'o_order c'
,
'b.order_id = c.id'
,
'left'
)
->
join
(
'g_houses d'
,
'c.house_id = d.id'
,
'left'
)
->
join
(
'a_agents e'
,
'
b
.agent_id = e.id'
,
'left'
)
->
join
(
'a_agents e'
,
'
a
.agent_id = e.id'
,
'left'
)
->
where
(
$params
)
->
sum
(
"a.fee"
);
return
$data
;
...
...
@@ -280,7 +280,25 @@ class OTaxes extends BaseModel
return
$result
;
}
/**
* @param $field
* @param $where
* @return float|int
*/
public
function
sumField
(
$field
,
$where
)
{
return
$this
->
where
(
$where
)
->
sum
(
$field
);
}
/**
* @param string $field
* @param $where
* @return float|int
*/
public
function
sumBargainFee
(
$field
=
'a.fee'
,
$where
)
{
return
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'o_bargain b'
,
'a.bargain_id = b.id'
,
'left'
)
->
where
(
$where
)
->
sum
(
$field
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment