1
This commit is contained in:
parent
d262d4e992
commit
7864689ee6
@ -17,27 +17,45 @@ class OrderCtrl {
|
||||
return $r;
|
||||
}
|
||||
|
||||
private function getMysql()
|
||||
private function getMysql($DNA)
|
||||
{
|
||||
$mysql_conf = getMysqlConfig();
|
||||
$mysql_conf = getMysqlConfig($DNA);
|
||||
$conn = new phpcommon\Mysql(array(
|
||||
'host' => $mysql_conf['host'],
|
||||
'port' => $mysql_conf['port'],
|
||||
'user' => $mysql_conf['user'],
|
||||
'passwd' => $mysql_conf['passwd'],
|
||||
'dbname' => 'paydb'
|
||||
'dbname' => 'paydb' . $mysql_conf['instance_id']
|
||||
));
|
||||
return $conn;
|
||||
}
|
||||
|
||||
public function genOrderId($account_id)
|
||||
private function getCpOrderIdDNA($cp_orderid)
|
||||
{
|
||||
|
||||
if (strlen($cp_orderid) < 2) {
|
||||
return 0;
|
||||
}
|
||||
$hex_str = substr($cp_orderid, strlen($cp_orderid) - 2);
|
||||
return hexdec($hex_str);
|
||||
}
|
||||
|
||||
public function getOrderByCpOrderId($orderid)
|
||||
private function getStrDNA($account_id)
|
||||
{
|
||||
$conn = $this->getMysql();
|
||||
return crc32($account_id) % 256;
|
||||
}
|
||||
|
||||
public function genOrderId($account_id)
|
||||
{
|
||||
$hex_str = dechex($this->getStrDNA($account_id));
|
||||
if (strlen($hex_str) < 2) {
|
||||
$hex_str = '0' . $hex_str;
|
||||
}
|
||||
return uniqid('201020') . $hex_str;
|
||||
}
|
||||
|
||||
public function getOrderByCpOrderId($cp_orderid)
|
||||
{
|
||||
$conn = $this->getMysql($this->getCpOrderIdDNA($cp_orderid));
|
||||
$row = $conn->execQueryOne('SELECT * FROM orderinfo ' .
|
||||
'WHERE orderid=:orderid;',
|
||||
array(
|
||||
@ -47,24 +65,6 @@ class OrderCtrl {
|
||||
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'] = '';
|
||||
@ -78,7 +78,7 @@ class OrderCtrl {
|
||||
{
|
||||
$gameid = phpcommon\extractGameId($order_info['account_id']);
|
||||
$openid = phpcommon\extractOpenId($order_info['account_id']);
|
||||
$conn = $this->getMysql();
|
||||
$conn = $this->getMysql($this->getStrDNA($order_info['account_id']));
|
||||
$ret = $conn->execScript('INSERT INTO orderinfo(' .
|
||||
' orderid, account_id, roleid, server_id, channel, ' .
|
||||
' poly_sdk_channel, unified_channel, ' .
|
||||
@ -119,9 +119,9 @@ class OrderCtrl {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function spPayConfirm($orderid, $sp_orderid, $sp_amount)
|
||||
public function spPayConfirm($cp_orderid, $sp_orderid, $sp_amount)
|
||||
{
|
||||
$conn = $this->getMysql();
|
||||
$conn = $this->getMysql($this->getCpOrderIdDNA($cp_orderid));
|
||||
$ret = $conn->execScript('UPDATE orderinfo SET ' .
|
||||
' sp_orderid = :sp_orderid, ' .
|
||||
' sp_amount = :sp_amount, ' .
|
||||
@ -129,7 +129,7 @@ class OrderCtrl {
|
||||
' sp_pay_result = :sp_pay_result ' .
|
||||
'WHERE orderid = :orderid;',
|
||||
array(
|
||||
':orderid' => $orderid,
|
||||
':orderid' => $cp_orderid,
|
||||
|
||||
':sp_orderid' => $sp_orderid,
|
||||
':sp_amount' => $sp_amount,
|
||||
|
Loading…
x
Reference in New Issue
Block a user