HouseKeepingController.php 5.3 KB

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