123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/5
- * Time: 下午5:24
- */
- namespace backend\server;
- use Yii;
- use common\models\ListHouse;
- use common\models\Vr;
- use common\models\HouseDetail;
- class ListhouseServer
- {
- //=============================一般性设置获取数据===================================================================
- //获取推送列表
- public function getListHouse()
- {
- $input = Yii::$app->request->post();
- $listhouseModel = new ListHouse();
- return $listhouseModel->getList($input);
- }
- //添加listhouse信息
- public function addListHouse()
- {
- $input = Yii::$app->request->post();
- $data = [];
- if (!empty($input['hid']) && !empty($input['list_id'])) {
- $data['hid'] = $input['hid'];
- $data['list_id'] = $input['list_id'];
- } else {
- return ['code' => '300', 'msg' => '信息不全'];
- }
- $listhouseModel = new ListHouse();
- if ($listhouseModel->listExists(['list_id' => $data['list_id'], 'hid' => $data['hid']])) {
- return ['code' => '300', 'msg' => '该楼盘已经存在'];
- }
- if (isset($input['informationInfo']) && is_array($input['informationInfo'])) {
- $data['information'] = json_encode($input['informationInfo'], JSON_UNESCAPED_UNICODE);
- }
- $listhouseModel->load($data, '');
- if ($listhouseModel->validate() && $listhouseModel->save()) {
- return ['code' => '200', 'msg' => '新增完成'];
- } else {
- return ['code' => '300', 'msg' => '新增失败'];
- }
- }
- //执行修改
- public function editListHouse()
- {
- $input = Yii::$app->request->post();
- if (isset($input['informationInfo']) && is_array($input['informationInfo'])) {
- $input['information'] = json_encode($input['informationInfo'], JSON_UNESCAPED_UNICODE);
- unset($input['informationInfo']);
- }
- $rows = ListHouse::findOne($input['id']);
- unset($input['id']);
- $rows->load($input, '');
- if ($rows->update()) {
- return ['code' => '200', 'msg' => '修改完成'];
- } else {
- return ['code' => '200', 'msg' => '修改失败'];
- }
- }
- /*
- * 列表数据状态设置
- * */
- public function setList()
- {
- $input = Yii::$app->request->post();
- if (!empty($input['id'])) {
- $model = ListHouse::findOne($input['id']);
- switch ($input['code']) {
- case 'del':
- if ($model->delete()) return ['code' => 200, 'msg' => '删除完成'];
- break;
- case 'state':
- $model->state = $input['val'];
- if ($model->save()) return ['code' => 200, 'msg' => '状态设置完成'];
- break;
- case 'sort':
- $model->sort = $input['val'];
- if ($model->save()) return ['code' => 200, 'msg' => '排序设置完成'];
- break;
- }
- return ['code' => 300, 'msg' => '执行失败'];
- }
- }
- //数据添加验证
- public function varcherListInfo()
- {
- $input = Yii::$app->request->post();
- switch ($input['list_id']){
- case 10://3DVR
- if(!(Vr::find()->where(['hid'=>$input['hid']])->exists())) return ['code'=>300,'msg'=>'该楼盘不存在3DVR'];
- break;
- case 11://航拍
- $data = HouseDetail::findOne($input['hid']);
- if(empty($data['panorama'])) return ['code'=>300,'msg'=>'该楼盘不存在航拍720视频'];
- break;
- }
- return ['code'=>200,'msg'=>'信息符合'];
- }
- //======================================================================================================================
- }
|