Model_logic_tools.php 2.1 KB

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