HouseKeepingController.php 9.7 KB

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