'北京', 2 => '天津', 3 => '河北', 4 => '山西', 5 => '内蒙古', 6 => '辽宁', 7 => '吉林', 8 => '黑龙江', 9 => '上海', 10 => '江苏', 11 => '浙江', 12 => '安徽', 13 => '福建', 14 => '江西', 15 => '山东', 16 => '河南', 17 => '湖北', 18 => '湖南', 19 => '广东', 20 => '广西', 21 => '海南', 22 => '重庆', 23 => '四川', 24 => '贵州', 25 => '云南', 26 => '西藏', 27 => '陕西', 28 => '甘肃', 29 => '青海', 30 => '宁夏', 31 => '新疆' ]; const Prov2Noes = [ '北京' => 1, '天津' => 2, '河北' => 3, '山西' => 4, '内蒙古' => 5, '辽宁' => 6, '吉林' => 7, '黑龙江' => 8, '上海' => 9, '江苏' => 10, '浙江' => 11, '安徽' => 12, '福建' => 13, '江西' => 14, '山东' => 15, '河南' => 16, '湖北' => 17, '湖南' => 18, '广东' => 19, '广西' => 20, '海南' => 21, '重庆' => 22, '四川' => 23, '贵州' => 24, '云南' => 25, '西藏' => 26, '陕西' => 27, '甘肃' => 28, '青海' => 29, '宁夏' => 30, '新疆' => 31, ]; #空号拦截状态 const CardState = [ 0 => '空号', 1 => '实号', 2 => '停机', 3 => '库无', 4 => '沉默号', 5 => '风险号' ]; function month_stamp($time=null) : int { $date = getdate($time); $stamp = $date['year'] * 100 + $date['mon']; return $stamp; } function scard_region($region) { if(array_key_exists($region,ProvinceList)) { return ProvinceList[$region]; } else { return ''; } } function topcard_type($str_type) { if(empty($str_type)) { return UnknownCard; } $str_type = trim(strtolower($str_type)); if($str_type == 'petrochina') { //中石油 return PetroChinaCard; } elseif ($str_type == 'sinopec') { //中石化 return SinopecCard; } elseif ($str_type == 'chinamobile') { //中石化 return ChinaMobileCard; } elseif($str_type == 'chinaunicom') { //手机卡 return ChinaUnicomCard; } elseif($str_type == 'chinatelecom') { //手机卡 return ChinaTelecomCard; } elseif($str_type == 'phone') { //手机卡 return PhoneCard; } elseif($str_type == 'third') { return ThirdRefillCard; } else { return UnknownCard; } } function scard_type($card_type) { if($card_type == PetroChinaCard) { //中石油 return 'petrochina'; } elseif ($card_type == SinopecCard) { //中石化 return 'sinopec'; } elseif ($card_type == ChinaMobileCard) { //中石化 return 'chinamobile'; } elseif($card_type == ChinaUnicomCard ) { //手机卡 return 'chinaunicom'; } elseif($card_type == ChinaTelecomCard) { //手机卡 return 'chinatelecom'; } elseif($card_type == PhoneCard) { //手机卡 return 'phone'; } elseif($card_type == ThirdRefillCard) { return 'third'; } else { return 'unknown'; } } function priority_cards($member_id, $page_type = '') { if($page_type == 'oil') { $types = [PetroChinaCard,SinopecCard]; } elseif($page_type == 'phone') { $types = [PhoneCard]; } else { $types = [PetroChinaCard,SinopecCard,PhoneCard]; } $user_cards = new user_topcards($member_id); return $user_cards->priority_cards($types); } function topcard_format($card_list) { $ret = []; foreach ($card_list as $item) { $card = new topcard($item); $item = $card->format(); $item['card_type'] = scard_type($item['card_type']); $ret[] = $item; } return $ret; } function simple_card_type($cardno) { if (preg_match('/^1[0-9]{18}$/', $cardno, $matches)) { return SinopecCard; } elseif (preg_match('/^9[0-9]{15}$/', $cardno, $matches)) { return PetroChinaCard; } elseif (preg_match('/^134[0-8]\d{7}$|^(?:13[5-9]|15[012789]|17[28]|18[23478]|19[578])\d{8}$/', $cardno, $matches)) { return ChinaMobileCard; } elseif (preg_match('/^(?:13[0-2]|15[56]|166|17[156]|18[56]|196)\d{8}$/', $cardno, $matches)) { return ChinaUnicomCard; } elseif (preg_match('/^(?:133|153|177|173|18[019]|19[0139])\d{8}$/', $cardno, $matches)) { return ChinaTelecomCard; } elseif (preg_match('/^(1349)\d{7}$/', $cardno, $matches)) { return ChinaTelecomCard; } elseif (preg_match('/^1\d{10}$/', $cardno, $matches)) { return PhoneCard; } else { return UnknownCard; } } function card_type($cardno,&$regin_no) { $regin_no = -1; if(preg_match( '/^1[0-9]{18}$/',$cardno,$matches)) { return SinopecCard; } elseif(preg_match( '/^9[0-9]{15}$/',$cardno,$matches)) { return PetroChinaCard; } elseif(preg_match('/^1\d{10}$/',$cardno,$matches)) { $regin_no = -1; if (preg_match('/^134[0-8]\d{7}$|^(?:13[5-9]|15[012789]|17[28]|18[23478]|19[578])\d{8}$/', $cardno, $matches)) { return ChinaMobileCard; } elseif (preg_match('/^(?:13[0-2]|15[56]|166|17[156]|18[56]|196)\d{8}$/', $cardno, $matches)) { return ChinaUnicomCard; } elseif (preg_match('/^(?:133|153|177|173|18[019]|19[0139])\d{8}$/', $cardno, $matches)) { return ChinaTelecomCard; } elseif (preg_match('/^(1349)\d{7}$/', $cardno, $matches)) { return ChinaTelecomCard; } else { return UnknownCard; } } else { return UnknownCard; } } function oil_type($cardno) { if(preg_match( '/^1[0-9]{18}$/',$cardno,$matches)) { return SinopecCard; } elseif(preg_match( '/^9[0-9]{15}$/',$cardno,$matches)) { return PetroChinaCard; } else { return UnknownCard; } } function is_validate($status) { if (in_array($status, [0,5])) { return false; } else { return true; } } function valid_phone($card_no) { $query = new card_query(); return $query->validate($card_no); } function electric_product_code($company_type,$use_type,$refill_amount) { // const ElectricCompanyTypes = ['nation', 'south']; // const ElectricUseTypes = ['home', 'commerce', 'pedlar']; return "DF_{$company_type}_{$use_type}_{$refill_amount}"; } function sino_coupon_product_code($refill_amount) { return "SHDZQ_{$refill_amount}"; } function is_alpha($text) { return is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text); }; function electric_exists($product) { static $products = []; return in_array($product,$products); }