HouseKeepingController.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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->status_time('!=',0);
  52. $criteria->sort('time',EMongoCriteria::SORT_DESC);
  53. $cursor = HouseKeeping::model()->findAll($criteria);
  54. $rows = CommonFn::getRowsFromCursor($cursor);
  55. $parsedRows = HouseKeeping::model()->parse($rows);
  56. $total = $cursor->count();
  57. echo CommonFn::composeDatagridData($parsedRows, $total);
  58. }
  59. public function actionEdit()
  60. {
  61. $status = intval(Yii::app()->request->getParam('status', 100));
  62. $contract = intval(Yii::app()->request->getParam('contract', 100));
  63. $type = intval(Yii::app()->request->getParam('type', 100));
  64. $cart = intval(Yii::app()->request->getParam('cart', 100));
  65. $skill = Yii::app()->request->getParam('skill_options');
  66. foreach ($skill as $value) {
  67. $skill[] = intval($value);
  68. }
  69. $age = intval(Yii::app()->request->getParam('age', 0));
  70. $tech = (Yii::app()->request->getParam('tech', ''));
  71. $tech_mobile = (Yii::app()->request->getParam('tech_mobile', ''));
  72. $desc = (Yii::app()->request->getParam('desc', ''));
  73. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  74. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  75. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  76. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  77. $store_id = (Yii::app()->request->getParam('store_id', ''));
  78. $id = Yii::app()->request->getParam('id');
  79. if (!CommonFn::isMongoId($id)) {
  80. CommonFn::requestAjax(false, '修改失败', array());
  81. }
  82. $h = HouseKeeping::get(new MongoId($id));
  83. if (!empty($contract)) {
  84. $h->contract = $contract;
  85. }
  86. if (!empty($store_id)) {
  87. $h->store_id = $store_id;
  88. }
  89. if (!empty($type)) {
  90. $h->type = $type;
  91. }
  92. if (!empty($cart)) {
  93. $h->cart = $cart;
  94. }
  95. if (!empty($skill)) {
  96. $h->skill = $skill;
  97. }
  98. if (!empty($age)) {
  99. $h->age = $age;
  100. }
  101. if (!empty($desc)) {
  102. $h->desc = $desc;
  103. }
  104. if (!empty($status)) {
  105. $h->status = $status;
  106. }
  107. if (!empty($status_time)) {
  108. $h->status_time = $status_time;
  109. }
  110. if (!empty($server_start_time)) {
  111. $h->server_start_time = $server_start_time;
  112. }
  113. if (!empty($server_end_time)) {
  114. $h->server_end_time = $server_end_time;
  115. }
  116. if (!empty($yc_time)) {
  117. $h->yc_time = $yc_time;
  118. }
  119. if (!empty($tech)) {
  120. $h->tech = $tech;
  121. }
  122. if (!empty($tech_mobile)) {
  123. $h->tech_mobile = $tech_mobile;
  124. }
  125. $success = $h->save();
  126. CommonFn::requestAjax($success, '修改成功', array());
  127. }
  128. public function actionAdd()
  129. {
  130. $h = new HouseKeeping();
  131. $h->user_name = '1';
  132. $h->mobile = '15600266816';
  133. $h->type = 1;
  134. $h->cart = 1;
  135. $h->address = '1dsfafsdf';
  136. $h->server_start_time = time();
  137. $h->server_end_time = time();
  138. $h->skill = array(1,2,3);
  139. $h->yc_time = time();
  140. $h->age = 18;
  141. $h->desc = 'fasdf1';
  142. $h->status = 1;
  143. $h->status_time = time();
  144. $h->tech = '12asdf';
  145. $h->contract = 1;
  146. $h->time = time();
  147. $h->save();
  148. }
  149. }