logger = $loggerFactory->get('ccb.notify'); } private function saveLog($func, $content) { $this->logger->info($func."\n".$content."\n"); } public function pay() { try { $this->saveLog(__FUNCTION__, $this->request->getBody()->getContents()); $data = $this->request->all(); if (!isset($data['Main_Ordr_No'], $data['Sign_Inf'])) { throw new BusinessException(500, '缺少参数'); } $ccb = ApplicationContext::getContainer()->get(CcbPaymentService::class); if (!$ccb->verifySign($ccb->createSign($data), $data['Sign_Inf'])) { throw new BusinessException(500, '验签失败'); } $model = CcbPayment::where('main_ordr_no', $data['Main_Ordr_No'])->first(); if (!$model) { throw new BusinessException(500, '下单记录不存在'); } $payResult = $ccb->gatherEnquireOrder($data['Main_Ordr_No']); if ($payResult['Ordr_Stcd'] != $data['Ordr_Stcd']) { throw new BusinessException(500, '订单状态不一致'); } // 状态已同步 if ($model->ordr_stcd == $data['Ordr_Stcd']) { return $this->response->json([ 'Svc_Rsp_St' => '00', ]); } $model->ordr_stcd = $data['Ordr_Stcd']; $model->pay_time = $data['Pay_Time']; $model->pay_type = $data['TYPE']; $model->pay_channel = $data['PAY_CHANNEL']; $model->debit_credit_type = $data['DEBIT_CREDIT_TYPE']; $model->save(); if ($payResult['Ordr_Stcd'] == '2') { $orderMain = $model->orderMain; if ($orderMain->state != OrderState::UNPAID) { throw new BusinessException(500, '订单状态异常'); } $this->orderOnlineService->doByPaid($orderMain->global_order_id); $this->separateAccountsService->orderOnlinePaid($orderMain->global_order_id); //记录当前市场的当天外卖订单数 $this->orderStatisticsService->setForMarket($orderMain->market_id); // 优惠券返券 $this->couponRebateService->couponRebateInTask($orderMain->global_order_id); // 喇叭通知,兼容旧音响,MQTT+IOT $res = $this->mqttService->speakToStore($orderMain->global_order_id); $res = $this->deviceService->pubMsgToStoreByOrderMainId($orderMain->global_order_id); // 打印订单,自动打印 $res = $this->feiePrintService->feiePrint($orderMain->global_order_id); // 记录badge $orderChildIds = Order::query()->where(['order_main_id' => $orderMain->global_order_id])->pluck('store_id'); $this->badgeService->doByOrder($orderMain->user_id, $orderChildIds, $orderMain->global_order_id, OrderState::PAID); // 公众号模板消息 $res = $this->miniprogramService->sendTemMsgForOnlineOrder($orderMain->global_order_id); } return $this->response->json([ 'Svc_Rsp_St' => '00', ]); } catch (\Exception $e) { return $this->response->json([ 'Svc_Rsp_St' => '01', 'Rsp_Inf' => $e instanceof BusinessException ? $e->getMessage() : '内部错误' ]); } } public function refund() { $this->saveLog(__FUNCTION__, $this->request->getBody()->getContents()); return $this->response->json([ 'Svc_Rsp_St' => '00', ]); } public function merchant() { $this->saveLog(__FUNCTION__, $this->request->getBody()->getContents()); return $this->response->json([ 'Svc_Rsp_St' => '00', ]); } public function accounting() { $this->saveLog(__FUNCTION__, $this->request->getBody()->getContents()); return $this->response->json([ 'Svc_Rsp_St' => '00', ]); } public function bill() { $this->saveLog(__FUNCTION__, $this->request->getBody()->getContents()); return $this->response->json([ 'Svc_Rsp_St' => '00', ]); } public function platform() { $this->saveLog(__FUNCTION__, $this->request->getBody()->getContents()); return $this->response->json([ 'Svc_Rsp_St' => '00', ]); } }