'Import Cief Lite Statement Transactions Details', 'message' => 'You have successfully updated the Cief Lite Statement Transactions Details' ]; } /** * @param Request $request * @return JsonResponse * @throws MalformedRequestException */ public function logic(Request $request) : JsonResponse { $object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports'); foreach ($object->getFiles() as $file){ $collection = Excel::toCollection(null, json_decode($file)->file_info->original->file, null, null, true); $sheet = $collection->first()->skip(1); $sheet->map(function ($row) { if (!$row[0] || trim($row[8]) !== "已审核") { return; } $postingDate =date('Y-m-d', strtotime($row[10])); $amount = ((float) str_replace(',', '', $row[7])); $statementTransaction = StatementTransaction::whereHas('account', function($query) { $query->where('statement_accounts.number', 8881040198515); })->whereDate('posting_date', $postingDate)->where('amount', $amount)->first(); if (!$statementTransaction) { return; } $owner = $statementTransaction->owners()->firstOrCreate([ 'type' => StatementTransactionOwnerType::WALLET_TOP_UP, 'system' => 'LITE', 'owner_reference'=> $row[0], ]); return $owner; }); } return $this->response([]); } }