1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace refill\dixin_normal;
- use mtopcard;
- class config
- {
- const ACCESS_TOKEN = '406c0c33c27e18662a756b369a1074c1';
- const KEY = 'a6573b34c420dc7304c4331672297f7d';
- const ORDER_URL = 'https://m.baiopen.com/openapi/method';
- const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/dixin_normal.php";
- const IS_DEBUG = false;
- private static $stStoreProducts = [
- 50 => [4 => 'G36211237846176976', 5 => 'G36211237856416056', 6 => 'G36211237851296016'],
- 100 => [4 => 'G36211237847712888', 5 => 'G36211237857952968', 6 => 'G36211237852832928'],
- 200 => [4 => 'G36211237849760104', 5 => 'G36211237859488880', 6 => 'G36211237854880144']
- ];
- public static function sign($params)
- {
- if (is_object($params)) { //对象转数组
- $params = json_decode(json_encode($params), true);
- }
- $params['sign_key'] = config::KEY;
- ksort($params);
- $formatData = [];
- foreach ($params as $k => $v) {
- if (is_array($v) || is_object($v)) {
- $v = json_encode($v, JSON_UNESCAPED_UNICODE);
- }
- if ((!empty($v) || (string)$v === '0') && $k != 'sign') {
- $formatData[] = "$k=$v";
- }
- }
- $signStr = implode('&', $formatData);
- return md5($signStr);
- }
- public static function sku_code($card_type,$amount)
- {
- if(config::IS_DEBUG)
- {
- if($card_type === mtopcard\ChinaMobileCard)
- {
- switch ($amount)
- {
- case 50:
- return 'G34707828905632832';
- }
- }
- elseif($card_type === mtopcard\ChinaUnicomCard)
- {
- switch ($amount)
- {
- case 50:
- return 'G34707828917408824';
- }
- }
- }
- else
- {
- if(array_key_exists($amount,self::$stStoreProducts)) {
- if(array_key_exists($card_type,self::$stStoreProducts[$amount])) {
- return self::$stStoreProducts[$amount][$card_type];
- }
- }
- return false;
- }
- }
- }
|