/******Check基本规则************** * 1. 如果条件为空或者条件列表未设置,则视为不需要满足这些条件; * 2. 目前版本定位主要有一条不满足,则加到Error List中,然后返回不再Check;如果今后有需要Check全部,则只需要把每个Error后的Return去掉即可 * 3. 调用方根据Check返回的ErrorList来判断是否通过,如果ErrorList的Count为0,表示通过 * ******************************/ /// <summary> /// 检查订单条件是否满足 /// </summary> /// <param name="soInfo"></param> /// <param name="condition"></param> /// <returns></returns> protected virtual List <string> CheckOrderCodition(SOInfo soInfo, PSOrderCondition condition) { List <string> errorList = new List <string>(); if (condition == null) { return(errorList); } if (condition.OrderMinAmount.HasValue) { if (!soInfo.BaseInfo.SOAmount.HasValue) { //throw new BizException("订单信息异常:订单总金额为空值!"); throw new BizException(ResouceManager.GetMessageString("MKT.Calculate", "Calculate_OrderAmountIsNull")); } if (condition.OrderMinAmount > soInfo.BaseInfo.SOAmount) { //errorList.Add("参加本活动时,订单金额必须达到此金额。包括商品金额、运费、手续费等所有金额,扣除捆绑等折扣,不扣除积分、礼品卡及余额"); errorList.Add(ResouceManager.GetMessageString("MKT.Calculate", "Calculate_OrderAmountNotEnough")); return(errorList); } } if (condition.PayTypeSysNoList != null && condition.PayTypeSysNoList.Count > 0) { if (!soInfo.BaseInfo.PayTypeSysNo.HasValue) { //throw new BizException("订单信息异常:还没有设置支付信息!"); throw new BizException(ResouceManager.GetMessageString("MKT.Calculate", "Calculate_NeedSetPayInfo")); } if (!condition.PayTypeSysNoList.Contains(soInfo.BaseInfo.PayTypeSysNo.Value)) { //errorList.Add("该客户选择的支付方式不答合优惠券要求!"); errorList.Add(ResouceManager.GetMessageString("MKT.Calculate", "Calculate_PayTypeNotMatchCoupons")); return(errorList); } } if (condition.ShippingTypeSysNoList != null && condition.ShippingTypeSysNoList.Count > 0) { if (soInfo.ShippingInfo == null || !soInfo.ShippingInfo.ShipTypeSysNo.HasValue) { //throw new BizException("订单信息异常:还没有设置配送信息!"); throw new BizException(ResouceManager.GetMessageString("MKT.Calculate", "Calculate_NeedSetShippingInfo")); } if (!condition.ShippingTypeSysNoList.Contains(soInfo.ShippingInfo.ShipTypeSysNo.Value)) { //errorList.Add("该客户选择的配送方式不答合优惠券要求!"); errorList.Add(ResouceManager.GetMessageString("MKT.Calculate", "Calculate_ShippingNotMatchCoupons")); return(errorList); } } return(errorList); }
/// <summary> /// 根据购买的商品,赠品信息创建赠品规则信息。单品买赠及厂商赠品时,商品为单个,同时买赠时商品为多个。 /// </summary> /// <param name="promotionInfo"></param> /// <param name="productList"></param> private void CreateGiftAndRules(SaleGiftBatchInfo promotionInfo, List <ProductItemInfo> productList) { PSOrderCondition orderCondition = new PSOrderCondition(); orderCondition.OrderMinAmount = 0M; //Create Gift Master int?giftMasterSysNo = _SaleGiftDA.CreateMaster(new SaleGiftInfo { Title = promotionInfo.RuleName, Description = promotionInfo.RuleDescription, Type = promotionInfo.SaleGiftType, Status = promotionInfo.Status, BeginDate = promotionInfo.BeginDate, EndDate = promotionInfo.EndDate, OrderCondition = orderCondition, PromotionLink = promotionInfo.PromotionLink, InUser = promotionInfo.InUser, DisCountType = promotionInfo.RebateCaculateMode, VendorSysNo = promotionInfo.VendorSysNo, CompanyCode = promotionInfo.CompanyCode }); //Generate SaleRules UpdateSaleRules(new BatchCreateSaleGiftSaleRuleInfo { IsGlobal = true, ProductList = productList, PromotionSysNo = giftMasterSysNo.Value, InUser = promotionInfo.InUser, CompanyCode = promotionInfo.CompanyCode }); //Create Gifts CreateGiftRules(new BatchCreateGiftRuleInfo { GiftComboType = promotionInfo.IsSpecifiedGift?SaleGiftGiftItemType.AssignGift:SaleGiftGiftItemType.GiftPool, ProductList = promotionInfo.Gifts, SumCount = promotionInfo.TotalQty, PromotionSysNo = giftMasterSysNo.Value, IsSpecial = 0, InUser = promotionInfo.InUser, CompanyCode = promotionInfo.CompanyCode }); }