HouseKeepingController.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 = intval(Yii::app()->request->getParam('id'));
  14. $store_id = intval(Yii::app()->request->getParam('store_id'));
  15. $criteria = new EMongoCriteria();
  16. // id筛选
  17. if ($id) {
  18. $criteria->user_id('==', new MongoId($id));
  19. }
  20. $je = JEmploye::get(new MongoId($id));
  21. $criteria->store_id('==', $je->owned_stores);
  22. $cursor = HouseKeeping::model()->findAll($criteria);
  23. $rows = CommonFn::getRowsFromCursor($cursor);
  24. $parsedRows = HouseKeeping::model()->parse($rows);
  25. $total = $cursor->count();
  26. echo CommonFn::composeDatagridData($parsedRows, $total);
  27. }
  28. public function actionGetStore()
  29. {
  30. $c= new EMongoCriteria();
  31. $c->status('==',2);
  32. $tmp = Store::model()->findAll($c);
  33. $i = 0;
  34. $data = array();
  35. foreach ($tmp as $k => $v) {
  36. $data[$i]['store_id'] = $v->store_id;
  37. $data[$i++]['store_name'] = $v->store_name;
  38. }
  39. echo json_encode($data);
  40. }
  41. public function actionEdit()
  42. {
  43. $status = intval(Yii::app()->request->getParam('status', ''));
  44. $contract = intval(Yii::app()->request->getParam('contract', ''));
  45. $type = intval(Yii::app()->request->getParam('type', ''));
  46. $cart = intval(Yii::app()->request->getParam('cart', ''));
  47. $skill = intval(Yii::app()->request->getParam('skill', ''));
  48. $age = intval(Yii::app()->request->getParam('age', 0));
  49. $tech = (Yii::app()->request->getParam('tech', ''));
  50. $desc = (Yii::app()->request->getParam('desc', ''));
  51. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  52. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  53. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  54. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  55. $id = Yii::app()->request->getParam('id');
  56. if (!CommonFn::isMongoId($id)) {
  57. CommonFn::requestAjax(false, '修改失败', array());
  58. }
  59. $h = HouseKeeping::get(new MongoId($id));
  60. if (!empty($contract)) {
  61. $h->contract = $contract;
  62. }
  63. if (!empty($type)) {
  64. $h->type = $type;
  65. }
  66. if (!empty($cart)) {
  67. $h->cart = $cart;
  68. }
  69. if (!empty($skill)) {
  70. $h->skill = $skill;
  71. }
  72. if (!empty($age)) {
  73. $h->age = $age;
  74. }
  75. if (!empty($desc)) {
  76. $h->desc = $desc;
  77. }
  78. if (!empty($status)) {
  79. $h->status = $status;
  80. }
  81. if (!empty($status_time)) {
  82. $h->status_time = $status_time;
  83. }
  84. if (!empty($server_start_time)) {
  85. $h->server_start_time = $server_start_time;
  86. }
  87. if (!empty($server_end_time)) {
  88. $h->server_end_time = $server_end_time;
  89. }
  90. if (!empty($yc_time)) {
  91. $h->yc_time = $yc_time;
  92. }
  93. if (!empty($tech)) {
  94. $h->tech = $tech;
  95. }
  96. $success = $h->save();
  97. CommonFn::requestAjax($success, '修改成功', array());
  98. }
  99. public function actionAdd()
  100. {
  101. $mobile = (Yii::app()->request->getParam('mobile', ''));
  102. $user_name = (Yii::app()->request->getParam('user_name', ''));
  103. $user_id = (Yii::app()->request->getParam('user_id', ''));
  104. $type = intval(Yii::app()->request->getParam('type', 1));
  105. $cart = intval(Yii::app()->request->getParam('cart', 1));
  106. $skill = intval(Yii::app()->request->getParam('skill', 1));
  107. $age = intval(Yii::app()->request->getParam('age', 1));
  108. $address = Yii::app()->request->getParam('address', '');
  109. $tech = (Yii::app()->request->getParam('tech', ''));
  110. $desc = (Yii::app()->request->getParam('desc', ''));
  111. $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
  112. $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
  113. $status_time = intval(Yii::app()->request->getParam('status_time', ''));
  114. $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
  115. $store_id = intval(Yii::app()->request->getParam('store_id', ''));
  116. $h = new HouseKeeping();
  117. $h->store_id = $store_id;
  118. $h->user_name = $user_name;
  119. $h->user_id = $user_id;
  120. $h->mobile = $mobile;
  121. $h->type = $type;
  122. $h->cart = $cart;
  123. $h->address = $address;
  124. $h->server_start_time = $server_start_time;
  125. $h->server_end_time = $server_end_time;
  126. $h->skill = $skill;
  127. $h->yc_time = $yc_time;
  128. $h->age = $age;
  129. $h->desc = $desc;
  130. $h->status = 1;
  131. $h->status_time = $status_time;
  132. $h->tech = $tech;
  133. $h->contract = 1;
  134. $h->time = time();
  135. $result = $h->save();
  136. if ($result) {
  137. CommonFn::requestAjax($result, '添加成功', array());
  138. } else {
  139. CommonFn::requestAjax($result, '添加失败', array());
  140. }
  141. }
  142. }