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
c6347abd
Commit
c6347abd
authored
Aug 08, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
业绩统计
parent
4afed411
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
189 additions
and
46 deletions
+189
-46
Performance.php
application/api_broker/controller/Performance.php
+2
-4
PerformanceService.php
application/api_broker/service/PerformanceService.php
+8
-22
PerformanceUtilService.php
application/api_broker/service/PerformanceUtilService.php
+114
-0
OBargainModel.php
application/model/OBargainModel.php
+64
-19
TAgentTotalModel.php
application/model/TAgentTotalModel.php
+1
-1
No files found.
application/api_broker/controller/Performance.php
View file @
c6347abd
...
...
@@ -37,7 +37,7 @@ class Performance extends Basic
{
header
(
'Access-Control-Allow-Origin:*'
);
$params
=
$this
->
params
;
/*
$params = array(
/*
$params = array(
"agent_id" => 80,
"type" => 3, //1表示个人业绩排行 2门店 3区域
"end_day" => "",
...
...
@@ -47,14 +47,12 @@ class Performance extends Basic
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
//默认排序一周 2018-07-18改为本月
$end_day
=
!
empty
(
$params
[
"end_day"
])
?
$params
[
"end_day"
]
:
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
//$start_day = !empty($params["start_day"]) ? $params["start_day"] : date("Y-m-d", strtotime("-7 day"));
$end_day
=
!
empty
(
$params
[
"end_day"
])
?
$params
[
"end_day"
]
:
date
(
"Y-m-d"
,
strtotime
(
"+1 day"
));
$start_day
=
!
empty
(
$params
[
"start_day"
])
?
$params
[
"start_day"
]
:
date
(
"Y-m-01"
,
time
());
$list
=
$this
->
service_
->
totalAgent
(
$params
[
"agent_id"
],
$params
[
"type"
],
$end_day
,
$start_day
);
//dump($list);
if
(
count
(
$list
)
>
0
)
{
$result
[
"list"
]
=
$list
;
$result
[
"start_time"
]
=
$start_day
;
...
...
application/api_broker/service/PerformanceService.php
View file @
c6347abd
...
...
@@ -51,7 +51,6 @@ class PerformanceService
$this
->
superviseModel
=
new
ASuperviseModel
();
}
/**
* @param $agent_id
* @param $type
...
...
@@ -64,15 +63,18 @@ class PerformanceService
*/
public
function
totalAgent
(
$agent_id
,
$type
,
$yesterday
,
$end_day
)
{
$agent_info
=
$this
->
getStoreAndDistrict
(
$agent_id
);
$params
[
"agent_id"
]
=
$agent_id
;
$agent_info
=
$this
->
agentModel
->
getAgentById
(
"id,store_id,district_id,level"
,
$params
);
if
(
count
(
$agent_info
)
>
0
)
{
$agent_info
=
$agent_info
[
0
];
}
$where_
=
[];
$where_
[
'
total
_time'
]
=
array
(
'between'
,
array
(
$end_day
,
$yesterday
)
);
$where_
[
'
a.create
_time'
]
=
array
(
'between'
,
array
(
$end_day
,
$yesterday
)
);
$field
=
"
agent_id,store_id,district_id,sum(performanc
e) as performance_total"
;
$field
=
"
b.id as agent_id,b.store_id,b.district_id,sum(a.scale_fe
e) as performance_total"
;
$order
=
"performance_total desc"
;
$result
=
$this
->
total
Model
->
getTotalByAgentId
(
$field
,
$where_
,
$type
,
$order
);
$result
=
$this
->
bargain
Model
->
getTotalByAgentId
(
$field
,
$where_
,
$type
,
$order
);
//dump($result);
$arr
=
[];
$field
=
"a.name,a.img,b.store_name,c.district_name"
;
...
...
@@ -127,23 +129,7 @@ class PerformanceService
}
/**
* @param $agent_id
* @return mixed|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getStoreAndDistrict
(
$agent_id
)
{
$params
[
"agent_id"
]
=
$agent_id
;
$agent_info
=
$this
->
agentModel
->
getAgentById
(
"id,store_id,district_id,level"
,
$params
);
if
(
count
(
$agent_info
)
>
0
)
{
return
$agent_info
[
0
];
}
return
null
;
}
/**
* 个人业绩
...
...
application/api_broker/service/PerformanceUtilService.php
0 → 100644
View file @
c6347abd
<?php
namespace
app\api_broker\service
;
use
app\model\AAgents
;
use
app\model\ASuperviseModel
;
use
app\model\GHouses
;
use
app\model\GHousesImgs
;
use
app\model\OBargainModel
;
use
app\model\OMarchInModel
;
use
app\model\OPayLogModel
;
use
app\model\OReportModel
;
use
app\model\TAgentTotalModel
;
use
app\model\Users
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/8/8
* Time : 10:22
* Intro:
*/
class
PerformanceUtilService
{
private
$totalModel
;
private
$agentModel
;
private
$houseModel
;
private
$userModel
;
private
$bargainModel
;
private
$reportModel
;
private
$marchInModel
;
private
$payLogModel
;
private
$gHousesImgModel
;
private
$superviseModel
;
public
function
__construct
()
{
$this
->
totalModel
=
new
TAgentTotalModel
();
$this
->
agentModel
=
new
AAgents
();
$this
->
houseModel
=
new
GHouses
();
$this
->
userModel
=
new
Users
();
$this
->
bargainModel
=
new
OBargainModel
();
$this
->
reportModel
=
new
OReportModel
();
$this
->
marchInModel
=
new
OMarchInModel
();
$this
->
payLogModel
=
new
OPayLogModel
();
$this
->
gHousesImgModel
=
new
GHousesImgs
();
$this
->
superviseModel
=
new
ASuperviseModel
();
}
private
function
isExcuseToday
(
$time
)
:
bool
{
$now_date
=
date
(
"Y-m-d"
,
time
());
if
(
$time
==
$now_date
)
{
return
true
;
}
return
false
;
}
public
function
HouseNum
(
$start_time
,
$end_time
,
$agent_ids
)
{
$is_today
=
$this
->
isExcuseToday
(
$end_time
);
if
(
$is_today
){
}
}
private
function
sumDistrictPerformance
(
$params
)
{
$result
=
[];
//房源
$addHouseNum
=
$this
->
houseModel
->
getAddHouseNum
(
$params
);
$result
[
"add_house_num"
]
=
isset
(
$addHouseNum
[
0
][
"num"
])
?
$addHouseNum
[
0
][
"num"
]
:
0
;
//dump($addHouseNum);
//客源
$addUserNum
=
$this
->
userModel
->
getAddUserNum
(
$params
);
$result
[
"add_user_num"
]
=
isset
(
$addUserNum
[
0
][
"num"
])
?
$addUserNum
[
0
][
"num"
]
:
0
;
//dump($addUserNum);
//业绩
$performanceSum
=
$this
->
bargainModel
->
getAddBargainNum
(
$params
,
1
);
//1表示业绩 2表示实收
$result
[
"performance"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
//实收
$receivedSum
=
$this
->
bargainModel
->
getReceived
(
$params
);
$result
[
"official_receipts"
]
=
isset
(
$receivedSum
[
0
][
"num"
])
?
$receivedSum
[
0
][
"num"
]
:
0
;
//dump($receivedSum);
//约带看
$reportNum
=
$this
->
reportModel
->
getAddReportNum
(
$params
);
$result
[
"look_at_num"
]
=
isset
(
$reportNum
[
0
][
"num"
])
?
$reportNum
[
0
][
"num"
]
:
0
;
//dump($reportNum);
//进场
$addMarchInNum
=
$this
->
marchInModel
->
getAddMarchInNum
(
$params
);
$result
[
"march_in_num"
]
=
isset
(
$addMarchInNum
[
0
][
"num"
])
?
$addMarchInNum
[
0
][
"num"
]
:
0
;
//dump($addMarchInNum);
//收款
$payLogNum
=
$this
->
payLogModel
->
getAddPayLogNum
(
$params
);
$result
[
"paylog"
]
=
isset
(
$payLogNum
[
0
][
"num"
])
?
$payLogNum
[
0
][
"num"
]
:
0
;
//dump($payLogNum);
// 监督
$result
[
"supervision_num"
]
=
$this
->
superviseModel
->
getSuperviseListCount
(
$params
);
return
$result
;
}
}
\ No newline at end of file
application/model/OBargainModel.php
View file @
c6347abd
...
...
@@ -132,7 +132,7 @@ class OBargainModel extends Model
return
$str
;
}
foreach
(
$data
as
$item
)
{
if
(
!
empty
(
$item
[
"industry_type"
]))
{
if
(
!
empty
(
$item
[
"industry_type"
]))
{
$str
.=
"、"
.
$item
[
"industry_type"
];
}
}
...
...
@@ -231,7 +231,7 @@ class OBargainModel extends Model
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
// echo $this->db_->getLastSql();
// echo $this->db_->getLastSql();
return
$result
;
}
...
...
@@ -280,14 +280,14 @@ class OBargainModel extends Model
{
$where_
=
$whereOr_
=
[];
if
(
isset
(
$params
[
"bargain_id"
]))
{
$where_
[
"a.id"
]
=
$params
[
"bargain_id"
];
$where_
[
"a.id"
]
=
$params
[
"bargain_id"
];
$whereOr_
[
"a.father_id"
]
=
$params
[
"bargain_id"
];
}
if
(
isset
(
$params
[
'id'
]))
{
$where_
[
'a.id'
]
=
$params
[
'id'
];
}
$result
=
$this
->
db_
->
field
(
$filed
)
->
alias
(
"a"
)
...
...
@@ -358,8 +358,8 @@ class OBargainModel extends Model
->
join
(
'o_report b'
,
'a.report_id = b.id'
,
'left'
)
->
join
(
'o_order c'
,
'a.order_id = c.id'
,
'left'
)
->
join
(
'g_houses d'
,
'c.house_id = d.id'
,
'left'
)
->
join
(
'a_agents f'
,
'b.report_agent_id=f.id'
,
'left'
)
->
join
(
'a_agents e'
,
'a.agent_id=e.id'
,
'left'
)
->
join
(
'a_agents f'
,
'b.report_agent_id=f.id'
,
'left'
)
->
join
(
'a_agents e'
,
'a.agent_id=e.id'
,
'left'
)
->
where
(
$params
)
->
having
(
'count(e.order_id) = 1'
)
->
order
(
$order_
)
...
...
@@ -372,8 +372,8 @@ class OBargainModel extends Model
->
join
(
'o_report b'
,
'a.report_id = b.id'
,
'left'
)
->
join
(
'o_order c'
,
'a.order_id = c.id'
,
'left'
)
->
join
(
'g_houses d'
,
'c.house_id = d.id'
,
'left'
)
->
join
(
'a_agents f'
,
'b.report_agent_id=f.id'
,
'left'
)
->
join
(
'a_agents e'
,
'a.agent_id=e.id'
,
'left'
)
->
join
(
'a_agents f'
,
'b.report_agent_id=f.id'
,
'left'
)
->
join
(
'a_agents e'
,
'a.agent_id=e.id'
,
'left'
)
->
where
(
$params
)
->
group
(
'a.id'
)
->
order
(
$order_
)
...
...
@@ -420,8 +420,8 @@ class OBargainModel extends Model
->
join
(
'o_report b'
,
'a.report_id = b.id'
,
'left'
)
->
join
(
'o_order c'
,
'a.order_id = c.id'
,
'left'
)
->
join
(
'g_houses d'
,
'c.house_id = d.id'
,
'left'
)
->
join
(
'a_agents f'
,
'b.report_agent_id=f.id'
,
'left'
)
->
join
(
'a_agents e'
,
'a.agent_id=e.id'
,
'left'
)
->
join
(
'a_agents f'
,
'b.report_agent_id=f.id'
,
'left'
)
->
join
(
'a_agents e'
,
'a.agent_id=e.id'
,
'left'
)
->
where
(
$params
)
->
having
(
'count(e.order_id) = 1'
)
->
group
(
'e.order_id'
)
...
...
@@ -431,8 +431,8 @@ class OBargainModel extends Model
->
join
(
'o_report b'
,
'a.report_id = b.id'
,
'left'
)
->
join
(
'o_order c'
,
'a.order_id = c.id'
,
'left'
)
->
join
(
'g_houses d'
,
'c.house_id = d.id'
,
'left'
)
->
join
(
'a_agents f'
,
'b.report_agent_id=f.id'
,
'left'
)
->
join
(
'a_agents e'
,
'a.agent_id=e.id'
,
'left'
)
->
join
(
'a_agents f'
,
'b.report_agent_id=f.id'
,
'left'
)
->
join
(
'a_agents e'
,
'a.agent_id=e.id'
,
'left'
)
->
where
(
$params
)
->
group
(
'a.id'
)
->
count
();
...
...
@@ -643,12 +643,19 @@ class OBargainModel extends Model
$field
=
"sum(practical_fee) as num,DATE(create_time) as day"
;
}
elseif
(
$type
==
3
)
{
$field
=
"count(1) as num,DATE(create_time) as day"
;
$where_
[
"father_id"
]
=
0
;
$where_
[
"trade_type"
]
=
10
;
//产品要求统计数量必须是出租类型的180620
}
if
(
isset
(
$params
[
"agent_id"
]))
{
$where_
[
"agent_id"
]
=
$params
[
"agent_id"
];
}
if
(
isset
(
$params
[
"agent_id"
])
&&
$type
==
3
)
{
unset
(
$where_
[
"agent_id"
]);
$where_
[
"submit_agent_id"
]
=
$params
[
"agent_id"
];
}
if
(
isset
(
$params
[
"create_time"
]))
{
$where_
[
"create_time"
]
=
$params
[
"create_time"
];
}
...
...
@@ -1131,13 +1138,14 @@ class OBargainModel extends Model
* @param $params
* @return array|bool|false|\PDOStatement|string|Model
*/
public
function
getBargainPartialDetail
(
$filed
,
$params
)
{
public
function
getBargainPartialDetail
(
$filed
,
$params
)
{
$where_
=
$whereOr_
=
[];
if
(
isset
(
$param
[
"bargain_id"
]))
{
$where_
[
"a.id"
]
=
$params
[
"bargain_id"
];
$where_
[
"a.id"
]
=
$params
[
"bargain_id"
];
$whereOr_
[
"a.father_id"
]
=
$params
[
"bargain_id"
];
}
if
(
isset
(
$params
[
'id'
]))
{
$where_
[
'a.id'
]
=
$params
[
'id'
];
}
...
...
@@ -1152,18 +1160,54 @@ class OBargainModel extends Model
->
order
(
"a.id asc"
)
->
find
();
$m_agent
=
new
AAgents
();
$filed_agent
=
'a.id,a.name,a.phone,b.store_name,c.district_name'
;
$agent_info
=
$m_agent
->
getAgentsInfoByAgentId
(
$filed_agent
,
[
'agent_id'
=>
$result
[
'agent_id'
]]);
$m_agent
=
new
AAgents
();
$filed_agent
=
'a.id,a.name,a.phone,b.store_name,c.district_name'
;
$agent_info
=
$m_agent
->
getAgentsInfoByAgentId
(
$filed_agent
,
[
'agent_id'
=>
$result
[
'agent_id'
]
]);
$result
[
'district_name'
]
=
$agent_info
[
0
][
'district_name'
];
$result
[
'store_name'
]
=
$agent_info
[
0
][
'store_name'
];
$result
[
'name'
]
=
$agent_info
[
0
][
'name'
];
$result
[
'phone'
]
=
$agent_info
[
0
][
'phone'
];
}
catch
(
\Exception
$ex
)
{
$result
=
false
;
}
return
$result
;
}
/**
* 获取分组统计数据
* @param $field
* @param $params
* @param $type
* @param string $order
* @return false|\PDOStatement|string|\think\Collection
*/
public
function
getTotalByAgentId
(
$field
,
$params
,
$type
,
$order
=
""
)
{
$group_
=
""
;
switch
(
$type
)
{
case
1
:
$group_
=
"b.agent_id"
;
break
;
case
2
:
$group_
=
"b.store_id"
;
break
;
case
3
:
$group_
=
"b.district_id"
;
break
;
}
$result
=
$this
->
db_
->
field
(
$field
)
->
alias
(
"a"
)
->
join
(
"a_agents b"
,
"a.agent_id = b.id"
,
"left"
)
->
where
(
$params
)
->
group
(
$group_
)
->
order
(
$order
)
->
select
();
echo
$this
->
db_
->
getLastSql
();
return
$result
;
}
}
\ No newline at end of file
application/model/TAgentTotalModel.php
View file @
c6347abd
...
...
@@ -87,7 +87,7 @@ class TAgentTotalModel extends Model
->
group
(
$group_
)
->
order
(
$order
)
->
select
();
//
echo $this->db_->getLastSql();
//
echo $this->db_->getLastSql();
return
$result
;
}
...
...
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