v-Brocloni пре 3 година
родитељ
комит
ecaad731d6
15 измењених фајлова са 474 додато и 0 уклоњено
  1. +277
    -0
      Common/zzfxUtils.class.php
  2. +14
    -0
      hotel/checkAliExpireTime.php
  3. +14
    -0
      hotel/clearReservingRoom.php
  4. +11
    -0
      hotel/getCtripNewOrder.php
  5. +18
    -0
      hotel/priceComparedWarning.php
  6. +14
    -0
      motocade/autoCreateProtocolFee.php
  7. +13
    -0
      motocade/autoFinishOutsideBusOrder.php
  8. +7
    -0
      motocade/finishBusOrder.php
  9. +18
    -0
      motocade/makeBusOrder.php
  10. +7
    -0
      motocade/notifyCustomerToRide.php
  11. +18
    -0
      motocade/roomCountWarning.php
  12. +18
    -0
      motocade/roomPriceWarning.php
  13. +14
    -0
      motocade/syncBusOrder.php
  14. +14
    -0
      motocade/uploadGpsData.php
  15. +17
    -0
      motocade/uploadGpsDataNew.php

+ 277
- 0
Common/zzfxUtils.class.php Прегледај датотеку

@@ -0,0 +1,277 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2016/10/8
* Time: 17:02
*/
class zzcsUtils
{
static function writeLog($log)
{
$dir = __DIR__ . "/../Log/";
if (!is_dir($dir)) {
mkdir($dir);
}
$filename = $dir . date("Y-m-d") . ".log";
$need_chmod = file_exists($filename);
$log_str = '[' . date("Y-m-d H:i:s") . ']';
file_put_contents($filename, $log_str . PHP_EOL, FILE_APPEND);
if ($need_chmod == false) {
@chmod($filename, 0777);
}
}
static function httpRequest($url, $data = null)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
if (!empty($data)) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}

/**
* 发送HTTP请求
* @param $url
* @param array $param
* @return mixed
* @throws Exception
*/
static function httpsPost($url, $param = array())
{
$ch = curl_init(); // 初始化一个 cURL 对象
curl_setopt($ch, CURLOPT_URL, $url); // 设置需要抓取的URL
curl_setopt($ch, CURLOPT_HEADER, 0); // // 设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
// 如果你想PHP去做一个正规的HTTP POST,设置这个选项为一个非零值。这个POST是普通的 application/x-www-from-urlencoded 类型,多数被HTML表单使用。
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param)); // 传递一个作为HTTP “POST”操作的所有数据的字符串。//http_build_query:生成 URL-encode 之后的请求字符串
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type:application/x-www-form-urlencoded;charset=utf-8'
));
$rtn = curl_exec($ch); // 运行cURL,请求网页
if ($errno = curl_errno($ch)) {
throw new Exception ('Curl Error(' . $errno . '):' . curl_error($ch));
}
curl_close($ch); // 关闭URL请求
return $rtn; // 返回获取的数据
}

/*
* 字段验证
* @params String 字段名,支持格式'attr1,attr2,attr3'
* @post Array 被验证的数组,默认为$_POST
*/
static function validateParams($params, $post = '')
{
if ($post == '')
$post = $_POST;
$result = array(
'status' => true,
'info' => ''
);
foreach ($params as $attr => $type) {
$list = explode(',', $attr);
foreach ($list as $item) {
$item = trim($item);
if($item != ''){
if (!isset($post[$item]) || $post[$item] == '') {
$result['status'] = false;
$result['info'] = '请填写所有必填项';
return $result;
} elseif (zzcsUtils::validate($post[$item], $type)) {
continue;

} else {
$result['status'] = false;
$result['info'] = ' 数据格式不正确';
return $result;
}
}

}
}
return $result;
}

/*
* 验证字段是否合法,URL必须带http(s),合法return true,非法return false
* @input mixed需要验证的参数
* @type 需要的方法,Number, Float, Integer, ID, Email, Phone, URL, ShenFenZheng,
*/
static function validate($input, $type = '')
{
$typeArr = explode(',', $type);
foreach ($typeArr as $type) {
switch (strtolower($type)) {
case 'amount':
$reg = '/^([1-9]\d*\.?\d{0,2}$)|0\.?\d{0,2}$/';
$message = '金额';
break;
case 'number':
$reg = '/^-?[0-9]*$/';
$message = '数字';
break;
case 'email':
$reg = '/^[a-zA-Z0-9!#$%&\'*+\\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+\\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/';
$message = '邮箱';
break;
case 'telorphone': //正则不正确,需再完善
$reg = '/^(d{3}-\d{8}|\d{4}-\d{7})|((0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8})$/';
$message = '电话';
break;
case 'tel':
$reg = '/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/';
$message = '手机';
break;
case 'phone':
$reg = '/^d{3}-\d{8}|\d{4}-\d{7}$/';
$message = '电话';
break;
case 'url':
$reg = '/^https?:\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(?::\d{1,5})?(?:$|[?\/#])$/i';
$message = '链接';
break;
case 'card':
$reg = '/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/';
$message = '身份证';
break;
case 'dcode':
$reg = '/^[1-9]\d{5}(?!\d)$/';
$message = '邮编';
break;
case 'time':
$reg = '/^(([0-1][0-9])|(2[0-3])):([0-5][0-9])$/';
$message = '时间';
break;
case 'empty':
default:
$reg = '/^[\s\S]*$/';

}

$result = preg_match($reg, $input);
if ($result == 0)
return false;
}

return true;
}

/*
* 上传多张图片,不确定图片张数,
* 图片路径以逗号分隔,
*
*/
static function uploadMultiple($name, $dirPath = '../coding/resource/upload/car/', $realPath = '../../resource/upload/car/')
{
$maxSize = 2000000;
$allow = array('image/gif', 'image/jpeg', 'image/png', 'image/pjpeg');
$path = '';
$type = '';
if (is_array($_FILES[$name]['name'])) { //多个文件
foreach ($_FILES[$name]['name'] as $key => $item) {
//图片不为空,且图片对应的类型也不为空
if ($_POST['bus_img_type'][$key] != '' && $item != '' && in_array($_FILES[$name]['type'][$key], $allow) && $_FILES[$name]['size'][$key] <= $maxSize) {
$newName = zzcsUtils::initFileName($path, zzcsUtils::getSuffix($_FILES[$name]['name'][$key]));
move_uploaded_file($_FILES[$name]["tmp_name"][$key],
__DIR__ . DIRECTORY_SEPARATOR . $dirPath . $newName);

if ($path == '') {
$path .= $realPath . $newName;
$type .= $_POST['bus_img_type'][$key];
} else {
$path .= ',' . $realPath . $newName;
$type .= ',' . $_POST['bus_img_type'][$key];

}
}
}
} else { //单个文件

}
if ($path != '')
return array('path' => $path, 'type' => $type);
else
return false;
}


/*
* 上传文件
* @type 上传类型,主要是图片,还有附件rar, word, excel,还没有需求
*/
static function upload($type, $file)
{
if ((($_FILES[$file]["type"] == "image/gif")
|| ($_FILES[$file]["type"] == "image/jpeg")
|| ($_FILES[$file]["type"] == "image/png")
|| ($_FILES[$file]["type"] == "image/pjpeg"))
&& ($_FILES[$file]["size"] < 200000)
) {
if ($_FILES[$file]["error"] > 0) {
return '';
} else {
$path = '../upload/car/';
$newName = zzcsUtils::initFileName($path, zzcsUtils::getSuffix($_FILES[$file]["name"]));
move_uploaded_file($_FILES[$file]["tmp_name"],
__DIR__ . DIRECTORY_SEPARATOR . $path . $newName);
return $path . $newName;
}
} else {
return '';
}
}

/*
* 在upload目录上传文件时,初始化一个不存在的文件名
*/
static function initFileName($path, $suffix)
{
$flag = true;

while ($flag) {
$name = time() . rand(10000, 99999);
if (!file_exists("$path$name$suffix")) {
$flag = false;
}
}
return $name . $suffix;
}

static function getSuffix($imgName)//获取图像文件类型
{
if (preg_match("/\.(jpg|jpeg|gif|png|bmp)$/i", $imgName, $matches)) {
$type = strtolower($matches[0]);
} else {
$type = "string";
}
return $type;
}

/*
* 删除车辆之前存放的图片
*/
static function deleteFiles($oldPath, $newPath)
{
if (is_string($oldPath))
$oldPath = explode(',', $oldPath);
if (is_string($newPath))
$newPath = explode(',', $newPath);
foreach ($oldPath as $item) {
if (!in_array($item, $newPath)) {
if (file_exists($item) && is_file($item))
unlink($item);
}
}
}
}

+ 14
- 0
hotel/checkAliExpireTime.php Прегледај датотеку

@@ -0,0 +1,14 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2017/12/26
* Time: 9:39
*/

/**
* 阿里控制台创建的应用,未上线sessionKey有效期为1天,上线后为三个月,需要每天检查一次,快过期通知研发人员及时更新
*/
define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
zzcsUtils::httpRequest('http://cs1.zhizhuchuxing.com/hotel/ali/check-expire-time');

+ 14
- 0
hotel/clearReservingRoom.php Прегледај датотеку

@@ -0,0 +1,14 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2017/12/26
* Time: 9:39
*/

/**
* 对于设置了保留房的取消时间,即最晚立即确认时间的渠道房型,应该轮询清除符合条件的库存
*/
define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
zzcsUtils::httpRequest('http://cs1.zhizhuchuxing.com/hotel/api/clear-reserving-room');

+ 11
- 0
hotel/getCtripNewOrder.php Прегледај датотеку

@@ -0,0 +1,11 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2018/5/22
* Time: 17:50
*/

define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
zzcsUtils::httpRequest('http://sandbox1.zhizhuchuxing.cn/hotel/ctrip-switch/getdltordernotify');

+ 18
- 0
hotel/priceComparedWarning.php Прегледај датотеку

@@ -0,0 +1,18 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2017/3/1
* Time: 16:46
*
* 部分酒店基础房型库存预警
*/

define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
zzcsUtils::httpRequest('http://cs1.zhizhuchuxing.com/hotel/compare-price/cron-price-warning');

/*
* 0,5-23 * * * php /usr/share/nginx/Cron/motocade/uploadGpsDataNew.php >>/usr/share/nginx/Cron/Log/uploadGpsDataNew.log 2>&1
* 0,5-23 * * * sleep 25 ;php /usr/share/nginx/Cron/motocade/uploadGpsDataNew.php >>/usr/share/nginx/Cron/Log/uploadGpsDataNew.log 2>&1
*/

+ 14
- 0
motocade/autoCreateProtocolFee.php Прегледај датотеку

@@ -0,0 +1,14 @@
<?php
/**
* Created by PhpStorm.
* 挂靠协议 每天自动生成挂靠费用
* User: wangxj
* Date: 2017/3/12
* Time: 13:25
*/

define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
$res = zzcsUtils::httpRequest('http://dllfo.zhizhuchuxing.com/motorcade/auto/auto-create-protocol');
zzcsUtils::writeLog($res);


+ 13
- 0
motocade/autoFinishOutsideBusOrder.php Прегледај датотеку

@@ -0,0 +1,13 @@
<?php
/**
* Created by PhpStorm.
* 挂靠协议 每天自动生成挂靠费用
* User: wangxj
* Date: 2017/3/12
* Time: 13:25
*/

define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
$res = zzcsUtils::httpRequest('http://dllfo.zhizhuchuxing.com/motorcade/auto/auto-finish-bus-order');
zzcsUtils::writeLog($res);

+ 7
- 0
motocade/finishBusOrder.php Прегледај датотеку

@@ -0,0 +1,7 @@
<?php
/**
* 自动完成出车订单, 每天凌晨 0点 01分执行 0 1 0 * * ?
*/
define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
zzcsUtils::httpRequest('http://dllcs1.zhizhuchuxing.com/api/driver-tour-guide/finish-task');

+ 18
- 0
motocade/makeBusOrder.php Прегледај датотеку

@@ -0,0 +1,18 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2017/4/4
* Time: 17:31
*/

define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
$date = date('Y-m-d', '+1 days');
$param = array(
'date' => $date
);
$res = zzcsUtils::httpsPost('http://dllfo.zhizhuchuxing.com//motorcade/zizai/auto-order', $param);
if (!$res) {
zzcsUtils::sendMessageToRTX('定时任务之生成出车任务异常',$res);
}

+ 7
- 0
motocade/notifyCustomerToRide.php Прегледај датотеку

@@ -0,0 +1,7 @@
<?php
/**
* 发车前15分钟短信通知客户乘车,每分钟执行一次 0 * * * * ?
*/
define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
zzcsUtils::httpRequest('http://dllcs1.zhizhuchuxing.com/api/driver-tour-guide/notify-customer');

+ 18
- 0
motocade/roomCountWarning.php Прегледај датотеку

@@ -0,0 +1,18 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2017/3/1
* Time: 16:46
*
* 部分酒店基础房型库存预警
*/

define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
zzcsUtils::httpRequest('http://dllcs1.zhizhuchuxing.com/hotel/hotel/room-count-warning');

/*
* 0,5-23 * * * php /usr/share/nginx/Cron/motocade/uploadGpsDataNew.php >>/usr/share/nginx/Cron/Log/uploadGpsDataNew.log 2>&1
* 0,5-23 * * * sleep 25 ;php /usr/share/nginx/Cron/motocade/uploadGpsDataNew.php >>/usr/share/nginx/Cron/Log/uploadGpsDataNew.log 2>&1
*/

+ 18
- 0
motocade/roomPriceWarning.php Прегледај датотеку

@@ -0,0 +1,18 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2017/3/1
* Time: 16:46
*
* 酒店价格预警 渠道的分销价(零售价)低于酒店的结算价时进行报警提醒酒店的运营负责人
*/

define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
zzcsUtils::httpRequest('http://dllcs1.zhizhuchuxing.com/hotel/hotel/price-warning');

/*
* 0,5-23 * * * php /usr/share/nginx/Cron/motocade/uploadGpsDataNew.php >>/usr/share/nginx/Cron/Log/uploadGpsDataNew.log 2>&1
* 0,5-23 * * * sleep 25 ;php /usr/share/nginx/Cron/motocade/uploadGpsDataNew.php >>/usr/share/nginx/Cron/Log/uploadGpsDataNew.log 2>&1
*/

+ 14
- 0
motocade/syncBusOrder.php Прегледај датотеку

@@ -0,0 +1,14 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2017/3/12
* Time: 13:25
*/


define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
$res = zzcsUtils::httpRequest('http://dllfo.zhizhuchuxing.com/motorcade/bus/sync-bus-order');
// $res = zzcsUtils::httpRequest('http://fo.zhizhuchuxing.com/motorcade/bus/sync-bus-order-tem'); //临时
zzcsUtils::writeLog($res);

+ 14
- 0
motocade/uploadGpsData.php Прегледај датотеку

@@ -0,0 +1,14 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2017/2/22
* Time: 10:59
* 定时任务
* 车辆运营管理系统-定时上传GPS数据
*/

define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
$res = zzcsUtils::httpRequest('http://dllfo.zhizhuchuxing.com/motorcade/gps/upload-gps-data');
zzcsUtils::writeLog($res);

+ 17
- 0
motocade/uploadGpsDataNew.php Прегледај датотеку

@@ -0,0 +1,17 @@
<?php
/**
* Created by PhpStorm.
* User: Steven
* Date: 2017/3/1
* Time: 16:46
*/

define('ROOT_PATH', dirname(__DIR__)); //项目根目录
require_once ROOT_PATH . '/Common/zzfxUtils.class.php'; //引入工具类
zzcsUtils::httpRequest('http://dllfo.zhizhuchuxing.com/motorcade/gps/upload-gps');
zzcsUtils::httpRequest('http://dllfo.zhizhuchuxing.com/motorcade/gps/get-gps-zz');

/*
* 0,5-23 * * * php /usr/share/nginx/Cron/motocade/uploadGpsDataNew.php >>/usr/share/nginx/Cron/Log/uploadGpsDataNew.log 2>&1
* 0,5-23 * * * sleep 25 ;php /usr/share/nginx/Cron/motocade/uploadGpsDataNew.php >>/usr/share/nginx/Cron/Log/uploadGpsDataNew.log 2>&1
*/

Loading…
Откажи
Сачувај