Files
spacestation/admin/controllers/Tmp.php
T
chenrx 6553c5b9b4 111
2024-05-27 14:58:26 +08:00

106 lines
4.1 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
/**
* 临时脚本
*/
class Tmp extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('auto/auto_brand_model');
$this->load->model('auto/auto_cars_model');
$this->load->model('auto/auto_series_model');
$this->load->library('carHome');
$this->load->helper('order');
}
//临时导入车型库脚本
public function importCars()
{
require_once COMMPATH . '/third_party/PHPExcel/IOFactory.php';
$file = FCPATH . 'temp/cars.xlsx';
$reader = \PHPExcel_IOFactory::createReader('Excel2007'); // 读取 excel 文档
$PHPExcel = $reader->load($file); // 文档名称
$objWorksheet = $PHPExcel->getActiveSheet();
$rowCnt = $objWorksheet->getHighestRow(); //获取总行数
$col_max = $objWorksheet->getHighestColumn();//最大列
$arr = array();
for ($i = 2; $i <= $rowCnt; $i++) { //读取内容
$carId = $objWorksheet->getCell('A' . $i)->getValue();
$brand = $objWorksheet->getCell('B' . $i)->getValue();
$series = $objWorksheet->getCell('C' . $i)->getValue();
$name = $objWorksheet->getCell('D' . $i)->getValue();
if (!$this->auto_cars_model->get(['third_car_id' => $carId])) {
$brandRow = $this->auto_brand_model->get(['name' => $brand]);
if (!$brandRow) {
$brand_id = $this->auto_brand_model->add(['name' => $brand, 'c_time' => time()]);
} else {
$brand_id = $brandRow['id'];
}
$seriesRow = $this->auto_series_model->get(['name' => $series, 'brand_id' => $brand_id]);
if (!$seriesRow) {
$s_id = $this->auto_series_model->add(['name' => $series, 'brand_id' => $brand_id, 'c_time' => time()]);
} else {
$s_id = $seriesRow['id'];
}
$insert = [
'third_car_id' => $carId,
'brand_id' => $brand_id,
'series_id' => $s_id,
'name' => $name,
'c_time' => time(),
];
$this->auto_cars_model->add($insert);
}
}
echo '导入完成';
}
public function testApi(){
$data = [
'buyerType' => 1,
'buyerName' => '李红',
'buyerPhone' => '144555566669',
'specId' => 67998,
'storeId' => 50,
'outOrderId' => create_order_no(),
'outLeadId' => 2,
'outOrderCreateTime' => date('Y-m-d H:i:s', time()),
'registerCityId' => 433100,
];
// $img = "https://img.liche.cn/liche/2024/05/18ead093c6f65269/53b4b876a3dccd57.jpg";
$data['autohomeOrderId'] = 20;
// $data['invoiceAmount'] = 7000;
// $data['isRegisterInStore'] = 1;
// $data['registerAmount'] = 700;
// $data['isInsured'] = 1;
// $data['isLoan'] = 1;
// $data['loanAmount'] = 500000;
// $data['loanPeriods'] = 36;
// $data['monthlyPayment'] = 3000;
// $data['carryCarDate'] = '2024-06-02';
// $data['payDate'] = '2024-05-27';
// $data['contractImg'] = $img;
// $data['invoiceImg'] = $img;
// $data['payImg'] = $img;
// $data['outColor'] = '黑色';
// $data['inColor'] = '蓝色';
// $data['deliveryDate'] = '2024-06-15';
// $data['downpaymentType'] = 1;
// $data['confirmAmount'] = 4000;
// $data['discountAmount'] = 0;
// $data['isLocalInvoice'] = 0;
// $data['idCardNo'] = '350522198910148675';
// $data['carDocumentImg'] = $img;
// $data['insuranceImg'] = $img;
// $data['deliveryPhoto'] = $img;
// $data['priceRightsConfirmDoc'] = $img;
$req = $this->carhome->saveOrder($data);
print_r($req);
exit;
}
}