HouseKeepingController.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. if (empty($tmp) ) {
  38. $data['user_id'] = '';
  39. $data['store_id'] = '';
  40. echo json_encode($data);exit;
  41. }
  42. $data['user_id'] = $tmp->user_id;
  43. $data['store_id'] = $tmp->owned_stores;
  44. echo json_encode($data);
  45. }
  46. public function actionGetStore()
  47. {
  48. $c= new EMongoCriteria();
  49. $c->status('==',2);
  50. $tmp = Store::model()->findAll($c);
  51. $i = 0;
  52. $data = array();
  53. foreach ($tmp as $k => $v) {
  54. $data[$i]['store_id'] = $v->store_id;
  55. $data[$i]['store_name'] = $v->store_name;
  56. $data[$i]['mobile'] = $v->mobile;
  57. $data[$i++]['address'] = $v->address;
  58. }
  59. echo json_encode($data);
  60. }
  61. public function actionEdit()
  62. {
  63. $status = intval(Yii::app()->request->getParam('status', ''));
  64. $contract = intval(Yii::app()->request->getParam('contract', ''));
  65. $type = intval(Yii::app()->request->getParam('type', ''));
  66. $cart = intval(Yii::app()->request->getParam('cart', ''));
  67. $skill = Yii::app()->request->getParam('skill', '');
  68. $age = intval(Yii::app()->request->getParam('age', 0));
  69. $tech = (Yii::app()->request->getParam('tech', ''));
  70. $tech_mobile = (Yii::app()->request->getParam('tech_mobile', ''));
  71. $desc = (Yii::app()->request->getParam('desc', ''));
  72. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  73. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  74. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  75. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  76. $id = Yii::app()->request->getParam('id');
  77. if (!CommonFn::isMongoId($id)) {
  78. CommonFn::requestAjax(false, '修改失败', array());
  79. }
  80. $h = HouseKeeping::get(new MongoId($id));
  81. if (!empty($contract)) {
  82. $h->contract = $contract;
  83. }
  84. if (!empty($type)) {
  85. $h->type = $type;
  86. }
  87. if (!empty($cart)) {
  88. $h->cart = $cart;
  89. }
  90. if (!empty($skill)) {
  91. $h->skill = $skill;
  92. }
  93. if (!empty($age)) {
  94. $h->age = $age;
  95. }
  96. if (!empty($desc)) {
  97. $h->desc = $desc;
  98. }
  99. if (!empty($status)) {
  100. $h->status = $status;
  101. }
  102. if (!empty($status_time)) {
  103. $h->status_time = $status_time;
  104. }
  105. if (!empty($server_start_time)) {
  106. $h->server_start_time = $server_start_time;
  107. }
  108. if (!empty($server_end_time)) {
  109. $h->server_end_time = $server_end_time;
  110. }
  111. if (!empty($yc_time)) {
  112. $h->yc_time = $yc_time;
  113. }
  114. if (!empty($tech)) {
  115. $h->tech = $tech;
  116. }
  117. if (!empty($tech_mobile)) {
  118. $h->tech_mobile = $tech_mobile;
  119. }
  120. $success = $h->save();
  121. if ($success && intval($h->status) == 2) {//status_time
  122. $c = new EMongoCriteria();
  123. $c->store_id('==',$h->store_id);
  124. $store = Store::model()->find($c);
  125. CommonSMS::send('jinguo_order_retrieve', array(
  126. 'user_name' => $h->user_name,
  127. 'year' => date('Y',$h->status_time),
  128. 'month' => date('m',$h->status_time),
  129. 'day' => date('d',$h->status_time),
  130. 'hour' => date('H',$h->status_time),
  131. 'minute' => date('i',$h->status_time),
  132. 'Interviewt' => '面试',
  133. 'store' => $store->store_name,
  134. 'address' => $store->address,
  135. 'phone' => $store->mobile,
  136. 'mobile' => $h->mobile,
  137. ));
  138. }
  139. CommonFn::requestAjax($success, '修改成功', array());
  140. }
  141. public function actionFlag()
  142. {
  143. $id = Yii::app()->request->getParam('id');
  144. if (!CommonFn::isMongoId($id)) {
  145. CommonFn::requestAjax(false, '修改失败', array());
  146. }
  147. $h = HouseKeeping::get(new MongoId($id));
  148. $h->flag = 1;
  149. $success = $h->save();
  150. CommonFn::requestAjax($success, '修改成功', array());
  151. }
  152. public function actionAdd()
  153. {
  154. $mobile = (Yii::app()->request->getParam('mobile', ''));
  155. $user_name = (Yii::app()->request->getParam('user_name', ''));
  156. $user_id = (Yii::app()->request->getParam('user_id', ''));
  157. $type = intval(Yii::app()->request->getParam('type', 1));
  158. $cart = intval(Yii::app()->request->getParam('cart', 1));
  159. $skill = json_decode(Yii::app()->request->getParam('skill'));
  160. $age = intval(Yii::app()->request->getParam('age', 1));
  161. $address = Yii::app()->request->getParam('address', '');
  162. $tech = (Yii::app()->request->getParam('tech', ''));
  163. $desc = (Yii::app()->request->getParam('desc', ''));
  164. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  165. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  166. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  167. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  168. $store_id = intval(Yii::app()->request->getParam('store_id', ''));
  169. $h = new HouseKeeping();
  170. $h->store_id = $store_id;
  171. $h->user_name = $user_name;
  172. $h->user_id = $user_id;
  173. $h->mobile = $mobile;
  174. $h->type = $type;
  175. $h->cart = $cart;
  176. $h->address = $address;
  177. $h->server_start_time = $server_start_time;
  178. $h->server_end_time = $server_end_time;
  179. $h->skill = $skill;
  180. $h->yc_time = $yc_time;
  181. $h->age = $age;
  182. $h->desc = $desc;
  183. $h->status = 1;
  184. $h->status_time = $status_time;
  185. $h->tech = $tech;
  186. $h->contract = 1;
  187. $h->flag = 0;
  188. $h->time = time();
  189. $result = $h->save();
  190. if ($result) {
  191. CommonFn::requestAjax($result, '添加成功', array());
  192. } else {
  193. CommonFn::requestAjax($result, '添加失败', array());
  194. }
  195. }
  196. public function actionAddUserInfo()
  197. {
  198. $user_id = Yii::app()->request->getParam('user_id','');
  199. if (empty($user_id) || !CommonFn::isMongoId($user_id)) {
  200. CommonFn::requestAjax(false, '添加失败1', array());
  201. }
  202. $mobile = Yii::app()->request->getParam('mobile','');
  203. $name = Yii::app()->request->getParam('name','');
  204. $user = RUser::get(new MongoId($user_id));
  205. $user->user_info = array('mobile' => $mobile,'name' => $name);
  206. if ($user->save()) {
  207. CommonFn::requestAjax(true, '添加成功', array());
  208. } else {
  209. CommonFn::requestAjax(false, '添加失败', array());
  210. }
  211. }
  212. }