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
0c20cc60
Commit
0c20cc60
authored
Mar 22, 2018
by
zw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
业绩
parent
7080021a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
9 deletions
+120
-9
Performance.php
application/api_broker/controller/Performance.php
+21
-1
PerformanceService.php
application/api_broker/service/PerformanceService.php
+90
-7
AAgents.php
application/model/AAgents.php
+9
-1
No files found.
application/api_broker/controller/Performance.php
View file @
0c20cc60
...
...
@@ -21,6 +21,13 @@ class Performance extends Basic{
$this
->
service_
=
new
PerformanceService
();
}
/**
* 业绩列表
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
selectPerformanceByTime
(){
$params
=
$this
->
params
;
$params
=
array
(
...
...
@@ -30,6 +37,19 @@ class Performance extends Basic{
if
(
!
isset
(
$params
[
"agent_id"
])
||
!
isset
(
$params
[
"type"
])){
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
$this
->
service_
->
totalAgent
(
$params
[
"agent_id"
],
$params
[
"type"
]);
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$end_day
=
date
(
"Y-m-d"
,
strtotime
(
"-7 day"
));
$list
=
$this
->
service_
->
totalAgent
(
$params
[
"agent_id"
],
$params
[
"type"
],
$yesterday
,
$end_day
);
//dump($list);
if
(
count
(
$list
)
>
0
){
$result
[
"list"
]
=
$list
;
$result
[
"start_time"
]
=
$yesterday
;
$result
[
"end_time"
]
=
$end_day
;
return
$this
->
response
(
"200"
,
"request success"
,
$result
);
}
}
}
application/api_broker/service/PerformanceService.php
View file @
0c20cc60
...
...
@@ -2,6 +2,7 @@
namespace
app\api_broker\service
;
use
app\model\AAgents
;
use
app\model\TAgentTotalModel
;
/**
...
...
@@ -14,23 +15,104 @@ use app\model\TAgentTotalModel;
class
PerformanceService
{
private
$totalModel
;
private
$agentModel
;
public
function
__construct
()
{
$this
->
totalModel
=
new
TAgentTotalModel
();
$this
->
agentModel
=
new
AAgents
();
}
public
function
totalAgent
(
$agent_id
,
$type
)
/**
* @param $agent_id
* @param $type
* @param $yesterday
* @param $end_day
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
totalAgent
(
$agent_id
,
$type
,
$yesterday
,
$end_day
)
{
$agent_info
=
$this
->
getStoreAndDistrict
(
$agent_id
);
$where_
=
[];
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$end_day
=
date
(
"Y-m-d"
,
strtotime
(
"-7 day"
));
$where_
[
'total_time'
]
=
array
(
'between'
,
array
(
$end_day
,
$yesterday
,)
);
//$where_['agent_id'] = $agent_id;
$where_
[
'total_time'
]
=
array
(
'between'
,
array
(
$end_day
,
$yesterday
,
)
);
$result
=
$this
->
totalModel
->
getTotalByAgentId
(
$where_
,
$type
);
//dump($result);
$arr
=
[];
$field
=
"a.name,a.img,b.store_name,c.district_name"
;
foreach
(
$result
as
$key
=>
$value
)
{
switch
(
$type
)
{
case
1
:
if
(
$value
[
"agent_id"
]
==
$agent_info
[
"id"
]
||
$key
<
5
)
{
$value
[
"index_"
]
=
$key
+
1
;
$value
[
"is_my"
]
=
$agent_info
[
"id"
];
$info
=
$this
->
agentModel
->
getAgentsInfoByAgentId
(
$field
,[
"agent_id"
=>
$value
[
"agent_id"
]]);
if
(
count
(
$info
)
>
0
){
$value
[
"name"
]
=
$info
[
0
][
"name"
];
$value
[
"img"
]
=
AGENTHEADERIMGURL
.
$info
[
0
][
"img"
];
$value
[
"store_name"
]
=
$info
[
0
][
"store_name"
];
$value
[
"district_name"
]
=
$info
[
0
][
"district_name"
];
}
array_push
(
$arr
,
$value
);
}
break
;
case
2
:
if
(
$value
[
"store_id"
]
==
$agent_info
[
"store_id"
]
||
$key
<
5
)
{
$value
[
"index_"
]
=
$key
+
1
;
$value
[
"is_my"
]
=
$agent_info
[
"store_id"
];
$info
=
$this
->
agentModel
->
getAgentsInfoByAgentId
(
$field
,[
"agent_id"
=>
$value
[
"agent_id"
]]);
if
(
count
(
$info
)
>
0
){
$value
[
"name"
]
=
$info
[
0
][
"name"
];
$value
[
"img"
]
=
AGENTHEADERIMGURL
.
$info
[
0
][
"img"
];
$value
[
"store_name"
]
=
$info
[
0
][
"store_name"
];
$value
[
"district_name"
]
=
$info
[
0
][
"district_name"
];
}
array_push
(
$arr
,
$value
);
}
break
;
case
3
:
$value
[
"index_"
]
=
$key
+
1
;
$value
[
"is_my"
]
=
$agent_info
[
"district_id"
];
$info
=
$this
->
agentModel
->
getAgentsInfoByAgentId
(
$field
,[
"agent_id"
=>
$value
[
"agent_id"
]]);
if
(
count
(
$info
)
>
0
){
$value
[
"name"
]
=
$info
[
0
][
"name"
];
$value
[
"img"
]
=
AGENTHEADERIMGURL
.
$info
[
0
][
"img"
];
$value
[
"store_name"
]
=
$info
[
0
][
"store_name"
];
$value
[
"district_name"
]
=
$info
[
0
][
"district_name"
];
}
array_push
(
$arr
,
$value
);
break
;
}
}
return
$arr
;
}
/**
* @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
;
$result
=
$this
->
totalModel
->
getTotalByAgentId
(
$where_
,
$type
);
dump
(
$result
);
}
}
\ No newline at end of file
application/model/AAgents.php
View file @
0c20cc60
...
...
@@ -364,7 +364,7 @@ class AAgents extends BaseModel
->
field
(
"id"
)
->
where
(
$params
)
->
select
();
echo
Db
::
table
(
$this
->
table
)
->
getLastSql
();
//
echo Db::table($this->table)->getLastSql();
return
$result
;
}
...
...
@@ -374,6 +374,14 @@ class AAgents extends BaseModel
if
(
isset
(
$params
[
"agent_id"
]))
{
$where_
[
"a.id"
]
=
$params
[
"agent_id"
];
}
if
(
isset
(
$params
[
"store_id"
]))
{
$where_
[
"b.id"
]
=
$params
[
"store_id"
];
$where_
[
"a.level"
]
=
array
(
"in"
,
"20,40"
);
}
if
(
isset
(
$params
[
"district_id"
]))
{
$where_
[
"c.id"
]
=
$params
[
"district_id"
];
$where_
[
"a.level"
]
=
array
(
"in"
,
"30,40"
);
}
$where_
[
"a.status"
]
=
0
;
$result
=
Db
::
table
(
$this
->
table
)
...
...
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