HouseKeepingController.php 5.2 KB

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