$redis_conf['host'], 'port' => $redis_conf['port'], 'passwd' => $redis_conf['passwd'] )); return $r; } protected function getMysql($account_id) { $mysql_conf = getMysqlConfig(crc32($account_id)); $conn = new phpcommon\Mysql(array( 'host' => $mysql_conf['host'], 'port' => $mysql_conf['port'], 'user' => $mysql_conf['user'], 'passwd' => $mysql_conf['passwd'], 'dbname' => 'gamedb2004_' . $mysql_conf['instance_id'] )); return $conn; } protected function getItem($item_id) { $g_conf_item_cluster = require('../res/item@item.php'); $item_conf = getItemConfig($g_conf_item_cluster, $item_id); $it = array( 'id' => $item_conf['id'], 'price' => $item_conf['gold'], 'dprice' => $item_conf['diamond_price'], 'discount' => $item_conf['discount'], 'shop_type' => $item_conf['shop_type'], 'type' => $item_conf['fuction'], 'bug_groupnum' => $item_conf['bug_groupnum'], 'shop_list' => $item_conf['shop_list'], 'bug_groupnum' => $item_conf['bug_groupnum'], 'Isbug_again' => $item_conf['Isbug_again'], ); return $it; } protected function getItemEx(&$g_conf_item_cluster, $item_id) { $item_conf = getItemConfig($g_conf_item_cluster, $item_id); $it = array( 'id' => $item_conf['id'], 'price' => $item_conf['gold'], 'dprice' => $item_conf['diamond_price'], 'discount' => $item_conf['discount'], 'shop_type' => $item_conf['shop_type'], 'type' => $item_conf['fuction'], 'bug_groupnum' => $item_conf['bug_groupnum'], 'shop_list' => $item_conf['shop_list'], 'bug_groupnum' => $item_conf['bug_groupnum'], 'Isbug_again' => $item_conf['Isbug_again'], ); return $it; } protected function getShop($shop_id) { $g_conf_shop_cluster = require('../res/shop@shop.php'); $shop_conf = getShopConfig($g_conf_shop_cluster, $shop_id); $s = array( 'shop_id' => $shop_conf['shop_id'], 'item_id' => $shop_conf['item_id'], 'num' => $shop_conf['num'], 'item_weight' => $shop_conf['item_weight'], 'discount' => $shop_conf['discount'], 'discount_weight' => $shop_conf['discount_weight'], 'tip' => $shop_conf['tip'], //'type' => $shop_conf['shop_type'], 'time' => $shop_conf['time'], 'price' => $shop_conf['price'], ); return $s; } protected function getParameter($para_id) { $g_conf_para_cluster = require('../res/parameter@parameter.php'); $para_conf = getParameterConfig($g_conf_para_cluster, $para_id); $p = array( 'id' => $para_conf['id'], 'param_name' => $para_conf['param_name'], 'param_value' => $para_conf['param_value'], ); return $p; } protected function getExplode($string) { $delim = "|"; $drop_multiply = explode($delim, $string); $delim1 = ":"; $arr = array(); for ($i = 0; $i < count($drop_multiply); $i++) { $mul = explode($delim1, $drop_multiply[$i]); array_push($arr, $mul); } return $arr; } protected function getShopInfo($shop_uuid) { $r = $this->getRedis($shop_uuid); if (!$r) { die(); return; } $shop_list = array(); $user_db_str = $r->get($shop_uuid); if (empty($user_db_str)) { $shop_list = $this->randomShop(1); $shop_db = array( 'shop_uuid' => $shop_uuid, 'shop_list' => $shop_list, ); $r -> set($shop_uuid, json_encode($shop_db)); $r -> pexpire($shop_uuid, 1000 * 3600 * 24); } else { $user_db = json_decode($user_db_str, true); if (empty($user_db)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); return; } foreach ($user_db['shop_list'] as $shop) { array_push($shop_list, array( 'shop_id' => $shop['shop_id'], 'item_id' => $shop['item_id'], 'item_num' => $shop['item_num'], 'discount' => $shop['discount'], 'price' => $shop['price'], 'tip' => $shop['tip'], 'status' => $shop['status'], 'time' => $shop['time'], )); } } return $shop_list; } public function shopInfo() { $account_id = $_REQUEST['account_id']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); if (!$login) { phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } $shop_uuid = 'game2004api_shop_uuid: ' . md5($_REQUEST['account_id']); $diamond_shop_uuid = 'game2004api_diamond_shop_uuid:' . md5($_REQUEST['account_id']); //商店信息 $shop_list = $this->getShopInfo($shop_uuid); $rand_coinshop = array(); $rand_diamondshop = array(); $g_conf_item_cluster = require('../res/item@item.php'); $rows = $conn->execQuery('SELECT * FROM bag WHERE accountid=:accountid;', array( ':accountid' => $account_id )); $status = 0; $coin_shop = array(); $diamond_shop = array(); $num = 1; foreach($g_conf_item_cluster as $items) { $it = $this->getItemEx($g_conf_item_cluster, $items['id']); $status = 0; foreach($rows as $r) { if ($r['id'] != $it['id']) { continue; } if ($r['status'] == 2 || $r['active_time'] != 0) { continue; } if ($it['Isbug_again'] == 1) { continue; } $status = 1; break; } if ($it['shop_type'] == 1) { if ($status == 0) { array_push($rand_coinshop,array( 'id' => $it['id'], )); } if ($it['Isbug_again'] == 1) { $num = $it['bug_groupnum']; } array_push($coin_shop,array( 'id' => $it['id'], 'price' => $it['price'], 'status' => $status, 'discount' => 0, 'coin_id' => 10001, 'num' => $num, 'shop_list' => $it['shop_list'], )); } else if ($it['shop_type'] == 2) { if ($status == 0) { array_push($rand_diamondshop,array( 'id' => $it['id'], )); } if ($it['Isbug_again'] == 1) { $num = $it['bug_groupnum']; } array_push($diamond_shop,array( 'id' => $it['id'], 'price' => $it['dprice'], 'status' => $status, 'discount' => 0, 'coin_id' => 10003, 'num' => $num, 'shop_list' => $it['shop_list'], )); } else if ($it['shop_type'] == 3) { if ($status == 0) { array_push($rand_coinshop,array( 'id' => $it['id'], )); } if ($it['Isbug_again'] == 1) { $num = $it['bug_groupnum']; } array_push($coin_shop,array( 'id' => $it['id'], 'price' => $it['price'], 'status' => $status, 'discount' => 0, 'coin_id' => 10001, 'num' => $num, 'shop_list' => $it['shop_list'], )); if ($status == 0) { array_push($rand_diamondshop,array( 'id' => $it['id'], )); } array_push($diamond_shop,array( 'id' => $it['id'], 'price' => $it['dprice'], 'status' => $status, 'discount' => 0, 'coin_id' => 10003, 'num' => $num, 'shop_list' => $it['shop_list'], )); } } $row_shop = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid;', array( ':accountid' => $account_id )); $randcoin_id = 0; $coin_discount = 0; if (count($rand_coinshop) >= 1) { $random_coin = Rand(0, count($rand_coinshop) - 1); $randcoin_id = $rand_coinshop[$random_coin]['id']; $cinfo = $this->getItem($randcoin_id); $coin_discount = $this->randdiscount($cinfo['discount']); } $randdiamnod_id = 0; $dia_discount = 0; if (count($rand_diamondshop) >= 1) { $random_diamond = Rand(0, count($rand_diamondshop) - 1); $randdiamnod_id = $rand_diamondshop[$random_diamond]['id']; $dinfo = $this->getItem($randdiamnod_id); $dia_discount = $this->randdiscount($dinfo['discount']); } if (!$row_shop) { $ret = $conn->execScript('INSERT INTO shop(accountid, coin_id, coin_discount, diamond_id, diamond_discount, create_time, modify_time) ' . ' VALUES(:account_id, :coin_id, :coin_discount, :diamond_id, :diamond_discount, :create_time, :modify_time) ' . ' ON DUPLICATE KEY UPDATE accountid=:account_id, coin_id=:coin_id, coin_discount=:coin_discount, diamond_id=:diamond_id, diamond_discount=:diamond_discount, modify_time=:modify_time;', array( ':account_id' => $account_id, ':coin_id' => $randcoin_id, ':coin_discount' => $coin_discount, ':diamond_id' => $randdiamnod_id, ':diamond_discount' => $dia_discount, ':create_time' => time(), ':modify_time' => time() )); if(!$ret){ die(); return; } } else { if (phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($row_shop['modify_time']) > 0) { $ret = $conn->execScript('UPDATE shop SET coin_id=:coin_id, coin_discount=:coin_discount, diamond_id=:diamond_id, diamond_discount=:diamond_discount, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, ':coin_id' => $randcoin_id, ':coin_discount' => $coin_discount, ':diamond_id' => $randdiamnod_id, ':diamond_discount' => $dia_discount, ':modify_time' => time() )); if (!$ret) { die(); return; } } else { $randcoin_id = $row_shop['coin_id']; $coin_discount = $row_shop['coin_discount']; $randdiamnod_id = $row_shop['diamond_id']; $dia_discount = $row_shop['diamond_discount']; } } foreach($coin_shop as &$co) { if ($co['id'] == $randcoin_id && $co['status'] != 1) { $co['discount'] = $coin_discount; $co['price'] = round($co['price'] * $coin_discount / 10); } } unset($co); foreach($diamond_shop as &$di) { if ($di['id'] == $randdiamnod_id && $di['status'] != 1) { $di['discount'] = $dia_discount; $di['price'] = round($di['price'] * $dia_discount / 10); } } unset($di); echo json_encode(array( 'errcode' => 0, 'errmsg'=> '', 'shop_uuid' => $shop_uuid, 'shop_list' => $shop_list, 'shop_flush_times' => 0, 'coin_shop' => $coin_shop, 'diamond_shop' => $diamond_shop, )); } protected function randdiscount($array) { $keys = 0; $weight_sum = 0; $weight_array = $this->getExplode($array); for ($ii = 0; $ii < count($weight_array); $ii++) { $weight_sum += $weight_array[$ii][1]; } $random = Rand(0, $weight_sum); $weight = 0; for ($ii = 0; $ii < count($weight_array); $ii++) { $weight += $weight_array[$ii][1]; if ($weight > $random) { $keys = $ii; break; } } return $weight_array[$keys][0]; } public function shopBuyMore() { $account_id = $_REQUEST['account_id']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); if (!$login) { phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } $id = $_REQUEST['id']; $type = $_REQUEST['type']; $num = $_REQUEST['num']; $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } $i = $this->getItem($id); $price = 0; if ($i['shop_type'] == 1) { $row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;', array( ':accountid' => $account_id, ':id' => $id )); $price = $i['price'] * $num; if ($row_c) { $price = round($i['price'] * $row_c['coin_discount'] / 10); } $this->SubCoin($price, $account_id, 1); } else if ($i['shop_type'] == 2) { $price = $i['dprice'] * $num; $row_d = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND diamond_id=:id;', array( ':accountid' => $account_id, ':id' => $id )); if ($row_d) { $price = round($i['dprice'] * $row_d['diamond_discount'] / 10); } $this->SubCoin($price, $account_id, 2); } else if ($i['shop_type'] == 3) { if ($type == 0) { $row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;', array( ':accountid' => $account_id, ':id' => $id )); $price = $i['price'] * $num; if ($row_c) { $price = round($price * $row_c['coin_discount'] / 10); } $this->SubCoin($price, $account_id, 1); } else if ($type == 1) { $price = $i['dprice'] * $num; $row_d = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND diamond_id=:id;', array( ':accountid' => $account_id, ':id' => $id )); if ($row_d) { $price = round($dprice * $row_d['diamond_discount'] / 10); } $this->SubCoin($price, $account_id, 2); } } //增加奖励 $addreward = new classes\AddReward(); $all_item_list = $addreward->addReward($id, $num, $account_id, 0, 0); $coin_num = $addreward->getCoinNum($account_id); $diamond_num = $addreward->getDiamondNum($account_id); $item_list = array(); array_push($item_list,array( 'item_id' => $id, 'item_num' => $num, 'time' => 0, )); echo json_encode(array( 'errcode' => 0, 'errmsg'=> '', 'coin_nums' => $coin_num, 'diamond_nums' => $diamond_num, 'item_list' => $item_list, 'all_item_list' => $all_item_list )); } public function buyItem() { $account_id = $_REQUEST['account_id']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); if (!$login) { phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } $id = $_REQUEST['id']; $type = $_REQUEST['type']; $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } $row = $conn->execQueryOne('SELECT status, active_time FROM bag WHERE accountid=:accountid AND id=:id;', array( ':accountid' => $account_id, ':id' => $id )); if ($row) { $it = $this->getItem($id); if ($row['status'] != 2 && $row['active_time'] == 0 && $it['Isbug_again'] != 1) { phpcommon\sendError(ERR_USER_BASE + 4, '商品已购买'); return; } } //扣除货币 $i = $this->getItem($id); $price = 0; $num = 1; if ($i['shop_type'] == 1) { $row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;', array( ':accountid' => $account_id, ':id' => $id )); $price = $i['price']; if ($i['type'] == 10) { $num = $i['bug_groupnum']; } if ($row_c) { $price = round($i['price'] * $row_c['coin_discount'] / 10); } $this->SubCoin($price, $account_id, 1); } else if ($i['shop_type'] == 2) { $price = $i['dprice']; if ($i['type'] == 10) { $num = $i['bug_groupnum']; } $row_d = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND diamond_id=:id;', array( ':accountid' => $account_id, ':id' => $id )); if ($row_d) { $price = round($i['dprice'] * $row_d['diamond_discount'] / 10); } $this->SubCoin($price, $account_id, 2); } else if ($i['shop_type'] == 3) { if ($type == 0) { $row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;', array( ':accountid' => $account_id, ':id' => $id )); $price = $i['price']; if ($i['type'] == 10) { $num = $i['bug_groupnum']; } if ($row_c) { $price = round($i['price'] * $row_c['coin_discount'] / 10); } $this->SubCoin($price, $account_id, 1); } else if ($type == 1) { $price = $i['dprice']; if ($i['type'] == 10) { $num = $i['bug_groupnum']; } $row_d = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND diamond_id=:id;', array( ':accountid' => $account_id, ':id' => $id )); if ($row_d) { $price = round($i['dprice'] * $row_d['diamond_discount'] / 10); } $this->SubCoin($price, $account_id, 2); } } //增加奖励 $addreward = new classes\AddReward(); $all_item_list = $addreward->addReward($id, $num, $account_id, 0, 0); $coin_num = $addreward->getCoinNum($account_id); $diamond_num = $addreward->getDiamondNum($account_id); $item_list = array(); array_push($item_list,array( 'item_id' => $id, 'item_num' => $num, 'time' => 0, )); echo json_encode(array( 'errcode' => 0, 'errmsg'=> '', 'coin_nums' => $coin_num, 'diamond_nums' => $diamond_num, 'item_list' => $item_list, 'all_item_list' => $all_item_list )); } public function buyDoubleItem() { $account_id = $_REQUEST['account_id']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); if (!$login) { phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } if (!isset($_REQUEST['shop_uuid'])) { return; } $shop_id = $_REQUEST['shop_id']; $shop_uuid = $_REQUEST['shop_uuid']; $item_id = 0; $item_num = 0; $price = 0; $status = 0; $flag = 0; $r = $this->getRedis($shop_uuid); $user_db_str = $r->get($shop_uuid); if (empty($user_db_str)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); return; } $user_db = json_decode($user_db_str, true); if (empty($user_db)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); return; } foreach ($user_db['shop_list'] as $shop) { if ($shop['shop_id'] == $shop_id) { $item_id = $shop['item_id']; $item_num = $shop['item_num']; $price = $shop['price']; $status = $shop['status']; $time = $shop['time']; $flag = 1; break; } } if ($flag == 0) { phpcommon\sendError(ERR_USER_BASE + 3, '没有这个商品'); return; } //增加奖励 $p = $this->getParameter(REWARD_TIMES); $times = $p['param_value'] - 1; $addreward = new classes\AddReward(); $addreward->addReward($item_id, $item_num * $times, $account_id, $time, 0); $coin_num = $addreward->getCoinNum($account_id); echo json_encode(array( 'errcode' => 0, 'errmsg'=> '', 'coin_nums' => $coin_num, )); } public function flushShop() { $account_id = $_REQUEST['account_id']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); if (!$login) { phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } if (!isset($_REQUEST['shop_uuid'])) { return; } $shop_uuid = $_REQUEST['shop_uuid']; $shop_type = $_REQUEST['shop_type']; $shop_list = array(); $flush_times = 0; if ($_REQUEST['type'] == 3) { $p = $this->getParameter(RAND_SHOP_GOLD); if ($shop_type == 2) { $p = $this->getParameter(RAND_DIAMONDSHOP_GOLD); } $this->SubCoin($p['param_value'], $account_id, $_REQUEST['type']); } $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } $row = $conn->execQueryOne('SELECT shop_flush_times, diamond_shop_flush_times FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id )); if (!$row) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } if ($shop_type == 1) { $p_flush = $this->getParameter(MAX_SHOP_REFRESH); if ($p_flush['param_value'] <= $row['shop_flush_times']) { phpcommon\sendError(ERR_USER_BASE + 3, '今日刷新次数已满'); return; } $ret = $conn->execScript('UPDATE user SET shop_flush_times=:shop_flush_times, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, ':shop_flush_times' => $row['shop_flush_times'] + 1, ':modify_time' => time() )); if (!$ret) { die(); return; } $flush_times = $row['shop_flush_times'] + 1; } if ($shop_type == 2) { $p_flush = $this->getParameter(RAND_DIAMONDSHOP_TIME); if ($p_flush['param_value'] <= $row['diamond_shop_flush_times']) { phpcommon\sendError(ERR_USER_BASE + 3, '今日刷新次数已满'); return; } $ret = $conn->execScript('UPDATE user SET diamond_shop_flush_times=:diamond_shop_flush_times, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, ':diamond_shop_flush_times' => $row['diamond_shop_flush_times'] + 1, ':modify_time' => time() )); if (!$ret) { die(); return; } $flush_times = $row['diamond_shop_flush_times'] + 1; } $r = $this->getRedis($shop_uuid); $user_db_str = $r->get($shop_uuid); if (empty($user_db_str)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); return; } $user_db = json_decode($user_db_str, true); if (empty($user_db)) { phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); return; } unset($user_db['shop_list']); $shop_list = $this->randomShop($shop_type); $user_db['shop_list'] = $shop_list; $r -> set($shop_uuid, json_encode($user_db)); $r -> pexpire($shop_uuid, 1000 * 3600 * 24); $addreward = new classes\AddReward(); $coin_num = $addreward->getCoinNum($account_id); $diamond_num = $addreward->getDiamondNum($account_id); echo json_encode(array( 'errcode' => 0, 'errmsg'=> '', 'shop_uuid' => $shop_uuid, 'shop_list' => $shop_list, 'flush_times' => $flush_times, 'coin_nums' => $coin_num, 'diamond_nums' => $diamond_num )); } protected function randomShop($type) { $shop_list = array(); $g_conf_shop_cluster = require('../res/shop@shop.php'); $coin_len = 0; $diamond_len = 0; $len = 0; $id = 0; for ($i = 1; $i <= count($g_conf_shop_cluster); $i++) { $s = $this->getShop($i); $coin_len++; } if ($type == 1) { $id = 1; $len = $coin_len; } if ($type == 2) { $id = $coin_len + 1; $len = $diamond_len + $coin_len; } for ($i = $id; $i <= $len; $i++) { $item_id = 0; $item_num = 0; $discount = 0; $price = 0; $key = 0; $s = $this->getShop($i); //确定商品id和数量 $weight_sum = 0; $weight_array = $this->getExplode($s['item_weight']); for ($ii = 0; $ii < count($weight_array); $ii++) { $weight_sum += $weight_array[$ii][0]; } $random = Rand(0, $weight_sum); $weight = 0; for ($ii = 0; $ii < count($weight_array); $ii++) { $weight += $weight_array[$ii][0]; if ($weight > $random) { $key = $ii; break; } } $item_id_array = $this->getExplode($s['item_id']); $num_array = $this->getExplode($s['num']); $item_id = $item_id_array[$key][0]; $item_num = $num_array[$key][0]; //确定折扣和价格 //$it = $this->getItem($item_id); $keys = 0; if ($s['tip'] == 1 || $s['tip'] == 2) { $discount = 0; $price = 0; } else { $keys = 0; $weight_sum = 0; $weight_array = $this->getExplode($s['discount_weight']); for ($ii = 0; $ii < count($weight_array); $ii++) { $weight_sum += $weight_array[$ii][0]; } $random = Rand(0, $weight_sum); $weight = 0; for ($ii = 0; $ii < count($weight_array); $ii++) { $weight += $weight_array[$ii][0]; if ($weight > $random) { $keys = $ii; break; } } $discount_array = $this->getExplode($s['discount']); $discount = $discount_array[$keys][0]; $price_array = $this->getExplode($s['price']); $price = round($price_array[$key][0] * $item_num * ($discount * 1.0 / 10)); /*if ($s['tip'] == 4) { $price = round($it['dprice'] * $item_num * ($discount * 1.0 / 10)); }*/ } $time_array = $this->getExplode($s['time']); $time = $time_array[$key][0]; array_push($shop_list, array( 'shop_id' => $s['shop_id'], 'item_id' => $item_id, 'item_num' => $item_num, 'discount' => $discount, 'price' => $price, 'tip' => $s['tip'], 'status' => 0, 'time' => $time )); } return $shop_list; } protected function subCoin($coin_num, $account_id, $tips) { $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } $rowCoin = $conn->execQueryOne('SELECT coin_num, diamond_num FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id )); if ($tips == 1) { //扣除货币 if ($rowCoin['coin_num'] < $coin_num) { phpcommon\sendError(ERR_USER_BASE + 3, '金币不足'); die(); } $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, ':coin_num' => $rowCoin['coin_num'] - $coin_num, ':modify_time' => time() )); if (!$ret) { die(); } } if ($tips == 2) { //扣除货币 if ($rowCoin['diamond_num'] < $coin_num) { phpcommon\sendError(ERR_USER_BASE + 5, '钻石不足'); die(); } $ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, ':diamond_num' => $rowCoin['diamond_num'] - $coin_num, ':modify_time' => time() )); if (!$ret) { die(); } } } } ?>