HouseKeepingController.php 4.9 KB

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