ListhouseServer.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/3/5
  6. * Time: 下午5:24
  7. */
  8. namespace backend\server;
  9. use Yii;
  10. use common\models\ListHouse;
  11. use common\models\Vr;
  12. use common\models\HouseDetail;
  13. class ListhouseServer
  14. {
  15. //=============================一般性设置获取数据===================================================================
  16. //获取推送列表
  17. public function getListHouse()
  18. {
  19. $input = Yii::$app->request->post();
  20. $listhouseModel = new ListHouse();
  21. return $listhouseModel->getList($input);
  22. }
  23. //添加listhouse信息
  24. public function addListHouse()
  25. {
  26. $input = Yii::$app->request->post();
  27. $data = [];
  28. if (!empty($input['hid']) && !empty($input['list_id'])) {
  29. $data['hid'] = $input['hid'];
  30. $data['list_id'] = $input['list_id'];
  31. } else {
  32. return ['code' => '300', 'msg' => '信息不全'];
  33. }
  34. $listhouseModel = new ListHouse();
  35. if ($listhouseModel->listExists(['list_id' => $data['list_id'], 'hid' => $data['hid']])) {
  36. return ['code' => '300', 'msg' => '该楼盘已经存在'];
  37. }
  38. if (isset($input['informationInfo']) && is_array($input['informationInfo'])) {
  39. $data['information'] = json_encode($input['informationInfo'], JSON_UNESCAPED_UNICODE);
  40. }
  41. $listhouseModel->load($data, '');
  42. if ($listhouseModel->validate() && $listhouseModel->save()) {
  43. return ['code' => '200', 'msg' => '新增完成'];
  44. } else {
  45. return ['code' => '300', 'msg' => '新增失败'];
  46. }
  47. }
  48. //执行修改
  49. public function editListHouse()
  50. {
  51. $input = Yii::$app->request->post();
  52. if (isset($input['informationInfo']) && is_array($input['informationInfo'])) {
  53. $input['information'] = json_encode($input['informationInfo'], JSON_UNESCAPED_UNICODE);
  54. unset($input['informationInfo']);
  55. }
  56. $rows = ListHouse::findOne($input['id']);
  57. unset($input['id']);
  58. $rows->load($input, '');
  59. if ($rows->update()) {
  60. return ['code' => '200', 'msg' => '修改完成'];
  61. } else {
  62. return ['code' => '200', 'msg' => '修改失败'];
  63. }
  64. }
  65. /*
  66. * 列表数据状态设置
  67. * */
  68. public function setList()
  69. {
  70. $input = Yii::$app->request->post();
  71. if (!empty($input['id'])) {
  72. $model = ListHouse::findOne($input['id']);
  73. switch ($input['code']) {
  74. case 'del':
  75. if ($model->delete()) return ['code' => 200, 'msg' => '删除完成'];
  76. break;
  77. case 'state':
  78. $model->state = $input['val'];
  79. if ($model->save()) return ['code' => 200, 'msg' => '状态设置完成'];
  80. break;
  81. case 'sort':
  82. $model->sort = $input['val'];
  83. if ($model->save()) return ['code' => 200, 'msg' => '排序设置完成'];
  84. break;
  85. }
  86. return ['code' => 300, 'msg' => '执行失败'];
  87. }
  88. }
  89. //数据添加验证
  90. public function varcherListInfo()
  91. {
  92. $input = Yii::$app->request->post();
  93. switch ($input['list_id']){
  94. case 10://3DVR
  95. if(!(Vr::find()->where(['hid'=>$input['hid']])->exists())) return ['code'=>300,'msg'=>'该楼盘不存在3DVR'];
  96. break;
  97. case 11://航拍
  98. $data = HouseDetail::findOne($input['hid']);
  99. if(empty($data['panorama'])) return ['code'=>300,'msg'=>'该楼盘不存在航拍720视频'];
  100. break;
  101. }
  102. return ['code'=>200,'msg'=>'信息符合'];
  103. }
  104. //======================================================================================================================
  105. }