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
b0beb3ce
Commit
b0beb3ce
authored
Dec 12, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实收汇总优化
parent
e969aa21
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
31 deletions
+53
-31
Finance.php
application/index/controller/Finance.php
+33
-15
OPartialCommission.php
application/model/OPartialCommission.php
+20
-16
No files found.
application/index/controller/Finance.php
View file @
b0beb3ce
...
...
@@ -1639,19 +1639,35 @@ class Finance extends Basic
$where
[
'a.confirm_status'
]
=
1
;
}
$m_
bargain
=
new
OPartialCommission
();
$m_
partial
=
new
OPartialCommission
();
$fields
=
'd.income_time,c.create_time,c.id,a.agent_id,b.name,b.phone'
;
$commission_fields
=
'sum(practical_fee) as practical_fee,sum(cash) as cash,sum(real_fee) as real_fee,sum(service_charge) as service_charge,
sum(charity_fund) as charity_fund'
;
if
(
!
empty
(
$this
->
params
[
'confirm_date'
]))
{
$commission_where
[
'a.confirm_date'
]
=
[
'between time'
,
[
$operation_start_data
,
$this
->
params
[
'confirm_date'
]
.
' 23:59:59'
]];
}
$commission_where
[
'b.income_time'
]
=
[
'between time'
,
[
$operation_start_data
,
$operation_end_data
]];
$commission_where
[
'confirm_status'
]
=
1
;
if
(
empty
(
$this
->
params
[
'excel'
])
&&
$this
->
params
[
'excel'
]
!=
1
)
{
$result_data
=
$m_
bargain
->
getCommissionTotalListV2
(
$pageNo
,
$pageSize
,
'a.agent_id desc'
,
$fields
,
$where
,
$operation_start_data
,
$operation_end_data
);
$result_data
=
$m_
partial
->
getCommissionTotalListV2
(
$pageNo
,
$pageSize
,
'a.agent_id desc'
,
$fields
,
$where
,
$operation_start_data
,
$operation_end_data
);
if
(
$result_data
[
'status'
]
==
'successful'
)
{
$data
[
'data'
][
'list'
]
=
$result_data
[
'data'
];
foreach
(
$data
[
'data'
][
'list'
]
as
$k
=>
$v
)
{
$data
[
'data'
][
'list'
][
$k
][
'income_date'
]
=
$income_date
;
$data
[
'data'
][
'list'
][
$k
][
'operation_date'
]
=
$operation_date
;
$data
[
'data'
][
'list'
][
$k
][
'over_fee'
]
=
$v
[
'practical_fee'
]
-
$v
[
'fee'
];
$list
=
[];
foreach
(
$result_data
[
'data'
]
as
$k
=>
$v
)
{
$list
[
$k
]
=
$v
;
$commission_where
[
'agent_id'
]
=
$v
[
'agent_id'
];
$commission_data
=
$m_partial
->
sumCommission
(
$commission_fields
,
$commission_where
);
$list
[
$k
][
'income_date'
]
=
$income_date
;
$list
[
$k
][
'operation_date'
]
=
$operation_date
;
$list
[
$k
][
'practical_fee'
]
=
$commission_data
[
'practical_fee'
];
$list
[
$k
][
'cash'
]
=
$commission_data
[
'cash'
];
$list
[
$k
][
'real_fee'
]
=
$commission_data
[
'real_fee'
];
$list
[
$k
][
'service_charge'
]
=
$commission_data
[
'service_charge'
];
$list
[
$k
][
'charity_fund'
]
=
$commission_data
[
'charity_fund'
];
$list
[
$k
][
'over_fee'
]
=
$commission_data
[
'practical_fee'
]
-
$v
[
'fee'
];
}
$data
[
'data'
][
'total'
]
=
$m_
bargain
->
getCommissionTotalListTotalV2
(
$where
);
$data
[
'data'
][
'list'
]
=
$list
;
$data
[
'data'
][
'total'
]
=
$m_
partial
->
getCommissionTotalListTotalV2
(
$where
);
}
else
{
$data
[
'code'
]
=
101
;
$data
[
'msg'
]
=
'内部错误'
.
$result_data
[
'msg'
];
...
...
@@ -1661,22 +1677,24 @@ class Finance extends Basic
//导出Excel
$pageSize
=
25000
;
$result_data
=
$m_
bargain
->
getCommissionTotalListV2
(
$pageNo
,
$pageSize
,
'a.agent_id desc'
,
$fields
,
$where
,
$operation_start_data
,
$operation_end_data
);
$result_data
=
$m_
partial
->
getCommissionTotalListV2
(
$pageNo
,
$pageSize
,
'a.agent_id desc'
,
$fields
,
$where
,
$operation_start_data
,
$operation_end_data
);
if
(
$result_data
[
'status'
]
==
'successful'
)
{
$data
=
$result_data
[
'data'
];
foreach
(
$data
as
$k
=>
$v
)
{
$commission_where
[
'agent_id'
]
=
$v
[
'agent_id'
];
$commission_data
=
$m_partial
->
sumCommission
(
$commission_fields
,
$commission_where
);
$excel_data
[
$k
][
'income_date'
]
=
$income_date
;
//收佣日期
$excel_data
[
$k
][
'operation_date'
]
=
$operation_date
;
//成交日期
$excel_data
[
$k
][
'district_store'
]
=
$v
[
'district_store'
];
//所属部门/门店
$excel_data
[
$k
][
'name'
]
=
$v
[
'name'
]
.
'-'
.
$v
[
'phone'
];
//业务员
$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
][
'service_charge'
]
=
$
commission_data
[
'service_charge'
];
//手续费
$excel_data
[
$k
][
'cash'
]
=
$
commission_data
[
'cash'
];
//现金奖
$excel_data
[
$k
][
'charity_fund'
]
=
$
commission_data
[
'charity_fund'
];
//慈善基金
$excel_data
[
$k
][
'practical_fee'
]
=
$
commission_data
[
'practical_fee'
];
//实收佣金
$excel_data
[
$k
][
'fee'
]
=
$v
[
'fee'
];
//税费
$excel_data
[
$k
][
'over_fee'
]
=
$
v
[
'practical_fee'
]
-
$v
[
'fee'
];
$excel_data
[
$k
][
'over_fee'
]
=
$
commission_data
[
'practical_fee'
]
-
$v
[
'fee'
];
}
$num
=
count
(
$excel_data
)
+
2
;
...
...
application/model/OPartialCommission.php
View file @
b0beb3ce
...
...
@@ -326,22 +326,6 @@ class OPartialCommission extends BaseModel
foreach
(
$should_commission
as
$kk
=>
$vv
)
{
$data
[
$k
][
'should_commission'
]
+=
$vv
;
}
$field_sum
=
'sum(practical_fee) as practical_fee,sum(cash) as cash,sum(real_fee) as real_fee,sum(service_charge) as service_charge,
sum(charity_fund) as charity_fund'
;
//应分佣金
$partial_commission
=
$this
->
field
(
$field_sum
)
->
where
(
'confirm_date'
,
'between time'
,
[
$operation_start_data
,
$operation_end_data
])
->
where
(
'agent_id'
,
$v
[
'agent_id'
])
->
where
(
'confirm_status'
,
1
)
->
where
(
'is_del'
,
0
)
->
find
();
$data
[
$k
][
'practical_fee'
]
=
$partial_commission
[
'practical_fee'
];
$data
[
$k
][
'cash'
]
=
$partial_commission
[
'cash'
];
$data
[
$k
][
'real_fee'
]
=
$partial_commission
[
'real_fee'
];
$data
[
$k
][
'service_charge'
]
=
$partial_commission
[
'service_charge'
];
$data
[
$k
][
'charity_fund'
]
=
$partial_commission
[
'charity_fund'
];
}
}
...
...
@@ -468,4 +452,23 @@ class OPartialCommission extends BaseModel
public
function
getFieldValue
(
$field
,
$where
)
{
return
$this
->
where
(
$where
)
->
value
(
$field
);
}
/**
* @param $field
* @param $where
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
sumCommission
(
$field
,
$where
)
{
$where
[
'a.is_del'
]
=
0
;
$where
[
'b.is_del'
]
=
0
;
return
$partial_commission
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'o_real_income b'
,
'a.real_income_id = b.id'
,
'left'
)
->
where
(
$where
)
->
find
();
}
}
\ 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