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
49f2b9e6
Commit
49f2b9e6
authored
Jan 07, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实收汇总5
parent
1bec173a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
70 deletions
+69
-70
Finance.php
application/index/controller/Finance.php
+65
-25
OPartialCommission.php
application/model/OPartialCommission.php
+4
-45
No files found.
application/index/controller/Finance.php
View file @
49f2b9e6
...
...
@@ -1501,6 +1501,10 @@ class Finance extends Basic
if
(
!
$this
->
request
->
isAjax
()
&&
$this
->
params
[
'excel'
]
!=
1
)
{
return
view
(
'commission_total'
);
}
$m_partial
=
new
OPartialCommission
();
$m_store
=
new
AStore
();
$m_agent
=
new
AAgents
();
$m_tax
=
new
OTaxes
();
$data
[
'code'
]
=
200
;
$data
[
'msg'
]
=
""
;
...
...
@@ -1511,18 +1515,15 @@ class Finance extends Basic
$operation_start_data
=
$operation_end_data
=
$income_date
=
$operation_date
=
''
;
$where
[
'a.confirm_status'
]
=
1
;
$is_bargain
=
0
;
$where_or
=
[];
/**收佣日期 start**/
$sql_string
=
'or a.agent_id in (SELECT agent_id FROM o_taxes WHERE is_del=0 and father_id > 0 and operation_date'
;
if
(
!
empty
(
$this
->
params
[
'income_start_date'
])
&&
empty
(
$this
->
params
[
'income_end_date'
]))
{
// $where[0] = ['EXP', "b.income_time > '{$this->params['income_start_date']}' OR c.operation_date > '{$this->params['income_start_date']}'"];
$where
[
0
]
=
[
'EXP'
,
"b.income_time > '
{
$this
->
params
[
'income_start_date'
]
}
'
{
$sql_string
}
> '
{
$this
->
params
[
'income_start_date'
]
}
' GROUP BY agent_id)"
];
$income_date
=
date
(
'Y.m.d'
,
strtotime
(
$this
->
params
[
'income_start_date'
]));
$operation_start_data
=
$this
->
params
[
'income_start_date'
];
}
if
(
!
empty
(
$this
->
params
[
'income_end_date'
])
&&
empty
(
$this
->
params
[
'income_start_date'
]))
{
// $where[0] = ['EXP', "b.income_time < '{$this->params['income_end_date']}' OR c.operation_date < '{$this->params['income_end_date']}'"];
$where
[
0
]
=
[
'EXP'
,
"b.income_time < '
{
$this
->
params
[
'income_end_date'
]
}
'
{
$sql_string
}
> '
{
$this
->
params
[
'income_end_date'
]
}
' GROUP BY agent_id)"
];
$income_date
=
'-'
.
date
(
'Y.m.d'
,
strtotime
(
$this
->
params
[
'income_end_date'
]));
$operation_end_data
=
$this
->
params
[
'income_end_date'
];
...
...
@@ -1539,7 +1540,6 @@ class Finance extends Basic
/**收佣日期 end**/
if
(
!
empty
(
$this
->
params
[
'bargain_start_date'
])
&&
empty
(
$this
->
params
[
'bargain_end_date'
]))
{
// $where[1] = ['EXP', "e.create_time > '{$this->params['bargain_start_date']} 00:00:00' OR c.operation_date > '{$this->params['bargain_start_date']}'"];
$where
[
1
]
=
[
'EXP'
,
"e.create_time > '
{
$this
->
params
[
'bargain_start_date'
]
}
00:00:00'
{
$sql_string
}
> '
{
$this
->
params
[
'bargain_start_date'
]
}
' GROUP BY agent_id)"
];
$operation_date
=
date
(
'Y.m.d'
,
strtotime
(
$this
->
params
[
'bargain_start_date'
]));
$operation_start_data
=
$this
->
params
[
'bargain_start_date'
];
...
...
@@ -1577,14 +1577,16 @@ class Finance extends Basic
$taxes_where
[
'b.agent_id'
]
=
$where
[
'a.agent_id'
]
=
$this
->
params
[
'agent_id'
];
}
$fields
=
'sum( a.practical_fee ) as practical_fee,sum( a.real_fee ) as real_fee,'
;
$fields
.=
'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
();
$partial_fields
=
'sum( a.practical_fee ) as practical_fee,sum( a.real_fee ) as real_fee,'
;
$partial_fields
.=
'sum( a.service_charge ) as service_charge,sum( a.charity_fund ) as charity_fund'
;
$fields
=
'a.agent_id,d.name,d.store_id,e.status'
;
$partial_where
[
'b.status'
]
=
[
'IN'
,
'10,11,13'
];
$partial_where
[
'a.is_del'
]
=
$taxes_where
[
'is_del'
]
=
0
;
$taxes_where
[
'a.father_id'
]
=
[
'>'
,
0
];
$taxes_where
[
'a.operation_date'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
if
(
empty
(
$this
->
params
[
'excel'
])
&&
$this
->
params
[
'excel'
]
!=
1
)
{
$m_tax
=
new
OTaxes
();
$taxes_where
[
'a.father_id'
]
=
[
'>'
,
0
];
$taxes_where
[
'a.is_del'
]
=
0
;
$taxes_where
[
'a.operation_date'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
...
...
@@ -1592,17 +1594,41 @@ class Finance extends Basic
$data
[
'data'
][
'total_taxes'
]
=
$m_tax
->
sumBargainFee
(
'a.fee'
,
$taxes_where
);;
if
(
!
empty
(
$this
->
params
[
'confirm_date'
]))
{
$where
[
'a.confirm_date'
]
=
[
'<='
,
$this
->
params
[
'confirm_date'
]
.
' 23:59:59'
];
$partial_where
[
'a.confirm_date'
]
=
$where
[
'a.confirm_date'
]
=
[
'<='
,
$this
->
params
[
'confirm_date'
]
.
' 23:59:59'
];
$partial_where
[
'a.confirm_status'
]
=
1
;
}
$list
=
$m_partial
->
getCommissionTotalList
(
$pageNo
,
$pageSize
,
$fields
,
$where
,
$operation_start_data
,
$operation_end_data
,
$is_bargain
);
foreach
(
$list
as
$k
=>
$v
)
{
if
(
in_array
(
$v
[
'status'
],
[
10
,
11
,
13
]))
{
$partial_where
[
'a.agent_id'
]
=
$v
[
'agent_id'
];
if
(
$is_bargain
!=
1
)
{
$partial_where
[
'c.income_time'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
}
else
{
$partial_where
[
'b.create_time'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
}
$partial_data
=
$m_partial
->
getSumMoney
(
$partial_fields
,
$partial_where
);
$list
[
$k
][
'service_charge'
]
=
empty
(
$partial_data
[
'service_charge'
])
?
0
:
$partial_data
[
'service_charge'
];
//手续费
$list
[
$k
][
'cash'
]
=
empty
(
$partial_data
[
'cash'
])
?
0
:
$partial_data
[
'cash'
];
//现金奖
$list
[
$k
][
'charity_fund'
]
=
empty
(
$partial_data
[
'charity_fund'
])
?
0
:
$partial_data
[
'charity_fund'
];
//慈善基金
$list
[
$k
][
'practical_fee'
]
=
empty
(
$partial_data
[
'practical_fee'
])
?
0
:
$partial_data
[
'practical_fee'
];
//实收佣金
}
else
{
$list
[
$k
][
'practical_fee'
]
=
0
;
$list
[
$k
][
'real_fee'
]
=
0
;
$list
[
$k
][
'service_charge'
]
=
0
;
$list
[
$k
][
'charity_fund'
]
=
0
;
}
$taxes_where
[
'b.agent_id'
]
=
$v
[
'agent_id'
];
$list
[
$k
][
'fee'
]
=
$m_tax
->
sumBargainFee
(
'a.fee'
,
$taxes_where
);
$list
[
$k
][
'income_date'
]
=
$income_date
;
$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
][
'service_charge'
]
=
empty
(
$v
[
'service_charge'
])
?
0
:
$v
[
'service_charge'
];
$list
[
$k
][
'charity_fund'
]
=
empty
(
$v
[
'charity_fund'
])
?
0
:
$v
[
'charity_fund'
];
$list
[
$k
][
'name'
]
=
$v
[
'name'
];
}
$data
[
'data'
][
'list'
]
=
$list
;
...
...
@@ -1621,26 +1647,40 @@ class Finance extends Basic
}
else
{
//导出Excel
$pageSize
=
25000
;
$fields
.=
',sum(a.should_commission) as should_commission,sum(a.cash) as cash'
;
$
partial_
fields
.=
',sum(a.should_commission) as should_commission,sum(a.cash) as cash'
;
if
(
!
empty
(
$this
->
params
[
'confirm_date'
]))
{
$where
[
'a.confirm_date'
]
=
[
'<='
,
$this
->
params
[
'confirm_date'
]
.
' 23:59:59'
];
$where
[
'a.confirm_status'
]
=
1
;
$
partial_where
[
'a.confirm_date'
]
=
$
where
[
'a.confirm_date'
]
=
[
'<='
,
$this
->
params
[
'confirm_date'
]
.
' 23:59:59'
];
$
partial_
where
[
'a.confirm_status'
]
=
1
;
}
$result_data
=
$m_partial
->
getCommissionTotalList
(
$pageNo
,
$pageSize
,
$fields
,
$where
,
$operation_start_data
,
$operation_end_data
,
$is_bargain
);
$partial_where
[
'b.status'
]
=
[
'IN'
,
'10,11,13'
];
$partial_where
[
'a.is_del'
]
=
$taxes_where
[
'is_del'
]
=
0
;
if
(
$is_bargain
!=
1
)
{
$partial_where
[
'c.income_time'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
}
else
{
$partial_where
[
'b.create_time'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
}
foreach
(
$result_data
as
$k
=>
$v
)
{
$excel_data
[
$k
][
'income_date'
]
=
$income_date
;
//收佣日期
$excel_data
[
$k
][
'operation_date'
]
=
$operation_date
;
//成交日期
$excel_data
[
$k
][
'district_store'
]
=
$m_store
->
getStoreDistrictName
(
$v
[
'store_id'
]);;
//所属部门/门店
$excel_data
[
$k
][
'name'
]
=
$m_agent
->
getAgentsById
(
$v
[
'agent_id'
],
'name'
);
//业务员
$excel_data
[
$k
][
'should_commission'
]
=
$v
[
'should_commission'
];
//应分佣金
$excel_data
[
$k
][
'service_charge'
]
=
$v
[
'service_charge'
];
//手续费
$excel_data
[
$k
][
'cash'
]
=
$v
[
'cash'
];
//现金奖
$excel_data
[
$k
][
'charity_fund'
]
=
$v
[
'charity_fund'
];
//慈善基金
$excel_data
[
$k
][
'practical_fee'
]
=
$v
[
'practical_fee'
];
//实收佣金
$excel_data
[
$k
][
'name'
]
=
$v
[
'name'
];
//业务员
$excel_data
[
$k
][
'fee'
]
=
$v
[
'fee'
];
$excel_data
[
$k
][
'over_fee'
]
=
$v
[
'practical_fee'
]
-
$v
[
'fee'
];
$partial_where
[
'a.agent_id'
]
=
$v
[
'agent_id'
];
$partial_data
=
$m_partial
->
getSumMoney
(
$partial_fields
,
$partial_where
);
$excel_data
[
$k
][
'should_commission'
]
=
empty
(
$partial_data
[
'should_commission'
])
?
0
:
$partial_data
[
'should_commission'
];
//应分佣金
$excel_data
[
$k
][
'service_charge'
]
=
empty
(
$partial_data
[
'service_charge'
])
?
0
:
$partial_data
[
'service_charge'
];
//手续费
$excel_data
[
$k
][
'cash'
]
=
empty
(
$partial_data
[
'cash'
])
?
0
:
$partial_data
[
'cash'
];
//现金奖
$excel_data
[
$k
][
'charity_fund'
]
=
empty
(
$partial_data
[
'charity_fund'
])
?
0
:
$partial_data
[
'charity_fund'
];
//慈善基金
$excel_data
[
$k
][
'practical_fee'
]
=
empty
(
$partial_data
[
'practical_fee'
])
?
0
:
$partial_data
[
'practical_fee'
];
//实收佣金
//税费
$taxes_where
[
'b.agent_id'
]
=
$v
[
'agent_id'
];
$excel_data
[
$k
][
'fee'
]
=
$m_tax
->
sumBargainFee
(
'a.fee'
,
$taxes_where
);
$excel_data
[
$k
][
'over_fee'
]
=
$partial_data
[
'practical_fee'
]
-
$excel_data
[
$k
][
'fee'
];
}
$num
=
count
(
$excel_data
)
+
2
;
...
...
application/model/OPartialCommission.php
View file @
49f2b9e6
...
...
@@ -205,26 +205,20 @@ class OPartialCommission extends BaseModel
}
/**
* 分佣提成汇总表
*
* @param int $pageNo
* @param int $pageSize
* @param string $field
* @param string $params
* @param $operation_start_data
* @param $operation_end_data
* @param $is_bargain
* @return array
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getCommissionTotalList
(
$pageNo
=
1
,
$pageSize
=
15
,
$field
=
''
,
$params
=
''
,
$operation_start_data
,
$operation_end_data
,
$is_bargain
)
public
function
getCommissionTotalList
(
$pageNo
=
1
,
$pageSize
=
15
,
$field
=
''
,
$params
=
''
)
{
$agent_id
=
$this
->
alias
(
'a'
)
->
field
(
'a.agent_id,d.name,d.store_id,d.district_id,e.status'
)
return
$this
->
alias
(
'a'
)
->
field
(
$field
)
->
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
)
...
...
@@ -232,41 +226,6 @@ class OPartialCommission extends BaseModel
->
page
(
$pageNo
)
->
group
(
'a.agent_id'
)
->
select
();
$partial_where
[
'a.confirm_status'
]
=
1
;
$partial_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
)
{
if
(
in_array
(
$v
[
'status'
],
[
10
,
11
,
13
]))
{
$partial_where
[
'a.agent_id'
]
=
$v
[
'agent_id'
];
if
(
$is_bargain
!=
1
)
{
$partial_where
[
'c.income_time'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
}
else
{
$partial_where
[
'b.create_time'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
}
$result
[
$k
]
=
$this
->
getSumMoney
(
$field
,
$partial_where
);
}
else
{
$result
[
$k
][
'practical_fee'
]
=
0
;
$result
[
$k
][
'real_fee'
]
=
0
;
$result
[
$k
][
'service_charge'
]
=
0
;
$result
[
$k
][
'charity_fund'
]
=
0
;
}
$taxes_where
[
'a.operation_date'
]
=
[
'between'
,
[
$operation_start_data
,
$operation_end_data
]];
$taxes_where
[
'b.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
)
{
...
...
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