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
aaa6a7ca
Commit
aaa6a7ca
authored
May 24, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
汇总表导出
parent
0ed1cc9f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
30 deletions
+65
-30
Finance.php
application/index/controller/Finance.php
+58
-24
OBargainModel.php
application/model/OBargainModel.php
+7
-6
No files found.
application/index/controller/Finance.php
View file @
aaa6a7ca
...
@@ -741,7 +741,7 @@ class Finance extends Basic
...
@@ -741,7 +741,7 @@ class Finance extends Basic
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getCommissionTotalList
()
{
public
function
getCommissionTotalList
()
{
if
(
!
$this
->
request
->
isAjax
())
{
if
(
!
$this
->
request
->
isAjax
()
&&
$this
->
params
[
'excel'
]
!=
1
)
{
return
view
(
'commission_total'
);
return
view
(
'commission_total'
);
}
}
...
@@ -752,26 +752,22 @@ class Finance extends Basic
...
@@ -752,26 +752,22 @@ class Finance extends Basic
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
15
:
$this
->
params
[
'pageSize'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
15
:
$this
->
params
[
'pageSize'
];
$fields
=
'a.id,a.agent_id,sum(b.fee) as fee,sum(c.practical_fee) as practical_fee,sum(c.cash) as cash,'
;
$fields
.=
'sum(c.service_charge) as service_charge,sum(b.fee) as fee,sum(c.real_fee) as real_fee,'
;
$fields
.=
'd.name,d.phone'
;
$where
[
'c.is_del'
]
=
0
;
//订单状态
$where
[
'c.is_del'
]
=
0
;
//订单状态
$where
[
'a.status'
]
=
[
'in'
,
'10,11'
];
//10已提交 11审核成功
//
$where['a.status'] = ['in', '10,11']; //10已提交 11审核成功
$where
[
'b.father_id'
]
=
[
'<>'
,
0
];
//去除税费总佣金
//
$where['b.father_id'] = ['<>', 0]; //去除税费总佣金
$where
[
'c.confirm_status'
]
=
1
;
//确认分佣
//
$where['c.confirm_status'] = 1; //确认分佣
/**收佣日期 start**/
/**收佣日期 start**/
if
(
!
empty
(
$this
->
params
[
'commission_start_date'
])
&&
empty
(
$this
->
params
[
'commission_end_date'
]))
{
if
(
!
empty
(
$this
->
params
[
'commission_start_date'
])
&&
empty
(
$this
->
params
[
'commission_end_date'
]))
{
$where
[
'b.operatio
n_dat
e'
]
=
[
'> time'
,
$this
->
params
[
'commission_start_time'
]];
$where
[
'b.operatio
f.income_tim
e'
]
=
[
'> time'
,
$this
->
params
[
'commission_start_time'
]];
}
}
if
(
!
empty
(
$this
->
params
[
'commission_end_date'
])
&&
empty
(
$this
->
params
[
'commission_start_date'
]))
{
if
(
!
empty
(
$this
->
params
[
'commission_end_date'
])
&&
empty
(
$this
->
params
[
'commission_start_date'
]))
{
$where
[
'
b.operation_dat
e'
]
=
[
'< time'
,
$this
->
params
[
'commission_end_time'
]];
$where
[
'
f.income_tim
e'
]
=
[
'< time'
,
$this
->
params
[
'commission_end_time'
]];
}
}
if
(
!
empty
(
$this
->
params
[
'commission_start_date'
])
&&
!
empty
(
$this
->
params
[
'commission_end_date'
]))
{
if
(
!
empty
(
$this
->
params
[
'commission_start_date'
])
&&
!
empty
(
$this
->
params
[
'commission_end_date'
]))
{
$where
[
'
b.operation_dat
e'
]
=
[
'between time'
,
[
$this
->
params
[
'commission_start_date'
],
$this
->
params
[
'commission_end_date'
]]];
$where
[
'
f.income_tim
e'
]
=
[
'between time'
,
[
$this
->
params
[
'commission_start_date'
],
$this
->
params
[
'commission_end_date'
]]];
}
}
/**收佣日期 end**/
/**收佣日期 end**/
...
@@ -791,25 +787,17 @@ class Finance extends Basic
...
@@ -791,25 +787,17 @@ class Finance extends Basic
/**开票日期 start**/
/**开票日期 start**/
if
(
!
empty
(
$this
->
params
[
'operation_start_date'
])
&&
empty
(
$this
->
params
[
'operation_end_date'
]))
{
if
(
!
empty
(
$this
->
params
[
'operation_start_date'
])
&&
empty
(
$this
->
params
[
'operation_end_date'
]))
{
$where_fee
[
'operation_date'
]
=
[
'> time'
,
$this
->
params
[
'operation_start_date'
]];
$where_fee
[
'
b.
operation_date'
]
=
[
'> time'
,
$this
->
params
[
'operation_start_date'
]];
}
}
if
(
!
empty
(
$this
->
params
[
'operation_end_date'
])
&&
empty
(
$this
->
params
[
'operation_start_date'
]))
{
if
(
!
empty
(
$this
->
params
[
'operation_end_date'
])
&&
empty
(
$this
->
params
[
'operation_start_date'
]))
{
$where_fee
[
'operation_date'
]
=
[
'> time'
,
$this
->
params
[
'operation_start_date'
]];
$where_fee
[
'
b.
operation_date'
]
=
[
'> time'
,
$this
->
params
[
'operation_start_date'
]];
}
}
if
(
!
empty
(
$this
->
params
[
'operation_start_date'
])
&&
!
empty
(
$this
->
params
[
'operation_end_date'
]))
{
if
(
!
empty
(
$this
->
params
[
'operation_start_date'
])
&&
!
empty
(
$this
->
params
[
'operation_end_date'
]))
{
$where_fee
[
'operation_date'
]
=
[
'between time'
,
[
$this
->
params
[
'operation_start_date'
]
,
$this
->
params
[
'operation_end_date'
]]];
$where_fee
[
'
b.
operation_date'
]
=
[
'between time'
,
[
$this
->
params
[
'operation_start_date'
]
,
$this
->
params
[
'operation_end_date'
]]];
}
}
if
(
isset
(
$where_fee
[
'operation_date'
]))
{
// $m_fee = new OTaxes();
// $where_fee['type'] = 1;
// $bargain_id = $m_fee->getFeeListColumn('bargain_id', $where_fee);
// if (!empty($bargain_id)) {
// $whereOr['a.id'] = implode(',',$bargain_id);
// }
}
/**开票日期 end**/
/**开票日期 end**/
/**经纪人手机号**/
/**经纪人手机号**/
...
@@ -835,8 +823,54 @@ class Finance extends Basic
...
@@ -835,8 +823,54 @@ class Finance extends Basic
}
}
$m_bargain
=
new
OBargainModel
();
$m_bargain
=
new
OBargainModel
();
$data
[
'data'
][
'list'
]
=
$m_bargain
->
getCommissionTotalList
(
$pageNo
,
$pageSize
,
'a.id desc'
,
$fields
,
$where
,
$whereOr
);
$data
[
'data'
][
'total'
]
=
$m_bargain
->
getCommissionTotalListTotal
(
$where
,
$whereOr
);
if
(
!
empty
(
$this
->
params
[
'excel'
])
&&
$this
->
params
[
'excel'
]
==
1
)
{
$fields
=
'f.income_time,a.create_time,sum(b.fee) as fee,sum(f.money) as money,sum(c.cash) as cash,'
;
$fields
.=
'sum(c.service_charge) as service_charge,'
;
$fields
.=
'd.name,d.phone,sum(c.charity_fund) as charity_fund, sum(should_commission) as should_commission'
;
$pageSize
=
25000
;
$data
=
$m_bargain
->
getCommissionTotalList
(
$pageNo
,
$pageSize
,
'a.id desc'
,
$fields
,
$where
,
$whereOr
);
foreach
(
$data
as
$k
=>
$v
)
{
$excel_data
[
$k
][
'income_time'
]
=
$v
[
'income_time'
];
//收佣日期
$excel_data
[
$k
][
'create_time'
]
=
$v
[
'create_time'
];
//成交日期
$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
][
'money'
]
=
$v
[
'money'
];
//实收佣金
$excel_data
[
$k
][
'fee'
]
=
$v
[
'fee'
];
//税费
$excel_data
[
$k
][
'over_fee'
]
=
$v
[
'real_fee'
]
-
$v
[
'charity_fund'
];
}
$num
=
count
(
$excel_data
)
+
1
;
$excel_data
[
$num
][
'income_time'
]
=
'合计'
;
//收佣日期
$excel_data
[
$num
][
'create_time'
]
=
''
;
//成交日期
$excel_data
[
$num
][
'district_store'
]
=
''
;
//所属部门/门店
$excel_data
[
$num
][
'name'
]
=
''
;
//业务员
$excel_data
[
$num
][
'should_commission'
]
=
"=SUM(E3:E
{
$num
}
)"
;
//应分佣金
$excel_data
[
$num
][
'service_charge'
]
=
"=SUM(F3:F
{
$num
}
)"
;
//手续费
$excel_data
[
$num
][
'cash'
]
=
"=SUM(G3:G
{
$num
}
)"
;
//现金奖
$excel_data
[
$num
][
'charity_fund'
]
=
"=SUM(H3:H
{
$num
}
)"
;
//慈善基金
$excel_data
[
$num
][
'money'
]
=
"=SUM(I3:I
{
$num
}
)"
;
//实收佣金
$excel_data
[
$num
][
'fee'
]
=
"=SUM(J3:J
{
$num
}
)"
;
//税费
$excel_data
[
$num
][
'over_fee'
]
=
"=SUM(K3:K
{
$num
}
)"
;
$export
=
new
ExportExcelUntil
();
$title
=
[
'收佣日期/开票日期'
,
'成交日期/开票日期'
,
'所属部门/门店'
,
'业务员'
,
'应分佣金(元)'
,
'手续费(元)'
,
'现金奖(元)'
,
'慈善基金(元)'
,
'实收佣金(元)'
,
'税费(元)'
,
'最终实收(元)'
];
$export
->
exportTable
(
'分佣提成汇总表'
,
$excel_data
,
11
,
'分佣提成汇总表'
,
$title
);
return
;
}
else
{
$fields
=
'a.id,a.agent_id,sum(b.fee) as fee,sum(c.practical_fee) as practical_fee,sum(c.cash) as cash,'
;
$fields
.=
'sum(c.service_charge) as service_charge,sum(b.fee) as fee,sum(c.real_fee) as real_fee,'
;
$fields
.=
'd.name,d.phone'
;
$data
[
'data'
][
'list'
]
=
$m_bargain
->
getCommissionTotalList
(
$pageNo
,
$pageSize
,
'a.id desc'
,
$fields
,
$where
,
$whereOr
);
$data
[
'data'
][
'total'
]
=
$m_bargain
->
getCommissionTotalListTotal
(
$where
,
$whereOr
);
}
return
$this
->
response
(
$data
[
'code'
],
$data
[
'msg'
],
$data
[
'data'
]);
return
$this
->
response
(
$data
[
'code'
],
$data
[
'msg'
],
$data
[
'data'
]);
}
}
...
...
application/model/OBargainModel.php
View file @
aaa6a7ca
...
@@ -609,17 +609,19 @@ class OBargainModel extends Model
...
@@ -609,17 +609,19 @@ class OBargainModel extends Model
* @param string $order_
* @param string $order_
* @param string $field
* @param string $field
* @param string $params
* @param string $params
* @param $whereOr
* @return false|\PDOStatement|string|\think\Collection
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getCommissionTotalList
(
$pageNo
=
1
,
$pageSize
=
15
,
$order_
=
'a.id desc'
,
$field
=
''
,
$params
=
''
,
$whereOr
)
{
public
function
getCommissionTotalList
(
$pageNo
=
1
,
$pageSize
=
15
,
$order_
=
'a.id desc'
,
$field
=
''
,
$params
=
''
,
$whereOr
=
[]
)
{
$data
=
$this
->
alias
(
'a'
)
$data
=
$this
->
alias
(
'a'
)
->
field
(
$field
)
->
field
(
$field
)
->
join
(
'o_taxes b'
,
'a.id = b.bargain_id'
,
'left'
)
->
join
(
'o_taxes b'
,
'a.id = b.bargain_id'
,
'left'
)
->
join
(
'o_partial_commission c'
,
'a.id = c.bargain_id'
,
'left'
)
->
join
(
'o_partial_commission c'
,
'a.id = c.bargain_id'
,
'left'
)
->
join
(
'a_agents d'
,
'a.agent_id = d.id'
,
'left'
)
->
join
(
'a_agents d'
,
'a.agent_id = d.id'
,
'left'
)
->
join
(
'o_real_income f'
,
'a.id = f.bargain_id'
,
'left'
)
->
where
(
$params
)
->
where
(
$params
)
->
whereOr
(
$whereOr
)
->
whereOr
(
$whereOr
)
->
order
(
$order_
)
->
order
(
$order_
)
...
@@ -646,16 +648,15 @@ class OBargainModel extends Model
...
@@ -646,16 +648,15 @@ class OBargainModel extends Model
* 分佣提成汇总表总数
* 分佣提成汇总表总数
*
*
* @param $params
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @param array $whereOr
* @throws \think\db\exception\DataNotFoundException
* @return int|string
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
*/
public
function
getCommissionTotalListTotal
(
$params
,
$whereOr
)
{
public
function
getCommissionTotalListTotal
(
$params
,
$whereOr
=
[]
)
{
return
$this
->
alias
(
'a'
)
return
$this
->
alias
(
'a'
)
->
join
(
'o_taxes b'
,
'a.id = b.bargain_id'
,
'left'
)
->
join
(
'o_taxes b'
,
'a.id = b.bargain_id'
,
'left'
)
->
join
(
'o_partial_commission c'
,
'a.id = c.bargain_id'
,
'left'
)
->
join
(
'o_partial_commission c'
,
'a.id = c.bargain_id'
,
'left'
)
->
join
(
'a_agents d'
,
'a.agent_id = d.id'
,
'left'
)
->
join
(
'a_agents d'
,
'a.agent_id = d.id'
,
'left'
)
->
join
(
'o_real_income f'
,
'a.id = f.bargain_id'
,
'left'
)
->
where
(
$params
)
->
where
(
$params
)
->
whereOr
(
$whereOr
)
->
whereOr
(
$whereOr
)
->
group
(
'd.id'
)
->
group
(
'd.id'
)
...
...
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