diff --git a/webapp/metatable/shop.php b/webapp/metatable/shop.php new file mode 100644 index 0000000..c68226a --- /dev/null +++ b/webapp/metatable/shop.php @@ -0,0 +1,88 @@ += 0; --$i) { + if (array_key_exists($goods_list[$i], $exclude_goods)) { + array_splice($goods_list, $i, 1); + array_splice($goods_weight, $i, 1); + --$num; + } + } + } + $goods = array(); + for ($i = 0; $i < $num; ++$i) { + $rand_space = 0; + foreach ($goods_weight as $value) { + $rand_space += $value; + } + + if ($rand_space <= 0) { + break; + } + $rnd_val = rand(0, $rand_space); + $curr_val = 0; + $discount = false; + if ($discount_num != 0) { + $discount = true; + $discount_num--; + } + for ($ii = 0; $ii < count($goods_weight); ++$ii) { + $curr_val += $goods_weight[$ii]; + if ($rnd_val <= $curr_val) { + array_push($goods, array( + 'id' => $goods_list[$ii], + 'active_time' => time(), + 'status' => 0, + 'isdiscount' => $discount, + )); + array_splice($goods_list, $ii, 1); + array_splice($goods_weight, $ii, 1); + break; + } + } + } + return $goods; +} + +function _internalGetShopConf() +{ + global $g_shop_table; + if (!$g_shop_table) { + $g_shop_table = require(getConfigBaseDir() . 'shop@shop.php'); + } + return $g_shop_table; +} diff --git a/webapp/metatable/shopGoods.php b/webapp/metatable/shopGoods.php new file mode 100644 index 0000000..5408ac9 --- /dev/null +++ b/webapp/metatable/shopGoods.php @@ -0,0 +1,38 @@ +