gorden 7 mēneši atpakaļ
vecāks
revīzija
f6ea099dc2

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

@@ -1107,7 +1107,7 @@ class WholeController extends Curd
                     $deptExtendJson = json_decode($restaurant->dept_extend_json,true);
                     if (isset($deptExtendJson['printer'])){
                         foreach($deptExtendJson['printer'] as $key => $item){
-                            if (strpos($key,'结') !== false && $order->order_status_payment == 'SUCCESS'){
+                            if (strpos($key,'结') !== false && $order->order_status_payment == 'SUCCESS'){
                                 $voteData = [
                                     'func'=>'procActionToPrinter',
                                     'sign'=>'',
@@ -1680,7 +1680,7 @@ class WholeController extends Curd
                     $deptExtendJson = json_decode($restaurant->dept_extend_json,true);
                     if (isset($deptExtendJson['printer'])){
                         foreach($deptExtendJson['printer'] as $key => $item){
-                            if (strpos($key,'结') !== false && $params['order_status_payment'] == 'SUCCESS'){
+                            if (strpos($key,'结') !== false && $params['order_status_payment'] == 'SUCCESS'){
                                 $voteData = [
                                     'func'=>'procActionToPrinter',
                                     'sign'=>'',
@@ -1691,7 +1691,8 @@ class WholeController extends Curd
                                         ],
                                         'printer_action'=>'ExecPrintOrder',
                                         'printer_data'=>[
-                                            'order_id'=>$params['orderId']
+                                            'order_id'=>$params['orderId'],
+                                            'order_batch'=>''
                                         ]
                                     ]
                                 ];
@@ -1707,7 +1708,8 @@ class WholeController extends Curd
                                         ],
                                         'printer_action'=>'ExecPrintOrder',
                                         'printer_data'=>[
-                                            'order_id'=>$params['orderId']
+                                            'order_id'=>$params['orderId'],
+                                            'order_batch'=>''
                                         ]
                                     ]
                                 ];
@@ -1992,7 +1994,13 @@ class WholeController extends Curd
         try{
             $order = Order::where('order_id',$params['order_id'])->first();
             $payDetail = PayDetail::where('join_pay_order_id',$order->order_groupby)->first();
-            $sheet = OrderSheet::where('join_sheet_order_id',$params['order_id'])->first();
+            $sheet = OrderSheet::where('join_sheet_order_id',$params['order_id'])->orderBy('order_sheet_addtimes','DESC')->first();
+            $sheetComponentJson = [];
+            if (!empty($sheet->order_sheet_component_json)){
+                $sheetComponentJson = json_decode($sheet->order_sheet_component_json,true);
+            }
+            $sheetComponentJson['order_batch'] = date('YmdHis');
+
             foreach($params['goodsContentList'] as $goods){
                 //{"unit": "份", "table": null, "premises": "15"}
                 $price = floatval($goods['goods_sales_price']);
@@ -2009,6 +2017,7 @@ class WholeController extends Curd
                     'order_sheet_pay' => $price * $goods['nbr'],
                     'order_sheet_task_status' => 'NONE',
                     'order_sheet_remark' => $params['order_remark'] ?? '',
+                    'order_sheet_component_json' => json_encode($sheetComponentJson),
                     'order_sheet_addtimes' => time(),
                     'order_sheet_extend_json'=>$sheet->order_sheet_extend_json ?? '[]'
                 ];
@@ -2040,7 +2049,42 @@ class WholeController extends Curd
             }
 
             Db::commit();
+
+            // 打小票
+            $restaurant = SysDept::where('dept_name',$params['dept_premises_id'])->where('dept_category','餐厅')->where('dept_status','ACTIVED')->first();
+            if (!empty($restaurant) && !empty($restaurant->dept_extend_json)){
+                $deptExtendJson = json_decode($restaurant->dept_extend_json,true);
+                if (isset($deptExtendJson['printer'])){
+                    foreach($deptExtendJson['printer'] as $key => $item){
+                        if ((strpos($key,'前台') !== false || strpos($key,'后厨') !== false)){
+                            $voteData = [
+                                'func'=>'procActionToPrinter',
+                                'sign'=>'',
+                                'data'=>[
+                                    'printer_premises'=>$restaurant->dept_id,
+                                    'printer_device'=>[
+                                        $key
+                                    ],
+                                    'printer_action'=>'ExecPrintOrder',
+                                    'printer_data'=>[
+                                        'order_id'=>$params['order_id'],
+                                        'order_batch'=>$sheetComponentJson['order_batch']
+                                    ]
+                                ]
+                            ];
+                            $result = json_decode(http_post_json(getenv('VOTE_MENU_URL'),$voteData),true);
+                            if ($result['success'] == false){
+                                // throw new BusinessException("加菜成功,小票打印失败,请在订单中心手动打印");
+                            }
+                        }
+                    }
+                }
+            }
+
             return json_success('加菜成功');
+        }catch(BusinessException $e){
+            
+            return json_fail($e->getMessage());
         }catch(\Exception $e){
             Db::rollBack();
             dump($e->getMessage());
@@ -2938,7 +2982,7 @@ class WholeController extends Curd
 
         try {
             foreach($printer as $print){
-                if (strpos($print,'结') !== false && $order->order_status_payment != 'SUCCESS'){
+                if (strpos($print,'结') !== false && $order->order_status_payment != 'SUCCESS'){
                     return json_fail('无法打印未支付的结账单');
                 }
 

+ 5 - 5
app/admin/controller/sms/SmsController.php

@@ -51,7 +51,7 @@ class SmsController
             Redis::expire($key, 600);
 
             Sms::app()->send($mobile, [
-                'template' => 'SMS_240865706',
+                'template' => 'SMS_469030007',
                 'data' => [
                     'code' => $code
                 ],
@@ -96,7 +96,7 @@ class SmsController
             Redis::expire($key, 600);
 
             Sms::app()->send($mobile, [
-                'template' => 'SMS_240865706',
+                'template' => 'SMS_469030007',
                 'data' => [
                     'code' => $code
                 ],
@@ -126,7 +126,7 @@ class SmsController
             Redis::expire($key, 600);
 
             Sms::app()->send($mobile, [
-                'template' => 'SMS_240865706',
+                'template' => 'SMS_469030007',
                 'data' => [
                     'code' => $code
                 ],
@@ -155,7 +155,7 @@ class SmsController
             Redis::expire($key, 600);
 
             Sms::app()->send($mobile, [
-                'template' => 'SMS_240865706',
+                'template' => 'SMS_469030007',
                 'data' => [
                     'code' => $code
                 ],
@@ -187,7 +187,7 @@ class SmsController
             Redis::expire($key, 600);
 
             Sms::app()->send($mobile, [
-                'template' => 'SMS_240865706',
+                'template' => 'SMS_469030007',
                 'data' => [
                     'code' => $code
                 ],

+ 2 - 2
app/admin/controller/sys_manage/RestaurantTableController.php

@@ -356,13 +356,13 @@ class RestaurantTableController extends Curd
                 $restaurant = SysDept::where('dept_super_id', $premise->dept_id)->where('dept_category', '餐厅')->where('dept_status', 'ACTIVED')->first();
             }
 
-            $tables = SysDept::where('dept_super_id', $restaurant->dept_id)->where('dept_category', '桌台')->get()->toArray();
+            $tables = SysDept::where('dept_super_id', $restaurant->dept_id)->where('dept_category', '桌台')->orderBy('dept_status','ASC')->get()->toArray();
 
             foreach ($tables as $table) {
                 $tableList[] = [
                     'key' => $table['dept_id'],
                     'label' => $table['dept_name'],
-                    'disabled' => $table['dept_status'] == 'ACTIVED' ? false : true
+                    'disabled' => $table['dept_status'] == 'ACTIVED' ? false : true,
                 ];
             }
 

+ 19 - 2
app/admin/service/goods/GoodsService.php

@@ -11,6 +11,7 @@ use app\model\GoodsLabel;
 use app\model\GoodsRunning;
 use app\model\GoodsSku;
 use app\model\OrderSheet;
+use app\model\Supplier;
 use app\model\SysCategory;
 use app\model\SysDept;
 use app\model\SysSerial;
@@ -519,6 +520,7 @@ class GoodsService
         $categoryIds = $request->get('category_id','');
         $categorySuperId = $request->get('category_super_id','');
         $joinGoodsCategoryId = $request->get('join_goods_category_id','');
+        $type = $request->get('type','');
         if (!$categoryIds && !$categorySuperId && !$joinGoodsCategoryId){
             return json_fail('参数异常');
         }
@@ -561,8 +563,23 @@ class GoodsService
         }
         $goods = Goods::with('sku')
             ->whereIn('join_goods_category_id',$goodsCategoryIds)
-            ->where('goods_status','ON')
-            ->select('goods_id','goods_id as id','goods_name as name','join_goods_category_id as pid','goods_attribute_json','goods_classify','goods_sales_price','goods_cover')
+            ->where('goods_status','ON');
+
+        if ($type == 'dishes'){
+            $uid = JwtToken::getCurrentId();
+            $user = SysUser::where('user_id', $uid)->first();
+            $restaurant = SysDept::where('dept_category', '餐厅')->where(function ($query) use ($user) {
+                $query->where('dept_id', $user->join_user_dept_id)->orWhere('dept_super_id', $user->join_user_dept_id);
+            })->first();
+            dump($restaurant->dept_id);
+            $supplier = Supplier::where('join_supplier_dept_id',$restaurant->dept_id)->first();
+            if ($supplier){
+                $goods = $goods->where('join_goods_supplier_id',$supplier->supplier_id);
+            }
+        }
+
+
+        $goods = $goods->select('goods_id','goods_id as id','goods_name as name','join_goods_category_id as pid','goods_attribute_json','goods_classify','goods_sales_price','goods_cover')
             ->orderBy('goods_sort','DESC')
             ->orderBy('goods_addtimes','DESC')
             ->get()