|
@@ -603,6 +603,12 @@ class WholeController extends Curd
|
|
|
if (!$order){
|
|
|
return json_fail('订单异常');
|
|
|
}
|
|
|
+ if (!empty($order->order_extend_json)){
|
|
|
+ $orderExtendJson = json_decode($order->order_extend_json,true);
|
|
|
+ if (isset($orderExtendJson['premises'])){
|
|
|
+ $premises = SysDept::where('dept_name',$orderExtendJson['premises'])->where('dept_category','营业场所')->first();
|
|
|
+ }
|
|
|
+ }
|
|
|
$params['orderId'] = $params['order_id'];
|
|
|
$params['orderGroupId'] = $order->order_groupby;
|
|
|
|
|
@@ -673,7 +679,7 @@ class WholeController extends Curd
|
|
|
Db::rollBack();
|
|
|
return json_fail('账户余额不足');
|
|
|
}
|
|
|
- if($params['pay_constitute'] == 'Y' && ($params['order_amount_pay'] > $account->member_account_surplus)){
|
|
|
+ if ($params['pay_constitute'] == 'Y' && ($params['order_amount_pay'] > $account->member_account_surplus)){
|
|
|
$qrcodePayAmount = $params['order_amount_pay'] - $account->member_account_surplus;
|
|
|
$params['order_amount_pay'] = $account->member_account_surplus;
|
|
|
}
|
|
@@ -710,9 +716,12 @@ class WholeController extends Curd
|
|
|
$paySum = $paySum + $item;
|
|
|
}
|
|
|
|
|
|
- if (700 - $paySum < $params['order_amount_pay']){
|
|
|
+ if ($params['pay_constitute'] == 'N' && 700 - $paySum < $params['order_amount_pay']){
|
|
|
Db::rollBack();
|
|
|
return json_fail('超出福利限额');
|
|
|
+ }else if($params['pay_constitute'] == 'Y' && 700 - $paySum < $params['order_amount_pay']){
|
|
|
+ $qrcodePayAmount = $params['order_amount_pay'] - (700 - $paySum);
|
|
|
+ $params['order_amount_pay'] = (700 - $paySum);
|
|
|
}
|
|
|
}else{
|
|
|
$payDetails = PayDetail::where('join_pay_member_id',$params['join_order_member_id'])
|
|
@@ -742,9 +751,12 @@ class WholeController extends Curd
|
|
|
$paySum = $paySum + $item;
|
|
|
}
|
|
|
|
|
|
- if (300 - $paySum < $params['order_amount_pay']){
|
|
|
+ if ($params['pay_constitute'] == 'N' && 300 - $paySum < $params['order_amount_pay']){
|
|
|
Db::rollBack();
|
|
|
return json_fail('超出福利限额');
|
|
|
+ }else if($params['pay_constitute'] == 'Y' && 300 - $paySum < $params['order_amount_pay']){
|
|
|
+ $qrcodePayAmount = $params['order_amount_pay'] - (300 - $paySum);
|
|
|
+ $params['order_amount_pay'] = (300 - $paySum);
|
|
|
}
|
|
|
}
|
|
|
$account->member_account_surplus = $account->member_account_surplus - $params['order_amount_pay'];
|
|
@@ -855,6 +867,9 @@ class WholeController extends Curd
|
|
|
$orderConfigJson = json_decode($order->order_config_json,true);
|
|
|
}
|
|
|
$orderConfigJson['preferential'] = $params['preferential'] ?? '';
|
|
|
+ if (isset($orderConfigJson['table']) && !empty($orderConfigJson['table'])){
|
|
|
+ SysDept::where('dept_id',$orderConfigJson['table'])->where('dept_category','桌台')->update(['dept_status'=>'ACTIVED']);
|
|
|
+ }
|
|
|
$order->order_config_json = json_encode($orderConfigJson);
|
|
|
$order->order_amount_pay = $params['order_amount_pay']+$qrcodePayAmount;
|
|
|
// 主订单
|
|
@@ -944,33 +959,52 @@ class WholeController extends Curd
|
|
|
// ]);
|
|
|
// }
|
|
|
// }
|
|
|
-
|
|
|
-
|
|
|
- Db::commit();
|
|
|
-
|
|
|
// 打小票
|
|
|
- $sheet = OrderSheet::where('join_sheet_order_id',$params['order_id'])->first();
|
|
|
- if (!empty($sheet->order_sheet_extend_json)){
|
|
|
- $sheetExtendJson = json_decode($sheet->order_sheet_extend_json,true);
|
|
|
- if (isset($sheetExtendJson['premises'])){
|
|
|
- $voteData = [
|
|
|
- 'func'=>'procActionToPrinter',
|
|
|
- 'sign'=>'',
|
|
|
- 'data'=>[
|
|
|
- 'printer_premises'=>$sheetExtendJson['premises'],
|
|
|
- 'printer_device'=>[
|
|
|
- "东泉度假村餐厅前台"
|
|
|
- ],
|
|
|
- 'printer_action'=>'ExecPrintOrder',
|
|
|
- 'printer_data'=>[
|
|
|
- 'order_id'=>$params['order_id']
|
|
|
- ]
|
|
|
- ]
|
|
|
- ];
|
|
|
- http_post_json(getenv('VOTE_MENU_URL'),$voteData);
|
|
|
+ if (!empty($premises)){
|
|
|
+ $restaurant = SysDept::where('dept_super_id',$premises->dept_id)->where('dept_category','餐厅')->first();
|
|
|
+ if (!empty($restaurant->dept_extend_json)){
|
|
|
+ $deptExtendJson = json_decode($restaurant->dept_extend_json,true);
|
|
|
+ if (isset($deptExtendJson['printer'])){
|
|
|
+ foreach($deptExtendJson['printer'] as $item){
|
|
|
+ if (strpos($item,'结账') !== false && $params['order_status_payment'] == 'SUCCESS'){
|
|
|
+ $voteData = [
|
|
|
+ 'func'=>'procActionToPrinter',
|
|
|
+ 'sign'=>'',
|
|
|
+ 'data'=>[
|
|
|
+ 'printer_premises'=>$premises->dept_id,
|
|
|
+ 'printer_device'=>[
|
|
|
+ $item
|
|
|
+ ],
|
|
|
+ 'printer_action'=>'ExecPrintOrder',
|
|
|
+ 'printer_data'=>[
|
|
|
+ 'order_id'=>$params['order_id']
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ http_post_json(getenv('VOTE_MENU_URL'),$voteData);
|
|
|
+ }else if ((strpos($item,'前台') !== false || strpos($item,'后厨') !== false) && $params['settlement_now'] == 'N'){
|
|
|
+ $voteData = [
|
|
|
+ 'func'=>'procActionToPrinter',
|
|
|
+ 'sign'=>'',
|
|
|
+ 'data'=>[
|
|
|
+ 'printer_premises'=>$premises->dept_id,
|
|
|
+ 'printer_device'=>[
|
|
|
+ $item
|
|
|
+ ],
|
|
|
+ 'printer_action'=>'ExecPrintOrder',
|
|
|
+ 'printer_data'=>[
|
|
|
+ 'order_id'=>$params['order_id']
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ http_post_json(getenv('VOTE_MENU_URL'),$voteData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
|
|
|
_syslog("订单","订单支付成功");
|
|
|
return json_success('支付成功');
|
|
@@ -1055,6 +1089,10 @@ class WholeController extends Curd
|
|
|
if (in_array('MEALS',$goodsClassifys)){
|
|
|
$params['submit_goods_classify'] = 'MEALS';
|
|
|
}
|
|
|
+ if (!empty($params['dept_premises_id'])){
|
|
|
+ $premises = SysDept::where('dept_name', $params['dept_premises_id'])->first();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
@@ -1191,9 +1229,12 @@ class WholeController extends Curd
|
|
|
$paySum = $paySum + $item;
|
|
|
}
|
|
|
|
|
|
- if (700 - $paySum < $params['order_amount_pay']){
|
|
|
+ if ($params['pay_constitute'] == 'N' && 700 - $paySum < $params['order_amount_pay']){
|
|
|
Db::rollBack();
|
|
|
return json_fail('超出福利限额');
|
|
|
+ }else if($params['pay_constitute'] == 'Y' && 700 - $paySum < $params['order_amount_pay']){
|
|
|
+ $qrcodePayAmount = $params['order_amount_pay'] - (700 - $paySum);
|
|
|
+ $params['order_amount_pay'] = (700 - $paySum);
|
|
|
}
|
|
|
}else{
|
|
|
$payDetails = PayDetail::where('join_pay_member_id',$params['join_order_member_id'])
|
|
@@ -1222,9 +1263,12 @@ class WholeController extends Curd
|
|
|
$paySum = $paySum + $item;
|
|
|
}
|
|
|
|
|
|
- if (300 - $paySum < $params['order_amount_pay']){
|
|
|
+ if ($params['pay_constitute'] == 'N' && 300 - $paySum < $params['order_amount_pay']){
|
|
|
Db::rollBack();
|
|
|
return json_fail('超出福利限额');
|
|
|
+ }else if($params['pay_constitute'] == 'Y' && 300 - $paySum < $params['order_amount_pay']){
|
|
|
+ $qrcodePayAmount = $params['order_amount_pay'] - (300 - $paySum);
|
|
|
+ $params['order_amount_pay'] = (300 - $paySum);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1354,7 +1398,7 @@ class WholeController extends Curd
|
|
|
$params['order_amount_pay'] = $params['order_amount_pay'] + $qrcodePayAmount;
|
|
|
|
|
|
if (in_array($params['delivery'],['PICKUP','ARRIVAL']) && !empty($params['dept_premises_id'])){
|
|
|
- $premises = SysDept::where('dept_name',$params['dept_premises_id'])->where('dept_category','营业场所')->first();
|
|
|
+ // $premises = SysDept::where('dept_name',$params['dept_premises_id'])->where('dept_category','营业场所')->first();
|
|
|
if (!$premises){
|
|
|
Db::rollBack();
|
|
|
|
|
@@ -1366,9 +1410,14 @@ class WholeController extends Curd
|
|
|
$orderConfigJson['premises'] = $params['dept_premises_id'];
|
|
|
$orderConfigJson['dept'] = $premises->dept_id;
|
|
|
$orderConfigJson['reach'] = "00:00";
|
|
|
- $orderConfigJson['table'] = null;
|
|
|
+ $orderConfigJson['table'] = $params['dept_table_id'] ?? null;
|
|
|
$orderConfigJson['express'] = "到店吃";
|
|
|
$orderConfigJson['tableid'] = null;
|
|
|
+
|
|
|
+ if ($params['settlement_now'] == 'N' && !empty($params['dept_table_id'])){
|
|
|
+ // 桌台设为使用中
|
|
|
+ SysDept::where('dept_id',$params['dept_table_id'])->where('dept_category','桌台')->update(['dept_status'=>'USING']);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$params['order_config_json'] = json_encode($orderConfigJson);
|
|
@@ -1386,7 +1435,6 @@ class WholeController extends Curd
|
|
|
// 入配送
|
|
|
$this->saveExpress($params);
|
|
|
} else if ($params['delivery'] == 'PICKUP') {
|
|
|
- $premises = SysDept::where('dept_name', $params['dept_premises_id'])->first();
|
|
|
$params['order_express_type'] = '自提';
|
|
|
if (!$premises) {
|
|
|
throw new BusinessException('自提门店不存在');
|
|
@@ -1464,6 +1512,51 @@ class WholeController extends Curd
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
+ // 打小票
|
|
|
+ if (!empty($premises)){
|
|
|
+ $restaurant = SysDept::where('dept_super_id',$premises->dept_id)->where('dept_category','餐厅')->first();
|
|
|
+ if (!empty($restaurant->dept_extend_json)){
|
|
|
+ $deptExtendJson = json_decode($restaurant->dept_extend_json,true);
|
|
|
+ if (isset($deptExtendJson['printer'])){
|
|
|
+ foreach($deptExtendJson['printer'] as $item){
|
|
|
+ if (strpos($item,'结账') !== false && $params['order_status_payment'] == 'SUCCESS'){
|
|
|
+ $voteData = [
|
|
|
+ 'func'=>'procActionToPrinter',
|
|
|
+ 'sign'=>'',
|
|
|
+ 'data'=>[
|
|
|
+ 'printer_premises'=>$premises->dept_id,
|
|
|
+ 'printer_device'=>[
|
|
|
+ $item
|
|
|
+ ],
|
|
|
+ 'printer_action'=>'ExecPrintOrder',
|
|
|
+ 'printer_data'=>[
|
|
|
+ 'order_id'=>$params['order_id']
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ http_post_json(getenv('VOTE_MENU_URL'),$voteData);
|
|
|
+ }else if ((strpos($item,'前台') !== false || strpos($item,'后厨') !== false) && $params['settlement_now'] == 'N'){
|
|
|
+ $voteData = [
|
|
|
+ 'func'=>'procActionToPrinter',
|
|
|
+ 'sign'=>'',
|
|
|
+ 'data'=>[
|
|
|
+ 'printer_premises'=>$premises->dept_id,
|
|
|
+ 'printer_device'=>[
|
|
|
+ $item
|
|
|
+ ],
|
|
|
+ 'printer_action'=>'ExecPrintOrder',
|
|
|
+ 'printer_data'=>[
|
|
|
+ 'order_id'=>$params['order_id']
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ http_post_json(getenv('VOTE_MENU_URL'),$voteData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Db::commit();
|
|
|
// 打小票
|
|
|
// $sheet = OrderSheet::where('join_sheet_order_id',$params['order_id'])->first();
|