|
@@ -112,6 +112,7 @@ if ($isedit) {
|
|
|
if (empty($item['product_id'])) continue;
|
|
|
|
|
|
$product_id = (int)$item['product_id'];
|
|
|
+ $spec_id = isset($item['spec_id']) ? (int)$item['spec_id'] : 0;
|
|
|
$quantity = (int)$item['quantity'];
|
|
|
$unit_price = (float)$item['unit_price'];
|
|
|
|
|
@@ -128,27 +129,26 @@ if ($isedit) {
|
|
|
$product_row = mysqli_fetch_assoc($product_result);
|
|
|
$product_name = $product_row['ProductName'];
|
|
|
|
|
|
- // 查询该产品在价格表中的最低价格要求
|
|
|
- // 根据产品ID和数量查找最接近但不超过当前订单数量的价格记录
|
|
|
- $price_query = "SELECT * FROM price
|
|
|
- WHERE productId = $product_id
|
|
|
- AND num <= $quantity
|
|
|
- ORDER BY num DESC
|
|
|
- LIMIT 1";
|
|
|
-
|
|
|
- $price_result = mysqli_query($conn, $price_query);
|
|
|
-
|
|
|
- if (mysqli_num_rows($price_result) > 0) {
|
|
|
- $price_row = mysqli_fetch_assoc($price_result);
|
|
|
- $min_price = (float)$price_row['price'];
|
|
|
+ // 如果有规格ID,检查规格价格
|
|
|
+ if ($spec_id > 0) {
|
|
|
+ $spec_query = "SELECT price, spec_name, spec_value FROM product_specifications
|
|
|
+ WHERE id = $spec_id AND product_id = $product_id
|
|
|
+ LIMIT 1";
|
|
|
+
|
|
|
+ $spec_result = mysqli_query($conn, $spec_query);
|
|
|
|
|
|
- // 如果单价低于指导价,标记错误
|
|
|
- if ($unit_price < $min_price) {
|
|
|
- $price_error = true;
|
|
|
- $error_product_name = $product_name;
|
|
|
- $error_min_price = $min_price;
|
|
|
- $error_current_price = $unit_price;
|
|
|
- break;
|
|
|
+ if (mysqli_num_rows($spec_result) > 0) {
|
|
|
+ $spec_row = mysqli_fetch_assoc($spec_result);
|
|
|
+ $min_price = (float)$spec_row['price'];
|
|
|
+
|
|
|
+ // 如果单价低于规格价格,标记错误
|
|
|
+ if ($min_price > 0 && $unit_price < $min_price) {
|
|
|
+ $price_error = true;
|
|
|
+ $error_product_name = $product_name . " (" . $spec_row['spec_name'] . ": " . $spec_row['spec_value'] . ")";
|
|
|
+ $error_min_price = $min_price;
|
|
|
+ $error_current_price = $unit_price;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -224,6 +224,7 @@ if ($isedit) {
|
|
|
if (empty($item['product_id'])) continue;
|
|
|
|
|
|
$product_id = (int)$item['product_id'];
|
|
|
+ $spec_id = isset($item['spec_id']) ? (int)$item['spec_id'] : 0;
|
|
|
$quantity = (int)$item['quantity'];
|
|
|
$unit_price = (float)$item['unit_price'];
|
|
|
|
|
@@ -240,27 +241,26 @@ if ($isedit) {
|
|
|
$product_row = mysqli_fetch_assoc($product_result);
|
|
|
$product_name = $product_row['ProductName'];
|
|
|
|
|
|
- // 查询该产品在价格表中的最低价格要求
|
|
|
- // 根据产品ID和数量查找最接近但不超过当前订单数量的价格记录
|
|
|
- $price_query = "SELECT * FROM price
|
|
|
- WHERE productId = $product_id
|
|
|
- AND num <= $quantity
|
|
|
- ORDER BY num DESC
|
|
|
- LIMIT 1";
|
|
|
-
|
|
|
- $price_result = mysqli_query($conn, $price_query);
|
|
|
-
|
|
|
- if (mysqli_num_rows($price_result) > 0) {
|
|
|
- $price_row = mysqli_fetch_assoc($price_result);
|
|
|
- $min_price = (float)$price_row['price'];
|
|
|
+ // 如果有规格ID,检查规格价格
|
|
|
+ if ($spec_id > 0) {
|
|
|
+ $spec_query = "SELECT price, spec_name, spec_value FROM product_specifications
|
|
|
+ WHERE id = $spec_id AND product_id = $product_id
|
|
|
+ LIMIT 1";
|
|
|
+
|
|
|
+ $spec_result = mysqli_query($conn, $spec_query);
|
|
|
|
|
|
- // 如果单价低于指导价,标记错误
|
|
|
- if ($unit_price < $min_price) {
|
|
|
- $price_error = true;
|
|
|
- $error_product_name = $product_name;
|
|
|
- $error_min_price = $min_price;
|
|
|
- $error_current_price = $unit_price;
|
|
|
- break;
|
|
|
+ if (mysqli_num_rows($spec_result) > 0) {
|
|
|
+ $spec_row = mysqli_fetch_assoc($spec_result);
|
|
|
+ $min_price = (float)$spec_row['price'];
|
|
|
+
|
|
|
+ // 如果单价低于规格价格,标记错误
|
|
|
+ if ($min_price > 0 && $unit_price < $min_price) {
|
|
|
+ $price_error = true;
|
|
|
+ $error_product_name = $product_name . " (" . $spec_row['spec_name'] . ": " . $spec_row['spec_value'] . ")";
|
|
|
+ $error_min_price = $min_price;
|
|
|
+ $error_current_price = $unit_price;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|