Order.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\presale\shop\controller;
  13. use addon\presale\model\PresaleOrder;
  14. use addon\presale\model\PresaleOrderCommon;
  15. use app\shop\controller\BaseShop;
  16. use app\model\order\OrderCommon as OrderCommonModel;
  17. use think\facade\Config;
  18. /**
  19. * 预售订单
  20. */
  21. class Order extends BaseShop
  22. {
  23. /*
  24. * 订单列表
  25. */
  26. public function lists()
  27. {
  28. $presale_id = input('presale_id', 0);
  29. $presale_order_model = new PresaleOrder();
  30. $condition = [
  31. [ 'ppo.site_id', '=', $this->site_id ],
  32. // [ 'ppo.refund_status', '=', 0 ]
  33. ];
  34. if ($presale_id > 0) {
  35. $condition[] = [ 'ppo.presale_id', '=', $presale_id ];
  36. }
  37. //获取续签信息
  38. if (request()->isAjax()) {
  39. $page = input('page', 1);
  40. $page_size = input('page_size', PAGE_LIST_ROWS);
  41. //搜索类型(订单号、商品名称)
  42. $order_label = input('order_label', 'order_no');
  43. $search = input('search', '');
  44. if ($search) {
  45. $condition[] = [ 'ppo.' . $order_label, 'like', '%' . $search . '%' ];
  46. }
  47. //订单状态
  48. $order_status = input('order_status', '');
  49. if ($order_status !== '') {
  50. $condition[] = [ 'ppo.order_status', '=', $order_status ];
  51. }
  52. //订单来源
  53. $order_from = input("order_from", '');
  54. if ($order_from) {
  55. $condition[] = [ "ppo.order_from", "=", $order_from ];
  56. }
  57. //定金支付方式
  58. $deposit_pay_type = input("deposit_pay_type", '');
  59. if ($deposit_pay_type) {
  60. $condition[] = [ "ppo.deposit_pay_type", "=", $deposit_pay_type ];
  61. }
  62. //尾款支付方式
  63. $final_pay_type = input("final_pay_type", '');
  64. if ($final_pay_type) {
  65. $condition[] = [ "ppo.final_pay_type", "=", $final_pay_type ];
  66. }
  67. //订单类型
  68. $order_type = input('order_type', '');
  69. if ($order_type && $order_type != 'all') {
  70. $condition[] = [ "ppo.order_type", "=", $order_type ];
  71. }
  72. //创建时间
  73. $start_time = input('start_time', '');
  74. $end_time = input('end_time', '');
  75. if ($start_time && $end_time) {
  76. $condition[] = [ 'ppo.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
  77. } elseif (!$start_time && $end_time) {
  78. $condition[] = [ 'ppo.create_time', '<=', date_to_time($end_time) ];
  79. } elseif ($start_time && !$end_time) {
  80. $condition[] = [ 'ppo.create_time', '>=', date_to_time($start_time) ];
  81. }
  82. $list = $presale_order_model->getPresaleOrderPageList($condition, $page, $page_size, 'id desc');
  83. if (!empty($list[ 'data' ][ 'list' ])) {
  84. foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
  85. $action_array = json_decode($v[ 'order_status_action' ], true);
  86. $list[ 'data' ][ 'list' ][ $k ][ 'action' ] = $action_array[ 'action' ];
  87. if ($v[ 'pay_end_time' ] < time()) {
  88. $list[ 'data' ][ 'list' ][ $k ][ 'can_refund' ] = 1;
  89. } else {
  90. $list[ 'data' ][ 'list' ][ $k ][ 'can_refund' ] = 0;
  91. }
  92. }
  93. }
  94. return $list;
  95. } else {
  96. //搜索方式
  97. $order_label_list = array (
  98. "order_no" => "订单号",
  99. "goods_name" => "商品名称",
  100. "name" => "收货人姓名",
  101. "mobile" => "收货人手机号",
  102. );
  103. $this->assign('order_label_list', $order_label_list);
  104. //订单状态
  105. $order_model = new PresaleOrderCommon();
  106. $order_status_list = $order_model->order_status;
  107. $this->assign("order_status_list", $order_status_list);
  108. //订单来源 (支持端口)
  109. $order_from = Config::get("app_type");
  110. $this->assign('order_from_list', $order_from);
  111. $order_common_model = new OrderCommonModel();
  112. $order_type_list = $order_common_model->getOrderTypeStatusList();
  113. $this->assign("order_type_list", $order_type_list);
  114. $pay_type = $order_common_model->getPayType();
  115. $this->assign("pay_type_list", $pay_type);
  116. $this->assign('presale_id', $presale_id);
  117. $this->forthMenu();
  118. return $this->fetch("order/lists");
  119. }
  120. }
  121. /**
  122. * 订单详情
  123. * @return mixed
  124. */
  125. public function detail()
  126. {
  127. $presale_order_model = new PresaleOrder();
  128. $id = input('id', '');
  129. $condition = [
  130. [ 'site_id', '=', $this->site_id ],
  131. [ 'id', '=', $id ]
  132. ];
  133. $info = $presale_order_model->getPresaleOrderInfo($condition);
  134. if (empty($info[ 'data' ])) $this->error('未获取到订单数据', addon_url('presale://shop/order/lists'));
  135. $this->assign('order_detail', $info[ 'data' ]);
  136. return $this->fetch("order/detail");
  137. }
  138. /**
  139. * 关闭订单
  140. */
  141. public function close()
  142. {
  143. if (request()->isAjax()) {
  144. $id = input('order_id');
  145. $order_common_model = new PresaleOrderCommon();
  146. $condition = [
  147. [ 'id', '=', $id ],
  148. [ 'site_id', '=', $this->site_id ]
  149. ];
  150. $res = $order_common_model->depositOrderClose($condition);
  151. return $res;
  152. }
  153. }
  154. /**
  155. * 删除订单
  156. */
  157. public function deleteOrder()
  158. {
  159. if (request()->isAjax()) {
  160. $id = input('order_id');
  161. $order_common_model = new PresaleOrderCommon();
  162. $condition = [
  163. [ 'id', '=', $id ],
  164. [ 'site_id', '=', $this->site_id ]
  165. ];
  166. $res = $order_common_model->deleteOrder($condition);
  167. return $res;
  168. }
  169. }
  170. /**
  171. * 线下支付定金
  172. */
  173. public function offlinePayDeposit()
  174. {
  175. if (request()->isAjax()) {
  176. $id = input('order_id');
  177. $order_common_model = new PresaleOrderCommon();
  178. $res = $order_common_model->offlinePayDeposit($id, $this->site_id);
  179. return $res;
  180. }
  181. }
  182. /**
  183. * 线下支付尾款
  184. */
  185. public function offlinePayFinal()
  186. {
  187. if (request()->isAjax()) {
  188. $id = input('order_id');
  189. $order_common_model = new PresaleOrderCommon();
  190. $res = $order_common_model->offlinePayFinal($id, $this->site_id);
  191. return $res;
  192. }
  193. }
  194. }