HouseKeepingController.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 = Yii::app()->request->getParam('store_id','');
  15. $criteria = new EMongoCriteria();
  16. if (!empty($store_id)) {
  17. $criteria->store_id('==', intval($store_id));
  18. }
  19. // id筛选
  20. if (!empty($id)) {
  21. $criteria->user_id('==', $id);
  22. }
  23. $criteria->sort('time',EMongoCriteria::SORT_DESC);
  24. $cursor = HouseKeeping::model()->findAll($criteria);
  25. $rows = CommonFn::getRowsFromCursor($cursor);
  26. $parsedRows = HouseKeeping::model()->parse($rows);
  27. $total = $cursor->count();
  28. echo CommonFn::composeDatagridData($parsedRows, $total);
  29. }
  30. public function actionGetUser()
  31. {
  32. $id = (Yii::app()->request->getParam('user_id'));
  33. $c= new EMongoCriteria();
  34. $c->user_id('==',new MongoId($id));
  35. $tmp = JEmploye::model()->find($c);
  36. $data = array();
  37. $data['user_id'] = $tmp->user_id;
  38. $data['store_id'] = $tmp->owned_stores;
  39. echo json_encode($data);
  40. }
  41. public function actionGetStore()
  42. {
  43. $c= new EMongoCriteria();
  44. $c->status('==',2);
  45. $tmp = Store::model()->findAll($c);
  46. $i = 0;
  47. $data = array();
  48. foreach ($tmp as $k => $v) {
  49. $data[$i]['store_id'] = $v->store_id;
  50. $data[$i]['store_name'] = $v->store_name;
  51. $data[$i]['mobile'] = $v->mobile;
  52. $data[$i++]['address'] = $v->address;
  53. }
  54. echo json_encode($data);
  55. }
  56. public function actionEdit()
  57. {
  58. $status = intval(Yii::app()->request->getParam('status', ''));
  59. $contract = intval(Yii::app()->request->getParam('contract', ''));
  60. $type = intval(Yii::app()->request->getParam('type', ''));
  61. $cart = intval(Yii::app()->request->getParam('cart', ''));
  62. $skill = Yii::app()->request->getParam('skill', '');
  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. $id = Yii::app()->request->getParam('id');
  71. if (!CommonFn::isMongoId($id)) {
  72. CommonFn::requestAjax(false, '修改失败', array());
  73. }
  74. $h = HouseKeeping::get(new MongoId($id));
  75. if (!empty($contract)) {
  76. $h->contract = $contract;
  77. }
  78. if (!empty($type)) {
  79. $h->type = $type;
  80. }
  81. if (!empty($cart)) {
  82. $h->cart = $cart;
  83. }
  84. if (!empty($skill)) {
  85. $h->skill = $skill;
  86. }
  87. if (!empty($age)) {
  88. $h->age = $age;
  89. }
  90. if (!empty($desc)) {
  91. $h->desc = $desc;
  92. }
  93. if (!empty($status)) {
  94. $h->status = $status;
  95. }
  96. if (!empty($status_time)) {
  97. $h->status_time = $status_time;
  98. }
  99. if (!empty($server_start_time)) {
  100. $h->server_start_time = $server_start_time;
  101. }
  102. if (!empty($server_end_time)) {
  103. $h->server_end_time = $server_end_time;
  104. }
  105. if (!empty($yc_time)) {
  106. $h->yc_time = $yc_time;
  107. }
  108. if (!empty($tech)) {
  109. $h->tech = $tech;
  110. }
  111. $success = $h->save();
  112. CommonFn::requestAjax($success, '修改成功', array());
  113. }
  114. public function actionAdd()
  115. {
  116. $mobile = (Yii::app()->request->getParam('mobile', ''));
  117. $user_name = (Yii::app()->request->getParam('user_name', ''));
  118. $user_id = (Yii::app()->request->getParam('user_id', ''));
  119. $type = intval(Yii::app()->request->getParam('type', 1));
  120. $cart = intval(Yii::app()->request->getParam('cart', 1));
  121. $skill = json_decode(Yii::app()->request->getParam('skill'));
  122. $age = intval(Yii::app()->request->getParam('age', 1));
  123. $address = Yii::app()->request->getParam('address', '');
  124. $tech = (Yii::app()->request->getParam('tech', ''));
  125. $desc = (Yii::app()->request->getParam('desc', ''));
  126. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  127. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  128. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  129. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  130. $store_id = intval(Yii::app()->request->getParam('store_id', ''));
  131. $h = new HouseKeeping();
  132. $h->store_id = $store_id;
  133. $h->user_name = $user_name;
  134. $h->user_id = $user_id;
  135. $h->mobile = $mobile;
  136. $h->type = $type;
  137. $h->cart = $cart;
  138. $h->address = $address;
  139. $h->server_start_time = $server_start_time;
  140. $h->server_end_time = $server_end_time;
  141. $h->skill = $skill;
  142. $h->yc_time = $yc_time;
  143. $h->age = $age;
  144. $h->desc = $desc;
  145. $h->status = 1;
  146. $h->status_time = $status_time;
  147. $h->tech = $tech;
  148. $h->contract = 1;
  149. $h->time = time();
  150. $result = $h->save();
  151. if ($result) {
  152. CommonFn::requestAjax($result, '添加成功', array());
  153. } else {
  154. CommonFn::requestAjax($result, '添加失败', array());
  155. }
  156. }
  157. public function actionAddUserInfo()
  158. {
  159. $user_id = Yii::app()->request->getParam('user_id','');
  160. if (empty($user_id) || !CommonFn::isMongoId($user_id)) {
  161. CommonFn::requestAjax(false, '添加失败1', array());
  162. }
  163. $mobile = Yii::app()->request->getParam('mobile','');
  164. $name = Yii::app()->request->getParam('name','');
  165. $user = RUser::get(new MongoId($user_id));
  166. $user->user_info = array('mobile' => $mobile,'name' => $name);
  167. if ($user->save()) {
  168. CommonFn::requestAjax(true, '添加成功', array());
  169. } else {
  170. CommonFn::requestAjax(false, '添加失败', array());
  171. }
  172. }
  173. }