1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace refill\yushang_normal;
- class config
- {
- // const AppKey = '211394653';
- // const AppSecret = 'cyQpQKMaGUG186iEZRt1uQ==';
- // const ORDER_URL = 'http://mbsmemberwebapi.test.onfishes.com/Order/InsertV2';
- // const QUERY_URL = 'http://mbsmemberwebapi.test.onfishes.com/Order/QueryV2';
- // const BALANCE_URL = 'http://mbsmemberwebapi.test.onfishes.com/Member/GetAccount';
- // const NOTIFY_URL = "https://api.mhigh.cn/racc/callback/mh/testcb.php";
- // const TestProduct = 'PLM100068';
- // const IS_DEBUG = true;
- public const AppKey = '211395563';
- public const AppSecret = 'MjY0NTU0NmUtNmNhOS00Y2YzLTk5YmUtMjM4MzIyYWE1MmVj';
- public const ORDER_URL = "http://mbapii.mbs.scyshy.com/Order/InsertV2";
- public const QUERY_URL = 'http://mbapiq.mbs.scyshy.com/Order/QueryV2';
- public const BALANCE_URL = 'http://mbapiq.mbs.scyshy.com/Member/GetAccount';
- public const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/yushang_normal.php";
- public const add_keys = ['AppKey', 'BuyCount', 'CallBackUrl', 'ChargeAccount', 'CustomerIP', 'MOrderID', 'ProductCode', 'TimesTamp', 'AppSecret'];
- public const query_keys = ['AppKey', 'TimesTamp', 'OrderID', 'MOrderID', 'AppSecret'];
- public const balance_keys = ['AppKey', 'TimesTamp', 'AppSecret'];
- public const notify_keys = ['AppKey', 'TimesTamp', 'OrderID', 'MOrderID', 'State', 'AppSecret'];
- private static $stStoreProducts = [
- 50 => [4 => 'PLM102741', 5 => 'PLM102741', 6 => 'PLM102741'],
- 100 => [4 => 'PLM102681', 5 => 'PLM102681', 6 => 'PLM102681'],
- 200 => [4 => 'PLM102742', 5 => 'PLM102742', 6 => 'PLM102742'],
- 300 => [4 => 'PLM104318', 5 => 'PLM104318', 6 => 'PLM104318'],
- 500 => [4 => 'PLM104319', 5 => 'PLM104319', 6 => 'PLM104319'],
- ];
- public static function sign($params,$keys): string
- {
- $str = '';
- foreach ($keys as $key)
- {
- if($key == 'AppKey') {
- $str .= config::AppKey;
- }
- elseif ($key == 'AppSecret') {
- $str .= config::AppSecret;
- }
- else {
- $val = $params[$key] ?? '';
- $str .= $val;
- }
- }
- return strtoupper(md5($str));
- }
- public static function gen_params($params,$keys)
- {
- $params['Sign'] =config::sign($params,$keys);
- $params['AppKey'] = config::AppKey;
- return $params;
- }
- //for 测试产品编码
- // public static function sku_code($card_type, $amount)
- // {
- // return config::TestProduct;
- // }
- public static function sku_code($card_type, $amount)
- {
- if (array_key_exists($amount, self::$stStoreProducts)) {
- if (array_key_exists($card_type, self::$stStoreProducts[$amount])) {
- return self::$stStoreProducts[$amount][$card_type];
- }
- }
- return false;
- }
- public static function time_stamp () : int
- {
- return intval(microtime(true) * 1000);
- }
- }
|