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

View File

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