HouseKeepingController.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. $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. $data[$i]['mobile'] = $v->mobile;
  51. $data[$i++]['address'] = $v->address;
  52. }
  53. echo json_encode($data);
  54. }
  55. public function actionEdit()
  56. {
  57. $status = intval(Yii::app()->request->getParam('status', ''));
  58. $contract = intval(Yii::app()->request->getParam('contract', ''));
  59. $type = intval(Yii::app()->request->getParam('type', ''));
  60. $cart = intval(Yii::app()->request->getParam('cart', ''));
  61. $skill = Yii::app()->request->getParam('skill', '');
  62. $age = intval(Yii::app()->request->getParam('age', 0));
  63. $tech = (Yii::app()->request->getParam('tech', ''));
  64. $desc = (Yii::app()->request->getParam('desc', ''));
  65. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  66. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  67. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  68. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  69. $id = Yii::app()->request->getParam('id');
  70. if (!CommonFn::isMongoId($id)) {
  71. CommonFn::requestAjax(false, '修改失败', array());
  72. }
  73. $h = HouseKeeping::get(new MongoId($id));
  74. if (!empty($contract)) {
  75. $h->contract = $contract;
  76. }
  77. if (!empty($type)) {
  78. $h->type = $type;
  79. }
  80. if (!empty($cart)) {
  81. $h->cart = $cart;
  82. }
  83. if (!empty($skill)) {
  84. $h->skill = $skill;
  85. }
  86. if (!empty($age)) {
  87. $h->age = $age;
  88. }
  89. if (!empty($desc)) {
  90. $h->desc = $desc;
  91. }
  92. if (!empty($status)) {
  93. $h->status = $status;
  94. }
  95. if (!empty($status_time)) {
  96. $h->status_time = $status_time;
  97. }
  98. if (!empty($server_start_time)) {
  99. $h->server_start_time = $server_start_time;
  100. }
  101. if (!empty($server_end_time)) {
  102. $h->server_end_time = $server_end_time;
  103. }
  104. if (!empty($yc_time)) {
  105. $h->yc_time = $yc_time;
  106. }
  107. if (!empty($tech)) {
  108. $h->tech = $tech;
  109. }
  110. $success = $h->save();
  111. CommonFn::requestAjax($success, '修改成功', array());
  112. }
  113. public function actionAdd()
  114. {
  115. $mobile = (Yii::app()->request->getParam('mobile', ''));
  116. $user_name = (Yii::app()->request->getParam('user_name', ''));
  117. $user_id = (Yii::app()->request->getParam('user_id', ''));
  118. $type = intval(Yii::app()->request->getParam('type', 1));
  119. $cart = intval(Yii::app()->request->getParam('cart', 1));
  120. $skill = json_decode(Yii::app()->request->getParam('skill'));
  121. $age = intval(Yii::app()->request->getParam('age', 1));
  122. $address = Yii::app()->request->getParam('address', '');
  123. $tech = (Yii::app()->request->getParam('tech', ''));
  124. $desc = (Yii::app()->request->getParam('desc', ''));
  125. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  126. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  127. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  128. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  129. $store_id = intval(Yii::app()->request->getParam('store_id', ''));
  130. $h = new HouseKeeping();
  131. $h->store_id = $store_id;
  132. $h->user_name = $user_name;
  133. $h->user_id = $user_id;
  134. $h->mobile = $mobile;
  135. $h->type = $type;
  136. $h->cart = $cart;
  137. $h->address = $address;
  138. $h->server_start_time = $server_start_time;
  139. $h->server_end_time = $server_end_time;
  140. $h->skill = $skill;
  141. $h->yc_time = $yc_time;
  142. $h->age = $age;
  143. $h->desc = $desc;
  144. $h->status = 1;
  145. $h->status_time = $status_time;
  146. $h->tech = $tech;
  147. $h->contract = 1;
  148. $h->time = time();
  149. $result = $h->save();
  150. if ($result) {
  151. CommonFn::requestAjax($result, '添加成功', array());
  152. } else {
  153. CommonFn::requestAjax($result, '添加失败', array());
  154. }
  155. }
  156. public function actionAddUserInfo()
  157. {
  158. $user_id = Yii::app()->request->getParam('user_id','');
  159. if (empty($user_id) || !CommonFn::isMongoId($user_id)) {
  160. CommonFn::requestAjax(false, '添加失败1', array());
  161. }
  162. $mobile = Yii::app()->request->getParam('mobile','');
  163. $name = Yii::app()->request->getParam('name','');
  164. $user = RUser::get(new MongoId($user_id));
  165. $user->user_info = array('mobile' => $mobile,'name' => $name);
  166. if ($user->save()) {
  167. CommonFn::requestAjax(true, '添加成功', array());
  168. } else {
  169. CommonFn::requestAjax(false, '添加失败', array());
  170. }
  171. }
  172. }