HouseKeepingController.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /**
  3. * Created by north.Deng's MAC
  4. * User: north.Deng
  5. * Date: 2018/1/8
  6. * Time: 上午11:39
  7. * description :
  8. */
  9. class HouseKeepingController extends AdminController
  10. {
  11. public function actionIndex()
  12. {
  13. $status_option = CommonFn::getComboboxData(HouseKeeping::$status_option, 1, true, 100);
  14. $type_option = CommonFn::getComboboxData(HouseKeeping::$type_option, 1, true, 100);
  15. $cart_options = CommonFn::getComboboxData(HouseKeeping::$cart_options, 1, true, 100);
  16. $skill_options = CommonFn::getComboboxData(HouseKeeping::$skill_options, 1, true, 100);
  17. $contract_option = CommonFn::getComboboxData(HouseKeeping::$contract_option, 1, true, 100);
  18. $c = new EMongoCriteria();
  19. $c->status('==',2);
  20. $tmp = Store::model()->findAll($c);
  21. foreach ($tmp as $k => $v) {
  22. $store_options[$v->store_id]['name'] = $v->store_name;
  23. }
  24. $this->render('index', [
  25. 'status_option' => $status_option,
  26. 'type_option' => $type_option,
  27. 'cart_options' => $cart_options,
  28. 'skill_options' => $skill_options,
  29. 'contract_option' => $contract_option,
  30. ]);
  31. }
  32. public function actionList()
  33. {
  34. $pageParams = CommonFn::getPageParams();
  35. $id = intval(Yii::app()->request->getParam('id'));
  36. $search = Yii::app()->request->getParam('search', '');
  37. $status = intval(Yii::app()->request->getParam('status', 100));
  38. $criteria = new EMongoCriteria($pageParams);
  39. // id筛选
  40. if ($id) {
  41. $criteria->_id('==', new MongoId($id));
  42. }
  43. // 状态筛选
  44. if ($status != 100) {
  45. $criteria->status('==', $status);
  46. }
  47. $criteria->sort('time',EMongoCriteria::SORT_DESC);
  48. $cursor = HouseKeeping::model()->findAll($criteria);
  49. $rows = CommonFn::getRowsFromCursor($cursor);
  50. $parsedRows = HouseKeeping::model()->parse($rows);
  51. $total = $cursor->count();
  52. echo CommonFn::composeDatagridData($parsedRows, $total);
  53. }
  54. public function actionEdit()
  55. {
  56. $status = intval(Yii::app()->request->getParam('status', 100));
  57. $contract = intval(Yii::app()->request->getParam('contract', 100));
  58. $type = intval(Yii::app()->request->getParam('type', 100));
  59. $cart = intval(Yii::app()->request->getParam('cart', 100));
  60. $skill = Yii::app()->request->getParam('skill_options');
  61. foreach ($skill as $value) {
  62. $skill[] = intval($value);
  63. }
  64. $age = intval(Yii::app()->request->getParam('age', 0));
  65. $tech = (Yii::app()->request->getParam('tech', ''));
  66. $desc = (Yii::app()->request->getParam('desc', ''));
  67. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  68. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  69. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  70. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  71. $store_id = (Yii::app()->request->getParam('store_id', ''));
  72. $id = Yii::app()->request->getParam('id');
  73. if (!CommonFn::isMongoId($id)) {
  74. CommonFn::requestAjax(false, '修改失败', array());
  75. }
  76. $h = HouseKeeping::get(new MongoId($id));
  77. if (!empty($contract)) {
  78. $h->contract = $contract;
  79. }
  80. if (!empty($store_id)) {
  81. $h->store_id = $store_id;
  82. }
  83. if (!empty($type)) {
  84. $h->type = $type;
  85. }
  86. if (!empty($cart)) {
  87. $h->cart = $cart;
  88. }
  89. if (!empty($skill)) {
  90. $h->skill = $skill;
  91. }
  92. if (!empty($age)) {
  93. $h->age = $age;
  94. }
  95. if (!empty($desc)) {
  96. $h->desc = $desc;
  97. }
  98. if (!empty($status)) {
  99. $h->status = $status;
  100. }
  101. if (!empty($status_time)) {
  102. $h->status_time = $status_time;
  103. }
  104. if (!empty($server_start_time)) {
  105. $h->server_start_time = $server_start_time;
  106. }
  107. if (!empty($server_end_time)) {
  108. $h->server_end_time = $server_end_time;
  109. }
  110. if (!empty($yc_time)) {
  111. $h->yc_time = $yc_time;
  112. }
  113. if (!empty($tech)) {
  114. $h->tech = $tech;
  115. }
  116. $success = $h->save();
  117. CommonFn::requestAjax($success, '修改成功', array());
  118. }
  119. public function actionAdd()
  120. {
  121. $h = new HouseKeeping();
  122. $h->user_name = '1';
  123. $h->mobile = '15600266816';
  124. $h->type = 1;
  125. $h->cart = 1;
  126. $h->address = '1dsfafsdf';
  127. $h->server_start_time = time();
  128. $h->server_end_time = time();
  129. $h->skill = array(1,2,3);
  130. $h->yc_time = time();
  131. $h->age = 18;
  132. $h->desc = 'fasdf1';
  133. $h->status = 1;
  134. $h->status_time = time();
  135. $h->tech = '12asdf';
  136. $h->contract = 1;
  137. $h->time = time();
  138. $h->save();
  139. }
  140. }