show_message($_LANG['ws_goods_attr_exists']); } elseif (in_array($goods['goods_attr_id'], $goods_attr)) { show_message($_LANG['ws_goods_attr_exists']); } } } } /* 获取购买商品的批发方案的价格阶梯 (一个方案多个属性组合、一个属性组合、一个属性、无属性) */ $attr_matching = false; foreach ($wholesale['price_list'] as $attr_price) { // 没有属性 if (empty($attr_price['attr'])) { $attr_matching = true; $goods_list[0]['qp_list'] = $attr_price['qp_list']; break; } elseif (($key = is_attr_matching($goods_list, $attr_price['attr'])) !== false) { $attr_matching = true; $goods_list[$key]['qp_list'] = $attr_price['qp_list']; } } if (!$attr_matching) { show_message($_LANG['ws_attr_not_matching']); } /* 检查数量是否达到最低要求 */ foreach ($goods_list as $goods_key => $goods) { if ($goods['number'] < $goods['qp_list'][0]['quantity']) { show_message($_LANG['ws_goods_number_not_enough']); } else { $goods_price = 0; foreach ($goods['qp_list'] as $qp) { if ($goods['number'] >= $qp['quantity']) {
if ($goods_number <= 0) { show_message($_LANG['ws_invalid_goods_number']); } $wholesale = wholesale_info($act_id); /* 检查session中该商品,该属性是否存在 */ if (isset($_SESSION['wholesale_goods'])) { foreach ($_SESSION['wholesale_goods'] as $goods) { if ($goods['goods_id'] == $wholesale['goods_id'] && $goods['goods_attr_id'] == $goods_attr) { show_message($_LANG['ws_goods_attr_exists']); } } } /* 检查批发价格单中该属性是否存在 */ $attr_matching = false; foreach ($wholesale['price_list'] as $attr_price) { if (empty($attr_price['attr']) || is_attr_matching($goods_attr, $attr_price['attr'])) { $attr_matching = true; $qp_list = $attr_price['qp_list']; break; } } if (!$attr_matching) { show_message($_LANG['ws_attr_not_matching']); } /* 检查数量是否达到最低要求 */ if ($goods_number < $qp_list[0]['quantity']) { show_message($_LANG['ws_goods_number_not_enough']); } else { $goods_price = 0; foreach ($qp_list as $qp) { if ($goods_number >= $qp['quantity']) {