fix: show configured store discount during hotel verification
| | |
| | | const validAmount = (): boolean => /^\d+(\.\d{1,2})?$/.test(amountText.value) && amountValue() > 0 |
| | | const quoteMatchesAmount = (): boolean => quote.value.originalAmount == Math.round(amountValue() * 100) |
| | | const canSubmit = computed((): boolean => validAmount() && selectedRuleId.value.length > 0 && quote.value.payAmount >= 0 && quoteMatchesAmount() && !submitting.value) |
| | | const formatBenefitNumber = (value: number): string => { |
| | | if (Math.round(value) == value) return '' + Math.round(value) |
| | | return value.toFixed(2).replace(/0+$/, '').replace(/\.$/, '') |
| | | } |
| | | const selectedRuleName = (): string => { |
| | | for (let index = 0; index < rules.value.length; index++) { |
| | | if (rules.value[index].id == selectedRuleId.value) return rules.value[index].name |
| | | if (rules.value[index].id == selectedRuleId.value) { |
| | | const rule = rules.value[index] |
| | | if (rule.benefitText.length > 0) return rule.benefitText |
| | | if (rule.fixedReduction > 0) return '到店消费立减' + formatBenefitNumber(rule.fixedReduction) + '元' |
| | | if (rule.discountRate > 0) return '到店消费' + formatBenefitNumber(rule.discountRate * 10) + '折' |
| | | return rule.name |
| | | } |
| | | } |
| | | return '人才专属优惠' |
| | | } |
| | |
| | | id: string |
| | | name: string |
| | | discountRate: number |
| | | fixedReduction: number |
| | | benefitText: string |
| | | subsidyEnabled: boolean |
| | | } |
| | | export type ManualConsumptionCoupon = { id: string; name: string; couponAmount: number; conditionType: string; conditionAmount: number } |
| | |
| | | id: value.id != null ? '' + value.id : '', |
| | | name: value.name != null ? '' + value.name : '人才优惠', |
| | | discountRate: numberValue(value.discountRate), |
| | | fixedReduction: numberValue(value.fixedReduction), |
| | | benefitText: value.benefitText != null ? '' + value.benefitText : '', |
| | | subsidyEnabled: value.subsidyEnabled == true |
| | | })), |
| | | coupons: (source.coupons != null ? source.coupons as Array<any> : []).map((value: any): ManualConsumptionCoupon => ({ id: '' + value.id, name: value.name != null ? '' + value.name : '优惠券', couponAmount: numberValue(value.couponAmount), conditionType: value.conditionType != null ? '' + value.conditionType : 'NONE', conditionAmount: numberValue(value.conditionAmount) })) |