HouseKeepingController.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. $tech_mobile = (Yii::app()->request->getParam('tech_mobile', ''));
  67. $desc = (Yii::app()->request->getParam('desc', ''));
  68. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  69. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  70. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  71. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  72. $store_id = (Yii::app()->request->getParam('store_id', ''));
  73. $id = Yii::app()->request->getParam('id');
  74. if (!CommonFn::isMongoId($id)) {
  75. CommonFn::requestAjax(false, '修改失败', array());
  76. }
  77. $h = HouseKeeping::get(new MongoId($id));
  78. if (!empty($contract)) {
  79. $h->contract = $contract;
  80. }
  81. if (!empty($store_id)) {
  82. $h->store_id = $store_id;
  83. }
  84. if (!empty($type)) {
  85. $h->type = $type;
  86. }
  87. if (!empty($cart)) {
  88. $h->cart = $cart;
  89. }
  90. if (!empty($skill)) {
  91. $h->skill = $skill;
  92. }
  93. if (!empty($age)) {
  94. $h->age = $age;
  95. }
  96. if (!empty($desc)) {
  97. $h->desc = $desc;
  98. }
  99. if (!empty($status)) {
  100. $h->status = $status;
  101. }
  102. if (!empty($status_time)) {
  103. $h->status_time = $status_time;
  104. }
  105. if (!empty($server_start_time)) {
  106. $h->server_start_time = $server_start_time;
  107. }
  108. if (!empty($server_end_time)) {
  109. $h->server_end_time = $server_end_time;
  110. }
  111. if (!empty($yc_time)) {
  112. $h->yc_time = $yc_time;
  113. }
  114. if (!empty($tech)) {
  115. $h->tech = $tech;
  116. }
  117. if (!empty($tech_mobile)) {
  118. $h->tech_mobile = $tech_mobile;
  119. }
  120. $success = $h->save();
  121. CommonFn::requestAjax($success, '修改成功', array());
  122. }
  123. public function actionAdd()
  124. {
  125. $h = new HouseKeeping();
  126. $h->user_name = '1';
  127. $h->mobile = '15600266816';
  128. $h->type = 1;
  129. $h->cart = 1;
  130. $h->address = '1dsfafsdf';
  131. $h->server_start_time = time();
  132. $h->server_end_time = time();
  133. $h->skill = array(1,2,3);
  134. $h->yc_time = time();
  135. $h->age = 18;
  136. $h->desc = 'fasdf1';
  137. $h->status = 1;
  138. $h->status_time = time();
  139. $h->tech = '12asdf';
  140. $h->contract = 1;
  141. $h->time = time();
  142. $h->save();
  143. }
  144. }