HouseKeepingController.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. $cancel_cause = Yii::app()->request->getParam('cancel_cause','');
  78. if (!CommonFn::isMongoId($id)) {
  79. CommonFn::requestAjax(false, '修改失败', array());
  80. }
  81. $h = HouseKeeping::get(new MongoId($id));
  82. if (!empty($contract)) {
  83. $h->contract = $contract;
  84. }
  85. if (!empty($type)) {
  86. $h->type = $type;
  87. }
  88. if (!empty($cart)) {
  89. $h->cart = $cart;
  90. }
  91. if (!empty($skill)) {
  92. $h->skill = $skill;
  93. }
  94. if (!empty($age)) {
  95. $h->age = $age;
  96. }
  97. if (!empty($desc)) {
  98. $h->desc = $desc;
  99. }
  100. if (!empty($status)) {
  101. $h->status = $status;
  102. if (intval($status) == 4) {
  103. if (!empty($cancel_cause)) {
  104. $h->cancel_cause = $cancel_cause;
  105. }
  106. }
  107. }
  108. if (!empty($status_time)) {
  109. $h->status_time = $status_time;
  110. }
  111. if (!empty($server_start_time)) {
  112. $h->server_start_time = $server_start_time;
  113. }
  114. if (!empty($server_end_time)) {
  115. $h->server_end_time = $server_end_time;
  116. }
  117. if (!empty($yc_time)) {
  118. $h->yc_time = $yc_time;
  119. }
  120. if (!empty($tech)) {
  121. $h->tech = $tech;
  122. }
  123. if (!empty($tech_mobile)) {
  124. $h->tech_mobile = $tech_mobile;
  125. }
  126. $success = $h->save();
  127. if ($success && intval($h->status) == 2) {//status_time
  128. $c = new EMongoCriteria();
  129. $c->store_id('==',$h->store_id);
  130. $store = Store::model()->find($c);
  131. CommonSMS::send('jinguo_order_retrieve', array(
  132. 'user_name' => $h->user_name,
  133. 'year' => date('Y',$h->status_time),
  134. 'month' => date('m',$h->status_time),
  135. 'day' => date('d',$h->status_time),
  136. 'hour' => date('H',$h->status_time),
  137. 'minute' => date('i',$h->status_time),
  138. 'Interviewt' => '面试',
  139. 'store' => $store->store_name,
  140. 'address' => $store->address,
  141. 'phone' => $store->mobile,
  142. 'mobile' => $h->mobile,
  143. ));
  144. }
  145. CommonFn::requestAjax($success, '修改成功', array());
  146. }
  147. public function actionFlag()
  148. {
  149. $id = Yii::app()->request->getParam('id');
  150. if (!CommonFn::isMongoId($id)) {
  151. CommonFn::requestAjax(false, '修改失败', array());
  152. }
  153. $h = HouseKeeping::get(new MongoId($id));
  154. $h->flag = 1;
  155. $success = $h->save();
  156. CommonFn::requestAjax($success, '修改成功', array());
  157. }
  158. public function actionAdd()
  159. {
  160. $mobile = (Yii::app()->request->getParam('mobile', ''));
  161. $user_name = (Yii::app()->request->getParam('user_name', ''));
  162. $user_id = (Yii::app()->request->getParam('user_id', ''));
  163. $type = intval(Yii::app()->request->getParam('type', 1));
  164. $cart = intval(Yii::app()->request->getParam('cart', 1));
  165. $skill = json_decode(Yii::app()->request->getParam('skill'));
  166. $age = intval(Yii::app()->request->getParam('age', 1));
  167. $address = Yii::app()->request->getParam('address', '');
  168. $tech = (Yii::app()->request->getParam('tech', ''));
  169. $desc = (Yii::app()->request->getParam('desc', ''));
  170. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  171. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  172. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  173. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  174. $store_id = intval(Yii::app()->request->getParam('store_id', ''));
  175. $h = new HouseKeeping();
  176. $h->store_id = $store_id;
  177. $h->user_name = $user_name;
  178. $h->user_id = $user_id;
  179. $h->mobile = $mobile;
  180. $h->type = $type;
  181. $h->cart = $cart;
  182. $h->address = $address;
  183. $h->server_start_time = $server_start_time;
  184. $h->server_end_time = $server_end_time;
  185. $h->skill = $skill;
  186. $h->yc_time = $yc_time;
  187. $h->age = $age;
  188. $h->desc = $desc;
  189. $h->status = 1;
  190. $h->status_time = $status_time;
  191. $h->tech = $tech;
  192. $h->contract = 1;
  193. $h->flag = 0;
  194. $h->time = time();
  195. $result = $h->save();
  196. if ($result) {
  197. CommonFn::requestAjax($result, '添加成功', array());
  198. } else {
  199. CommonFn::requestAjax($result, '添加失败', array());
  200. }
  201. }
  202. public function actionAddUserInfo()
  203. {
  204. $user_id = Yii::app()->request->getParam('user_id','');
  205. if (empty($user_id) || !CommonFn::isMongoId($user_id)) {
  206. CommonFn::requestAjax(false, '添加失败1', array());
  207. }
  208. $mobile = Yii::app()->request->getParam('mobile','');
  209. $name = Yii::app()->request->getParam('name','');
  210. $user = RUser::get(new MongoId($user_id));
  211. $user->user_info = array('mobile' => $mobile,'name' => $name);
  212. if ($user->save()) {
  213. CommonFn::requestAjax(true, '添加成功', array());
  214. } else {
  215. CommonFn::requestAjax(false, '添加失败', array());
  216. }
  217. }
  218. }