Exemplo n.º 1
0
CustomerInfo.prototype.getPaymentPriceByCondition = function(pCondition, paymentPrice) {
    var baseType = pCondition.baseType;
    var baseAmount = pCondition.baseAmount;
    
    if (baseType === null || baseType === undefined || baseType === 'PERMANENT') {
        return this.getTotalPaymentPrice() + paymentPrice;
    }
    
    if (baseAmount === null || baseAmount === undefined || baseAmount <= 0) {
        return paymentPrice;
    }
    
    var baseDate = new Date();
    
    if (baseType === 'DAY') {
        baseDate = CommonUtil.addDays(baseDate, baseAmount * -1);
    } else if (baseType === 'MONTH') {
        baseDate = CommonUtil.addMonths(baseDate, baseAmount * -1);
    } else if (baseType === 'YEAR') {
        baseDate = CommonUtil.addYears(baseDate, baseAmount * -1);
    }
    
    var totalPaymentPrice = 0;
    
    for (var i = 0, l = this._paymentInfo.length; i < l; i++) {
        var visitDate = new Date(this._paymentInfo[i].createDatetime);
        if (baseDate <= visitDate) {
            totalPaymentPrice += this._paymentInfo[i].paymentPrice;
        }
    }
    
    return totalPaymentPrice + paymentPrice;
};
Exemplo n.º 2
0
CustomerInfo.prototype.getVisitCountByCondition = function(pCondition) {
    var baseType = pCondition.baseType;
    var baseAmount = pCondition.baseAmount;
    
    if (baseType === null || baseType === undefined || baseType === 'PERMANENT') {
        return this._summary.totalVisitCount + 1;
    }
    
    if (baseAmount === null || baseAmount === undefined || baseAmount <= 0) {
        return 1;
    }
    
    var baseDate = new Date();
    
    if (baseType === 'DAY') {
        baseDate = CommonUtil.addDays(baseDate, baseAmount * -1);
    } else if (baseType === 'MONTH') {
        baseDate = CommonUtil.addMonths(baseDate, baseAmount * -1);
    } else if (baseType === 'YEAR') {
        baseDate = CommonUtil.addYears(baseDate, baseAmount * -1);
    }
    
    var visitCount = 0;
    
    for (var i = 0, l = this._paymentInfo.length; i < l; i++) {
        var visitDate = new Date(this._paymentInfo[i].createDatetime);
        if (baseDate <= visitDate) {
            visitCount++;
        }
    }
    
    return visitCount + 1;
};