Browse Source

Bug 修复

gorden 2 tháng trước cách đây
mục cha
commit
82dde89149

+ 1 - 1
app/admin/controller/member/BenefitController.php

@@ -150,7 +150,7 @@ class BenefitController extends Curd
                 'write_off_member_id' => $request->post('write_off_member_id'),
                 'join_order_member_id' => $memberId
             ];
-            $writeOffData = OrderService::generateWriteOffData($params);
+            $writeOffData = OrderService::generateWriteOffDataByOrderProcess($params);
 
             $appointments = Appointment::where('join_appointment_member_benefit_id', $benefitId)
                 ->where('appointment_status', 'INIT')

+ 7 - 3
app/admin/service/member/MemberService.php

@@ -946,7 +946,7 @@ class MemberService
             $memberId = $params['member_id'];
             $member = Member::where('member_id', $params['member_id'])->first();
             if (!$member) {
-                return json_fail("暂无数据");
+                throw new BusinessException('数据异常');
             }
             $extendJson = [];
             if (!empty($member->member_extend_json)) {
@@ -957,7 +957,7 @@ class MemberService
             if (!empty($params['user_id'])) {
                 $deptId = SysUser::where('user_id', $params['user_id'])->value('join_user_dept_id');
                 if (!$deptId) {
-                    throw new BusinessException('请先关联业务员和门店');
+                    throw new BusinessException('您选择的业务员没有关联门店');
                 }
                 $extendJson['belong'] = ['user_id' => $params['user_id'], 'premises' => $deptId];
             }
@@ -1032,7 +1032,11 @@ class MemberService
             }
 
             Db::commit();
-        } catch (\Exception $e) {
+        }catch (BusinessException $e){
+            Db::rollBack();
+            dump($e->getMessage() . ';line:' . $e->getLine());
+            return json_fail($e->getMessage());
+        }catch (\Exception $e) {
             Db::rollBack();
             dump($e->getMessage() . ';line:' . $e->getLine());
             return json_fail("数据更新失败");

+ 118 - 117
app/admin/service/order/AppointmentService.php

@@ -35,7 +35,7 @@ class AppointmentService
         $status = $request->get('status', '');
         $premisesName = $request->get('premises', '');
         $appointmentMode = $request->get('appointment_mode', '');
-        $type = $request->get('type','');
+        $type = $request->get('type', '');
 
         $rows = Db::table('appointment')
             ->leftJoin('member', 'member.member_id', '=', 'appointment.join_appointment_member_id')
@@ -46,30 +46,31 @@ class AppointmentService
             ->leftJoin('order_return', 'order_return.join_return_order_id', '=', 'appointment.join_appointment_order_id')
             ->leftJoin('member_benefit', 'member_benefit.member_benefit_id', '=', 'appointment.join_appointment_member_benefit_id')
             ->leftJoin('goods_sku', 'goods_sku.goods_sku_id', '=', 'appointment.join_appointment_goods_sku_id')
-            ->whereIn('appointment_status',['PAYING','WAITING','PENDING','DOING','DONE','CANCEL','REVOKE'])
+            ->whereIn('appointment_status', ['PAYING', 'WAITING', 'PENDING', 'DOING', 'DONE', 'CANCEL', 'REVOKE'])
             ->when($id != '', function ($query) use ($id) {
                 $query->where('appointment.appointment_id', 'like', '%' . $id . '%');
             })->when($mobile != '', function ($query) use ($mobile) {
-                $query->where(function($query2) use ($mobile) {
+                $query->where(function ($query2) use ($mobile) {
                     $query2->where('member.member_mobile', 'like', '%' . $mobile . '%')
-                    ->orWhere('member_cert.member_cert_name', 'like', '%' . $mobile . '%');
+                        ->orWhere('member_cert.member_cert_name', 'like', '%' . $mobile . '%');
                 });
             })->when($status != '', function ($query) use ($status) {
                 $query->where('appointment.appointment_status', $status);
-            })->when($premisesName != '',function($query) use ($premisesName){
-                $query->whereJsonContains('appointment_apply_json->premises',$premisesName);
-            })->when($appointmentMode != '',function($query) use ($appointmentMode){
-                if($appointmentMode == 'ONLINE'){
-                    $query->whereIn('appointment_mode',['ONLINE','ORDER']);
-                }else{
-                    $query->where('appointment_mode',$appointmentMode);
+            })->when($premisesName != '', function ($query) use ($premisesName) {
+                $query->whereJsonContains('appointment_apply_json->premises', $premisesName);
+            })->when($appointmentMode != '', function ($query) use ($appointmentMode) {
+                if ($appointmentMode == 'ONLINE') {
+                    $query->whereIn('appointment_mode', ['ONLINE', 'ORDER']);
+                } else {
+                    $query->where('appointment_mode', $appointmentMode);
                 }
-            })->when(!empty($type), function ($query) use ($type){
-                if ($type == 'todayDONE'){
-                    $query->where('appointment_status','DONE');
-                    $query->whereBetween('appointment_addtimes',[strtotime(date('Y-m-d').' 00:00:00'),strtotime(date('Y-m-d').' 23:59:59')]);
-                }elseif ($type == 'todayAppointment'){
-                    $query->where('appointment_datetime',date('Y-m-d'));
+            })->when(!empty($type), function ($query) use ($type) {
+                if ($type == 'todayDONE') {
+                    $query->where('appointment_status', 'DONE');
+                    $query->whereRaw('LEFT(appointment_done_datetime,10)=?', [date('Y-m-d')]);
+//                    $query->whereBetween('appointment_addtimes',[strtotime(date('Y-m-d').' 00:00:00'),strtotime(date('Y-m-d').' 23:59:59')]);
+                } elseif ($type == 'todayAppointment') {
+                    $query->where('appointment_datetime', date('Y-m-d'));
                 }
             });
 
@@ -79,10 +80,10 @@ class AppointmentService
             'member_cert.member_cert_name',
             'member_info.member_info_nickname',
             'goods.goods_name', 'goods.goods_cover', 'goods.goods_sales_price',
-            'order.order_id','order.order_name', 'goods_sku.goods_sku_specs_json', 'order.order_amount_total', 'order.order_amount_pay',
-            'order.order_category', 'order.order_status_system', 'order.order_status_payment', 'order.order_status_storage','order.order_is_complete',
-            'order.order_addtimes','order_return.order_return_status',
-            'member_benefit.member_benefit_name','member_benefit.member_benefit_id as benefit_id'
+            'order.order_id', 'order.order_name', 'goods_sku.goods_sku_specs_json', 'order.order_amount_total', 'order.order_amount_pay',
+            'order.order_category', 'order.order_status_system', 'order.order_status_payment', 'order.order_status_storage', 'order.order_is_complete',
+            'order.order_addtimes', 'order_return.order_return_status',
+            'member_benefit.member_benefit_name', 'member_benefit.member_benefit_id as benefit_id'
         )
             ->orderBy('appointment.appointment_addtimes', 'desc')
             ->forPage($page, $pageSize)
@@ -93,12 +94,12 @@ class AppointmentService
             $row->goods_sku_specs_json = !empty($row->goods_sku_specs_json) ? json_decode($row->goods_sku_specs_json, true) : [];
             $row->order_addtimes = date('Y-m-d H:i:s', $row->order_addtimes);
             $row->appointment_addtimes = date('Y-m-d H:i:s', $row->appointment_addtimes);
-            $row->appointment_apply_json = !empty($row->appointment_apply_json) ? json_decode($row->appointment_apply_json,true) : [];
-            $row->appointment_doing_json = !empty($row->appointment_doing_json) ? json_decode($row->appointment_doing_json,true) : [];
-            $row->appointment_result_json = !empty($row->appointment_result_json) ? json_decode($row->appointment_result_json,true) : [];
+            $row->appointment_apply_json = !empty($row->appointment_apply_json) ? json_decode($row->appointment_apply_json, true) : [];
+            $row->appointment_doing_json = !empty($row->appointment_doing_json) ? json_decode($row->appointment_doing_json, true) : [];
+            $row->appointment_result_json = !empty($row->appointment_result_json) ? json_decode($row->appointment_result_json, true) : [];
             if ($row->appointment_category == 'NOFEE') {
                 $row->member_benefit_name = "后付费预约";
-            }elseif ($row->appointment_category == 'GREENWAY'){
+            } elseif ($row->appointment_category == 'GREENWAY') {
                 $row->member_benefit_name = "就医绿通";
             }
             if (!empty($row->appointment_apply_json)) {
@@ -107,12 +108,12 @@ class AppointmentService
                 $row->appointment_times = $applyJson['times'] ?? '';
             }
 
-            $skus = GoodsSku::where('join_sku_goods_id',$row->join_appointment_goods_id)->where('goods_sku_status','ON')
-                ->where('goods_sku_id',$row->join_appointment_goods_sku_id)
-                ->select('goods_sku_id','goods_sku_specs_json','goods_sku_sales_price')
+            $skus = GoodsSku::where('join_sku_goods_id', $row->join_appointment_goods_id)->where('goods_sku_status', 'ON')
+                ->where('goods_sku_id', $row->join_appointment_goods_sku_id)
+                ->select('goods_sku_id', 'goods_sku_specs_json', 'goods_sku_sales_price')
                 ->get();
             $skuJson = [];
-            foreach ($skus as $key => $sku){
+            foreach ($skus as $key => $sku) {
                 if (!empty($sku->goods_sku_specs_json)) {
                     $specsJson = json_decode($sku->goods_sku_specs_json, true);
                     $skuTitle = '';
@@ -158,22 +159,22 @@ class AppointmentService
      */
     public static function arrival(Request $request)
     {
-        $appointmentId = $request->post('id','');
-        if (!$appointmentId){
+        $appointmentId = $request->post('id', '');
+        if (!$appointmentId) {
             return json_fail("参数异常");
         }
 
-        $appointment = Appointment::where('appointment_id',$appointmentId)->first();
-        
+        $appointment = Appointment::where('appointment_id', $appointmentId)->first();
+
         Db::beginTransaction();
-        try{
+        try {
             $appointment->appointment_doing_datetime = date('Y-m-d H:i:s');
             $appointment->appointment_status = 'DOING';
             $appointment->save();
             Db::commit();
 
             return json_success('操作成功');
-        }catch(\Exception $e){
+        } catch (\Exception $e) {
             dump($e->getMessage());
             Db::rollBack();
             return json_fail('到店状态修改失败');
@@ -186,29 +187,29 @@ class AppointmentService
      */
     public static function done(Request $request)
     {
-        $appointmentId = $request->post('id','');
-        $isGenerateOrder = $request->post('is_generate_order','');
-        if (!$appointmentId || !$isGenerateOrder){
+        $appointmentId = $request->post('id', '');
+        $isGenerateOrder = $request->post('is_generate_order', '');
+        if (!$appointmentId || !$isGenerateOrder) {
             return json_fail("参数异常");
         }
 
-        $appointment = Appointment::where('appointment_id',$appointmentId)->first();
-        
-        
+        $appointment = Appointment::where('appointment_id', $appointmentId)->first();
+
+
         Db::beginTransaction();
-        try{
+        try {
             $appointment->appointment_done_datetime = date('Y-m-d H:i:s');
             $appointment->appointment_status = 'DONE';
             // 不产生订单,走核销
-            if ($isGenerateOrder == 'N'){
+            if ($isGenerateOrder == 'N') {
                 $appointment->save();
 
                 Db::commit();
                 return json_success('操作成功');
             }
-            $applyJson = json_decode($appointment->appointment_apply_json,true);
-            $goods = Goods::where('goods_id',$appointment->join_appointment_goods_id)->first();
-            $sku = GoodsSku::where('goods_sku_id',$appointment->join_appointment_goods_sku_id)->where('goods_sku_status','ON')->first();
+            $applyJson = json_decode($appointment->appointment_apply_json, true);
+            $goods = Goods::where('goods_id', $appointment->join_appointment_goods_id)->first();
+            $sku = GoodsSku::where('goods_sku_id', $appointment->join_appointment_goods_sku_id)->where('goods_sku_status', 'ON')->first();
             $orderId = 'OD' . date('ymdHi') . random_string(4, 'up');
             $groupBy = 'OD' . date('ymdHi') . random_string(4, 'up');
             $order = [
@@ -225,7 +226,7 @@ class AppointmentService
                 'order_status_storage' => 'PENDING',
                 'order_platform' => 'SYSTEM',
                 'order_addtimes' => time(),
-                'order_config_json' => json_encode(['premises'=>$applyJson['premises']])
+                'order_config_json' => json_encode(['premises' => $applyJson['premises']])
             ];
             Order::insert($order);
             // 订单号更新到预约
@@ -252,14 +253,14 @@ class AppointmentService
             $pay = [
                 'join_pay_member_id' => $appointment->join_appointment_member_id,
                 'join_pay_order_id' => $groupBy,
-                'pay_status'=>'WAITING',
+                'pay_status' => 'WAITING',
                 'pay_amount' => $sheet['order_sheet_pay'],
                 'pay_remark' => '预约单',
                 'pay_addtimes' => time(),
                 'pay_paytimes' => date('Y-m-d H:i:s'),
-                'pay_prepayid'=>$appointment->join_appointment_member_id.'-CASH',
-                'pay_category'=>$goods->goods_classify,
-                'join_pay_object_json' => ['order_id'=>$orderId]
+                'pay_prepayid' => $appointment->join_appointment_member_id . '-CASH',
+                'pay_category' => $goods->goods_classify,
+                'join_pay_object_json' => ['order_id' => $orderId]
             ];
             PayDetail::insert($pay);
 
@@ -267,7 +268,7 @@ class AppointmentService
             Db::commit();
 
             return json_success('操作成功');
-        }catch(\Exception $e){
+        } catch (\Exception $e) {
             dump($e->getMessage());
             Db::rollBack();
             return json_fail('到店状态修改失败');
@@ -289,7 +290,7 @@ class AppointmentService
         try {
             // 如果没有,新建
             if (empty($params['join_appointment_member_id']) && !empty($params['username']) && !empty($params['mobile'])) {
-                if(Member::where('member_mobile',$params['mobile'])->exists()){
+                if (Member::where('member_mobile', $params['mobile'])->exists()) {
                     Db::rollBack();
                     return json_fail('会员已存在,请勿重复创建');
                 }
@@ -331,7 +332,7 @@ class AppointmentService
                     'mobile' => $member['member_mobile'],
                     'person' => $params['person'],
                     'remark' => '',
-                    'remark_apply_employe' => $params['remark_apply_employe'] ?? '',  
+                    'remark_apply_employe' => $params['remark_apply_employe'] ?? '',
                     'premises' => $params['premises'],
                     'times' => $params['appointment_times']
                 ]);
@@ -339,17 +340,17 @@ class AppointmentService
 
             Appointment::insert($data);
             Db::commit();
-            _syslog("预约","添加预约成功");
+            _syslog("预约", "添加预约成功");
             return json_success("添加预约成功");
-        }catch (BusinessException $e){
+        } catch (BusinessException $e) {
             Db::rollBack();
 
-            _syslog("预约","添加预约失败");
+            _syslog("预约", "添加预约失败");
             return json_fail($e->getMessage());
         } catch (\Exception $e) {
             Db::rollBack();
             dump($e->getMessage());
-            _syslog("预约","添加预约失败");
+            _syslog("预约", "添加预约失败");
             return json_fail("添加预约失败");
         }
     }
@@ -421,13 +422,13 @@ class AppointmentService
                     }
                 ])->where('member_id', $params['join_appointment_member_id'])
                     ->first();
-                if(!$member){
+                if (!$member) {
                     throw new BusinessException("核销人员不存在");
                 }
                 $member = $member->toArray();
                 $applyJson = [];
-                if (!empty($appointment->appointment_apply_json)){
-                    $applyJson = json_decode($appointment->appointment_apply_json,true);
+                if (!empty($appointment->appointment_apply_json)) {
+                    $applyJson = json_decode($appointment->appointment_apply_json, true);
                 }
                 $applyJson['name'] = !empty($member['cert']['member_cert_name']) ? $member['cert']['member_cert_name'] : $member['member_mobile'];
                 $applyJson['mobile'] = $member['member_mobile'];
@@ -452,7 +453,7 @@ class AppointmentService
 
             // 如果服务结束,没有生成过订单,生成订单
             if ($params['appointment_status'] == 'DONE' && empty($appointment->join_appointment_order_id) && $params['settlement_mode'] != 'QUOTA') {
-                $sku = GoodsSku::find($params['join_appointment_goods_sku_id']);    
+                $sku = GoodsSku::find($params['join_appointment_goods_sku_id']);
                 $orderId = 'OD' . date('ymdHi') . random_string(4, 'up');
                 $groupBy = 'OD' . date('ymdHi') . random_string(4, 'up');
                 $order = [
@@ -497,9 +498,9 @@ class AppointmentService
                     'pay_amount' => $sheet['order_sheet_pay'],
                     'pay_remark' => '预约单',
                     'pay_addtimes' => time(),
-                    'pay_prepayid' => $params['join_appointment_member_id'].'-'.$params['settlement_mode'],
+                    'pay_prepayid' => $params['join_appointment_member_id'] . '-' . $params['settlement_mode'],
                     'pay_paytimes' => date('Y-m-d H:i:s'),
-                    'pay_category'=>$goods->goods_classify
+                    'pay_category' => $goods->goods_classify
                 ];
                 // 现金余额结算
                 if ($params['settlement_mode'] == 'CASH') {
@@ -514,10 +515,10 @@ class AppointmentService
                     if ($amount < $sheet['order_sheet_pay']) {
                         throw new BusinessException("账户余额不足");
                     } else {
-                        if($account->member_account_surplus < $sheet['order_sheet_pay']){
-                            $account->member_account_added = $account->member_account_added - ($sheet['order_sheet_pay']-$account->member_account_surplus);
+                        if ($account->member_account_surplus < $sheet['order_sheet_pay']) {
+                            $account->member_account_added = $account->member_account_added - ($sheet['order_sheet_pay'] - $account->member_account_surplus);
                             $account->member_account_surplus = 0;
-                        }else{
+                        } else {
                             $account->member_account_surplus = $account->member_account_surplus - $sheet['order_sheet_pay'];
                         }
                         MemberAccount::where('member_account_id', $account->member_account_id)->update([
@@ -529,7 +530,7 @@ class AppointmentService
                         $pay['join_pay_object_json'] = json_encode(['payment' => ['member_account_id' => $account->member_account_id]]);
                         // 更新订单状态
 
-                        Order::where('order_id', $orderId)->update(['order_status_system' => 'DONE','order_is_complete'=>'Y', 'order_status_payment' => 'SUCCESS']);
+                        Order::where('order_id', $orderId)->update(['order_status_system' => 'DONE', 'order_is_complete' => 'Y', 'order_status_payment' => 'SUCCESS']);
                         OrderSheet::where('join_sheet_order_id', $orderId)->update(['order_sheet_status' => 'DONE']);
                     }
                     // $pay['pay_category'] = 'CASH';
@@ -552,7 +553,7 @@ class AppointmentService
                         $pay['pay_status'] = 'SUCCESS';
                         $pay['join_pay_object_json'] = json_encode(['payment' => ['member_account_id' => $account->member_account_id]]);
                         // 更新订单状态
-                        Order::where('order_id', $orderId)->update(['order_status_system' => 'DONE','order_is_complete'=>'Y', 'order_status_payment' => 'SUCCESS']);
+                        Order::where('order_id', $orderId)->update(['order_status_system' => 'DONE', 'order_is_complete' => 'Y', 'order_status_payment' => 'SUCCESS']);
                         OrderSheet::where('join_sheet_order_id', $orderId)->update(['order_sheet_status' => 'DONE']);
                     }
                     // $pay['pay_category'] = 'CASH';
@@ -562,31 +563,31 @@ class AppointmentService
                     $pay['pay_status'] = 'SUCCESS';
                     PayDetail::insert($pay);
                     // 更新订单状态
-                    Order::where('order_id', $orderId)->update(['order_status_system' => 'DONE','order_is_complete'=>'Y', 'order_status_payment' => 'SUCCESS']);
+                    Order::where('order_id', $orderId)->update(['order_status_system' => 'DONE', 'order_is_complete' => 'Y', 'order_status_payment' => 'SUCCESS']);
                     OrderSheet::where('join_sheet_order_id', $orderId)->update(['order_sheet_status' => 'DONE']);
                 }
 
                 // 回写权益表
-                $benefitId = 'BF'.date('ymdHi').random_string(4,'up');
+                $benefitId = 'BF' . date('ymdHi') . random_string(4, 'up');
                 $benefitData = [
-                    'member_benefit_id'=>$benefitId,
-                    'join_benefit_member_id'=>$params['join_appointment_member_id'],
-                    'join_benefit_goods_id'=>$params['join_appointment_goods_id'],
-                    'join_benefit_goods_sku_id'=>$params['join_appointment_goods_sku_id'] ?? '',
-                    'join_benefit_order_id'=>$orderId,
-                    'member_benefit_status'=>'DONE',
-                    'member_benefit_name'=>$goods->goods_name,
-                    'member_benefit_limit_count'=>1,
-                    'member_benefit_used_count'=>1,
-                    'member_benefit_addtimes'=>time()
+                    'member_benefit_id' => $benefitId,
+                    'join_benefit_member_id' => $params['join_appointment_member_id'],
+                    'join_benefit_goods_id' => $params['join_appointment_goods_id'],
+                    'join_benefit_goods_sku_id' => $params['join_appointment_goods_sku_id'] ?? '',
+                    'join_benefit_order_id' => $orderId,
+                    'member_benefit_status' => 'DONE',
+                    'member_benefit_name' => $goods->goods_name,
+                    'member_benefit_limit_count' => 1,
+                    'member_benefit_used_count' => 1,
+                    'member_benefit_addtimes' => time()
                 ];
                 MemberBenefit::insert($benefitData);
-                
+
                 // $premisesName = SysDept::where('dept_id',$params['premises'])->value('dept_name');
                 // 记录核销
                 $paramsData = [
                     'dept_premises_id' => $params['premises'],
-                    'order_remark'=>$params['appointment_remark'],
+                    'order_remark' => $params['appointment_remark'],
                     'write_off_member_id' => $params['write_off_member_id'],
                     'join_order_member_id' => $params['join_appointment_member_id'],
                 ];
@@ -600,55 +601,55 @@ class AppointmentService
                 ]);
             }
             // 已有服务核销
-            if($params['appointment_status'] == 'DONE' && $params['settlement_mode'] == 'QUOTA' && !empty($params['quota_id'])){
+            if ($params['appointment_status'] == 'DONE' && $params['settlement_mode'] == 'QUOTA' && !empty($params['quota_id'])) {
                 // $premisesName = SysDept::where('dept_id',$params['premises'])->value('dept_name');
                 $paramsData = [
-                    'member_id'=>$params['join_appointment_member_id'],
-                    'nbr'=>$params['person'],
-                    'times'=>date('Y-m-d H:i:s'),
+                    'member_id' => $params['join_appointment_member_id'],
+                    'nbr' => $params['person'],
+                    'times' => date('Y-m-d H:i:s'),
                     'write_off_member_id' => $params['write_off_member_id'],
-                    'remark'=>$params['appointment_remark'],
-                    'dept_premises_id'=>$params['premises']
+                    'remark' => $params['appointment_remark'],
+                    'dept_premises_id' => $params['premises']
                 ];
-                $quotaType = substr($params['quota_id'],0,2);
-                if($quotaType == 'MQ'){
-                    $quota = MemberQuota::where('member_quota_id',$params['quota_id'])
-                    ->select('member_quota_id','join_member_rule_added_component_id')
-                    ->first()
-                    ->toArray();
+                $quotaType = substr($params['quota_id'], 0, 2);
+                if ($quotaType == 'MQ') {
+                    $quota = MemberQuota::where('member_quota_id', $params['quota_id'])
+                        ->select('member_quota_id', 'join_member_rule_added_component_id')
+                        ->first()
+                        ->toArray();
                     $paramsData['component_id'] = $quota['join_member_rule_added_component_id'];
 
                     QuotaController::doWriteOff($paramsData);
                     // 回写权益ID
-                    if(empty($appointment->join_appointment_member_benefit_id)){
+                    if (empty($appointment->join_appointment_member_benefit_id)) {
                         Appointment::where('appointment_id', $appointmentId)->update(['join_appointment_member_benefit_id' => $params['quota_id']]);
                     }
-                }else if($quotaType == 'BF'){
+                } else if ($quotaType == 'BF') {
                     $paramsData['benefit_id'] = $params['quota_id'];
-                    BenefitController::doWriteOff($paramsData,$appointment);
+                    BenefitController::doWriteOff($paramsData, $appointment);
 
                     // 清除后付费预约
-                    if($appointment->appointment_category == 'NOFEE'){
+                    if ($appointment->appointment_category == 'NOFEE') {
                         Appointment::where('appointment_id', $appointmentId)->delete();
                     }
                 }
 
-                _syslog("预约","已有服务核销");
+                _syslog("预约", "已有服务核销");
             }
 
 
             Db::commit();
-            _syslog("预约","预约数据更新成功");
+            _syslog("预约", "预约数据更新成功");
             return json_success("数据更新成功");
-        }catch(\support\exception\BusinessException $e){
+        } catch (\support\exception\BusinessException $e) {
             Db::rollBack();
-            dump($e->getFile().'--'.$e->getLine());
-            _syslog("预约","预约数据更新失败");
+            dump($e->getFile() . '--' . $e->getLine());
+            _syslog("预约", "预约数据更新失败");
             return json_fail($e->getMessage());
         } catch (\Exception $e) {
             Db::rollBack();
-            dump($e->getFile().'--'.$e->getLine());
-            _syslog("预约","预约数据更新失败");
+            dump($e->getFile() . '--' . $e->getLine());
+            _syslog("预约", "预约数据更新失败");
             return json_fail("数据更新失败");
         }
     }
@@ -659,26 +660,26 @@ class AppointmentService
     public static function cancelApply(Request $request)
     {
 
-        $appointmentId = $request->post('id','');
-        if (!$appointmentId){
+        $appointmentId = $request->post('id', '');
+        if (!$appointmentId) {
             return json_fail("参数异常");
         }
 
-        $appointment = Appointment::where('appointment_id',$appointmentId)->first();
-        if(!$appointment){
+        $appointment = Appointment::where('appointment_id', $appointmentId)->first();
+        if (!$appointment) {
             return json_fail("参数异常");
         }
 
-        try{
+        try {
             $appointment->appointment_status = 'CANCEL';
             $appointment->appointment_cancel_datetime = date('Y-m-d H:i:s');
             $appointment->save();
 
             return json_success('取消成功');
-        }catch(\Exception $e){
+        } catch (\Exception $e) {
             return json_fail('取消失败');
         }
-        
+
     }
 
     public static function getTimes(Request $request)
@@ -687,12 +688,12 @@ class AppointmentService
         $date = $request->get('date', '');
 //        $memberId = $request->get('member_id', '');
         $appointmentId = $request->get('appointment_id', '');
-        $premisesName = $request->get('premisses','');
+        $premisesName = $request->get('premisses', '');
         if (!$goodsId || !$date) {
             return json_fail("查询时间段失败!");
         }
 
-        if (!$premisesName){
+        if (!$premisesName) {
             return json_fail("请先选择预约场所");
         }
 
@@ -704,7 +705,7 @@ class AppointmentService
         // 当前服务已预约出去的
         $appointments = Appointment::where('join_appointment_goods_id', $goodsId)
             ->where('appointment_datetime', $date)
-            ->whereJsonContains('appointment_apply_json->premises',$premisesName)
+            ->whereJsonContains('appointment_apply_json->premises', $premisesName)
             ->when($appointmentId != '', function ($query) use ($appointmentId) {
                 $query->where('appointment_id', '<>', $appointmentId);
             })
@@ -723,7 +724,7 @@ class AppointmentService
                     if (!empty($appointment['appointment_apply_json'])) {
                         $applyJson = json_decode($appointment['appointment_apply_json'], true);
                         $applyJsonTimes = $applyJson['times'] ?? '';
-                        
+
                         if ($time['duration'] == $applyJsonTimes) {
                             $times[$key]['person'] -= $applyJson['person'];
                             if ($times[$key]['person'] < 1) {