修复 修改兑换码批次的生效时间,如果立减金的有效期大于了修改后的时间,立减金的生效时间也要跟着修改

This commit is contained in:
wangsongsole 2022-06-20 10:35:12 +08:00
parent c4c491e752
commit 659f5f225e
1 changed files with 31 additions and 1 deletions

View File

@ -534,7 +534,16 @@ export default class exchangedit extends React.Component {
const addProductCopy = { legal: [], reduce: [] } const addProductCopy = { legal: [], reduce: [] }
addProduct.map((item) => { addProduct.map((item) => {
if (item.type === 2) { if (item.type === 2) {
if (item.origin) addProductCopy.reduce.push(item.origin) if (item.origin) {
const is = this.compareDate(
this.state.codeInfo.date_time[1],
item.origin.time_limit.effect_time.end_time
)
if (!is)
item.origin.time_limit.effect_time.end_time =
this.state.codeInfo.date_time[1]
addProductCopy.reduce.push(item.origin)
}
} else { } else {
addProductCopy.legal.push(item) addProductCopy.legal.push(item)
} }
@ -544,6 +553,13 @@ export default class exchangedit extends React.Component {
const updateProductCopy = { legal: [], reduce: [] } const updateProductCopy = { legal: [], reduce: [] }
updateProduct.map((item) => { updateProduct.map((item) => {
if (item.type === 2) { if (item.type === 2) {
const is = this.compareDate(
this.state.codeInfo.date_time[1],
item.time_limit.effect_time.end_time
)
if (!is)
item.time_limit.effect_time.end_time =
this.state.codeInfo.date_time[1]
updateProductCopy.reduce.push(item) updateProductCopy.reduce.push(item)
} else { } else {
updateProductCopy.legal.push(item) updateProductCopy.legal.push(item)
@ -569,6 +585,12 @@ export default class exchangedit extends React.Component {
return { data, addProduct, updateProduct } return { data, addProduct, updateProduct }
} }
//比较时间
compareDate(d1, d2) {
return new Date(d1.replace(/-/g, '/')) > new Date(d2.replace(/-/g, '/'))
}
submitCodeData() { submitCodeData() {
if (!this.state.reseller) { if (!this.state.reseller) {
Notify.error('该兑换码对应分销商不存在') Notify.error('该兑换码对应分销商不存在')
@ -747,6 +769,14 @@ export default class exchangedit extends React.Component {
let model2 = this.state.codeInfo let model2 = this.state.codeInfo
model2.date_time = e model2.date_time = e
this.setState({ codeInfo: model2 }) this.setState({ codeInfo: model2 })
sessionStorage.setItem(
'knockGold_effectDate',
JSON.stringify({
begin_time: model2.date_time[0],
end_time: model2.date_time[1]
})
)
} }
//渲染范围列表数据以及数据转换 //渲染范围列表数据以及数据转换