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
583ddc1f
Commit
583ddc1f
authored
Jul 31, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app新增商铺
parent
44637095
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
242 additions
and
2 deletions
+242
-2
Shop.php
application/api_broker/controller/Shop.php
+36
-2
GHouses.php
application/model/GHouses.php
+205
-0
route.php
application/route.php
+1
-0
No files found.
application/api_broker/controller/Shop.php
View file @
583ddc1f
...
@@ -388,11 +388,9 @@ class Shop extends Basic
...
@@ -388,11 +388,9 @@ class Shop extends Basic
* 新增和编辑商铺
* 新增和编辑商铺
*
*
* @return \think\Response
* @return \think\Response
* @throws \Exception
* @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
* @throws \think\exception\PDOException
*/
*/
public
function
edit
()
public
function
edit
()
{
{
...
@@ -422,6 +420,42 @@ class Shop extends Basic
...
@@ -422,6 +420,42 @@ class Shop extends Basic
return
$this
->
response
(
$result
[
'code'
],
$result
[
'msg'
],
$result
[
'data'
]);
return
$this
->
response
(
$result
[
'code'
],
$result
[
'msg'
],
$result
[
'data'
]);
}
}
/**
* 新增和编辑商铺
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
editV2
()
{
$result
[
'code'
]
=
200
;
$result
[
'msg'
]
=
''
;
$result
[
'data'
]
=
[];
if
(
$this
->
request
->
isPost
())
{
$house_id
=
$this
->
gHousesModel
->
app_addV2
(
$this
->
params
,
$this
->
agentId
);
//添加或编辑商铺
if
(
$house_id
)
{
$result
[
'data'
][
'house_id'
]
=
$house_id
[
'house_id'
];
$result
[
'data'
][
'internal_title'
]
=
empty
(
$this
->
params
[
'internal_title'
])
?
""
:
$this
->
params
[
'internal_title'
];
}
else
{
$data
[
'code'
]
=
101
;
$data
[
'msg'
]
=
'Add houses failure'
;
}
}
else
{
if
(
empty
(
$this
->
params
[
'id'
]))
{
$result
[
'code'
]
=
101
;
$result
[
'msg'
]
=
'Id is null'
;
}
else
{
//获取商铺详情
$result
[
'data'
]
=
$this
->
gHousesModel
->
getHouseById
(
$this
->
params
[
'id'
],
1
);
}
}
return
$this
->
response
(
$result
[
'code'
],
$result
[
'msg'
],
$result
[
'data'
]);
}
/**
/**
* 上传商铺图片
* 上传商铺图片
*
*
...
...
application/model/GHouses.php
View file @
583ddc1f
...
@@ -1128,4 +1128,209 @@ class GHouses extends BaseModel
...
@@ -1128,4 +1128,209 @@ class GHouses extends BaseModel
return
$result
;
return
$result
;
}
}
/**
* 添加和编辑商铺
*
* @param $params
* @return mixed
* @throws \Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
app_addV2
(
$params
,
$agent_id
)
{
$this
->
startTrans
();
if
(
isset
(
$params
[
'phone'
]))
{
$case
=
new
ACase
();
$case_id
=
$case
->
addCase
(
$params
[
'phone'
]);
$params
[
'case_id'
]
=
$case_id
;
}
if
(
!
empty
(
$params
[
'province'
])
||
!
empty
(
$params
[
'city'
])
||
!
empty
(
$params
[
'disc'
]))
{
$regions
=
new
Regions
();
$code_arr
=
$regions
->
getRegionsCodeByName
(
$params
[
'province'
],
$params
[
'city'
],
$params
[
'disc'
]);
$params
[
'code'
]
=
is_array
(
$code_arr
)
?
implode
(
'##'
,
$code_arr
)
:
''
;
}
if
(
!
empty
(
$params
[
'rent_price'
]))
{
$params
[
'rent_price'
]
=
$params
[
'rent_price'
]
*
100
;
//存分
}
if
(
!
empty
(
$params
[
'management_fee'
]))
{
$params
[
'management_fee'
]
=
$params
[
'management_fee'
]
*
100
;
//存分
}
if
(
!
empty
(
$params
[
'slotting_fee'
]))
{
$params
[
'slotting_fee'
]
=
$params
[
'slotting_fee'
]
*
100
;
//存分
}
if
(
!
empty
(
$params
[
'external_slotting_fee'
]))
{
if
(
$params
[
'external_slotting_fee'
]
!=
-
1
)
{
$params
[
'external_slotting_fee'
]
=
$params
[
'external_slotting_fee'
]
*
100
;
//存分
}
}
if
(
isset
(
$params
[
'internal_title'
]))
{
$params
[
'internal_title'
]
=
trim
(
$params
[
'internal_title'
]);
}
//新增或编辑
if
(
empty
(
$params
[
'id'
]))
{
$params
[
'upload_id'
]
=
$agent_id
;
$this
->
allowField
(
true
)
->
save
(
$params
);
$house_id
=
$this
->
id
;
$result
[
'house_id'
]
=
$this
->
id
;
$result
[
'internal_title'
]
=
$params
[
'internal_title'
];
}
else
{
$house_data
=
$this
->
field
(
'id,internal_title,residue_num,total'
)
->
where
(
'id'
,
$params
[
'id'
])
->
where
(
'status'
,
'<>'
,
3
)
->
find
();
if
(
!
empty
(
$house_data
[
'id'
]))
{
//剩余商铺为0下架
if
(
isset
(
$params
[
'residue_num'
]))
{
if
(
empty
(
$params
[
'residue_num'
])
||
empty
(
$params
[
'total'
]))
{
$params
[
'status'
]
=
2
;
}
else
{
$params
[
'status'
]
=
1
;
}
}
//商铺总数为0下架
if
(
isset
(
$params
[
'total'
]))
{
if
(
empty
(
$params
[
'total'
]))
{
$params
[
'status'
]
=
2
;
}
else
{
$params
[
'status'
]
=
1
;
}
}
if
(
!
isset
(
$params
[
"status"
]))
{
if
(
$house_data
[
"residue_num"
]
==
0
||
$house_data
[
"total"
]
==
0
)
{
$params
[
'status'
]
=
2
;
}
else
{
$params
[
'status'
]
=
1
;
}
}
$params
[
'operation_id'
]
=
$params
[
'userId'
];
$this
->
allowField
(
true
)
->
isUpdate
(
true
)
->
save
(
$params
,
[
'id'
=>
$params
[
'id'
]
]);
$house_id
=
$this
->
id
;
}
else
{
$house_id
=
$params
[
'id'
];
}
$result
[
'internal_title'
]
=
$house_data
[
'internal_title'
];
$result
[
'house_id'
]
=
$house_id
;
}
$params
[
'house_id'
]
=
$house_id
;
if
(
isset
(
$params
[
'start_business_date'
]))
{
$params
[
'start_business_date'
]
=
date
(
'Y-m-d H:i:s'
,
strtotime
(
$params
[
'start_business_date'
]));
}
if
(
!
empty
(
$params
[
'landlord_phone'
]))
{
$landlord_phone
=
[];
//排除没有手机号数据
if
(
is_array
(
json_decode
(
$params
[
'landlord_phone'
],
true
)))
{
$params
[
'landlord_phone'
]
=
json_decode
(
$params
[
'landlord_phone'
],
true
);
foreach
(
$params
[
'landlord_phone'
]
as
$k
=>
$v
)
{
if
(
!
empty
(
$v
[
'phone'
]))
{
$landlord_phone
[
$k
][
'name'
]
=
empty
(
$v
[
'name'
])
?
'房东'
:
$v
[
'name'
];
$landlord_phone
[
$k
][
'phone'
]
=
$v
[
'phone'
];
}
}
}
else
{
//兼容之前逗号隔开的手机号
$params
[
'landlord_phone'
]
=
explode
(
','
,
$params
[
'landlord_phone'
]);
foreach
(
$params
[
'landlord_phone'
]
as
$key
=>
$val
)
{
$landlord_phone
[
$key
][
'name'
]
=
'房东'
;
$landlord_phone
[
$key
][
'phone'
]
=
$val
;
}
}
if
(
isset
(
$landlord_phone
[
0
][
'phone'
]))
{
$params
[
'landlord_phone'
]
=
json_encode
(
$landlord_phone
);
}
}
if
(
isset
(
$params
[
'landlord_remark'
]))
{
$params
[
'landlord_remark'
]
=
trim
(
$params
[
'landlord_remark'
]);
//房东备注
}
$houses_ext
=
new
GHousesExt
();
//新增或编辑根据id
if
(
$params
[
'id'
]
==
''
)
{
$houses_ext
->
allowField
(
true
)
->
save
(
$params
);
}
else
{
$house_ext_data
=
$houses_ext
->
field
(
'id'
)
->
where
(
'house_id'
,
$params
[
'id'
])
->
find
();
//没有数据就新增
if
(
empty
(
$house_ext_data
))
{
$data_ext
[
'house_id'
]
=
$params
[
'house_id'
];
$data_ext
[
'fee_rule'
]
=
$params
[
'fee_rule'
];
$data_ext
[
'internal_item_advantage'
]
=
$params
[
'internal_item_advantage'
];
$data_ext
[
'external_item_advantage'
]
=
$params
[
'external_item_advantage'
];
$data_ext
[
'tiny_brochure_url'
]
=
$params
[
'tiny_brochure_url'
];
$data_ext
[
'auditorium'
]
=
$params
[
'auditorium'
];
$data_ext
[
'traffic'
]
=
$params
[
'traffic'
];
$data_ext
[
'agent_start_time'
]
=
$params
[
'agent_start_time'
];
$data_ext
[
'agent_end_time'
]
=
$params
[
'agent_end_time'
];
$data_ext
[
'enter_num'
]
=
$params
[
'enter_num'
];
$data_ext
[
'do_business_date'
]
=
$params
[
'do_business_date'
];
$data_ext
[
'start_business_date'
]
=
$params
[
'start_business_date'
];
$data_ext
[
'opening_date'
]
=
$params
[
'opening_date'
];
$data_ext
[
'sign_rule'
]
=
$params
[
'sign_rule'
];
$data_ext
[
'landlord_phone'
]
=
$params
[
'landlord_phone'
];
$data_ext
[
'landlord_remark'
]
=
$params
[
'landlord_remark'
];
$houses_ext
->
allowField
(
true
)
->
save
(
$data_ext
);
}
else
{
$houses_ext
->
allowField
(
true
)
->
isUpdate
(
true
)
->
save
(
$params
,
[
'id'
=>
$house_ext_data
[
'id'
]
]);
}
}
$agents
=
new
GHousesToAgents
();
//权限人
if
(
isset
(
$params
[
'agent_data'
]))
{
$agents
->
addAgents
(
$params
[
'agent_data'
],
$house_id
,
1
);
}
//盘方
if
(
isset
(
$params
[
'agent_dish'
]))
{
$agents
->
addAgents
(
$params
[
'agent_dish'
],
$house_id
,
2
);
}
//独家方
if
(
isset
(
$params
[
'exclusive_ids'
]))
{
$agents
->
addAgents
(
$params
[
'exclusive_ids'
],
$house_id
,
3
);
}
if
(
$params
[
'image_file'
])
{
$m_img
=
new
GHousesImgs
();
$image_file
=
json_decode
(
$params
[
'image_file'
],
true
);
$img_data
=
[];
foreach
(
$image_file
as
$k
=>
$v
)
{
$img_data
[
$k
][
'house_id'
]
=
$result
[
'house_id'
];
$img_data
[
$k
][
'img_name'
]
=
$v
[
'img_name'
];
$img_data
[
$k
][
'img_type'
]
=
$v
[
'img_type'
];
}
$m_img
->
addHouseImgAll
(
$img_data
);
}
if
(
$result
[
'house_id'
]
!=
NULL
)
{
$this
->
commit
();
}
else
{
$this
->
rollback
();
}
return
$result
;
}
}
}
application/route.php
View file @
583ddc1f
...
@@ -466,6 +466,7 @@ Route::group('broker', [
...
@@ -466,6 +466,7 @@ Route::group('broker', [
'center'
=>
[
'api_broker/MyCenter/center'
,
[
'method'
=>
'get|post'
]
],
'center'
=>
[
'api_broker/MyCenter/center'
,
[
'method'
=>
'get|post'
]
],
'houseEdit'
=>
[
'api_broker/shop/edit'
,
[
'method'
=>
'get|post'
]
],
//编辑商铺
'houseEdit'
=>
[
'api_broker/shop/edit'
,
[
'method'
=>
'get|post'
]
],
//编辑商铺
'houseEditV2'
=>
[
'api_broker/shop/editV2'
,
[
'method'
=>
'get|post'
]
],
//编辑商铺
'getLabelsShopList'
=>
[
'api_broker/label/getLabelsShopList'
,
[
'method'
=>
'get'
]
],
//编辑商铺
'getLabelsShopList'
=>
[
'api_broker/label/getLabelsShopList'
,
[
'method'
=>
'get'
]
],
//编辑商铺
'uploadHouseFile'
=>
[
'api_broker/shop/uploadHouseFile'
,
[
'method'
=>
'post'
]
],
//商铺上传文件
'uploadHouseFile'
=>
[
'api_broker/shop/uploadHouseFile'
,
[
'method'
=>
'post'
]
],
//商铺上传文件
'delHouseFile'
=>
[
'api_broker/shop/delHouseFile'
,
[
'method'
=>
'post'
]
],
//商铺文件删除
'delHouseFile'
=>
[
'api_broker/shop/delHouseFile'
,
[
'method'
=>
'post'
]
],
//商铺文件删除
...
...
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