HouseKeepingController.php 5.5 KB

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