Order.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Index.php
  4. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  5. * =========================================================
  6. * Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
  7. * ----------------------------------------------
  8. * 官方网址: https://www.niushop.com
  9. * =========================================================
  10. * @author : niuteam
  11. * @date : 2022.8.8
  12. * @version : v5.0.0.1
  13. */
  14. namespace addon\pinfan\api\controller;
  15. use addon\pinfan\model\PinfanOrder as PinfanOrderModel;
  16. use app\api\controller\BaseApi;
  17. /**
  18. * 拼团订单
  19. * @author Administrator
  20. *
  21. */
  22. class Order extends BaseApi
  23. {
  24. /**
  25. * 拼团订单详情
  26. * @return string
  27. */
  28. public function detail()
  29. {
  30. $token = $this->checkToken();
  31. if ($token[ 'code' ] < 0) return $this->response($token);
  32. $id = isset($this->params[ 'id' ]) ? $this->params[ 'id' ] : 0;//拼团订单主键id
  33. if (empty($id)) {
  34. return $this->response($this->error('', 'REQUEST_ID'));
  35. }
  36. $pinfan_order_model = new PinfanOrderModel();
  37. $res = $pinfan_order_model->getPinfanOrderDetail($id, $this->member_id, $this->site_id);
  38. return $this->response($res);
  39. }
  40. /**
  41. * 拼团列表
  42. * @return string
  43. */
  44. public function page()
  45. {
  46. $token = $this->checkToken();
  47. if ($token[ 'code' ] < 0) return $this->response($token);
  48. $pinfan_order_model = new PinfanOrderModel();
  49. $condition = array (
  50. [ "ppo.member_id", "=", $this->member_id ],
  51. [ "ppo.site_id", "=", $this->site_id ]
  52. );
  53. $pintuan_status = isset($this->params[ 'pintuan_status' ]) ? $this->params[ 'pintuan_status' ] : 'all';
  54. if ($pintuan_status != "all") {
  55. $condition[] = [ "ppg.status", "=", $pintuan_status ];
  56. } else {
  57. $condition[] = [ "ppg.status", "<>", "0" ];//不查询未支付的拼团
  58. }
  59. $page_index = isset($this->params[ 'page' ]) ? $this->params[ 'page' ] : 1;
  60. $page_size = isset($this->params[ 'page_size' ]) ? $this->params[ 'page_size' ] : PAGE_LIST_ROWS;
  61. $res = $pinfan_order_model->getPinfanOrderPageList($condition, $page_index, $page_size, "o.pay_time desc");
  62. if (!empty($res[ 'data' ][ 'list' ])) {
  63. foreach ($res[ 'data' ][ 'list' ] as $k => $v) {
  64. $member_list = $pinfan_order_model->getPinfanOrderList([ [ "group_id", "=", $v[ "group_id" ] ] ], "member_img,nickname");
  65. $res[ 'data' ][ 'list' ][ $k ][ 'member_list' ] = $member_list[ 'data' ];
  66. }
  67. }
  68. return $this->response($res);
  69. }
  70. }