Model_logic_tools.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. ];
  38. if(!isset($arr[$shop])){
  39. return "";
  40. }else{
  41. return $arr[$shop];
  42. }
  43. }
  44. function getOrderTable($shop){
  45. $tt = [];
  46. $smt = [];
  47. $dlz = [3,4];
  48. if(in_array($shop,$tt)){
  49. return "fullordertt";
  50. }
  51. if(in_array($shop,$smt)){
  52. return "fullordersmt";
  53. }
  54. if(in_array($shop,$dlz)){
  55. return "fullorder";
  56. }
  57. return "";
  58. }
  59. /**
  60. * 对外通信的加密工具类
  61. *$decrypt 要加密内容
  62. */
  63. function toolsjiami($decrypt,$key = "",$iv = ""){
  64. if(empty($key)){
  65. $key = $this->key;
  66. }
  67. if(empty($iv)){
  68. $iv = $this->iv;
  69. }
  70. return openssl_encrypt($decrypt,'AES-128-CBC',$key,0,$iv);
  71. }
  72. /**
  73. * 对外通信的解密工具类
  74. *$encrypt 要解密内容
  75. */
  76. function toolsjiemi($encrypt,$key="",$iv=""){
  77. if(empty($key)){
  78. $key = $this->key;
  79. }
  80. if(empty($iv)){
  81. $iv = $this->iv;
  82. }
  83. return openssl_decrypt($encrypt,'AES-128-CBC',$key,0,$iv);
  84. }
  85. }