123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <?php
-
- namespace app\api\controller;
-
- use app\api\logic\OrderInvoiceLogic;
- use app\api\logic\OrderLogic;
- use app\api\validate\OrderValidate;
- use app\common\basics\Api;
- use app\common\server\JsonServer;
- use app\common\server\WechatMiniExpressSendSyncServer;
-
-
- class Order extends Api
- {
-
-
- public function submitOrder()
- {
- $post = $this->request->post();
- $post['user_id'] = $this->user_id;
- $post['client'] = $this->client;
- (new OrderValidate())->goCheck('add', $post);
- $order = OrderLogic::add($post);
- if (false === $order) {
- return JsonServer::error(OrderLogic::getError());
- }
- return JsonServer::success('下单成功!', $order);
- }
-
-
-
- public function settlement()
- {
- $post = $this->request->post();
- $post['user_id'] = $this->user_id;
- $post['client'] = $this->client;
- $result = OrderLogic::settlement($post);
- if($result === false) {
- return JsonServer::error(OrderLogic::getError(), [], 301);
- }
- return JsonServer::success('获取成功', $result);
- }
-
-
-
-
- public function lists()
- {
- $type = $this->request->get('type', 'all');
- $order_list = OrderLogic::getOrderList($this->user_id, $type, $this->page_no, $this->page_size);
- return JsonServer::success('获取成功', $order_list);
- }
-
-
-
- public function getOrderDetail()
- {
- $get = $this->request->get();
- (new OrderValidate())->goCheck('detail', $get);
- $detail = OrderLogic::getOrderDetail($get['id']);
- return JsonServer::success('获取成功', $detail);
- }
-
-
-
- function wxReceiveDetail()
- {
- return JsonServer::success('获取成功', OrderLogic::wxReceiveDetail(input('order_id/d'), $this->user_id));
- }
-
-
-
- public function cancel()
- {
- $order_id = $this->request->post('id');
- if (empty($order_id)) {
- return JsonServer::error('参数错误');
- }
- return OrderLogic::cancel($order_id, $this->user_id);
- }
-
-
-
- public function confirm()
- {
- $order_id = $this->request->post('id');
- if (empty($order_id)) {
- return JsonServer::error('参数错误');
- }
- return OrderLogic::confirm($order_id, $this->user_id);
- }
-
-
-
- public function del()
- {
- $order_id = $this->request->post('id');
- if (empty($order_id)) {
- return JsonServer::error('参数错误');
- }
- return OrderLogic::del($order_id, $this->user_id);
- }
-
-
-
- public function pay_result()
- {
- $id = $this->request->get('id');
- $from = $this->request->get('from');
- $result = OrderLogic::pay_result($id,$from);
- if ($result !== false) {
- return JsonServer::success('', $result);
- } else {
- return JsonServer::error('参数错误');
- }
- }
-
-
-
- public function getPayWay()
- {
- $params = $this->request->get();
- if(!isset($params['from']) || !isset($params['order_id'])) {
- return JsonServer::error('参数缺失');
- }
- $pay_way = OrderLogic::getPayWay($this->user_id, $this->client, $params);
- return JsonServer::success('', $pay_way);
- }
-
-
-
- public function orderTraces()
- {
- $order_id = $this->request->get('id');
- $tips = '参数错误';
- if ($order_id) {
- $traces = OrderLogic::orderTraces($order_id, $this->user_id);
- if ($traces) {
- return JsonServer::success('获取成功', $traces);
- }
- $tips = '暂无物流信息';
- }
- return JsonServer::error($tips);
- }
-
-
-
- public function getPayStatus()
- {
- $id = $this->request->get('id');
- $from = $this->request->get('from');
- $result = OrderLogic::getPayStatus($id,$from);
- if ($result !== false) {
- return JsonServer::success('', $result);
- } else {
- return JsonServer::error('参数错误');
- }
- }
-
-
-
-
-
- public function invoice()
- {
- $id = $this->request->get('id');
- $result = OrderInvoiceLogic::getInvoiceDetailByOrderId($id);
- return JsonServer::success('获取成功', $result);
- }
-
-
-
- function wechatSyncCheck()
- {
- $id = $this->request->get('id');
-
- $order = \app\common\model\order\Order::where('id', $id)->where('user_id', $this->user_id)->findOrEmpty();
-
- $result = WechatMiniExpressSendSyncServer::wechatSyncCheck($order);
-
- if (! $result) {
- return JsonServer::error('获取失败');
- }
-
- return JsonServer::success('成功', $result);
- }
-
- }
|