= $money) payLog(true, '金额错误!'); $arr = explode('_', $_POST['name']); $serverId = $arr['0']; $roleId = $arr['1']; $username = $arr['2']; if(!isset($serverId) || !isset($roleId) || !isset($username)) payLog(true, 'serverId/roleId/username参数错误!'); $sid = intval(str_replace('s', '', $serverId)); $db_name = 'mir_actor_s'.$sid; if(0 >= $sid) payLog(true, '区服ID错误!'); // 计算得出通知验证结果 $alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); if(!$verify_result) { payLog(true, '签名验证失败'); } // 连接区服数据库 $actorDB = new mysqli($_CONFIG_DB['db_host'], $_CONFIG_DB['db_user'], $_CONFIG_DB['db_password'], $db_name, $_CONFIG_DB['db_port']); if ($actorDB->connect_error) payLog(true, '区服数据库连接失败: '.$actorDB->connect_error); $feeSQL = "INSERT INTO `feecallback` (`pfid`, `serverid`, `actorid`, `account`, `prodid`, `num`, `oldserverid`) VALUES ('$pfid', '$sid', '$roleId', '$username', '{$wupin["$money"]}', '$bili', '1')"; // FEE插入成功 if (TRUE === $actorDB->query($feeSQL)) { payLog(false, 'fee insert success'.PHP_EOL.$feeSQL); // 连接订单数据库 $orderDB = new mysqli($_CONFIG_DB['db_host'], $_CONFIG_DB['db_user'], $_CONFIG_DB['db_password'], $_CONFIG_DB['db_name'], $_CONFIG_DB['db_port']); if ($orderDB->connect_error) { $actorDB->close(); payLog(true, '订单数据库连接失败: '.$orderDB->connect_error); } // test //payLog(false, 'fee insert success 1'); // 根据角色ID获取帐号ID $actorRes = $actorDB->query("SELECT accountid, actorname FROM `actors` WHERE actorid = $roleId LIMIT 1"); $actor = $actorRes->fetch_array(MYSQLI_ASSOC); $actorRes->free(); if(empty($actor)) { $orderDB->close(); $actorDB->close(); payLog(true, '获取accountid失败'); } $accountId = $actor['accountid']; $roleName = $actor['actorname']; // test //payLog(false, 'fee insert success 2'); // 连接帐号数据库 $accountDB = new mysqli($_CONFIG_DB['db_host'], $_CONFIG_DB['db_user'], $_CONFIG_DB['db_password'], 'mir_account', $_CONFIG_DB['db_port']); if ($accountDB->connect_error) { $orderDB->close(); $actorDB->close(); payLog(true, '帐号数据库连接失败: '.$accountDB->connect_error); } // test //payLog(false, 'fee insert success 3'); // 根据帐号ID获取帐号 $accountRes = $accountDB->query("SELECT account FROM `globaluser` WHERE userid = $accountId LIMIT 1"); $accountData = $accountRes->fetch_array(MYSQLI_ASSOC); $accountRes->free(); if(empty($accountData)) { $orderDB->close(); $actorDB->close(); $accountDB->close(); payLog(true, '获取account失败'); } $account = $accountData['account']; // test //payLog(false, 'fee insert success 4'); // 创建订单记录 $orderSQL = "INSERT INTO `order` (`account`, `server_id`, `role_id`, `role_name`, `product`, `money`, `time`) VALUES ('$account', '$sid', '$roleId', '$roleName', '{$wupin["$money"]}', '$money', '$time')"; if (FALSE === $orderDB->query($orderSQL)) { payLog(false, 'order create fail'.PHP_EOL.$orderSQL.PHP_EOL.'sql error: '.$orderDB->error); } // test //payLog(false, 'fee insert success 5'); $actorDB->close(); $orderDB->close(); $accountDB->close(); exit('success'); } else { $actorDB->close(); payLog(false, 'fee insert fail'.PHP_EOL.$feeSQL.PHP_EOL.'sql error: '.$actorDB->error); exit('Error: '.$feeSQL.'
'.$actorDB->error); }