Example #1
0
 public CrmRuleValue FindRuleValue(DateTime saleTime, CrmVipCard vipCard, CrmArticle article, int payTypeId, CrmBankCardPayment bankCard, out CrmBankCardCodeScope bankCardCodeScope)
 {
     bankCardCodeScope = null;
     if (WithinPeriodOfTime(saleTime) && (saleTime.CompareTo(BeginTime) > 0) && (saleTime.CompareTo(EndTime) < 0) && (BeginTime.CompareTo(DateTime.MinValue) > 0) && (EndTime.CompareTo(DateTime.MinValue) > 0))
     {
         if (ArticleIds != null)
         {
             int inx = SeekUtils.IndexOfAscendingIntArray(ArticleIds, article.ArticleId);
             if (inx >= 0)
             {
                 return(ArticleRuleValues[inx]);
             }
         }
         if (Items != null)
         {
             foreach (CrmRuleBillItem ruleItem in Items)
             {
                 if (ruleItem.Match(article, vipCard, saleTime, payTypeId, bankCard, out bankCardCodeScope))
                 {
                     return(ruleItem.RuleValue);
                 }
             }
         }
     }
     return(null);
 }
Example #2
0
        public bool Match(CrmArticle article, CrmVipCard vipCard, DateTime saleDate, int payTypeId, CrmBankCardPayment bankCard, out CrmBankCardCodeScope bankCardCodeScope)
        {
            bankCardCodeScope = null;
            bool ok = ((!ExistDept) || (SeekUtils.IndexOfLikeStringArray(DeptCodes, article.DeptCode) >= 0)) &&
                      ((!ExistCategory) || (SeekUtils.IndexOfLikeStringArray(CategoryCodes, article.CategoryCode) >= 0)) &&
                      ((!ExistContract) || (SeekUtils.IndexOfAscendingIntArray(ContractIds, article.ContractId) >= 0)) &&
                      ((!ExistBrand) || (SeekUtils.IndexOfAscendingIntArray(BrandIds, article.BrandId) >= 0)) &&
                      ((!ExistArticle) || (SeekUtils.IndexOfAscendingIntArray(ArticleIds, article.ArticleId) >= 0)) &&
                      ((!ExistPayType) || ((payTypeId > 0) && (SeekUtils.IndexOfAscendingIntArray(PayTypes, payTypeId) >= 0)));

            if (ok && ExistBank)
            {
                ok = false;
                if (bankCard != null)
                {
                    foreach (CrmBankCardCodeScope scope in bankCard.BankCardCodeScopeList)
                    {
                        if ((scope.BankId > 0) && (SeekUtils.IndexOfAscendingIntArray(BankIds, scope.BankId) >= 0))
                        {
                            bankCardCodeScope = scope;
                            ok = true;
                            break;
                        }
                    }
                }
            }
            if (ok && ExistBankCard && (bankCard != null))
            {
                ok = false;
                if (bankCard != null)
                {
                    foreach (CrmBankCardCodeScope scope in bankCard.BankCardCodeScopeList)
                    {
                        if ((scope.ScopeId > 0) && (SeekUtils.IndexOfAscendingIntArray(BankCardCodeScopeIds, scope.ScopeId) >= 0))
                        {
                            bankCardCodeScope = scope;
                            ok = true;
                            break;
                        }
                    }
                }
            }

            if (ok && ExistVipGroup)
            {
                ok = false;
                if (VipGroups != null)
                {
                    foreach (CrmVipGroup vipGroup in VipGroups)
                    {
                        if (vipGroup.Match(vipCard, saleDate))
                        {
                            ok = true;
                            break;
                        }
                    }
                }
            }
            return(ok);
        }
Example #3
0
/*
 *      public CrmRuleValue FindRuleValue(DateTime saleTime, CrmArticle article)
 *      {
 *          //翠微版要改,只有商品条件,取不到规则 2012.2.24
 *          if (WithinPeriodOfTime(saleTime) && (saleTime.CompareTo(BeginTime) > 0) && (saleTime.CompareTo(EndTime) < 0) && (BeginTime.CompareTo(DateTime.MinValue) > 0) && (EndTime.CompareTo(DateTime.MinValue) > 0))
 *          {
 *              if (ArticleIds != null)
 *              {
 *                  int inx = SeekUtils.IndexOfAscendingIntArray(ArticleIds, article.ArticleId);
 *                  if (inx >= 0)
 *                  {
 *                      return ArticleRuleValues[inx];
 *                  }
 *              }
 *              if (Items != null)
 *              {
 *                  foreach (CrmRuleBillItem ruleItem in Items)
 *                  {
 *                      if (ruleItem.Match(article))
 *                      {
 *                          return ruleItem.RuleValue;
 *                      }
 *                  }
 *              }
 *          }
 *          return null;
 *      }
 * */
        public CrmRuleValue FindRuleValue(DateTime saleTime, CrmVipCard vipCard, CrmArticle article)
        {
            //翠微版要改,只有商品条件,取不到规则 2012.2.24
            if (WithinPeriodOfTime(saleTime) && (saleTime.CompareTo(BeginTime) > 0) && (saleTime.CompareTo(EndTime) < 0) && (BeginTime.CompareTo(DateTime.MinValue) > 0) && (EndTime.CompareTo(DateTime.MinValue) > 0))
            {
                if (ArticleIds != null)
                {
                    int inx = SeekUtils.IndexOfAscendingIntArray(ArticleIds, article.ArticleId);
                    if (inx >= 0)
                    {
                        return(ArticleRuleValues[inx]);
                    }
                }
                if (Items != null)
                {
                    foreach (CrmRuleBillItem ruleItem in Items)
                    {
                        if (ruleItem.Match(article, vipCard, saleTime))
                        {
                            return(ruleItem.RuleValue);
                        }
                    }
                }
            }
            return(null);
        }
Example #4
0
        //public bool Match(CrmArticle article)
        //{
        //    return ((!ExistDept) || (SeekUtils.IndexOfLikeStringArray(DeptCodes, article.DeptCode) >= 0))
        //           && ((!ExistCategory) || (SeekUtils.IndexOfLikeStringArray(CategoryCodes, article.CategoryCode) >= 0))
        //           && ((!ExistContract) || (SeekUtils.IndexOfAscendingIntArray(ContractIds, article.ContractId) >= 0))
        //           && ((!ExistBrand) || (SeekUtils.IndexOfAscendingIntArray(BrandIds, article.BrandId) >= 0))
        //           && ((!ExistArticle) || (SeekUtils.IndexOfAscendingIntArray(ArticleIds, article.ArticleId) >= 0));    //翠微要改
        //}

        public bool Match(CrmArticle article, CrmVipCard vipCard, DateTime saleDate)
        {
            bool ok = ((!ExistDept) || (SeekUtils.IndexOfLikeStringArray(DeptCodes, article.DeptCode) >= 0)) &&
                      ((!ExistCategory) || (SeekUtils.IndexOfLikeStringArray(CategoryCodes, article.CategoryCode) >= 0)) &&
                      ((!ExistContract) || (SeekUtils.IndexOfAscendingIntArray(ContractIds, article.ContractId) >= 0)) &&
                      ((!ExistBrand) || (SeekUtils.IndexOfAscendingIntArray(BrandIds, article.BrandId) >= 0)) &&
                      ((!ExistArticle) || (SeekUtils.IndexOfAscendingIntArray(ArticleIds, article.ArticleId) >= 0));

            if (ok && ExistVipGroup && (VipGroups != null))
            {
                foreach (CrmVipGroup vipGroup in VipGroups)
                {
                    if (vipGroup.Match(vipCard, saleDate))
                    {
                        return(true);
                    }
                }
                ok = false;
            }
            return(ok);
        }