Browse Source

餐饮订单

gorden 6 months ago
parent
commit
c56227c915

+ 40 - 22
app/admin/controller/order/RefundController.php

@@ -19,20 +19,20 @@ class RefundController extends Curd
     {
         $this->model = new OrderReturn();
         $this->validate = true;
-        $this->validateClass=new ReturnValidate();
+        $this->validateClass = new ReturnValidate();
     }
 
     public function select(Request $request): Response
     {
         [$where, $format, $limit, $field, $order] = $this->selectInput($request);
         $order = $request->get('order', 'desc');
-        $type = $request->get('type','');
+        $type = $request->get('type', '');
         $field = $field ?? 'order_return_addtimes';
         $where['order_return_category'] = '退款';
-        if ($type == 'today'){
+        if ($type == 'today') {
             $where['order_return_addtimes'] = [
-                strtotime(date('Y-m-d').' 00:00:00'),
-                strtotime(date('Y-m-d').' 23:59:59')
+                strtotime(date('Y-m-d') . ' 00:00:00'),
+                strtotime(date('Y-m-d') . ' 23:59:59')
             ];
         }
         $query = $this->doSelect($where, $field, $order);
@@ -45,8 +45,8 @@ class RefundController extends Curd
             'member' => function ($query) {
                 $query->select('member_id', 'member_mobile');
             },
-            'cert'=>function($query){
-                $query->select('join_cert_member_id','member_cert_name');
+            'cert' => function ($query) {
+                $query->select('join_cert_member_id', 'member_cert_name');
             },
             'order' => function ($query) {
                 $query->select('order_id', 'order_name');
@@ -89,13 +89,13 @@ class RefundController extends Curd
 
     public function afterQuery($items)
     {
-        foreach ($items as &$item){
-            if (!empty($item['order_return_apply_json']) && is_json($item['order_return_apply_json'])){
-                $json = json_decode($item['order_return_apply_json'],true);
+        foreach ($items as &$item) {
+            if (!empty($item['order_return_apply_json']) && is_json($item['order_return_apply_json'])) {
+                $json = json_decode($item['order_return_apply_json'], true);
                 $item['order_return_apply_json'] = $json['apply'] ?? '';
             }
-            if (!empty($item['order_return_recharge_json']) && is_json($item['order_return_recharge_json'])){
-                $json = json_decode($item['order_return_recharge_json'],true);
+            if (!empty($item['order_return_recharge_json']) && is_json($item['order_return_recharge_json'])) {
+                $json = json_decode($item['order_return_recharge_json'], true);
                 $item['order_return_recharge_json'] = $json['change'] ?? '';
             }
 
@@ -113,14 +113,14 @@ class RefundController extends Curd
         if (!$model) {
             throw new BusinessException('记录不存在', 2);
         }
-        if (empty($model->order_return_accept_datetimes) && $model->order_return_status == 'PENDING' && $data['order_return_status'] == 'DOING'){
+        if (empty($model->order_return_accept_datetimes) && $model->order_return_status == 'PENDING' && $data['order_return_status'] == 'DOING') {
             $data['order_return_accept_datetimes'] = date('Y-m-d H:i:s');
         }
-        if (!empty($data['order_return_apply_json'])){
-            $data['order_return_apply_json'] = json_encode(['apply'=>$data['order_return_apply_json']]);
+        if (!empty($data['order_return_apply_json'])) {
+            $data['order_return_apply_json'] = json_encode(['apply' => $data['order_return_apply_json']]);
         }
-        if (!empty($data['order_return_recharge_json'])){
-            $data['order_return_recharge_json'] = json_encode(['change'=>$data['order_return_recharge_json']]);
+        if (!empty($data['order_return_recharge_json'])) {
+            $data['order_return_recharge_json'] = json_encode(['change' => $data['order_return_recharge_json']]);
         }
 
         unset($data[$primary_key]);
@@ -175,13 +175,13 @@ class RefundController extends Curd
                 $item['goods']['components'] = $goodsArr;
             }
 
-            if (!empty($item['refund'])){
-                if (!empty($item['refund']['order_return_apply_json'])  && is_json($item['refund']['order_return_apply_json'])){
-                    $json = json_decode($item['refund']['order_return_apply_json'],true);
+            if (!empty($item['refund'])) {
+                if (!empty($item['refund']['order_return_apply_json']) && is_json($item['refund']['order_return_apply_json'])) {
+                    $json = json_decode($item['refund']['order_return_apply_json'], true);
                     $item['refund']['order_return_apply_json'] = $json['reason'] ?? '';
                 }
-                if (!empty($item['refund']['order_return_recharge_json'])  && is_json($item['refund']['order_return_recharge_json'])){
-                    $json = json_decode($item['refund']['order_return_recharge_json'],true);
+                if (!empty($item['refund']['order_return_recharge_json']) && is_json($item['refund']['order_return_recharge_json'])) {
+                    $json = json_decode($item['refund']['order_return_recharge_json'], true);
                     $item['refund']['order_return_recharge_json'] = $json['change'] ?? '';
                 }
             }
@@ -197,4 +197,22 @@ class RefundController extends Curd
 
         return json_success('', $data);
     }
+
+    public function customRefund(Request $request)
+    {
+        $orderId = $request->post('order_id','');
+        $orderId = $request->post('order_id', '');
+        $amount = $request->post('refund_amount', 0);
+        $password = $request->post('refund_password', '');
+        if (!$orderId || !$amount || !$password) {
+            return json_fail('参数异常');
+        }
+        if ($password != '123456') {
+            return json_fail('支付密码错误');
+        }
+        $order = Order::where('order_id',$orderId)->where('order_status_payment','SUCCESS')->first();
+        if (!$order){
+            return json_fail("订单异常");
+        }
+    }
 }

+ 6 - 4
app/admin/controller/order/WholeController.php

@@ -1964,10 +1964,13 @@ class WholeController extends Curd
                 }
                 $params['submit_premises_id'] = $premises->dept_id;
             }
-            if (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS' && !empty($params['dept_table_id'])) {
-                $table = SysDept::where('dept_id', $params['dept_table_id'])->where('dept_category', '桌台')->first();
+            if (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS' && !empty($params['dept_premises_id'])) {
+                $table = '';
+                if (!empty($params['dept_table_id'])){
+                    $table = SysDept::where('dept_id', $params['dept_table_id'])->where('dept_category', '桌台')->first();
+                }
                 $orderConfigJson['premises'] = $params['dept_premises_id'];
-                $orderConfigJson['dept'] = $premises->dept_id;
+                $orderConfigJson['dept'] = $premises->dept_id ?? 0;
                 $orderConfigJson['reach'] = "00:00";
                 $orderConfigJson['table'] = !empty($table) ? $table->dept_name : null;
                 $orderConfigJson['express'] = "到店吃";
@@ -3545,7 +3548,6 @@ class WholeController extends Curd
     public function doRefund(Request $request)
     {
         $orderId = $request->post('order_id', '');
-        // $returnId = $request->post('return_id', '');
         $amount = $request->post('refund_amount', 0);
         $password = $request->post('refund_password', '');
         if (!$orderId || !$amount || !$password) {