You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
//从汉特倒入订单的过程
|
|
|
|
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Import_orders extends CI_Controller {
|
|
|
|
public function __construct() {
|
|
parent::__construct();
|
|
$this->load->model('Import_model');
|
|
$this->data['nav'] = 'index';
|
|
$this->data['nav_header'] = $this->load->view('index/order_header', '', true);
|
|
}
|
|
|
|
public function index() {
|
|
echo '从汉特导入订单';
|
|
}
|
|
|
|
//检查是否有新订单
|
|
public function sync() {
|
|
//加上文件锁,保障同步过程同一时间运行一次
|
|
define("LOCK_FILE_PATH", sys_get_temp_dir()."/lock.orders");
|
|
if (!file_exists(LOCK_FILE_PATH)) {
|
|
$fp = fopen(LOCK_FILE_PATH, "w");
|
|
fclose($fp);
|
|
}
|
|
$fp = fopen(LOCK_FILE_PATH, "r");
|
|
if (!$fp) {
|
|
echo "Failed to open the lock file!";
|
|
exit(1); //异常处理
|
|
}
|
|
|
|
flock($fp, LOCK_EX);
|
|
//此处添加原子操作代码
|
|
@set_time_limit(0);
|
|
$data = array();
|
|
$this->Import_model->tour();
|
|
$this->Import_model->business();
|
|
$this->load->view('header', $this->data);
|
|
$this->load->view('import_orders');
|
|
$this->load->view('footer');
|
|
|
|
//此处添加原子操作代码 end
|
|
flock($fp, LOCK_UN);
|
|
fclose($fp);
|
|
}
|
|
|
|
}
|