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
156819c5
Commit
156819c5
authored
Sep 06, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化商铺与经纪人人关系
parent
6c72a893
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
144 additions
and
77 deletions
+144
-77
HouseService.php
application/index/service/HouseService.php
+116
-74
GHousesToAgents.php
application/model/GHousesToAgents.php
+28
-3
No files found.
application/index/service/HouseService.php
View file @
156819c5
...
@@ -23,10 +23,14 @@ use app\task\controller\ResultsSummaryNewTask;
...
@@ -23,10 +23,14 @@ use app\task\controller\ResultsSummaryNewTask;
class
HouseService
class
HouseService
{
{
protected
$house
;
protected
$house
;
protected
$agent
;
protected
$agetn_house
;
public
function
__construct
()
public
function
__construct
()
{
{
$this
->
house
=
new
GHouses
();
$this
->
house
=
new
GHouses
();
$this
->
agent
=
new
AAgents
();
$this
->
agetn_house
=
new
GHousesToAgents
();
}
}
/**
/**
...
@@ -35,6 +39,7 @@ class HouseService
...
@@ -35,6 +39,7 @@ class HouseService
* @param array $data
* @param array $data
* @param int $agent_id
* @param int $agent_id
* @return array
* @return array
* @throws \think\exception\PDOException
*/
*/
public
function
addHouse
(
array
$data
,
int
$agent_id
)
:
array
public
function
addHouse
(
array
$data
,
int
$agent_id
)
:
array
{
{
...
@@ -62,12 +67,8 @@ class HouseService
...
@@ -62,12 +67,8 @@ class HouseService
return
$result
;
return
$result
;
}
}
$sum
=
new
ResultsSummaryNewTask
();
$m_agent
=
new
AAgents
();
$houses_ext
=
new
GHousesExt
();
$houses_ext
=
new
GHousesExt
();
$house_img
=
new
GHousesImgs
();
$house_img
=
new
GHousesImgs
();
$agents
=
new
GHousesToAgents
();
$records
=
new
GOperatingRecords
();
//商铺扩展字段
//商铺扩展字段
$houses_ext
->
addHouseExt
(
$data
,
$house_id
);
$houses_ext
->
addHouseExt
(
$data
,
$house_id
);
...
@@ -80,67 +81,36 @@ class HouseService
...
@@ -80,67 +81,36 @@ class HouseService
if
(
$image_result
[
'status'
]
==
'fail'
)
{
if
(
$image_result
[
'status'
]
==
'fail'
)
{
$result
[
'status'
]
=
'fail'
;
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
'编辑图片失败,'
.
$validate
->
getError
();
$result
[
'msg'
]
=
'编辑图片失败,'
.
$validate
->
getError
();
return
$result
;
return
$result
;
}
}
}
}
//案场权限人
//案场权限人
if
(
isset
(
$data
[
'agent_data'
]))
{
if
(
isset
(
$data
[
'agent_data'
]))
{
$agent_data
=
array_unique
(
explode
(
','
,
$data
[
'agent_data'
]));
$result_agent_data
=
$this
->
releaseRelationship
(
$data
[
'agent_data'
],
$house_id
,
1
);
$agents
->
addHouseAgent
(
$agent_data
,
$house_id
,
1
);
if
(
$result_agent_data
[
'status'
]
==
'fail'
)
{
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
'新增或编辑案场权限人失败,'
.
$result_agent_data
[
'msg'
];
}
}
}
//盘方
//盘方
if
(
isset
(
$data
[
'agent_dish'
]))
{
if
(
isset
(
$data
[
'agent_dish'
]))
{
$agent_dish
=
array_unique
(
explode
(
','
,
$data
[
'agent_dish'
]));
$result_agent_dish
=
$this
->
releaseRelationship
(
$data
[
'agent_dish'
],
$house_id
,
2
);
$agents
->
addHouseAgent
(
$agent_dish
,
$house_id
,
2
);
if
(
$result_agent_dish
[
'status'
]
==
'fail'
)
{
$result
[
'status'
]
=
'fail'
;
//更新业绩统计
$result
[
'msg'
]
=
'新增或编辑盘方失败,'
.
$result_agent_dish
[
'msg'
];
$date
=
date
(
'Y-m-d H:i:s'
);
$agent_name
=
[];
foreach
(
$data
[
'agent_dish'
]
as
$k
=>
$v
)
{
$agent_data
=
$m_agent
->
verifyUser
(
'id,store_id,district_id,name'
,
''
,
[
'id'
=>
$v
]);
//获取被修改人信息
$sum
->
updateTotalByAgentId
(
$agent_data
[
'id'
],
$agent_data
[
'store_id'
],
$agent_data
[
'district_id'
],
$date
);
//被修改的人
$agent_name
[]
=
$agent_data
[
'name'
];
}
if
(
!
empty
(
$agent_name
))
{
//记录新增盘方
$records
->
record
(
''
,
2
,
'新增为:'
.
implode
(
','
,
$agent_name
),
$house_id
);
}
}
}
}
//独家方
//独家方
if
(
isset
(
$data
[
'exclusive_ids'
]))
{
if
(
isset
(
$data
[
'exclusive_ids'
]))
{
$exclusive_ids
=
array_unique
(
explode
(
','
,
$data
[
'exclusive_ids'
]));
$result_exclusive_ids
=
$this
->
releaseRelationship
(
$data
[
'exclusive_ids'
],
$house_id
,
3
);
$agents
->
addHouseAgent
(
$exclusive_ids
,
$house_id
,
3
);
if
(
$result_exclusive_ids
[
'status'
]
==
'fail'
)
{
}
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
'新增或编辑独家方失败,'
.
$result_exclusive_ids
[
'msg'
];
//解除案场权限人绑定关系
if
(
isset
(
$data
[
'del_agent_data'
]))
{
$agent_data_arr
=
explode
(
','
,
$data
[
'del_agent_data'
]);
foreach
(
$agent_data_arr
as
$k
=>
$v
)
{
$agents
->
del
(
$v
,
$house_id
);
}
}
//解除盘方绑定关系
if
(
isset
(
$data
[
'del_agent_dish'
]))
{
$agent_dish_arr
=
explode
(
','
,
$data
[
'del_agent_dish'
]);
foreach
(
$agent_dish_arr
as
$k
=>
$v
)
{
$num
=
$agents
->
getAgentHouseNum
(
$v
,
2
);
if
(
$num
>
0
)
{
$agents
->
del
(
$v
,
$house_id
);
$del_agent_name
[]
=
$m_agent
->
getAgentsById
(
$v
,
'name'
);
//获取被修改人信息
}
}
if
(
!
empty
(
$del_agent_name
))
{
//记录删除盘方
$records
=
new
GOperatingRecords
();
$records
->
record
(
''
,
2
,
'删除盘方:'
.
implode
(
','
,
$del_agent_name
),
$house_id
);
}
}
}
}
...
@@ -148,7 +118,7 @@ class HouseService
...
@@ -148,7 +118,7 @@ class HouseService
//剩余商铺为0下架
//剩余商铺为0下架
if
(
empty
(
$data
[
'residue_num'
])
||
empty
(
$data
[
'total'
]))
{
if
(
empty
(
$data
[
'residue_num'
])
||
empty
(
$data
[
'total'
]))
{
$push
=
new
PushMessageService
();
$push
=
new
PushMessageService
();
$push
->
record
(
1
,
[
0
=>
$house_id
],
0
,
$agent_id
);
//记录推送信息
$push
->
record
(
1
,
[
0
=>
$house_id
],
0
,
$agent_id
);
//记录推送信息
}
}
}
}
...
@@ -158,28 +128,6 @@ class HouseService
...
@@ -158,28 +128,6 @@ class HouseService
return
$result
;
return
$result
;
}
}
/**
* 删除商铺与经纪人关系
*
* @param $agent_id
* @param $house_id
* @return mixed
*/
public
function
updateAgentHouse
(
$agent_id
,
$house_id
)
{
$agents
=
new
GHousesToAgents
();
$result
=
$agents
->
del
(
$agent_id
,
$house_id
);
if
(
$result
)
{
$data
[
'status'
]
=
'successful'
;
$data
[
'msg'
]
=
'编辑成功'
;
}
else
{
$data
[
'status'
]
=
'fail'
;
$data
[
'msg'
]
=
'编辑失败'
;
}
return
$data
;
}
/**
/**
* 根据商铺id获取独家附件
* 根据商铺id获取独家附件
*
*
...
@@ -209,4 +157,97 @@ class HouseService
...
@@ -209,4 +157,97 @@ class HouseService
return
$result
;
return
$result
;
}
}
/**
* @param $agent_data
* @param $house_id
* @param $type
* @return bool
* @throws \think\exception\PDOException
*/
public
function
releaseRelationship
(
$agent_data
,
$house_id
,
$type
)
{
if
(
empty
(
$agent_data
))
{
return
false
;
}
$agent_id
=
array_unique
(
explode
(
','
,
$agent_data
));
$agent_house_where
[
'is_del'
]
=
0
;
$agent_house_where
[
'houses_id'
]
=
$house_id
;
$agent_house_where
[
'type'
]
=
$type
;
$agent_data_old
=
$this
->
agetn_house
->
getAgentHouseAll
(
'id,agents_id,houses_id'
,
$agent_house_where
);
foreach
(
$agent_data_old
[
'data'
]
as
$k
=>
$v
)
{
if
(
in_array
(
$v
[
'agents_id'
],
$agent_id
))
{
continue
;
}
else
{
$update_data
[
$k
][
'id'
]
=
$v
[
'id'
];
$update_data
[
$k
][
'agents_id'
]
=
$v
[
'agents_id'
];
$update_data
[
$k
][
'houses_id'
]
=
$v
[
'houses_id'
];
$update_data
[
$k
][
'type'
]
=
$type
;
$update_data
[
$k
][
'is_del'
]
=
1
;
$del_agent_id
[]
=
$v
[
'agents_id'
];
}
}
foreach
(
$agent_id
as
$k2
=>
$v2
)
{
if
(
in_array
(
$v2
,
$agent_data_old
[
'data'
]))
{
continue
;
}
else
{
$insert_data
[
$k2
][
'agents_id'
]
=
$v2
;
$insert_data
[
$k2
][
'houses_id'
]
=
$house_id
;
$insert_data
[
$k2
][
'type'
]
=
$type
;
$add_agent_id
[]
=
$v2
;
}
}
$this
->
agetn_house
->
startTrans
();
try
{
//伪删除关系
if
(
!
empty
(
$update_data
))
{
$this
->
agetn_house
->
updateUserAll
(
$update_data
);
}
if
(
!
empty
(
$insert_data
))
{
$this
->
agetn_house
->
insertAll
(
$insert_data
);
}
//处理盘方
if
(
$type
==
2
)
{
if
(
!
empty
(
$del_agent_id
))
{
$del_agent_name
=
$this
->
agent
->
getAgentById
(
'name'
,
[
'in_id'
=>
implode
(
','
,
$del_agent_id
)
]);
if
(
!
empty
(
$del_agent_name
))
{
//记录删除盘方
$records
=
new
GOperatingRecords
();
$remark
=
'删除盘方:'
.
implode
(
','
,
$del_agent_name
);
$records
->
record
(
''
,
2
,
$remark
,
$house_id
);
}
}
if
(
!
empty
(
$add_agent_id
))
{
//更新业绩统计
$sum
=
new
ResultsSummaryNewTask
();
$date
=
date
(
'Y-m-d H:i:s'
);
$agent_name
=
[];
foreach
(
$add_agent_id
as
$k
=>
$v
)
{
$agent_data
=
$this
->
agent
->
verifyUser
(
'id,store_id,district_id,name'
,
''
,
[
'id'
=>
$v
]);
//获取被修改人信息
$sum
->
updateTotalByAgentId
(
$agent_data
[
'id'
],
$agent_data
[
'store_id'
],
$agent_data
[
'district_id'
],
$date
);
//被修改的人
$agent_name
[]
=
$agent_data
[
'name'
];
}
}
}
$this
->
agetn_house
->
commit
();
$result
[
'status'
]
=
'successful'
;
}
catch
(
\Exception
$e
)
{
$this
->
agetn_house
->
rollback
();
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
$e
->
getMessage
();
}
return
$result
;
}
}
}
\ No newline at end of file
application/model/GHousesToAgents.php
View file @
156819c5
...
@@ -373,12 +373,18 @@ class GHousesToAgents extends BaseModel
...
@@ -373,12 +373,18 @@ class GHousesToAgents extends BaseModel
/**
/**
* @param $data
* @param $data
* @return array|false
* @return mixed
* @throws \Exception
*/
*/
public
function
updateUserAll
(
$data
)
public
function
updateUserAll
(
$data
)
{
{
return
$this
->
saveAll
(
$data
);
try
{
$data
[
'data'
]
=
$this
->
saveAll
(
$data
);
$data
[
'status'
]
=
'successful'
;
}
catch
(
\Exception
$e
)
{
$data
[
'status'
]
=
'fail'
;
$data
[
'msg'
]
=
$e
->
getMessage
();
}
return
$data
;
}
}
/**
/**
...
@@ -428,4 +434,23 @@ class GHousesToAgents extends BaseModel
...
@@ -428,4 +434,23 @@ class GHousesToAgents extends BaseModel
return
$this
->
where
(
$where
)
return
$this
->
where
(
$where
)
->
column
(
$field
);
->
column
(
$field
);
}
}
/**
* @param $field
* @param $where
* @return mixed
*/
public
function
getAgentHouseAll
(
$field
,
$where
)
{
try
{
$data
[
'data'
]
=
$this
->
field
(
$field
)
->
where
(
$where
)
->
select
();
$data
[
'status'
]
=
'successful'
;
}
catch
(
\Exception
$e
)
{
$data
[
'data'
]
=
[];
$data
[
'status'
]
=
'fail'
;
}
return
$data
;
}
}
}
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