You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

64 lines
2.0 KiB

  1. <?php
  2. //Author:fuhc
  3. //Date:20160930
  4. require_once __DIR__."/../Conf/Config.inc";
  5. require_once __DIR__.'/Function.php';
  6. //日志工具
  7. class LogTable{
  8. public $DBTool; //操作数据库工具类
  9. static $HTLog;
  10. function __construct(){
  11. require_once __DIR__.'/DB.php';
  12. $this->DBTool=DB::getInstance();
  13. }
  14. function insertLog($model,$info){
  15. $rowset=$this->insertLogDB($model);
  16. if($rowset['code']=="0"){
  17. writeLog($info."_Success");
  18. }else{
  19. writeLog($info.'_Fail'.'---'.$rowset['info']);
  20. }
  21. }
  22. // single
  23. public static function getInstance(){
  24. if(FALSE == (self::$HTLog instanceof self)){
  25. self :: $HTLog = new self();
  26. }
  27. return self::$HTLog;
  28. }
  29. // 插入Log
  30. //user_id,log_type,hotel_id,parent_room_type,room_type,log_desc
  31. //1:酒店 2:房态 3:订单
  32. function insertLogDB($ModelLog){
  33. $user_id=isset($ModelLog['user_id'])?$ModelLog['user_id']:"0";
  34. $log_type=isset($ModelLog['log_type'])?$ModelLog['log_type']:"0";
  35. $hotel_id=isset($ModelLog['hotel_id'])?$ModelLog['hotel_id']:"0";
  36. $room_type=isset($ModelLog['room_type'])?$ModelLog['room_type']:"0";
  37. $parent_room_type=$room_type=="0"?0:-1;
  38. $order_id=isset($ModelLog['order_id'])?$ModelLog['order_id']:"0";
  39. $log_desc=$ModelLog['log_desc'];
  40. if($room_type!="0" || $room_type!=0){
  41. $sql="select parent_room_type from opera_hotel_room where room_type='{$room_type}' limit 1";
  42. $rowset=$this->DBTool->queryBySql($sql);
  43. writeLog($sql.json_encode($rowset));
  44. if($rowset['code']=="0"){
  45. $parent_room_type=isset($rowset['rowset'][0]['parent_room_type'])?$rowset['rowset'][0]['parent_room_type']:"0";
  46. }
  47. }
  48. $sql="insert into opera_hotel_log (create_user_id,create_time,log_type,hotel_id,order_id,parent_room_type,room_type,log_desc)
  49. values('{$user_id}',now(),'{$log_type}','{$hotel_id}','{$order_id}','{$parent_room_type}','{$room_type}','{$log_desc}');";
  50. writeLog('sql= '.$sql);
  51. $rowset=$this->DBTool->execSql($sql);
  52. $data['code']=$rowset['code'];
  53. $data['info']=$rowset['info'];
  54. return $data;
  55. }
  56. }