Model_logic_tools.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 = [2,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. function transfer_img_url($url,$host){
  91. if(strpos($url,'/img/thumb?src=') !== false){
  92. preg_match('/src=([^&]+)&w=/', $url, $matches);
  93. $result = $matches[1] ?? '';
  94. if(empty($result)){
  95. return $url;
  96. }
  97. $result = $host."/".$result;
  98. return $result;
  99. }elseif(strpos($url,'https://1.wepolicy.cn')!== false){
  100. $str = str_replace('https://1.wepolicy.cn',$host,$url);
  101. return $str;
  102. }elseif(strpos($url,'http://1.wepolicy.cn')!== false){
  103. $str = str_replace('http://1.wepolicy.cn',$host,$url);
  104. return $str;
  105. }elseif(strpos($url,'http://erp.hnwmzp.cn')!== false){
  106. $str = str_replace('http://erp.hnwmzp.cn',$host,$url);
  107. return $str;
  108. }elseif(strpos($url,'http://a.wepolicy.cn')!== false){
  109. $str = str_replace('http://a.wepolicy.cn',$host,$url);
  110. return $str;
  111. }elseif(strpos($url,'https://erp.hnwmzp.cn')!== false){
  112. $str = str_replace('http://a.wepolicy.cn',$host,$url);
  113. return $str;
  114. }else{
  115. return $url;
  116. }
  117. }
  118. }