config.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace refill\yushang_normal;
  3. class config
  4. {
  5. // const AppKey = '211394653';
  6. // const AppSecret = 'cyQpQKMaGUG186iEZRt1uQ==';
  7. // const ORDER_URL = 'http://mbsmemberwebapi.test.onfishes.com/Order/InsertV2';
  8. // const QUERY_URL = 'http://mbsmemberwebapi.test.onfishes.com/Order/QueryV2';
  9. // const BALANCE_URL = 'http://mbsmemberwebapi.test.onfishes.com/Member/GetAccount';
  10. // const NOTIFY_URL = "https://api.mhigh.cn/racc/callback/mh/testcb.php";
  11. // const TestProduct = 'PLM100068';
  12. // const IS_DEBUG = true;
  13. public const AppKey = '211395563';
  14. public const AppSecret = 'MjY0NTU0NmUtNmNhOS00Y2YzLTk5YmUtMjM4MzIyYWE1MmVj';
  15. public const ORDER_URL = "http://mbapii.mbs.scyshy.com/Order/InsertV2";
  16. public const QUERY_URL = 'http://mbapiq.mbs.scyshy.com/Order/QueryV2';
  17. public const BALANCE_URL = 'http://mbapiq.mbs.scyshy.com/Member/GetAccount';
  18. public const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/yushang_normal.php";
  19. public const add_keys = ['AppKey', 'BuyCount', 'CallBackUrl', 'ChargeAccount', 'CustomerIP', 'MOrderID', 'ProductCode', 'TimesTamp', 'AppSecret'];
  20. public const query_keys = ['AppKey', 'TimesTamp', 'OrderID', 'MOrderID', 'AppSecret'];
  21. public const balance_keys = ['AppKey', 'TimesTamp', 'AppSecret'];
  22. public const notify_keys = ['AppKey', 'TimesTamp', 'OrderID', 'MOrderID', 'State', 'AppSecret'];
  23. private static $stStoreProducts = [
  24. 50 => [4 => 'PLM102741', 5 => 'PLM102741', 6 => 'PLM102741'],
  25. 100 => [4 => 'PLM102681', 5 => 'PLM102681', 6 => 'PLM102681'],
  26. 200 => [4 => 'PLM102742', 5 => 'PLM102742', 6 => 'PLM102742'],
  27. 300 => [4 => 'PLM104318', 5 => 'PLM104318', 6 => 'PLM104318'],
  28. 500 => [4 => 'PLM104319', 5 => 'PLM104319', 6 => 'PLM104319'],
  29. ];
  30. public static function sign($params,$keys): string
  31. {
  32. $str = '';
  33. foreach ($keys as $key)
  34. {
  35. if($key == 'AppKey') {
  36. $str .= config::AppKey;
  37. }
  38. elseif ($key == 'AppSecret') {
  39. $str .= config::AppSecret;
  40. }
  41. else {
  42. $val = $params[$key] ?? '';
  43. $str .= $val;
  44. }
  45. }
  46. return strtoupper(md5($str));
  47. }
  48. public static function gen_params($params,$keys)
  49. {
  50. $params['Sign'] =config::sign($params,$keys);
  51. $params['AppKey'] = config::AppKey;
  52. return $params;
  53. }
  54. //for 测试产品编码
  55. // public static function sku_code($card_type, $amount)
  56. // {
  57. // return config::TestProduct;
  58. // }
  59. public static function sku_code($card_type, $amount)
  60. {
  61. if (array_key_exists($amount, self::$stStoreProducts)) {
  62. if (array_key_exists($card_type, self::$stStoreProducts[$amount])) {
  63. return self::$stStoreProducts[$amount][$card_type];
  64. }
  65. }
  66. return false;
  67. }
  68. public static function time_stamp () : int
  69. {
  70. return intval(microtime(true) * 1000);
  71. }
  72. }