Model_logic_tools.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * 封装一些常规的订单操作
  4. */
  5. class Model_logic_tools extends Lin_Model {
  6. public $key = "v!frlbpnjgir6amg"; //加密所需要到的key
  7. public $iv = "k!2w94m6jt!6ook4";//加密所需要到的iv
  8. function __construct(){
  9. parent::__construct();
  10. }
  11. // 返回参数方法
  12. /**
  13. * $code 状态码
  14. * $msg 返回信息
  15. * $data 数据
  16. */
  17. function ret_json($code,$msg,$data = []){
  18. return json_encode([
  19. 'code'=>$code,
  20. 'msg'=>$msg,
  21. 'data'=>$data
  22. ],JSON_UNESCAPED_UNICODE);
  23. }
  24. function ret_arr($code,$msg,$data = []){
  25. return [
  26. 'code'=>$code,
  27. 'msg'=>$msg,
  28. 'data'=>$data
  29. ];
  30. }
  31. //根据shop 来判断是那个店铺 到时间直接选中表就好
  32. function getshopname($shop){
  33. $arr = [
  34. 2=>"asteriahair",
  35. 3=>"alipearlhair",
  36. 4=>"westkis",
  37. 6=>"wigginshair",
  38. ];
  39. if(!isset($arr[$shop])){
  40. return "";
  41. }else{
  42. return $arr[$shop];
  43. }
  44. }
  45. function getOrderTable($shop){
  46. $tt = [];
  47. $smt = [];
  48. $dlz = [3,4,6];
  49. if(in_array($shop,$tt)){
  50. return "fullordertt";
  51. }
  52. if(in_array($shop,$smt)){
  53. return "fullordersmt";
  54. }
  55. if(in_array($shop,$dlz)){
  56. return "fullorder";
  57. }
  58. return "";
  59. }
  60. /**
  61. * 对外通信的加密工具类
  62. *$decrypt 要加密内容
  63. */
  64. function toolsjiami($decrypt,$key = "",$iv = ""){
  65. if(empty($key)){
  66. $key = $this->key;
  67. }
  68. if(empty($iv)){
  69. $iv = $this->iv;
  70. }
  71. return openssl_encrypt($decrypt,'AES-128-CBC',$key,0,$iv);
  72. }
  73. /**
  74. * 对外通信的解密工具类
  75. *$encrypt 要解密内容
  76. */
  77. function toolsjiemi($encrypt,$key="",$iv=""){
  78. if(empty($key)){
  79. $key = $this->key;
  80. }
  81. if(empty($iv)){
  82. $iv = $this->iv;
  83. }
  84. return openssl_decrypt($encrypt,'AES-128-CBC',$key,0,$iv);
  85. }
  86. function writeCache($filename,$data){
  87. }
  88. function readCache($filename){
  89. }
  90. }