| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <?php
- /**
- * Niushop商城系统 - 团队十年电商经验汇集巨献!
- * =========================================================
- * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
- * ----------------------------------------------
- * 官方网址: https://www.niushop.com
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
- * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
- * =========================================================
- */
- namespace addon\store\shopapi\controller;
- use addon\store\model\order\Order as OrderCommonModel;
- use app\model\order\OrderLog;
- /**
- * 订单控制器
- * Class Sysorder
- * @package addon\shop\siteapi\controller
- */
- class Order extends BaseStoreApi
- {
- /**
- * 列表
- * @return false|string
- */
- public function lists()
- {
- $order_common_model = new OrderCommonModel();
- $page = $this->params[ 'page' ] ?? 1;
- $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
- $search_text = $this->params[ 'search_text' ] ?? '';
- $order_status = $this->params[ 'order_status' ] ?? 'all';
- $start_time = $this->params[ 'start_time' ] ?? '';
- $end_time = $this->params[ 'end_time' ] ?? '';
- $trade_type = $this->params[ 'trade_type' ] ?? '';
- $order_from = $this->params[ 'order_from' ] ?? '';
- $pay_type = $this->params[ 'pay_type' ] ?? '';
- $condition = [
- [ 'site_id', '=', $this->site_id ],
- [ 'store_id', '=', $this->store_id ],
- [ 'is_delete', '=', 0 ],
- [ 'order_type', '=', 'o2o' ],
- ];
- //订单状态
- if ($order_status != 'all' && !empty($order_status)) {
- if ($order_status == $order_common_model::ORDER_REFUNDING) {
- $condition[] = [ 'is_exist_refund', '=', 1 ];
- } else {
- $condition[] = [ 'order_status', '=', $order_status ];
- }
- }
- //订单时间
- if (!empty($start_time) && empty($end_time)) {
- $condition[] = [ 'create_time', '>=', date_to_time($start_time) ];
- } elseif (empty($start_time) && !empty($end_time)) {
- $condition[] = [ 'create_time', '<=', date_to_time($end_time) ];
- } elseif (!empty($start_time) && !empty($end_time)) {
- $condition[] = [ 'create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
- }
- //订单内容
- if ($search_text != '') {
- $condition[] = [ 'order_no|out_trade_no|order_name|nickname', 'like', '%' . $search_text . '%' ];
- }
- //收货方式
- if ($trade_type != '') {
- $condition[] = [ 'trade_type', '=', $trade_type ];
- }
- //订单来源
- if ($order_from != '') {
- $condition[] = [ 'order_from', '=', $order_from ];
- }
- //订单支付
- if ($pay_type != '') {
- $condition[] = [ 'pay_type', '=', $pay_type ];
- }
- $order = 'create_time desc';
- $field = '*';
- $list = $order_common_model->getOrderPageList($condition, $page, $page_size, $order, $field);
- return $this->response($list);
- }
- /**
- * 获取支付方式
- */
- public function getOrderPayType()
- {
- $order_common_model = new OrderCommonModel();
- $pay_type_list = $order_common_model->getPayType('o2o');
- return $this->response($this->success($pay_type_list));
- }
- /**
- * 获取订单状态
- */
- public function getOrderStatus()
- {
- $trade_type = $this->params[ 'trade_type' ] ?? 'service';
- $order_common_model = new OrderCommonModel();
- $list = $order_common_model->getOrderStatusList([
- 'trade_type' => $trade_type,
- ]);
- return $this->response($this->success($list));
- }
- /**
- * 获取订单来源
- */
- public function getOrderFromType()
- {
- $order_common_model = new OrderCommonModel();
- $list = $order_common_model->getOrderFromList('o2o');
- return $this->response($this->success($list));
- }
- /**
- * 获取订单信息
- */
- public function info()
- {
- $order_id = $this->params[ 'order_id' ] ?? 0;
- //订单信息
- $order_common_model = new OrderCommonModel();
- $condition = array (
- [ 'order_id', '=', $order_id ],
- [ 'site_id', '=', $this->site_id ],
- [ 'store_id', '=', $this->store_id ],
- );
- $res = $order_common_model->getOrderInfo($condition)[ 'data' ];
- return $this->response($res);
- }
- /**
- * 订单详情
- */
- public function detail()
- {
- $order_id = $this->params[ 'order_id' ] ?? 0;
- //订单详情
- $order_common_model = new OrderCommonModel();
- $order_detail = $order_common_model->getOrderDetail($order_id, $this->site_id)[ 'data' ];
- if (empty($order_detail)) return $this->response($this->error(null, '无法获取订单数据'));
- //查询订单日志
- $order_log_model = new OrderLog();
- $log_condition = [
- [ 'order_id', '=', $order_id ],
- ];
- $order_detail[ 'order_log_list' ] = $order_log_model->getOrderLogList($log_condition, '*', 'action_time desc,id desc')[ 'data' ];
- return $this->response($this->success($order_detail));
- }
- /**
- * 卖家备注
- */
- public function orderRemark()
- {
- $order_id = $this->params[ 'order_id' ] ?? 0;
- $remark = $this->params[ 'remark' ] ?? '';
- $order_common_model = new OrderCommonModel();
- $data = array (
- "remark" => $remark,
- "order_id" => $order_id,
- "site_id" => $this->site_id,
- "uid" => $this->uid
- );
- $result = $order_common_model->orderUpdateRemark($data);
- return $this->response($result);
- }
- /**
- * 订单调价
- * @return mixed
- */
- public function adjustPrice()
- {
- $order_id = $this->params[ 'order_id' ] ?? 0;
- $adjust_money = $this->params[ 'adjust_money' ] ?? 0;
- $shipping_money = $this->params[ 'shipping_money' ] ?? 0;
- $order_common_model = new OrderCommonModel();
- $params = array (
- 'order_id' => $order_id,
- 'adjust_money' => $adjust_money,
- 'shipping_money' => $shipping_money,
- 'site_id' => $this->site_id,
- 'uid' => $this->uid
- );
- $result = $order_common_model->orderAdjustMoney($params);
- return $this->response($result);
- }
- /**
- * 订单关闭
- * @return mixed
- */
- public function close()
- {
- $order_id = $this->params[ 'order_id' ] ?? 0;
- $order_common_model = new OrderCommonModel();
- $order_close_params = array (
- 'order_id' => $order_id,
- 'site_id' => $this->site_id,
- 'uid' => $this->uid
- );
- $result = $order_common_model->orderClose($order_close_params);
- return $this->response($result);
- }
- /**
- * 订单删除
- */
- public function delete()
- {
- $order_id = $this->params[ 'order_id' ] ?? 0;
- $order_common_model = new OrderCommonModel();
- $result = $order_common_model->orderDelete($order_id, $this->site_id);
- return $this->response($result);
- }
- }
|