123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- <?php
- namespace mtopcard;
- require_once(BASE_HELPER_PATH . '/mtopcard/card_query.php');
- require_once(BASE_HELPER_PATH . '/mtopcard/topcard.php');
- require_once(BASE_HELPER_PATH . '/mtopcard/user_topcards.php');
- require_once(BASE_HELPER_PATH . '/mtopcard/CardPaper.php');
- require_once(BASE_HELPER_PATH . '/mtopcard/cards_helper.php');
- #用户卡的类型
- const UnknownCard = 0;
- const PetroChinaCard = 1; //中石油
- const SinopecCard = 2; //中石化
- const PhoneCard = 3; //手机卡
- const ChinaMobileCard = 4; //手机卡
- const ChinaUnicomCard = 5; //手机卡
- const ChinaTelecomCard = 6; //手机卡
- const ThirdRefillCard = 7; //三方账号充值
- //三方产品类型
- const ThirdOnlineProduct = 1;
- const ThirdElectricProduct = 2;
- const ThirdSMSProduct = 3;
- const ThirdSinopecECouponPoroduct = 4;
- //三方卡号类型:1 手机号,2 QQ号,3 微信号,4 电卡
- const ThirdCardPhone = 1;
- const ThirdCardQQ = 2;
- const ThirdCardWexin = 3;
- const ThirdCardElect = 4;
- const ElectricCompanyTypes = ['nation', 'south'];
- const ElectricUseTypes = ['home', 'commerce', 'pedlar'];
- const CardidVerifyLength = 6;
- #卡的状态
- const CardNormal = 1;
- const CardDeled = 2;
- #限制参数
- const UserMaxCards = 10;
- const CardMaxUsers = 5;
- #card_key参数设置
- const UnusedCard = 0;
- const ReserveCard = 1;
- const AssignedCard = 2;
- const FreezedCard = 3;
- #充值卡类型
- const OilCardPaper = 1;
- const PhoneCardPaper = 2;
- const ThirdCardPaper = 3;
- #省份列表
- const ProvinceList = [
- 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 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 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);
- }
|