fix: 修改优惠券库存校验

This commit is contained in:
zhangds 2024-05-21 11:40:07 +08:00
parent 7436db391b
commit 04cda1102f
2 changed files with 12 additions and 4 deletions

View File

@ -11,7 +11,7 @@ import Form from "@/components/form/main"
import Grid from "@/components/gird/main.js"
import Ipt from "@/components/input/main"
import { knockGoldFun, submitIsKm } from "@/tools/index"
import { mulNum } from "@/tools/number"
import { mulNum, divNum } from "@/tools/number"
import { isAmount } from "@/tools/validate"
import { useSetState } from "ahooks"
import { isSameDay } from "date-fns"
@ -31,6 +31,7 @@ import {
Sweetalert
} from "zent"
import UseGoodsScopePop from "../UseGoodsScopePop/index"
import "./style.less"
const initArray = (targetNum) => {
@ -498,13 +499,21 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
// --
let sum = 0
arr.map((item) => {
// sum += parseInt(item.quantity)
sum += item.all_budget
// 1.
if (item.type === 1) {
sum += parseInt(item.quantity)
} else {
// 2.
sum += parseInt(
divNum(item.only.all_budget, mulNum(item.only.reduce_amount, item.only.send_num))
)
}
})
if (sum < Number(form_rule_data.quantity)) {
Notify.error("所选商品库存总数小于发放量")
return false
}
//
if (couponType === 1) {
return true

View File

@ -175,7 +175,6 @@ const UseProductPop = forwardRef((props, ref) => {
return new Promise((resolve, reject) => {
//
if (productData) {
debugger
setModel({
goods_id: productData.goods_id,
cost_price: productData.cost_price,