Pointexchange.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\Pointexchange\shop\controller;
  11. use addon\pointexchange\model\Order as ExchangeOrderModel;
  12. use app\shop\controller\BaseShop;
  13. /**
  14. * 兑换发放订单
  15. */
  16. class Pointexchange extends BaseShop
  17. {
  18. public function __construct()
  19. {
  20. parent::__construct();
  21. $this->replace = [
  22. 'POINTEXCHANGE_CSS' => __ROOT__ . '/addon/pointexchange/shop/view/public/css',
  23. 'POINTEXCHANGE_JS' => __ROOT__ . '/addon/pointexchange/shop/view/public/js',
  24. 'POINTEXCHANGE_IMG' => __ROOT__ . '/addon/pointexchange/shop/view/public/img',
  25. ];
  26. }
  27. /**
  28. * 兑换订单列表
  29. * @return mixed
  30. */
  31. public function lists()
  32. {
  33. $exchange_id = input('exchange_id', '');
  34. if (request()->isAjax()) {
  35. $page = input('page', 1);
  36. $page_size = input('page_size', PAGE_LIST_ROWS);
  37. $search_text = input('search_text', '');
  38. $condition = [];
  39. if ($search_text) {
  40. $condition[] = [ 'eo.exchange_name', 'like', '%' . $search_text . '%' ];
  41. }
  42. $name = input('name', '');
  43. if (!empty($name)) {
  44. $condition[] = [ 'm.nickname', 'like', '%' . $name . '%' ];
  45. }
  46. $mobile = input('mobile', '');
  47. if (!empty($mobile)) {
  48. $condition[] = [ 'eo.mobile', 'like', '%' . $mobile . '%' ];
  49. }
  50. $type = input('type', '');
  51. if ($type) {
  52. $condition[] = [ 'eo.type', '=', $type ];
  53. }
  54. if ($exchange_id) {
  55. $condition[] = [ 'eo.exchange_goods_id', '=', $exchange_id ];
  56. }
  57. $start_time = input('start_time', '');
  58. $end_time = input('end_time', '');
  59. if ($start_time && !$end_time) {
  60. $condition[] = [ 'eo.pay_time', '>=', date_to_time($start_time) ];
  61. } elseif (!$start_time && $end_time) {
  62. $condition[] = [ 'eo.pay_time', '<=', date_to_time($end_time) ];
  63. } elseif ($start_time && $end_time) {
  64. $condition[] = [ 'eo.pay_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
  65. }
  66. $order = 'eo.create_time desc';
  67. $field = 'eo.*,m.nickname';
  68. $exchange_order_model = new ExchangeOrderModel();
  69. return $exchange_order_model->getExchangePageList($condition, $page, $page_size, $order, $field, 'eo', [
  70. [ 'member m', 'm.member_id=eo.member_id', 'left' ]
  71. ]);
  72. } else {
  73. $this->assign('exchange_id', $exchange_id);
  74. return $this->fetch("exchange_order/lists", [], $this->replace);
  75. }
  76. }
  77. /**订单详情
  78. * @return mixed
  79. */
  80. public function detail()
  81. {
  82. $order_id = input('order_id', 0);
  83. $order_model = new ExchangeOrderModel();
  84. $order_info = $order_model->getOrderInfo([ [ 'site_id', '=', $this->site_id ], [ 'order_id', '=', $order_id ] ]);
  85. $order_info = $order_info[ "data" ];
  86. if (empty($order_info)) $this->error('未获取到订单数据', addon_url('pointexchange://shop/pointexchange/lists'));
  87. $this->assign("order_info", $order_info);
  88. return $this->fetch('exchange_order/detail');
  89. }
  90. }