This commit is contained in:
aozhiwei 2019-03-26 19:27:08 +08:00
commit 5aacc2e840
10 changed files with 140 additions and 0 deletions

10
.gitigonre Normal file
View File

@ -0,0 +1,10 @@
*.*\~
*.*~
*.*\#
*.*#
~*.*
\#*.*
*.tar
*.tar.gz
config
.idea

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "third_party/phpcommon"]
path = third_party/phpcommon
url = git@git.kingsome.cn:server_common/phpcommon.git

1
config Symbolic link
View File

@ -0,0 +1 @@
/var/data/conf_test/pay/webapp/config/

1
third_party/phpcommon vendored Submodule

@ -0,0 +1 @@
Subproject commit 4fa9d00842f4fd2fb2c0b3c82bfdaa4f7ac6a602

View File

@ -0,0 +1,54 @@
<?php
$g_conf_mysql_cluster = require('../config/pay.mysql.cluster.php');
$g_conf_redis_cluster = require('../config/pay.redis.cluster.php');
function checkMysqlConfig()
{
$instance_id = 1;
global $g_conf_mysql_cluster;
foreach ($g_conf_mysql_cluster as $instance) {
if ($instance_id != $instance['instance_id']) {
error_log('pay.mysql.cluster.php config error');
die();
}
$instance_id++;
}
}
function checkRedisConfig()
{
$instance_id = 1;
global $g_conf_redis_cluster;
foreach ($g_conf_redis_cluster as $instance) {
if ($instance_id != $instance['instance_id']) {
error_log('pay.redis.cluster.php config error');
die();
}
$instance_id++;
}
}
function getMysqlConfig($hash_value)
{
if ($hash_value < 0) {
die('hash_value < 0 ' . $hash_value);
}
global $g_conf_mysql_cluster;
$idx = $hash_value % count($g_conf_mysql_cluster);
return $g_conf_mysql_cluster[$idx];
}
function getRedisConfig($hash_value)
{
if ($hash_value < 0) {
die('hash_value < 0 ' . $hash_value);
}
global $g_conf_redis_cluster;
$idx = $hash_value % count($g_conf_redis_cluster);
return $g_conf_redis_cluster[$idx];
}
checkMysqlConfig();
checkRedisConfig();

View File

@ -0,0 +1,6 @@
<?php
ini_set('date.timezone','Asia/Shanghai');
require 'phpcommon/common.php';
require 'config_loader.php';

View File

@ -0,0 +1 @@
../phpcommon/Controller/OpsController.class.php

View File

@ -0,0 +1,39 @@
<?php
class PayController {
protected function getRedis($accountid)
{
$redis_conf = getRedisConfig(crc32($accountid));
$r = new phpcommon\Redis(array(
'host' => $redis_conf['host'],
'port' => $redis_conf['port'],
'passwd' => $redis_conf['passwd']
));
return $r;
}
protected function getMysql($accountid)
{
$mysql_conf = getMysqlConfig(crc32($accountid));
$conn = new phpcommon\Mysql(array(
'host' => $mysql_conf['host'],
'port' => $mysql_conf['port'],
'user' => $mysql_conf['user'],
'passwd' => $mysql_conf['passwd'],
'dbname' => 'kefudb' . $mysql_conf['instance_id']
));
return $conn;
}
public function getOrderId()
{
echo 'sss';
}
public function notifyAllUser()
{
}
}

24
webapp/index.php Normal file
View File

@ -0,0 +1,24 @@
<?php
require 'bootstrap/init.php';
if (empty($_REQUEST['c']) || empty($_REQUEST['a'])) {
die();
return;
}
function autoload_controller__($classname)
{
require_once "controller/$classname.class.php";
spl_autoload_unregister('autoload_controller__');
}
spl_autoload_register('autoload_controller__');
try{
$c = $_REQUEST['c'];
$a = $_REQUEST['a'];
$classname = $c .'Controller';
$obj = eval('return (new $classname())->$a();');
} catch (Exception $e){
echo($e);
}

1
webapp/phpcommon Symbolic link
View File

@ -0,0 +1 @@
../third_party/phpcommon/