|
- <?php
- //Author:fuhc
- //Date:20160930
-
- require_once __DIR__."/../Conf/Config.inc";
- require_once __DIR__.'/Function.php';
-
- //日志工具
- class LogTable{
-
- public $DBTool; //操作数据库工具类
-
- static $HTLog;
- function __construct(){
- require_once __DIR__.'/DB.php';
- $this->DBTool=DB::getInstance();
- }
-
-
- function insertLog($model,$info){
- $rowset=$this->insertLogDB($model);
- if($rowset['code']=="0"){
- writeLog($info."_Success");
- }else{
- writeLog($info.'_Fail'.'---'.$rowset['info']);
- }
- }
-
- // single
- public static function getInstance(){
- if(FALSE == (self::$HTLog instanceof self)){
- self :: $HTLog = new self();
- }
- return self::$HTLog;
- }
- // 插入Log
- //user_id,log_type,hotel_id,parent_room_type,room_type,log_desc
- //1:酒店 2:房态 3:订单
- function insertLogDB($ModelLog){
- $user_id=isset($ModelLog['user_id'])?$ModelLog['user_id']:"0";
- $log_type=isset($ModelLog['log_type'])?$ModelLog['log_type']:"0";
- $hotel_id=isset($ModelLog['hotel_id'])?$ModelLog['hotel_id']:"0";
- $room_type=isset($ModelLog['room_type'])?$ModelLog['room_type']:"0";
- $parent_room_type=$room_type=="0"?0:-1;
- $order_id=isset($ModelLog['order_id'])?$ModelLog['order_id']:"0";
- $log_desc=$ModelLog['log_desc'];
- if($room_type!="0" || $room_type!=0){
- $sql="select parent_room_type from opera_hotel_room where room_type='{$room_type}' limit 1";
- $rowset=$this->DBTool->queryBySql($sql);
- writeLog($sql.json_encode($rowset));
- if($rowset['code']=="0"){
- $parent_room_type=isset($rowset['rowset'][0]['parent_room_type'])?$rowset['rowset'][0]['parent_room_type']:"0";
- }
- }
- $sql="insert into opera_hotel_log (create_user_id,create_time,log_type,hotel_id,order_id,parent_room_type,room_type,log_desc)
- values('{$user_id}',now(),'{$log_type}','{$hotel_id}','{$order_id}','{$parent_room_type}','{$room_type}','{$log_desc}');";
- writeLog('sql= '.$sql);
- $rowset=$this->DBTool->execSql($sql);
- $data['code']=$rowset['code'];
- $data['info']=$rowset['info'];
- return $data;
- }
- }
|