Order.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\fenxiao\shop\controller;
  11. use addon\fenxiao\model\FenxiaoOrder;
  12. use app\shop\controller\BaseShop;
  13. /**
  14. * 分销订单
  15. */
  16. class Order extends BaseShop
  17. {
  18. protected $replace = []; //视图输出字符串内容替换 相当于配置文件中的'view_replace_str'
  19. public function __construct()
  20. {
  21. parent::__construct();
  22. $this->replace = [
  23. 'FENXIAO_JS' => __ROOT__ . '/addon/fenxiao/shop/view/public/js',
  24. 'FENXIAO_CSS' => __ROOT__ . '/addon/fenxiao/shop/view/public/css'
  25. ];
  26. }
  27. /**
  28. * 分销订单列表
  29. */
  30. public function lists()
  31. {
  32. if (request()->isAjax()) {
  33. $model = new FenxiaoOrder();
  34. $page_index = input('page', 1);
  35. $page_size = input('page_size', PAGE_LIST_ROWS);
  36. $status = input('status', 0);
  37. $condition = [ [ 'fo.site_id', '=', $this->site_id ] ];
  38. if ($status == 3) {
  39. $condition[] = [ 'fo.is_refund', '=', 1 ];
  40. }
  41. if (in_array($status, [ 1, 2 ])) {
  42. $condition[] = [ 'fo.is_settlement', '=', $status - 1 ];
  43. }
  44. $search_text_type = input('search_text_type', "sku_name");//商品名称/订单编号
  45. $search_text = input('search_text', "");
  46. if (!empty($search_text)) {
  47. $condition[] = [ 'fo.' . $search_text_type, 'like', '%' . $search_text . '%' ];
  48. }
  49. //下单时间
  50. $start_time = input('start_time', '');
  51. $end_time = input('end_time', '');
  52. if (!empty($start_time) && empty($end_time)) {
  53. $condition[] = [ 'fo.create_time', '>=', date_to_time($start_time) ];
  54. } elseif (empty($start_time) && !empty($end_time)) {
  55. $condition[] = [ 'fo.create_time', '<=', date_to_time($end_time) ];
  56. } elseif (!empty($start_time) && !empty(date_to_time($end_time))) {
  57. $condition[] = [ 'fo.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
  58. }
  59. $list = $model->getFenxiaoOrderPage($condition, $page_index, $page_size);
  60. return $list;
  61. } else {
  62. $this->forthMenu();
  63. //订单状态
  64. return $this->fetch('order/lists', [], $this->replace);
  65. }
  66. }
  67. public function detail()
  68. {
  69. $fenxiao_order_model = new FenxiaoOrder();
  70. $order_id = input('order_id', '');
  71. $order_info = $fenxiao_order_model->getFenxiaoOrderDetail([ [ 'order_id', '=', $order_id ] ]);
  72. if (empty($order_info[ 'data' ])) $this->error('未获取到订单数据', addon_url('fenxiao://shop/order/lists'));
  73. $this->assign('order_detail', $order_info[ 'data' ]);
  74. return $this->fetch('order/detail');
  75. }
  76. /**
  77. * 订单导出
  78. */
  79. public function exportorder()
  80. {
  81. $model = new FenxiaoOrder();
  82. $status = input('status', 0);
  83. $fenxiao_order_id = input('order_ids', "");
  84. $condition = [ [ 'fo.site_id', '=', $this->site_id ] ];
  85. if ($status == 3) {
  86. $condition[] = [ 'fo.is_refund', '=', 1 ];
  87. }
  88. if (in_array($status, [ 1, 2 ])) {
  89. $condition[] = [ 'fo.is_settlement', '=', $status - 1 ];
  90. }
  91. $search_text_type = input('search_text_type', "goods_name");//商品名称/订单编号
  92. $search_text = input('search_text', "");
  93. if (!empty($search_text)) {
  94. $condition[] = [ 'fo.' . $search_text_type, 'like', '%' . $search_text . '%' ];
  95. }
  96. //下单时间
  97. $start_time = input('start_time', '');
  98. $end_time = input('end_time', '');
  99. if (!empty($start_time) && empty($end_time)) {
  100. $condition[] = [ 'fo.create_time', '>=', date_to_time($start_time) ];
  101. } elseif (empty($start_time) && !empty($end_time)) {
  102. $condition[] = [ 'fo.create_time', '<=', date_to_time($end_time) ];
  103. } elseif (!empty($start_time) && !empty(date_to_time($end_time))) {
  104. $condition[] = [ 'fo.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
  105. }
  106. if ($fenxiao_order_id) {
  107. $condition = [];
  108. $condition[] = [ "fo.fenxiao_order_id", "in", $fenxiao_order_id ];
  109. }
  110. $model->orderExport($condition);
  111. return;
  112. }
  113. }