Order.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\giftcard\shop\controller;
  11. use addon\giftcard\model\card\Card as CardModel;
  12. use addon\giftcard\model\order\GiftCardOrder;
  13. use app\model\member\Member;
  14. use app\model\system\UserGroup;
  15. /**
  16. * 礼品卡订单控制器
  17. */
  18. class Order extends Giftcard
  19. {
  20. public function __construct()
  21. {
  22. parent::__construct();
  23. if (!request()->isAjax()) {
  24. $this->forthMenu();
  25. }
  26. $this->replace = [
  27. 'GIFTCARD_CSS' => __ROOT__ . '/addon/giftcard/shop/view/public/css',
  28. 'GIFTCARD_JS' => __ROOT__ . '/addon/giftcard/shop/view/public/js',
  29. 'GIFTCARD_IMG' => __ROOT__ . '/addon/giftcard/shop/view/public/img',
  30. 'GIFTCARD_CSV' => __ROOT__ . '/addon/giftcard/shop/view/public/csv',
  31. ];
  32. }
  33. /**
  34. * 订单列表
  35. * @return mixed
  36. */
  37. public function order()
  38. {
  39. $giftcard_id = input('giftcard_id', 0);
  40. $order_model = new GiftCardOrder();
  41. if (request()->isAjax()) {
  42. $page = input('page', 1);
  43. $page_size = input('page_size', PAGE_LIST_ROWS);
  44. $status = input('status', 'all');
  45. $start_time = input('start_time', '');
  46. $end_time = input('end_time', '');
  47. $nickname = input('nickname', '');
  48. $order_no = input('order_no', '');
  49. $card_right_type = input('card_right_type', '');
  50. $condition = array (
  51. [ 'o.site_id', '=', $this->site_id ],
  52. [ 'o.is_delete', '=', 0 ],
  53. [ 'o.order_status', '=', 'complete' ],
  54. );
  55. if ($giftcard_id > 0) {
  56. $condition[] = [ 'o.giftcard_id', '=', $giftcard_id ];
  57. }
  58. if (!empty($nickname)) {
  59. $condition[] = [ 'm.nickname', 'like', '%' . $nickname . '%' ];
  60. }
  61. if (!empty($card_right_type)) {
  62. $condition[] = [ 'o.card_right_type', '=', $card_right_type ];
  63. }
  64. if (!empty($order_no)) {
  65. $condition[] = [ 'o.order_no', '=', $order_no ];
  66. }
  67. //支付时间
  68. if (!empty($start_time) && empty($end_time)) {
  69. $condition[] = [ "o.pay_time", ">=", date_to_time($start_time) ];
  70. } elseif (empty($start_time) && !empty($end_time)) {
  71. $condition[] = [ "o.pay_time", "<=", date_to_time($end_time) ];
  72. } elseif (!empty($start_time) && !empty($end_time)) {
  73. $condition[] = [ 'o.pay_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
  74. }
  75. $order = 'o.create_time desc';
  76. $field = 'o.*, m.nickname,m.headimg,m.mobile';
  77. $join = [
  78. [ 'member m', 'o.member_id = m.member_id', 'left' ]
  79. ];
  80. $store_id_arr = [];
  81. $userGroupModel = new UserGroup();
  82. $userInfo = $this->user_info;
  83. $userGroupWhere['uid'] = $userInfo['uid'];
  84. $userGroupList = $userGroupModel->getUserList($userGroupWhere,'uid,store_id');
  85. $store_id_arr = array_column($userGroupList['data'],'store_id');
  86. if(!empty($store_id_arr) && !$userInfo['is_admin']){
  87. $mObj = new Member();
  88. $member_condition[] = [ "store_id", "in", $store_id_arr];
  89. $member_list = $mObj->getMemberList($member_condition,'member_id,nickname');
  90. $member_id_arr = array_column($member_list['data'],'member_id');
  91. $condition[] = [ "member_id", "in", $member_id_arr];
  92. }
  93. $list = $order_model->getOrderDetailPageList($condition, $page, $page_size, $order, $field, 'o', $join);
  94. return $list;
  95. }
  96. $this->assign('forth_menu', []);
  97. $this->assign('giftcard_id', $giftcard_id);
  98. return $this->fetch("order/order", [], $this->replace);
  99. }
  100. /**
  101. * 详情
  102. * @return mixed|void
  103. */
  104. public function detail()
  105. {
  106. $order_id = input('order_id', '');
  107. $order_model = new GiftCardOrder();
  108. $order_detail = $order_model->getOrderDetail([ 'site_id' => $this->site_id, 'order_id' => $order_id ])[ 'data' ] ?? [];
  109. $card_model = new CardModel();
  110. $card_list = $card_model->getCardList([ [ 'site_id', '=', $this->site_id ], [ 'order_id', '=', $order_detail[ 'order_id' ] ] ])[ 'data' ];
  111. foreach ($card_list as $k => $v) {
  112. $card_list[ $k ] = $card_model->tran($v);
  113. }
  114. $this->assign('order_detail', $order_detail);
  115. $this->assign('card_list', $card_list);
  116. return $this->fetch("order/detail", [], $this->replace);
  117. }
  118. }