HouseKeepingController.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. /**
  3. * Created by north.Deng's MAC
  4. * User: north.Deng
  5. * Date: 2018/1/9
  6. * Time: 上午10:02
  7. * description :
  8. */
  9. class HouseKeepingController extends JBaseController
  10. {
  11. public function actionList()
  12. {
  13. $id = (Yii::app()->request->getParam('id'));
  14. $store_id = intval(Yii::app()->request->getParam('store_id'));
  15. $criteria = new EMongoCriteria();
  16. // id筛选
  17. if ($id) {
  18. $criteria->user_id('==', new MongoId($id));
  19. $je = JEmploye::get(new MongoId($id));
  20. $criteria->store_id('==', $je->owned_stores);
  21. }
  22. $criteria->store_id('==', intval($store_id));
  23. $cursor = HouseKeeping::model()->findAll($criteria);
  24. $rows = CommonFn::getRowsFromCursor($cursor);
  25. $parsedRows = HouseKeeping::model()->parse($rows);
  26. $total = $cursor->count();
  27. echo CommonFn::composeDatagridData($parsedRows, $total);
  28. }
  29. public function actionGetUser()
  30. {
  31. $id = (Yii::app()->request->getParam('user_id'));
  32. $c= new EMongoCriteria();
  33. $c->user_id('==',new MongoId($id));
  34. $tmp = JEmploye::model()->find($c);
  35. $data = array();
  36. $data['user_id'] = $tmp->user_id;
  37. $data['store_id'] = $tmp->owned_stores;
  38. echo json_encode($data);
  39. }
  40. public function actionGetStore()
  41. {
  42. $c= new EMongoCriteria();
  43. $c->status('==',2);
  44. $tmp = Store::model()->findAll($c);
  45. $i = 0;
  46. $data = array();
  47. foreach ($tmp as $k => $v) {
  48. $data[$i]['store_id'] = $v->store_id;
  49. $data[$i++]['store_name'] = $v->store_name;
  50. }
  51. echo json_encode($data);
  52. }
  53. public function actionEdit()
  54. {
  55. $status = intval(Yii::app()->request->getParam('status', ''));
  56. $contract = intval(Yii::app()->request->getParam('contract', ''));
  57. $type = intval(Yii::app()->request->getParam('type', ''));
  58. $cart = intval(Yii::app()->request->getParam('cart', ''));
  59. $skill = intval(Yii::app()->request->getParam('skill', ''));
  60. $age = intval(Yii::app()->request->getParam('age', 0));
  61. $tech = (Yii::app()->request->getParam('tech', ''));
  62. $desc = (Yii::app()->request->getParam('desc', ''));
  63. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  64. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  65. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  66. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  67. $id = Yii::app()->request->getParam('id');
  68. if (!CommonFn::isMongoId($id)) {
  69. CommonFn::requestAjax(false, '修改失败', array());
  70. }
  71. $h = HouseKeeping::get(new MongoId($id));
  72. if (!empty($contract)) {
  73. $h->contract = $contract;
  74. }
  75. if (!empty($type)) {
  76. $h->type = $type;
  77. }
  78. if (!empty($cart)) {
  79. $h->cart = $cart;
  80. }
  81. if (!empty($skill)) {
  82. $h->skill = $skill;
  83. }
  84. if (!empty($age)) {
  85. $h->age = $age;
  86. }
  87. if (!empty($desc)) {
  88. $h->desc = $desc;
  89. }
  90. if (!empty($status)) {
  91. $h->status = $status;
  92. }
  93. if (!empty($status_time)) {
  94. $h->status_time = $status_time;
  95. }
  96. if (!empty($server_start_time)) {
  97. $h->server_start_time = $server_start_time;
  98. }
  99. if (!empty($server_end_time)) {
  100. $h->server_end_time = $server_end_time;
  101. }
  102. if (!empty($yc_time)) {
  103. $h->yc_time = $yc_time;
  104. }
  105. if (!empty($tech)) {
  106. $h->tech = $tech;
  107. }
  108. $success = $h->save();
  109. CommonFn::requestAjax($success, '修改成功', array());
  110. }
  111. public function actionAdd()
  112. {
  113. $mobile = (Yii::app()->request->getParam('mobile', ''));
  114. $user_name = (Yii::app()->request->getParam('user_name', ''));
  115. $user_id = (Yii::app()->request->getParam('user_id', ''));
  116. $type = intval(Yii::app()->request->getParam('type', 1));
  117. $cart = intval(Yii::app()->request->getParam('cart', 1));
  118. $skill = intval(Yii::app()->request->getParam('skill', 1));
  119. $age = intval(Yii::app()->request->getParam('age', 1));
  120. $address = Yii::app()->request->getParam('address', '');
  121. $tech = (Yii::app()->request->getParam('tech', ''));
  122. $desc = (Yii::app()->request->getParam('desc', ''));
  123. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  124. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  125. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  126. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  127. $store_id = intval(Yii::app()->request->getParam('store_id', ''));
  128. $h = new HouseKeeping();
  129. $h->store_id = $store_id;
  130. $h->user_name = $user_name;
  131. $h->user_id = $user_id;
  132. $h->mobile = $mobile;
  133. $h->type = $type;
  134. $h->cart = $cart;
  135. $h->address = $address;
  136. $h->server_start_time = $server_start_time;
  137. $h->server_end_time = $server_end_time;
  138. $h->skill = $skill;
  139. $h->yc_time = $yc_time;
  140. $h->age = $age;
  141. $h->desc = $desc;
  142. $h->status = 1;
  143. $h->status_time = $status_time;
  144. $h->tech = $tech;
  145. $h->contract = 1;
  146. $h->time = time();
  147. $result = $h->save();
  148. if ($result) {
  149. CommonFn::requestAjax($result, '添加成功', array());
  150. } else {
  151. CommonFn::requestAjax($result, '添加失败', array());
  152. }
  153. }
  154. }