|
|
@ -377,6 +377,13 @@ export default { |
|
|
|
customServiceItemCount: [], |
|
|
|
// 当日价格 |
|
|
|
currentDayPrice: 0, |
|
|
|
|
|
|
|
freePetConfig : { |
|
|
|
cat: { freeCount: 1 }, |
|
|
|
smallDog: { freeCount: 0 }, |
|
|
|
mediumDog: { freeCount: 0 }, |
|
|
|
largeDog: { freeCount: 0 } |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
@ -806,52 +813,84 @@ export default { |
|
|
|
return acc + this.calculatePetCost(pet); |
|
|
|
}, 0); |
|
|
|
// 如果总宠物费用>30 |
|
|
|
const freeQuota = this.price_config.freeQuota |
|
|
|
if (totalPetCost > Number(freeQuota.threshold)) { |
|
|
|
freeQuota.rules.forEach(rule => { |
|
|
|
if (rule.type === 'cat' && catCount >= rule.count) { |
|
|
|
additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
catCount = catCount - rule.count |
|
|
|
}else if(rule.type === 'smallDog' && smallDogCount >= rule.count){ |
|
|
|
additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
smallDogCount = smallDogCount - rule.count |
|
|
|
}else if(rule.type === 'mediumDog' && mediumDogCount >= rule.count){ |
|
|
|
additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
mediumDogCount = mediumDogCount - rule.count |
|
|
|
}else{ |
|
|
|
additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
} |
|
|
|
}) |
|
|
|
// if (totalPetCost > 30) { |
|
|
|
// // 如果猫数量>=3 |
|
|
|
// if (catCount >= 3) { |
|
|
|
// additionalCost = totalPetCost - 30 |
|
|
|
// catCount = catCount - 3 |
|
|
|
// } else if (smallDogCount >= 2) { |
|
|
|
// additionalCost = totalPetCost - 30 |
|
|
|
// smallDogCount = smallDogCount - 2 |
|
|
|
// } else if (mediumDogCount >= 1) { |
|
|
|
// additionalCost = totalPetCost - 30 |
|
|
|
// mediumDogCount = mediumDogCount - 1 |
|
|
|
// } else { |
|
|
|
// additionalCost = totalPetCost - 25 |
|
|
|
// catCount = catCount - 1 |
|
|
|
// smallDogCount = smallDogCount - 1 |
|
|
|
// } |
|
|
|
petTypeCounts.push({ |
|
|
|
date, |
|
|
|
largeDogCount, |
|
|
|
mediumDogCount, |
|
|
|
smallDogCount, |
|
|
|
catCount |
|
|
|
}) |
|
|
|
} |
|
|
|
// const freeQuota = this.price_config.freeQuota |
|
|
|
// if (totalPetCost > Number(freeQuota.threshold)) { |
|
|
|
// freeQuota.rules.forEach(rule => { |
|
|
|
// if (rule.type === 'cat' && catCount >= rule.count) { |
|
|
|
// additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
// catCount = catCount - rule.count |
|
|
|
// }else if(rule.type === 'smallDog' && smallDogCount >= rule.count){ |
|
|
|
// additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
// smallDogCount = smallDogCount - rule.count |
|
|
|
// }else if(rule.type === 'mediumDog' && mediumDogCount >= rule.count){ |
|
|
|
// additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
// mediumDogCount = mediumDogCount - rule.count |
|
|
|
// }else{ |
|
|
|
// additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// // if (totalPetCost > 30) { |
|
|
|
// // // 如果猫数量>=3 |
|
|
|
// // if (catCount >= 3) { |
|
|
|
// // additionalCost = totalPetCost - 30 |
|
|
|
// // catCount = catCount - 3 |
|
|
|
// // } else if (smallDogCount >= 2) { |
|
|
|
// // additionalCost = totalPetCost - 30 |
|
|
|
// // smallDogCount = smallDogCount - 2 |
|
|
|
// // } else if (mediumDogCount >= 1) { |
|
|
|
// // additionalCost = totalPetCost - 30 |
|
|
|
// // mediumDogCount = mediumDogCount - 1 |
|
|
|
// // } else { |
|
|
|
// // additionalCost = totalPetCost - 25 |
|
|
|
// // catCount = catCount - 1 |
|
|
|
// // smallDogCount = smallDogCount - 1 |
|
|
|
// // } |
|
|
|
// } |
|
|
|
|
|
|
|
petTypeCounts.push({ |
|
|
|
date, |
|
|
|
largeDogCount, |
|
|
|
mediumDogCount, |
|
|
|
smallDogCount, |
|
|
|
catCount |
|
|
|
}) |
|
|
|
|
|
|
|
// 如果有大型犬,额外费用为40元/只 |
|
|
|
if (largeDogCount > 0) { |
|
|
|
additionalCost += (40 * largeDogCount) |
|
|
|
// 根据 freePetConfig 配置计算免费宠物数量 |
|
|
|
const freePetConfig = this.price_config.freePetConfig || this.freePetConfig |
|
|
|
|
|
|
|
// 如果有大型犬,超过免费数量的收费 |
|
|
|
if (largeDogCount > freePetConfig.largeDog.freeCount) { |
|
|
|
const chargeableCount = largeDogCount - freePetConfig.largeDog.freeCount |
|
|
|
additionalCost += (this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '大型', |
|
|
|
}) * chargeableCount) |
|
|
|
} |
|
|
|
// 如果有中型犬,超过免费数量的收费 |
|
|
|
if (mediumDogCount > freePetConfig.mediumDog.freeCount) { |
|
|
|
const chargeableCount = mediumDogCount - freePetConfig.mediumDog.freeCount |
|
|
|
additionalCost += (this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '中型', |
|
|
|
}) * chargeableCount) |
|
|
|
} |
|
|
|
// 如果有小型犬,超过免费数量的收费 |
|
|
|
if (smallDogCount > freePetConfig.smallDog.freeCount) { |
|
|
|
const chargeableCount = smallDogCount - freePetConfig.smallDog.freeCount |
|
|
|
additionalCost += (this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '小型', |
|
|
|
}) * chargeableCount) |
|
|
|
} |
|
|
|
// 如果有猫,超过免费数量的收费 |
|
|
|
if (catCount > freePetConfig.cat.freeCount) { |
|
|
|
const chargeableCount = catCount - freePetConfig.cat.freeCount |
|
|
|
additionalCost += (this.calculatePetCost({ |
|
|
|
petType: 'cat', |
|
|
|
bodyType: '小型', |
|
|
|
}) * chargeableCount) |
|
|
|
} |
|
|
|
|
|
|
|
// 如果有额外费用,添加到总额外费用 |
|
|
|
if (additionalCost > 0) { |
|
|
|
additionalTotalCost += additionalCost; |
|
|
@ -917,11 +956,11 @@ export default { |
|
|
|
let petExtra = this.price_config.petExtra |
|
|
|
let petCost = 0; |
|
|
|
if (pet.petType === 'cat') { |
|
|
|
petCost += Number(petExtra.cat); // 猫额外费用 |
|
|
|
petCost += Number(petExtra.cat.price); // 猫额外费用 |
|
|
|
} else if (pet.petType === 'dog' && pet.bodyType.includes('小型')) { |
|
|
|
petCost += Number(petExtra.smallDog); // 小型犬额外费用 |
|
|
|
petCost += Number(petExtra.smallDog.price); // 小型犬额外费用 |
|
|
|
} else if (pet.petType === 'dog' && pet.bodyType.includes('中型')) { |
|
|
|
petCost += Number(petExtra.mediumDog); // 中型犬额外费用 |
|
|
|
petCost += Number(petExtra.mediumDog.price); // 中型犬额外费用 |
|
|
|
} |
|
|
|
return petCost; |
|
|
|
}, |
|
|
@ -1044,50 +1083,60 @@ export default { |
|
|
|
const petTypeArr = this.petTypeCounts.filter(item => item.largeDogCount > 0 || item.mediumDogCount > 0 || |
|
|
|
item.smallDogCount > 0 || item.catCount > 0) |
|
|
|
// 假设largeDogCount=1 mediumDogCount=2 smallDogCount=3 catCount=4 则生成4条数据 |
|
|
|
|
|
|
|
petTypeArr.forEach(item => { |
|
|
|
if (item.largeDogCount > 0) { |
|
|
|
// 获取免费宠物配置 |
|
|
|
const freePetConfig = this.price_config.freePetConfig || this.freePetConfig |
|
|
|
|
|
|
|
// 只显示收费的宠物数量(扣除免费数量) |
|
|
|
const chargeableLargeDogCount = Math.max(0, item.largeDogCount - freePetConfig.largeDog.freeCount) |
|
|
|
const chargeableMediumDogCount = Math.max(0, item.mediumDogCount - freePetConfig.mediumDog.freeCount) |
|
|
|
const chargeableSmallDogCount = Math.max(0, item.smallDogCount - freePetConfig.smallDog.freeCount) |
|
|
|
const chargeableCatCount = Math.max(0, item.catCount - freePetConfig.cat.freeCount) |
|
|
|
|
|
|
|
if (chargeableLargeDogCount > 0) { |
|
|
|
additionalCostItem.push({ |
|
|
|
itemName: '大型犬', |
|
|
|
price: this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '大型', |
|
|
|
}), |
|
|
|
quantity: item.largeDogCount, |
|
|
|
quantity: chargeableLargeDogCount, |
|
|
|
unit: '只', |
|
|
|
date: item.date |
|
|
|
}) |
|
|
|
} |
|
|
|
if (item.mediumDogCount > 0) { |
|
|
|
if (chargeableMediumDogCount > 0) { |
|
|
|
additionalCostItem.push({ |
|
|
|
itemName: '中型犬', |
|
|
|
price: this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '中型', |
|
|
|
}), |
|
|
|
quantity: item.mediumDogCount, |
|
|
|
quantity: chargeableMediumDogCount, |
|
|
|
unit: '只', |
|
|
|
date: item.date |
|
|
|
}) |
|
|
|
} |
|
|
|
if (item.smallDogCount > 0) { |
|
|
|
if (chargeableSmallDogCount > 0) { |
|
|
|
additionalCostItem.push({ |
|
|
|
itemName: '小型犬', |
|
|
|
price: this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '小型', |
|
|
|
}), |
|
|
|
quantity: item.smallDogCount, |
|
|
|
quantity: chargeableSmallDogCount, |
|
|
|
unit: '只', |
|
|
|
date: item.date |
|
|
|
}) |
|
|
|
} |
|
|
|
if (item.catCount > 0) { |
|
|
|
if (chargeableCatCount > 0) { |
|
|
|
additionalCostItem.push({ |
|
|
|
itemName: '猫猫', |
|
|
|
price: this.calculatePetCost({ |
|
|
|
petType: 'cat', |
|
|
|
}), |
|
|
|
quantity: item.catCount, |
|
|
|
quantity: chargeableCatCount, |
|
|
|
unit: '只', |
|
|
|
date: item.date |
|
|
|
}) |
|
|
@ -1249,55 +1298,58 @@ export default { |
|
|
|
let totalPetCost = currentDayPets.reduce((acc, pet) => { |
|
|
|
return acc + this.calculatePetCost(pet); |
|
|
|
}, 0); |
|
|
|
// 如果总宠物费用>30 |
|
|
|
const freeQuota = this.price_config.freeQuota |
|
|
|
if (totalPetCost > Number(freeQuota.threshold)) { |
|
|
|
freeQuota.rules.forEach(rule => { |
|
|
|
if (rule.type === 'cat' && catCount >= rule.count) { |
|
|
|
additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
catCount = catCount - rule.count |
|
|
|
}else if(rule.type === 'smallDog' && smallDogCount >= rule.count){ |
|
|
|
additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
smallDogCount = smallDogCount - rule.count |
|
|
|
}else if(rule.type === 'mediumDog' && mediumDogCount >= rule.count){ |
|
|
|
additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
mediumDogCount = mediumDogCount - rule.count |
|
|
|
}else{ |
|
|
|
additionalCost = totalPetCost - Number(rule.freeAmount) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
if (largeDogCount > 0) { |
|
|
|
additionalCostItem.push({ itemName: '大型犬', price: this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '大型', |
|
|
|
}), quantity: largeDogCount, unit: '只' }) |
|
|
|
} |
|
|
|
if (mediumDogCount > 0) { |
|
|
|
additionalCostItem.push({ itemName: '中型犬', price: this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '中型', |
|
|
|
}), quantity: mediumDogCount, unit: '只' }) |
|
|
|
} |
|
|
|
if (smallDogCount > 0) { |
|
|
|
additionalCostItem.push({ itemName: '小型犬', price: this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '小型', |
|
|
|
}), quantity: smallDogCount, unit: '只' }) |
|
|
|
} |
|
|
|
if (catCount > 0) { |
|
|
|
additionalCostItem.push({ itemName: '猫猫', price: this.calculatePetCost({ |
|
|
|
petType: 'cat', |
|
|
|
}), quantity: catCount, unit: '只' }) |
|
|
|
} |
|
|
|
|
|
|
|
// 根据 freePetConfig 配置计算免费宠物数量 |
|
|
|
const freePetConfig = this.price_config.freePetConfig || { |
|
|
|
cat: { freeCount: 1 }, |
|
|
|
smallDog: { freeCount: 0 }, |
|
|
|
mediumDog: { freeCount: 0 }, |
|
|
|
largeDog: { freeCount: 0 } |
|
|
|
} |
|
|
|
// 如果有大型犬,额外费用为40元/只 |
|
|
|
if (largeDogCount > 0) { |
|
|
|
|
|
|
|
// 计算收费的宠物数量(扣除免费数量) |
|
|
|
const chargeableLargeDogCount = Math.max(0, largeDogCount - freePetConfig.largeDog.freeCount) |
|
|
|
const chargeableMediumDogCount = Math.max(0, mediumDogCount - freePetConfig.mediumDog.freeCount) |
|
|
|
const chargeableSmallDogCount = Math.max(0, smallDogCount - freePetConfig.smallDog.freeCount) |
|
|
|
const chargeableCatCount = Math.max(0, catCount - freePetConfig.cat.freeCount) |
|
|
|
|
|
|
|
// 计算额外宠物费用 |
|
|
|
if (chargeableLargeDogCount > 0) { |
|
|
|
additionalCost += (this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '大型', |
|
|
|
}) * largeDogCount) |
|
|
|
}) * chargeableLargeDogCount) |
|
|
|
additionalCostItem.push({ itemName: '大型犬', price: this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '大型', |
|
|
|
}), quantity: chargeableLargeDogCount, unit: '只' }) |
|
|
|
} |
|
|
|
if (chargeableMediumDogCount > 0) { |
|
|
|
additionalCost += (this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '中型', |
|
|
|
}) * chargeableMediumDogCount) |
|
|
|
additionalCostItem.push({ itemName: '中型犬', price: this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '中型', |
|
|
|
}), quantity: chargeableMediumDogCount, unit: '只' }) |
|
|
|
} |
|
|
|
if (chargeableSmallDogCount > 0) { |
|
|
|
additionalCost += (this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '小型', |
|
|
|
}) * chargeableSmallDogCount) |
|
|
|
additionalCostItem.push({ itemName: '小型犬', price: this.calculatePetCost({ |
|
|
|
petType: 'dog', |
|
|
|
bodyType: '小型', |
|
|
|
}), quantity: chargeableSmallDogCount, unit: '只' }) |
|
|
|
} |
|
|
|
if (chargeableCatCount > 0) { |
|
|
|
additionalCost += (this.calculatePetCost({ |
|
|
|
petType: 'cat', |
|
|
|
}) * chargeableCatCount) |
|
|
|
additionalCostItem.push({ itemName: '猫猫', price: this.calculatePetCost({ |
|
|
|
petType: 'cat', |
|
|
|
}), quantity: chargeableCatCount, unit: '只' }) |
|
|
|
} |
|
|
|
// 当日多次服务次数 - 基础价格乘以倍数 |
|
|
|
let multServicesTotalCost = 0 |
|
|
|