O2oAppController.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * 微信企业号o2o应用控制器
  4. * 用于存放公共接口
  5. * @author 2015-12-10
  6. */
  7. class O2oAppController extends CController {
  8. public $layout = 'qyindex';
  9. public function actionIndex() {
  10. }
  11. /**
  12. * 获取普通订单详情接口
  13. */
  14. public function actionGetOrderInfo() {
  15. $id = Yii::app()->request->getParam('id', '');
  16. $user = intval(Yii::app()->request->getParam('user', 0));
  17. if ($id == '' || !CommonFn::isMongoId($id)) {
  18. O2oApp::response(false, '订单未录入', array());
  19. }
  20. $_id = new MongoId($id);
  21. $order = ROrder::get($_id);
  22. // if (!$order || $order->technician != $user) {
  23. if (!$order) {
  24. O2oApp::response(false, '未查询到订单', array());
  25. }
  26. $parsedOrder = $order->parseRow($order);
  27. O2oApp::response(true, '', $parsedOrder);
  28. }
  29. /**
  30. * 获取追加订单详情接口
  31. */
  32. public function actionGetAppendInfo() {
  33. $id = Yii::app()->request->getParam('id', '');
  34. if ($id == '' || !CommonFn::isMongoId($id)) {
  35. O2oApp::response(false, '订单未录入', array());
  36. }
  37. $_id = new MongoId($id);
  38. $append = AppendOrder::get($_id);
  39. if (!$append) {
  40. O2oApp::response(false, '未查询到订单', array());
  41. }
  42. $parsedAppend = $append->parseRow($append);
  43. O2oApp::response(true, '', $parsedAppend);
  44. }
  45. /**
  46. * 获取订单及评价详情接口
  47. */
  48. public function actionGetCommentInfo() {
  49. $id = Yii::app()->request->getParam('id', '');
  50. $user = intval(Yii::app()->request->getParam('user', 0));
  51. if ($id == '' || !CommonFn::isMongoId($id)) {
  52. O2oApp::response(false, '订单未录入', array());
  53. }
  54. $_id = new MongoId($id);
  55. $order = ROrder::get($_id);
  56. // if (!$order || $order->technician != $user) {
  57. if (!$order) {
  58. O2oApp::response(false, '未查询到订单', array());
  59. }
  60. // Comment信息
  61. $comment = Comment::getByOrder($_id);
  62. $parsedOrder = $order->parseRow($order);
  63. $parsedOrder['comment'] = $comment ? $comment->content : '';
  64. O2oApp::response(true, '', $parsedOrder);
  65. }
  66. }