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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
| class ofcard_service { var $gateway ; var $param ;
function ofcard_service($cardnum ,$order_id ,$game_userid ,$userid ,$userpws ,$version){ $this ->gateway = 'http://esales1.ofcard.com:8088/onlineorder.do ' ; $this ->param = array (); $this ->param[ 'userid' ] = $userid ; $this ->param[ 'userpws' ] = md5( $userpws ); $this ->param[ 'cardid' ] = $this ->get_cardid( $game_userid ); $this ->param[ 'cardnum' ] = $cardnum /50; $this ->param[ 'sporder_id' ] = $order_id ; $this ->param[ 'sporder_time' ] = date ( 'YmdHis' ); $this ->param[ 'game_userid' ] = $game_userid ; $keystr = 'OFCARD' ; $this ->param[ 'md5_str' ] = strtoupper ( md5( $this ->param[ 'userid' ]. $this ->param[ 'userpws' ]. $this ->param[ 'cardid' ]. $this ->param[ 'cardnum' ]. $this ->param[ 'sporder_id' ]. $this ->param[ 'sporder_time' ]. $game_userid . $keystr ) ); $this ->param[ 'version' ] = $version ; }
function recharge( $snoopy , $db , $order_id ) { $snoopy ->submit( $this ->gateway, $this ->param); $sql = "UPDATE `recharge` SET `is_recharge` = " . $this->get_xml_value( "game_state" ,$snoopy ->results) . ", `ofcard_trade_id` = '" . $this ->get_xml_value( "orderid" , $snoopy ->results) . "', `purchase_price` = '" . $this ->get_xml_value( "ordercash" , $snoopy ->results) . "' WHERE `order_id` = " . $order_id ; $db ->query( $sql ); return $this ->get_xml_value( "game_state" , $snoopy ->results); }
function get_xml_value( $name , $xml ) { $ret = '' ; preg_match( "|<" . $name . ">(.*)</" . $name . ">|U" , $xml , $ret ); return $ret [1]; }
function get_is_recharge( $userid , $spbillid ){ $status_url = "http://202.102.53.141:83/api/query.do?userid= " . $userid . "&spbillid=" . $spbillid ; return file_get_contents ( $status_url ); }
function get_leftcredit( $userid , $userpws , $version ) { $url = "http://esales1.ofcard.com:8088/queryuserinfo.do?userid= " . $userid . "&userpws=" . md5( $userpws ) . "&version=" . $version ; return self::get_xml_value( "ret_leftcredit" , file_get_contents ( $url )); }
function is_recharge( $phoneno , $price , $userid ) { $url = "http://esales1.ofcard.com:8088/telcheck.do?phoneno= " . $phoneno . "&price=" . $price . "&userid=" . $userid ; $ret = split( '#' , file_get_contents ( $url )); return (1 == $ret [0]); }
function get_cardid( $phoneno ) { $num = substr ( $phoneno , 0, 3); $ChinaMobile = array(134,135,147,147,136,137,138,139,150,151,152,182,157,158,159,187,188); $ChinaUnicom = array (130,131,132,155,156,145,185,186); $ChinaTelecom = array (133,153,180,189); if (in_array( $num , $ChinaMobile ) || in_array( $num , $ChinaUnicom )) { return '140101' ; } if (in_array( $num , $ChinaTelecom )) { return '18' ; } } } $ofcard = new ofcard_service( $original_price ,$dingdan ,$mobile ,$userid ,$userpws ,$version ); $ofcard ->recharge( $snoopy , $db , $dingdan );
|