$v) { if (is_array($v)) { // 递归处理子数组 $processedValue = $this->changeArrayToString($v); // 判断是否为索引数组(键为0,1,2...的连续整数) $isIndexed = false; if (!empty($processedValue)) { $keys = array_keys($processedValue); $isIndexed = ($keys === range(0, count($processedValue) - 1)); } if ($isIndexed) { // 索引数组:将子元素转为字符串并用逗号连接 $data[$k] = implode(',', array_map('strval', $processedValue)); } else { // 关联数组:保持结构,值已递归处理为字符串 $data[$k] = $processedValue; } } else { // 非数组值直接转为字符串 $data[$k] = strval($v); } } return $data; } public function test() { $temp_file = str_replace('\\', '/', tempnam(sys_get_temp_dir(), 'cos_')); dump($temp_file); die; // dump($this->getReportResult()); // die; // // 1 // // 2 // $res = $this->shouldReport(24, 93); // dump($res); // die; // // $real_click = 1; // $rate = 55; // $tmp = ceil((100 - $rate) / 100 * 10 - 1); // dump($tmp); // die; // $res = $real_click % $tmp; // dump($res); // // die; /*$sm4 = new NewSm4(); $data = [ 'enquiryInfoReq' => [ 'dealNo' => 'test1001', 'fileType' => '01', 'fileName' => 'a.txt', 'fileContent' => 'abcdefg', 'estimateTimes' => '01', 'message' => '无', 'tlrname' => '游*', 'oprTel' => '0000000', 'bnkno' => '17850', 'type' => '01', ] ]; $result = array_merge([ 'tranno' => 'E002', 'channelno' => 'EST', 'comno' => 'EST13', 'isn' => (new BocCfService())->genIsn(), ], $data); $encrypt_content = $sm4->setKey('2fb0e7538089bd3a46ce946dabeaf88f')->encryptData(json_encode($result, 256)); $estimate_timestamp = (int)round(microtime(true) * 1000); $sm3 = new Sm3(); $estimate_sign = $sm3->sign($estimate_timestamp . json_encode($result, 256)); $res = curlRequest('http://123.207.51.47/GZSrv/public/index.php/admin/boccf/gz_estimate', 'post', http_build_query([ 'tranno' => 'E002', 'content' => $encrypt_content, ]), [ 'Content-Type: application/x-www-form-urlencoded', "estimate_timestamp: $estimate_timestamp", "estimate_sign: $estimate_sign", ]); echo '
';
        print_r($res);
        die;*/

        $str = <<decrypt($str);
//        echo '
';
//        print_r($a);
//        echo '
'; // die; $sm3 = new Sm3(); $b = $sm3->sign('1764841895316' . $a); $aa = json_decode($a, 1); echo '
';
        print_r($a);
        die;


//        $res = curlRequest('http://183.47.59.6:10081/pmcs-tran/api/estimate', 'post', http_build_query([
//            'tranno' => 'E002',
//            'content' => '873139dbab492e66d5c3bd19e3d2ec8c3413f6ff8f7ecde67d6b3581eb29fea5f5a5a2701df28b43507fb5d5dfa41f1e796e99dd4e0960c5c557b0c65a7bc4a62b491cf06ea4dcbd90dc8b9144ee7d68a4c2f96262103bd96de4e4c078390e8c12f22e36761da7fbd3c89ae38b5e2d30',
//        ]), [
//            'Content-Type: application/x-www-form-urlencoded',
//            'estimate_timestamp: 1751598636629',
//            'estimate_sign: bd6bf1d0847039b21dedbc300522e611c78eb2b15f91f3f0a3d84e5f6ad45993'
//        ]);
//        dump($res);
//        die;


        //密钥:2fb0e7538089bd3a46ce946dabeaf88f
        //sm4("张三")="f202deff4656b14521525b56392f07e1"
        //sm3("1750996654060"+"张三")="9e4ea344722680424c03b02410248b88c8240cf95ea5b52c8c00c44008c63c33"
        // 国密
//        $sm3 = new Sm3();
////        $a = $sm3->sign("1750996654060"."张三");
////        $a = $sm3->sign("1751537129184张三");
//        $a = $sm3->sign('1751593633356{"tranno":"E005","channelno":"EST","com_no":"EST13","isn":"202507040946037911","orgInfoReq":{"tlrname":"游*"}}');
////        $a = $sm3->sign("1751537129184".'873139dbab492e66d5c3bd19e3d2ec8c3413f6ff8f7ecde67d6b3581eb29fea5e6135fb64fc501a396745b37ea48e6bcdfad83cc5f923ce65ebe70e625c6b243e8fa73647bc35636613621ca753d8e5653fef688424f4ec99b41818e641a267b9ebeaf17aaa8bb27a92aec680119a788');
//        dump($a);
//        die;

//        $sm4 = new NewSm4();

//        $original_plain_text_data = '{"tranno":"E005","channelno":"EST","com_no":"","isn":"isn_6865fdd9bae9b1.50223708","orgInfoReq":{"tlrname":"游*"}}';
//        $new_key = '2fb0e7538089bd3a46ce946dabeaf88f';
//
//        $encrypted_text_data = $sm4->setKey($new_key)->encryptData(($original_plain_text_data)); // 加密字符串
//        echo '加密后的数据: '. $encrypted_text_data;
//        echo '
'; // $decrypted_text_data = $sm4->setKey($new_key)->decryptData('6d9b81cf1ad8dfec8876a5650105c35c4e8fe632cff45d2791812fc59e1617c8f2d62c3cb91fe5de1cbd3d336939501fe84dafde1beb590da8b0654657f99a6e51af90b2fbf81ef1a9a07a1916ff6363'); // dump($decrypted_text_data); // die; /*$sm42 = new MySm4(); $encrypted_text_data = $sm42->encrypt($new_key, $original_plain_text_data); // 加密字符串 echo '加密后的数据: '. $encrypted_text_data; echo '
'; $decrypted_text_data = $sm42->decrypt($new_key,$encrypted_text_data); echo '解密后的数据: '. ($decrypted_text_data); die;*/ // 加密 /*$ciphertext = openssl_encrypt($original_plain_text_data, 'sm4-ecb', $new_key, OPENSSL_RAW_DATA); echo "加密后的数据:" . bin2hex($ciphertext) . PHP_EOL; // 解密 $decryptedtext = openssl_decrypt($ciphertext, 'sm4-ecb', $new_key, OPENSSL_RAW_DATA); echo "解密后的数据:" . $decryptedtext . PHP_EOL; die;*/ //DES/CBC/PKCS5Padding加密 $des = new DesCrypto($this->des_key, hex2bin($this->des_iv)); // $enstr = $des->encrypt('{"tranno":"E003","channelno":"EST","com_no":"","isn":"isn_685e5ce08c8d65.84584504","enquiryInfoReq":{"dealNo":"DN2025062700001","estimateDealNo":"GZS20250600140","roomArea":"100.00","unitPrice":"10000.00","totalPrice":"1000000.00","price1":"1000000.00","price2":"1000000.00","tax":"0.00","status":"03","evalTime":"20250627","name":"","telephoneNumber":"","intentFileType":"02","houseAddr":"天安公寓1栋102","coveredArea":null,"completionDate":"20250601","regPrice":"1000000.00","landNo":null,"landLimitDate":"","landBgnDate":"","landEndDate":"","houseProperty":"1","registDate":"20220601","houseUse":"1","ownerName":null}}'); // print_r($enstr); // die; // $str = '9UV1RgJtmTw='; // $str = 'CufTA/m0o6SOAq/3W+H4sXsxOE2LVDDaueqsyjGbRFBHJm0gLDEbcroR8ZB1VX78qa0hIIJfahYpzbCqeCmvpEuPllkk7pfG8I+B6jqCpTvpgf6Aglw59O8DcKY1JmJtOoOxpu6CCJXmMw0ehmAwsFAL36sVW7dbHOtrHRQn2qOcdMPr3wNHAKQgu47bQmn4YV5jXmbH2uApcrNLXJwbT1jSRi4ZUjcoAdoN9PQrO7AnDxmSEEWWu8MCubk4EVOZLDB4bFLW4HczmyRx8mrEcEzt54aunf0Ax1ATunuCvOMX/9SADDlnm5kRvtdiTKuwQbD17S613AB+qPcUzHgN9HkTiw4TXMNa4yKwi6AFTk5+e2R40u3z1Vqsc2JI9CeX0MSJxC0hCOc46f5eqU1e3qoNjsmVJ4c/lZKcd8Tzw0M4d/zd58G3H6wFQYjnYB7z5OOernU33L2uX4JPb/rb6915qRJWB4tes1ImyvcoOvU16xBkEfUq5YewGyA6ZlQCXffisQbeOMT1+X05Ab8g20eZI0jUVU/QL5Q9nQAykrdstmxym5Y/eJjP3RiiD4vJnt8WupKn58w//JgiFDnDqBVKzkcDmVxVyU9/fPS7hqKIJPM+BY5jdKsPz62oEubT/qT2Q9olng72l33vuDcNfgbjmMiyF3SEbucAyzohvtLxfMtgyQVFRM/hzlxUY+Ep/AqM2OV5QPs7N8X6ltsV2S/wF+4NJtsbk+NPYu79y/vIV57+MmuxxdPfRLGO8mLNk7Va55BDroNJlmweLiiIfvGELUjkksToyHuLGfC2UolKCalXoPTdnWwvybypnpyRgygXIv1tyOk='; // $str = '2lp3mO4IJgTh0g/mJAuO9VY1k7ja0/UnawQmSmoGlVhffnMGVBT5gfupppzkeDjd1vJPDgBTWX2FHOdexYBO4OPPUJ6iyKZ3'; $str = '2lp3mO4IJgTGhys5R9yTY0C8rziGNkWizGKefwhnHgNTzO2m50373EXUOzdnOcXN+QcFXgEfUXJBaH3gJQV1sgdWMZ8PEgin5QKMeQbUJDYikr9bIum9mQ=='; $data = $des->decrypt($str); print_r($data); die; } public function test2() { $product_list = Db::name('product')->select(); foreach ($product_list as $v) { $insert_data = []; $code_name_list = Db::name('taxation_item')->where('taxation_id', $v['id'])->column('code_name'); if ( (in_array('S', $code_name_list) && !in_array('U', $code_name_list)) || (!in_array('S', $code_name_list) && in_array('U', $code_name_list)) ) { dump($v); } /*if(!in_array('S', $code_name_list) && !in_array('U', $code_name_list)) { $insert_data[] = [ 'taxation_id' => $v['id'], 'code_name' => 'S', 'name' => '扣除项目金额', 'create_time' => time(), ]; $insert_data[] = [ 'taxation_id' => $v['id'], 'code_name' => 'U', 'name' => '规定税率', 'create_time' => time(), ]; Db::name('taxation_item')->insertAll($insert_data); }*/ } } public function test3() { $fileUrl = 'https://evasys-1352283793.cos.ap-guangzhou.myqcloud.com/uploads/GZIQR_202506191458344775.png'; $path = parse_url($fileUrl, PHP_URL_PATH); $objectKey = substr($path, 1); } public function parseContent() { $content = $this->request->post('content'); $boc_cf_service = new BocCfService(); dump($boc_cf_service->parseContentString($content)); } // 询价申请 public function gz_estimate() { $data = $this->request->post(); $header = $this->request->header(); $boc_service = new BocCfService(); // 验证请求参数 if (!$boc_service->checkRequestParams($data)) { return $boc_service->buildResponseData(BocCfService::RETURN_CODE_ARRAY['1002']); } // 验证header信息 if (!$boc_service->checkRequestHeader( $header, json_encode($boc_service->parseContentString($data['content']), 256), )) { return $boc_service->buildResponseData(BocCfService::RETURN_CODE_ARRAY['1001']); } switch ($data['tranno']) { case BocCfService::INQUIRY_APPLY: // 询价申请 return $boc_service->inquiryApply($data); case BocCfService::APPLY_TO_PROVIDE_EVA_REPORT: // 申请出具评估报告 // todo return $boc_service->applyToProvideEvaReport($data); } return $boc_service->buildResponseData(BocCfService::RETURN_CODE_ARRAY['1000']); } public function repairEstimatedNo() { $list = Db::name('inquiry') ->where('estimated_no', 'LIKE', '国中深(预)字【2025】%') ->whereNotNull('seal_time') ->order('seal_time asc') ->select(); $update_data = []; $index_array = []; $six_index = 0; $seven_index = 0; // 国中深(预)字【2025】第F1B070782-ZG号 // $res = mb_substr('国中深(预)字【2025】第F1B070782-ZG号', 17, 2); $bank_list = [ '中国工商银行' => 'GS', '深圳农村商业银行' => 'SN', '中国邮政储蓄银行' => 'YZ', '深圳宝安融兴村镇银行' => 'BR', '广东华兴银行' => 'GH', '中国民生银行' => 'MS', '招商银行' => 'ZS', '平安银行' => 'PA', '广州银行' => 'GZ', '广东南粤银行' => 'NY', '浙商银行' => 'ZY', '深圳宝安村镇银行' => 'BC', '深圳宝安桂银村镇银行' => 'BG', '中国银行' => 'ZG', '兴业银行' => 'XY', '澳门国际银行' => 'AM', '厦门国际银行' => 'XM', '华夏银行' => 'HX', '华商银行' => 'HS', '宁波银行' => 'NB', '交通银行' => 'JT', '中国农业银行' => 'NY', '珠海华润银行' => 'HR', '中国建设银行' => 'JS', '杭州银行' => 'HZ', ]; foreach ($list as $key => $value) { $which_month = mb_substr($value['seal_time'], 5, 2); if (!in_array($which_month, ['06', '07'])) continue; $one = mb_substr($value['estimated_no'], 0, 17); if (!array_key_exists($value['bank_name'], $bank_list)) continue; $five = $bank_list[$value['bank_name']]; if ($which_month == '07') { if (empty($index_array[$value['branchCom_id']])) { if (empty($index_array[$value['branchCom_id']]['seven_index'])) { $index_array[$value['branchCom_id']]['seven_index'] = 1; } else { $index_array[$value['branchCom_id']]['seven_index']++; } } else { if (empty($index_array[$value['branchCom_id']]['seven_index'])) { $index_array[$value['branchCom_id']]['seven_index'] = 1; } else { $index_array[$value['branchCom_id']]['seven_index']++; } } $tmp = [ 'id' => $value['id'], 'one' => $one, 'two' => $which_month, 'three' => str_pad($index_array[$value['branchCom_id']]['seven_index'], 4, '0', STR_PAD_LEFT), 'four' => '-', 'five' => $five . '号', ]; } else { if (empty($index_array[$value['branchCom_id']])) { if (empty($index_array[$value['branchCom_id']]['six_index'])) { $index_array[$value['branchCom_id']]['six_index'] = 1; } else { $index_array[$value['branchCom_id']]['six_index']++; } } else { if (empty($index_array[$value['branchCom_id']]['six_index'])) { $index_array[$value['branchCom_id']]['six_index'] = 1; } else { $index_array[$value['branchCom_id']]['six_index']++; } } $tmp = [ 'id' => $value['id'], 'one' => $one, 'two' => $which_month, 'three' => str_pad($index_array[$value['branchCom_id']]['six_index'], 4, '0', STR_PAD_LEFT), 'four' => '-', 'five' => $five . '号', ]; } $update_data[] = $tmp; } Db::startTrans(); foreach ($update_data as $key => $value) { $res = Db::name('inquiry')->where('id', $value['id'])->update([ 'estimated_no' => $value['one'] . $value['two'] . $value['three'] . $value['four'] . $value['five'], ]); if ($res === false) { Db::rollback(); Log::debug('res:'); Log::debug($res); return $this->buildFailed('更新失败'); } } Db::commit(); return $this->buildSuccess(); } public function repairEstimatedQrcodeUrl() { $ids = Db::name('inquiry') ->whereNotNull("estimated_no") ->whereNotNull("estimated_qrcode_url") ->where('id', 190729) ->column('id'); foreach($ids as $k => $id) { $estimate_qrcode_unique_key = md5(uniqid()); $estimated_qrcode_content = env("uploadFile.qrcode_url") . "/index.php/admin/Pending/getAnticounterfeitPage?quot_id=" . $id . "&key=" . $estimate_qrcode_unique_key; $qrcode_oss_url = Tools::createQRCode($estimated_qrcode_content); if (!empty($qrcode_oss_url)) { $res = Db::name('inquiry')->where('id', $id)->update([ 'estimated_qrcode_url2' => $qrcode_oss_url, 'estimate_qrcode_unique_key' => $estimate_qrcode_unique_key, ]); if (!$res) { Log::debug('更新失败,id:' . $id); } } } } public function importOldData() { $file_url = ROOT_PATH . "/public/uploads/20250908/25-1.xlsx"; $filename = basename($file_url); preg_match('/^(\d+)/', $filename, $matches); $fileSuffix = isset($matches[1]) ? $matches[1] : ''; $sqlFileName = 'pg_inquiry_old_data' . ($fileSuffix ? '_' . $fileSuffix : '') . '.sql'; try { // 使用PHPExcel读取Excel文件 $objReader = PHPExcel_IOFactory::createReaderForFile($file_url); $objPHPExcel = $objReader->load($file_url); // 获取第一个工作表 $sheet = $objPHPExcel->getSheet(0); // 获取最大行数和列数 $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); // 定义Excel表头与数据库字段的映射关系 $fieldMapping = [ '分支机构' => 'branch_institution', '委托方' => 'client', '委托类型' => 'client_type', '委托方联系人' => 'client_contact', '委托方联系电话' => 'client_contact_mobile', '业务联系人' => 'business_contact', '询价编号' => 'inquiry_number', '业务联系人电话' => 'business_contact_mobile', '业务员' => 'business_uesr_name', '创建人' => 'creator', '业务员所属部门' => 'business_user_dept', '创建时间' => 'create_date', '项目名称' => 'property_full_name', '看现场联系人' => 'see_spot_contact', '看现场联系人电话' => 'see_spot_contact_mobile', '借款人' => 'borrower', '业务编号' => 'business_no', '互审' => 'mutual_review', '初审' => 'first_review', '二审' => 'second_review', '三审' => 'third_review', '终审' => 'final_review', '盖章' => 'seal', '复印' => 'photocopy', '其他' => 'other', '环节' => 'link', '客户名称' => 'customer_name', '已转业务' => 'transferred_business', '价格争议' => 'price_disputes', '当前处理人' => 'current_handler', '询价状态' => 'inquiry_status', '评估总值' => 'eva_total_value', '总税费' => 'total_taxes', '总净值' => 'eva_net_value', '法定优先受偿款总额' => 'compensation', '回价时间' => 'return_price_time', '应补地价总额' => 'land_price_supple', '价格说明' => 'price_description', '估价师' => 'valuer', '是否需查勘' => 'is_need_survey', '询价备注' => 'inquiry_remark', '转交理由' => 'transfer_reason', '单价' => 'eva_unit_price', '登记价' => 'reg_price', '用途' => '`usage`', '产权类型' => 'property_type', '委估对象全称' => 'eva_object_full_name', '房产证登记日期' => 'reg_date', '购买日期' => 'purchase_date', '建筑面积' => 'size' ]; // 获取第一行表头,建立列与字段的映射 $columnMapping = []; // 将列名转换为列索引进行遍历(PHPExcel兼容方法) $highestColumnIndex = \PHPExcel_Cell::columnIndexFromString($highestColumn); for ($colIndex = 0; $colIndex < $highestColumnIndex; $colIndex++) { // 将列索引转换回列名 $col = \PHPExcel_Cell::stringFromColumnIndex($colIndex); $headerValue = $sheet->getCell($col . '1')->getValue(); if (isset($fieldMapping[$headerValue])) { $columnMapping[$col] = $fieldMapping[$headerValue]; } } // 生成SQL插入语句 $sqlContent = ""; // 从第二行开始读取数据(第一行是标题) for ($row = 2; $row <= $highestRow; $row++) { $fields = []; $values = []; // 遍历每一列 foreach ($columnMapping as $col => $field) { $cellValue = $sheet->getCell($col . $row)->getValue(); // 处理空值和特殊字符 if ($cellValue === null || $cellValue === '') { $cellValue = 'NULL'; } else { // 转义特殊字符,防止SQL注入 $cellValue = str_replace("'", "''", $cellValue); $cellValue = "'" . $cellValue . "'"; } $fields[] = $field; $values[] = $cellValue; } // 生成INSERT语句 $sql = "INSERT INTO pg_inquiry_old_data (" . implode(', ', $fields) . ") VALUES (" . implode(', ', $values) . ");\n"; $sqlContent .= $sql; } // 保存SQL文件到public目录 $sqlFilePath = ROOT_PATH . 'public' . DS . 'uploads' . DS . $sqlFileName; file_put_contents($sqlFilePath, $sqlContent); // 删除临时文件 // unlink($file_url); // 返回SQL文件的下载链接 return $this->buildSuccess([ 'sql_file_url' => Env::get('uploadFile.host_url') . DS . 'uploads' . DS . $sqlFileName ]); } catch (PHPExcel_Reader_Exception $e) { return $this->buildFailed('读取Excel文件失败: ' . $e->getMessage()); } catch (PHPExcel_Exception $e) { return $this->buildFailed('Excel操作失败: ' . $e->getMessage()); } catch (Exception $e) { return $this->buildFailed('操作失败: ' . $e->getMessage()); } } public function updateLogoPath() { $oldPattern = 'http://{$_SERVER["HTTP_HOST"]}/GZSrv/public'; $newPattern = 'http://{$_SERVER["HTTP_HOST"]}/dev/GZSrv/version1/public'; $sql = "UPDATE pg_estimate SET estimate_sheet = REPLACE( estimate_sheet, '".addslashes($oldPattern)."', '".addslashes($newPattern)."' ) WHERE estimate_sheet LIKE '%".addslashes($oldPattern)."%' AND id = 106"; try { print_r($sql);die; $res = Db::execute($sql); dump($res); die; $count = Db::getPdo()->rowCount(); return "成功更新 {$count} 条记录,路径已从'{$oldPattern}'替换为'{$newPattern}'"; } catch (\Exception $e) { Log::error('LOGO路径更新失败:' . $e->getMessage()); return "替换失败:" . $e->getMessage(); } } }