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
a17a3d52
Commit
a17a3d52
authored
Jan 20, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编辑商铺
parent
6df84c14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
87 deletions
+160
-87
Houses.php
application/index/controller/Houses.php
+22
-87
GHousesImgs.php
application/model/GHousesImgs.php
+138
-0
No files found.
application/index/controller/Houses.php
View file @
a17a3d52
...
...
@@ -37,22 +37,18 @@ class Houses extends Basic
if
(
$params
[
'id'
])
{
$params
[
'update_time'
]
=
$date
;
}
else
{
$params
[
'create_time'
]
=
$date
;
$params
[
'update_time'
]
=
$date
;
}
$house
=
new
GHouses
();
$house
->
startTrans
();
//
$house->startTrans();
//新增或编辑
if
(
$params
[
'id'
]
==
''
)
{
$house
->
allowField
(
true
)
->
save
(
$params
);
$house
_id
=
$house
->
allowField
(
true
)
->
save
(
$params
);
}
else
{
$house
->
allowField
(
true
)
->
isUpdate
(
true
)
->
save
(
$params
,
[
'id'
=>
$params
[
'id'
]]);
$house
_id
=
$house
->
allowField
(
true
)
->
isUpdate
(
true
)
->
save
(
$params
,
[
'id'
=>
$params
[
'id'
]]);
}
$params
[
'house_id'
]
=
$house
->
id
;
$params
[
'house_id'
]
=
$house_id
;
$house_ext
=
new
GHousesExt
();
if
(
$params
[
'start_business_date'
])
{
...
...
@@ -61,100 +57,39 @@ class Houses extends Basic
//新增或编辑根据id
if
(
$params
[
'id'
]
==
''
)
{
$house_ext
->
allowField
(
true
)
->
save
(
$params
);
$
ext_id
=
$
house_ext
->
allowField
(
true
)
->
save
(
$params
);
}
else
{
$house_ext_data
=
$house_ext
->
field
(
'id'
)
->
where
(
'house_id'
,
$params
[
'id'
])
->
find
();
$house_ext
->
allowField
(
true
)
->
isUpdate
(
true
)
->
save
(
$params
,
[
'id'
=>
$house_ext_data
[
'id'
]]);
$
ext_id
=
$
house_ext
->
allowField
(
true
)
->
isUpdate
(
true
)
->
save
(
$params
,
[
'id'
=>
$house_ext_data
[
'id'
]]);
}
/***保存图片 hujun 2018.1.19 start***/
$house_img
=
new
GHousesImgs
();
//新增图片
if
(
$params
[
'id'
]
!=
''
)
{
//编辑图片
$house_img_data
=
$house_img
->
field
(
'id,img_name,img_type'
)
->
where
(
'img_type <> 6 AND house_id = '
.
$params
[
'id'
])
->
select
();
$count
=
0
;
foreach
(
$house_img_data
as
$k
=>
$v
)
{
if
(
$v
->
img_type
==
1
&&
$v
->
img_name
==
$params
[
'cover'
])
{
$house_img_edit
[
'0'
][
'id'
]
=
$v
->
id
;
$house_img_edit
[
'0'
][
'img_type'
]
=
5
;
$params
[
'cover'
]
=
0
;
//删除重复的数据
$count
=
1
;
}
foreach
(
$params
[
'slideshow'
]
as
$kk
=>
$vv
)
{
if
(
$v
->
img_type
==
2
&&
$v
->
img_name
==
$vv
)
{
unset
(
$params
[
'slideshow'
][
$kk
]);
$kk
+=
$count
;
$house_img_edit
[
$kk
][
'id'
]
=
$v
->
id
;
$house_img_edit
[
$kk
][
'img_type'
]
=
5
;
$params
[
'cover'
]
=
0
;
}
}
}
$house_img
->
isUpdate
(
true
)
->
saveAll
(
$house_img_edit
);
}
$count
=
0
;
$insert_img
=
array
();
//1列表页封面图
if
(
$params
[
'cover'
])
{
$insert_img
[
'0'
][
'house_id'
]
=
$house
->
id
;
$insert_img
[
'0'
][
'img_type'
]
=
1
;
$insert_img
[
'0'
][
'img_name'
]
=
$params
[
'cover'
];
$insert_img
[
'0'
][
'create_time'
]
=
$params
[
'create_time'
];
$insert_img
[
'0'
][
'update_time'
]
=
$params
[
'update_time'
];
$count
=
count
(
$insert_img
)
+
1
;
}
//2详情页轮播图
if
(
$params
[
'slideshow'
])
{
foreach
(
$params
[
'slideshow'
]
as
$k
=>
$v
)
{
$k
+=
$count
;
$insert_img
[
$k
][
'house_id'
]
=
$house
->
id
;
$insert_img
[
$k
][
'img_type'
]
=
2
;
$insert_img
[
$k
][
'img_name'
]
=
$v
;
$insert_img
[
$k
][
'create_time'
]
=
$params
[
'create_time'
];
$insert_img
[
$k
][
'update_time'
]
=
$params
[
'update_time'
];
}
if
(
count
(
$insert_img
)
>
0
)
{
$count
=
count
(
$insert_img
)
+
1
;
}
}
//3楼层平面图
if
(
$params
[
'plan'
])
{
foreach
(
$params
[
'plan'
]
as
$kk
=>
$vv
)
{
$kk
+=
$count
;
$insert_img
[
$kk
][
'house_id'
]
=
$house
->
id
;
$insert_img
[
$kk
][
'img_type'
]
=
3
;
$insert_img
[
$kk
][
'img_name'
]
=
$vv
;
$insert_img
[
$kk
][
'create_time'
]
=
$params
[
'create_time'
];
$insert_img
[
$kk
][
'update_time'
]
=
$params
[
'update_time'
];
}
}
$house_img
->
saveAll
(
$insert_img
);
/***保存图片 hujun 2018.1.19 end***/
if
(
$house
->
id
&&
count
(
$house_img
)
>
0
&&
$house_ext
->
id
)
{
$house
->
commit
();
$return
=
$this
->
response
(
$result
[
'code'
],
$result
[
'msg'
]);
if
(
$params
[
'id'
]
==
''
)
{
$img_
=
$house_img
->
add
(
$params
,
$house_id
);
}
else
{
$house
->
rollback
();
$return
=
$this
->
response
(
101
,
$result
[
'msg'
]);
$house_img
->
edit
(
$params
,
$house_id
);
}
/***保存图片 hujun 2018.1.19 end***/
// if ($house->id && count($img_) > 0 && $ext_id) {
// $house->commit();
// $return = $this->response($result['code'], $result['msg']);
// } else {
// $house->rollback();
$return
=
$this
->
response
(
200
,
$result
[
'msg'
]);
// }
}
elseif
(
$this
->
request
->
param
(
'id'
)){
//获取商铺详情
$house
=
new
GHouses
();
$result
[
'data'
]
=
$house
->
find
();
$return
=
$this
->
response
(
$result
[
'code'
],
$result
[
'msg'
],
$result
[
'data'
]);
}
else
{
//商铺添加页面
$return
=
view
(
'edit'
);
}
return
$return
;
}
...
...
application/model/GHousesImgs.php
View file @
a17a3d52
...
...
@@ -12,4 +12,141 @@ namespace app\model;
class
GHousesImgs
extends
BaseModel
{
protected
$table
=
'g_houses_imgs'
;
/**
* 商铺图片添加
*
* @param $params
* @param $house_id
* @return array|false
* @throws \Exception
*/
public
function
add
(
$params
,
$house_id
)
{
$date
=
date
(
'Y-m-d H:i:s'
);
$params
[
'create_time'
]
=
$date
;
$params
[
'update_time'
]
=
$date
;
$count
=
0
;
$insert_img
=
array
();
//1列表页封面图
if
(
$params
[
'cover'
])
{
$insert_img
[
'0'
][
'house_id'
]
=
$house_id
;
$insert_img
[
'0'
][
'img_type'
]
=
1
;
$insert_img
[
'0'
][
'img_name'
]
=
$params
[
'cover'
];
$insert_img
[
'0'
][
'create_time'
]
=
$params
[
'create_time'
];
$insert_img
[
'0'
][
'update_time'
]
=
$params
[
'update_time'
];
$count
=
count
(
$insert_img
)
+
1
;
}
//2详情页轮播图
if
(
$params
[
'slide_show'
])
{
foreach
(
$params
[
'slide_show'
]
as
$k
=>
$v
)
{
$k
+=
$count
;
$insert_img
[
$k
][
'house_id'
]
=
$params
[
'house_id'
];
$insert_img
[
$k
][
'img_type'
]
=
2
;
$insert_img
[
$k
][
'img_name'
]
=
$v
;
$insert_img
[
$k
][
'create_time'
]
=
$params
[
'create_time'
];
$insert_img
[
$k
][
'update_time'
]
=
$params
[
'update_time'
];
}
if
(
count
(
$insert_img
)
>
0
)
{
$count
=
count
(
$insert_img
)
+
1
;
}
}
//3楼层平面图
if
(
$params
[
'plan'
])
{
foreach
(
$params
[
'plan'
]
as
$kk
=>
$vv
)
{
$kk
+=
$count
;
$insert_img
[
$kk
][
'house_id'
]
=
$params
[
'house_id'
];
$insert_img
[
$kk
][
'img_type'
]
=
3
;
$insert_img
[
$kk
][
'img_name'
]
=
$vv
;
$insert_img
[
$kk
][
'create_time'
]
=
$params
[
'create_time'
];
$insert_img
[
$kk
][
'update_time'
]
=
$params
[
'update_time'
];
}
}
return
$this
->
saveAll
(
$insert_img
);
}
/**
* 商铺图片编辑
*
* @param $params
* @param $house_id
* @return array|false
* @throws \Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
edit
(
$params
,
$house_id
)
{
//编辑图片
$house_img_data
=
$this
->
field
(
'id,img_name,img_type'
)
->
where
(
'img_status <> 1 AND house_id = '
.
$house_id
)
->
select
();
$key
=
0
;
$house_img_edit
=
array
();
$slide_show
=
$params
[
'slide_show'
];
$plan
=
$params
[
'plan'
];
foreach
(
$house_img_data
as
$k
=>
$v
)
{
//1列表页封面图
if
(
$v
->
img_type
==
1
)
{
if
(
$params
[
'cover'
]
!=
$v
->
img_name
)
{
/*伪删除之前的图片*/
$house_img_edit
[
$key
][
'id'
]
=
$v
->
id
;
$house_img_edit
[
$key
][
'img_status'
]
=
1
;
$key
++
;
}
else
{
/*提交图片相同清除提交的图片*/
$params
[
'cover'
]
=
0
;
}
}
//2详情页轮播图
if
(
$v
->
img_type
==
2
)
{
if
(
$slide_show
!=
''
)
{
foreach
(
$slide_show
as
$kk
=>
$vv
)
{
if
(
in_array
(
$v
->
img_name
,
$slide_show
))
{
$img_key
=
array_search
(
$v
->
img_name
,
$params
[
'slide_show'
]);
//根据值查找对应的key
unset
(
$params
[
'slide_show'
][
$img_key
]);
}
else
{
$house_img_edit
[
$key
][
'id'
]
=
$v
->
id
;
$house_img_edit
[
$key
][
'img_status'
]
=
1
;
$key
++
;
}
}
}
else
{
//伪删除全部的轮播图
$house_img_edit
[
$key
][
'id'
]
=
$v
->
id
;
$house_img_edit
[
$key
][
'img_status'
]
=
1
;
$key
++
;
}
}
//3楼层平面图
if
(
$v
->
img_type
==
3
)
{
if
(
$plan
!=
''
)
{
foreach
(
$plan
as
$kk
=>
$vv
)
{
if
(
in_array
(
$v
->
img_name
,
$plan
))
{
$img_key
=
array_search
(
$v
->
img_name
,
$params
[
'plan'
]);
//根据值查找对应的key
unset
(
$params
[
'plan'
][
$img_key
]);
}
else
{
$house_img_edit
[
$key
][
'id'
]
=
$v
->
id
;
$house_img_edit
[
$key
][
'img_status'
]
=
1
;
$key
++
;
}
}
}
else
{
//伪删除全部的轮播图
$house_img_edit
[
$key
][
'id'
]
=
$v
->
id
;
$house_img_edit
[
$key
][
'img_status'
]
=
1
;
$key
++
;
}
}
}
$this
->
add
(
$params
,
$house_id
);
return
$this
->
saveAll
(
$house_img_edit
);
}
}
\ No newline at end of file
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