config.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace refill\dixin_normal;
  3. use mtopcard;
  4. class config
  5. {
  6. const ACCESS_TOKEN = '406c0c33c27e18662a756b369a1074c1';
  7. const KEY = 'a6573b34c420dc7304c4331672297f7d';
  8. const ORDER_URL = 'https://m.baiopen.com/openapi/method';
  9. const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/dixin_normal.php";
  10. const IS_DEBUG = false;
  11. private static $stStoreProducts = [
  12. 50 => [4 => 'G36211237846176976', 5 => 'G36211237856416056', 6 => 'G36211237851296016'],
  13. 100 => [4 => 'G36211237847712888', 5 => 'G36211237857952968', 6 => 'G36211237852832928'],
  14. 200 => [4 => 'G36211237849760104', 5 => 'G36211237859488880', 6 => 'G36211237854880144']
  15. ];
  16. public static function sign($params)
  17. {
  18. if (is_object($params)) { //对象转数组
  19. $params = json_decode(json_encode($params), true);
  20. }
  21. $params['sign_key'] = config::KEY;
  22. ksort($params);
  23. $formatData = [];
  24. foreach ($params as $k => $v) {
  25. if (is_array($v) || is_object($v)) {
  26. $v = json_encode($v, JSON_UNESCAPED_UNICODE);
  27. }
  28. if ((!empty($v) || (string)$v === '0') && $k != 'sign') {
  29. $formatData[] = "$k=$v";
  30. }
  31. }
  32. $signStr = implode('&', $formatData);
  33. return md5($signStr);
  34. }
  35. public static function sku_code($card_type,$amount)
  36. {
  37. if(config::IS_DEBUG)
  38. {
  39. if($card_type === mtopcard\ChinaMobileCard)
  40. {
  41. switch ($amount)
  42. {
  43. case 50:
  44. return 'G34707828905632832';
  45. }
  46. }
  47. elseif($card_type === mtopcard\ChinaUnicomCard)
  48. {
  49. switch ($amount)
  50. {
  51. case 50:
  52. return 'G34707828917408824';
  53. }
  54. }
  55. }
  56. else
  57. {
  58. if(array_key_exists($amount,self::$stStoreProducts)) {
  59. if(array_key_exists($card_type,self::$stStoreProducts[$amount])) {
  60. return self::$stStoreProducts[$amount][$card_type];
  61. }
  62. }
  63. return false;
  64. }
  65. }
  66. }