HouseKeepingController.php 9.8 KB

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