61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
export function canComputedPackFee(v) {
|
|
return v.pack && v.status != 'return' && v.status != 'refund' && v.status != 'part_refund'
|
|
}
|
|
export function returnCanComputedGoodsArr(arr) {
|
|
return arr.filter(v => canComputedPackFee(v))
|
|
}
|
|
export function returnPackFee(arr) {
|
|
return arr.reduce((prve, cur) => {
|
|
return prve + cur.packAmount
|
|
}, 0).toFixed(2)
|
|
}
|
|
|
|
export function canTuicai(orderInfo, item) {
|
|
if (orderInfo.status == 'unpaid' && orderInfo.isPostpaid !== null && orderInfo.isPostpaid == 0) {
|
|
return false
|
|
}
|
|
return orderInfo.status == 'unpaid' && orderInfo.useType != 'dine-in-before' && item.status != 'return'
|
|
}
|
|
export function canTuiKuan(orderInfo, item) {
|
|
if( item ){
|
|
return (orderInfo.status == 'done' || orderInfo.status == 'part_refund')
|
|
&& item.status != 'return' && item.status != 'refund' && item.status != 'refunding'
|
|
&& (item.returnNum < item.num)
|
|
} else {
|
|
let data = false;
|
|
uni.$utils.objToArrary(orderInfo.detailMap).some((v,i)=>{
|
|
if( orderInfo.refundAmount < orderInfo.payAmount || (orderInfo.status == 'done' || orderInfo.status == 'part_refund' ) && v.status != 'return' && v.status != 'refund' && v.status != 'refunding' && (v.returnNum+v.refundNum < v.num) ){
|
|
data = true
|
|
return data
|
|
}
|
|
})
|
|
return data
|
|
}
|
|
|
|
}
|
|
export function isTuiCai(item) {
|
|
return item.status == 'return' || item.status == 'part_refund'
|
|
}
|
|
export function isTui(item) {
|
|
return item.status == 'return' || item.status == 'refund' || item.status == 'part_refund'
|
|
}
|
|
export function isGift(item) {
|
|
return !isTui(item) && item.isGift == 1
|
|
}
|
|
export function numSum(arr) {
|
|
const sum = arr.reduce((a, b) => {
|
|
return a + b * 100
|
|
}, 0)
|
|
return (sum / 100).toFixed(2)
|
|
}
|
|
export function mathFloorPrice(price,item) {
|
|
if( item ){
|
|
if( item.productType == 'weight' || item.type == 'weight'){
|
|
return (Math.floor(price * 100)/100).toFixed(2)
|
|
} else {
|
|
return parseFloat(price).toFixed(2)
|
|
}
|
|
} else {
|
|
return parseFloat(price).toFixed(2)
|
|
}
|
|
} |