$redis_conf['host'], 'port' => $redis_conf['port'], 'passwd' => $redis_conf['passwd'] )); return $r; } protected function getMysql() { $mysql_conf = getMysqlConfig(); $conn = new phpcommon\Mysql(array( 'host' => $mysql_conf['host'], 'port' => $mysql_conf['port'], 'user' => $mysql_conf['user'], 'passwd' => $mysql_conf['passwd'], 'dbname' => 'paydb' )); return $conn; } public function getOrderByCpOrderId($orderid) { $conn = $this->getMysql(); $row = $conn->execQueryOne('SELECT * FROM orderinfo ' . 'WHERE orderid=:orderid;', array( ':orderid' => $orderid ) ); return $row; } public function getOrderBySpOrderId($channel, $sp_orderid) { $conn = $this->getMysql(); $row = $conn->execQueryOne('SELECT * FROM orderinfo ' . 'WHERE channel=:channel AND sp_orderid=:sp_orderid;', array( ':channel' => $channel, ':sp_orderid' => $sp_orderid ) ); return $row; } public function addOrder($order_info) { return $this->internalAddOrder($order_info); } public function addPreOrder($pre_order_info) { $pre_order_info['sp_orderid'] = ''; $pre_order_info['sp_amount'] = 0; $pre_order_info['sp_confirm_time'] = 0; $pre_order_info['sp_pay_result'] = 0; return $this->internalAddOrder($pre_order_info); } private function internalAddOrder($order_info) { $gameid = phpcommon\extractGameId($order_info['account_id']); $openid = phpcommon\extractOpenId($order_info['account_id']); $conn = $this->getMysql(); $ret = $conn->execScript('INSERT INTO orderinfo(' . ' orderid, account_id, roleid, server_id, channel, ' . ' poly_sdk_channel, unified_channel, ' . ' gameid, openid, itemid, try_count, price, ipv4, status, ' . ' confirmtime, createtime, sp_orderid, sp_amount, ' . ' sp_confirm_time, sp_pay_result ' . ' ) ' . 'VALUES (:orderid, :account_id, :roleid, :server_id, :channel, ' . ' :poly_sdk_channel, :unified_channel, ' . ' :gameid, :openid, :itemid, :try_count, :price, :ipv4, :status, ' . ' :confirmtime, :createtime, :sp_orderid, :sp_amount, ' . ' :sp_confirm_time, :sp_pay_result ' . ' );', array( ':orderid' => $order_info['orderid'], ':account_id' => $order_info['account_id'], ':roleid' => $order_info['roleid'], ':server_id' => $order_info['server_id'], ':channel' => $order_info['channel'], ':poly_sdk_channel' => $order_info['poly_sdk_channel'], ':unified_channel' => $order_info['unified_channel'], ':gameid' => $gameid, ':openid' => $openid, ':itemid' => $order_info['itemid'], ':try_count' => 0, ':price' => $order_info['price'], ':ipv4' => $order_info['ipv4'], ':status' => 0, ':confirmtime' => 0, ':createtime' => time(), ':sp_orderid' => $order_info['sp_orderid'], ':sp_amount' => $order_info['sp_amount'], ':sp_confirm_time' => $order_info['sp_confirm_time'], ':sp_pay_result' => $order_info['sp_pay_result'], ) ); return $ret; } public function spPayConfirm($orderid, $sp_orderid, $sp_amount) { $conn = $this->getMysql(); $ret = $conn->execScript('UPDATE orderinfo SET ' . ' sp_orderid = :sp_orderid, ' . ' sp_amount = :sp_amount, ' . ' sp_confirm_time = :sp_confirm_time, ' . ' sp_pay_result = :sp_pay_result ' . 'WHERE orderid = :orderid;', array( ':orderid' => $orderid, ':sp_orderid' => $sp_orderid, ':sp_amount' => $sp_amount, ':sp_confirm_time' => time(), ':sp_pay_result' => 1, ) ); return $ret; } }