public void Init() { Catalog = AppConst.StringNull; sCustomer = null; sSO = null; sRMA = null; GiftHash = new Hashtable(5); BrowseHistoryList = new ArrayList(5); }
public void UpdateSO(SOInfo oParam) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //�������� SOInfo originInfo = this.LoadSO(oParam.SysNo); this.UpdateSOMaster(oParam); //�ж�item���� if(originInfo.ItemHash.Count!=oParam.ItemHash.Count) throw new BizException("SessionInfo expired,please reload this SaleOrder."); if(oParam.ItemHash.Count>0) { foreach(SOItemInfo item in oParam.ItemHash.Values) { if(originInfo.ItemHash.ContainsKey(item.ProductSysNo)) { SOItemInfo originItem = (SOItemInfo)originInfo.ItemHash[item.ProductSysNo]; //�ж������ϸ�б仯���� if(originItem.Cost!=item.Cost||originItem.Price!=item.Price||originItem.Quantity!=item.Quantity||originItem.Warranty!=item.Warranty ||originItem.DiscountAmt!=item.DiscountAmt||originItem.GiftSysNo!=item.GiftSysNo||originItem.Weight!=item.Weight||originItem.Point!=item.Point) { //������ϸ if (oParam.IsWholeSale == 0) //���۵ļ۸����¶�����ʱ��Ϊ 2007-07-03 { item.Price = originItem.Price; } this.UpdateSOItem(item); } //���¿�� if(item.Quantity!=originItem.Quantity) InventoryManager.GetInstance().SetOrderQty(oParam.StockSysNo,item.ProductSysNo,(item.Quantity-originItem.Quantity)); } else throw new BizException("SessionInfo expired,please reload this SaleOrder."); } } //�ж�SaleRule�Ƿ��б仯 if(originInfo.SaleRuleHash.Count==oParam.SaleRuleHash.Count) { foreach(SOSaleRuleInfo originSR in originInfo.SaleRuleHash.Values) { if(!oParam.SaleRuleHash.ContainsValue(originSR)) { this.UpdateSOSaleRule(oParam); break; } } } else { //�������۹��� this.UpdateSOSaleRule(oParam); } //���¿ͻ��ջ���Ϣ�ͻ��� Hashtable paramHash = new Hashtable(); paramHash.Add("SysNo",oParam.CustomerSysNo); paramHash.Add("ReceiveAddress",oParam.ReceiveAddress); paramHash.Add("ReceiveContact",oParam.ReceiveContact); paramHash.Add("ReceiveName",oParam.ReceiveName); paramHash.Add("ReceivePhone",oParam.ReceivePhone); paramHash.Add("ReceiveCellPhone",oParam.ReceiveCellPhone); paramHash.Add("ReceiveZip",oParam.ReceiveZip); paramHash.Add("ReceiveAreaSysNo",oParam.ReceiveAreaSysNo); CustomerManager.GetInstance().Update(paramHash); PointManager.GetInstance().SetScore(oParam.CustomerSysNo,(originInfo.PointPay-oParam.PointPay), (int)AppEnum.PointLogType.UpdateSO, oParam.SysNo.ToString()); //FreeShipFeeManager.GetInstance().SetFreeShipFee(oParam.CustomerSysNo,(originInfo.FreeShipFeePay - oParam.FreeShipFeePay),(int)AppEnum.FreeShipFeeLogType.UpdateSO,oParam.SysNo.ToString()); scope.Complete(); } }
/// <summary> /// 检测优惠券是否能使用于SO /// </summary> /// <param name="oCoupon"></param> /// <param name="soInfo"></param> public void CheckCouponSO(CouponInfo oCoupon, SOInfo soInfo) { //有效期 if (oCoupon.ValidTimeTo < DateTime.Now) { throw new BizException("优惠券已经过期,不能使用"); } else if (oCoupon.ValidTimeFrom > DateTime.Now) { throw new BizException("优惠券尚未生效,不能使用"); } //状态 else if (oCoupon.Status != (int)AppEnum.CouponStatus.Activation && oCoupon.Status != (int)AppEnum.CouponStatus.PartlyUsed) { throw new BizException("此优惠券没有被激活或已经使用,不能使用"); } //使用次数 else if (oCoupon.MaxUseDegree == oCoupon.UsedDegree) { throw new BizException("该优惠券已达到最高使用次数,不能再使用"); } DataSet soItemDS = new DataSet(); //销售单的明细商品(仅主商品),增加大、中、小类,增加品牌项 if (soInfo.ItemHash.Count > 0) { string sysNoStr = ""; foreach (SOItemInfo soItem in soInfo.ItemHash.Values) { if (soItem.ProductType == (int)AppEnum.SOItemType.ForSale) { sysNoStr += soItem.ProductSysNo + ","; } } sysNoStr = sysNoStr.TrimEnd(','); if (sysNoStr != "") { string sql = @" SELECT Product.SysNo,Product.ManufacturerSysNo,Product.C3SysNo,Category3.C2SysNo,Category2.C1SysNo FROM Product (NOLOCK) JOIN Category3 (NOLOCK) ON Category3.SysNo = product.C3SysNo JOIN Category2 (NOLOCK) ON Category2.SysNo = Category3.C2SysNo JOIN Category1 (NOLOCK) ON Category1.SysNo = Category2.C1SysNo WHERE Product.SysNo IN(" + sysNoStr + ")"; soItemDS = SqlHelper.ExecuteDataSet(sql); if (Util.HasMoreRow(soItemDS)) { soItemDS = ConvertSOItemDS(soItemDS, soInfo); } } } else { throw new BizException("没有购买任何商品"); } #region 优惠券类型 的类别/商品/品牌 检测 if (oCoupon.CouponType == (int)AppEnum.CouponType.Category) { string cstr = oCoupon.CategorySysNoCom; string[] cList = cstr.Split(','); if (cList.Length > 0) { ArrayList c1List = new ArrayList(); ArrayList c2List = new ArrayList(); ArrayList c3List = new ArrayList(); for (int i = 0; i < cList.Length; i++) { string[] cx = cList[i].ToString().Split('_'); switch (cx[0].ToString()) { case "c1": case "C1": c1List.Add(Util.TrimIntNull(cx[1])); break; case "c2": case "C2": c2List.Add(Util.TrimIntNull(cx[1])); break; case "c3": case "C3": c3List.Add(Util.TrimIntNull(cx[1])); break; default: break; } } decimal categorybuyAmt = 0; bool IsContainsCategory = false; foreach (DataRow dr in soItemDS.Tables[0].Rows) { int c1SysNo = Util.TrimIntNull(dr["C1SysNo"]); int c2SysNo = Util.TrimIntNull(dr["C2SysNo"]); int c3SysNo = Util.TrimIntNull(dr["C3SysNo"]); int currqty = Util.TrimIntNull(dr["Qty"]); decimal currprice = Util.TrimDecimalNull(dr["Price"]); bool isInCategory = false; if (c1List.Contains(c1SysNo)) { IsContainsCategory = true; isInCategory = true; } else if (c2List.Contains(c2SysNo)) { IsContainsCategory = true; isInCategory = true; } else if (c3List.Contains(c3SysNo)) { IsContainsCategory = true; isInCategory = true; } if (isInCategory == true) categorybuyAmt += currprice * currqty; } if (IsContainsCategory == false) throw new BizException("您使用的是类别优惠券,只能购买相应的类别商品时才能使用"); if (categorybuyAmt < oCoupon.SaleAmt) throw new BizException("您使用的是类别优惠券,符合优惠类别的购买商品的金额总和不满足使用要求"); } } else if (oCoupon.CouponType == (int)AppEnum.CouponType.Product) { string pstr = oCoupon.ProductSysNoCom; decimal productbuyAmt = 0; bool IsContainsProduct = false; foreach (DataRow dr in soItemDS.Tables[0].Rows) { int productsysno = Util.TrimIntNull(dr["SysNo"]); int currqty = Util.TrimIntNull(dr["Qty"]); decimal currprice = Util.TrimDecimalNull(dr["Price"]); bool isInProduct = false; if (pstr.Contains(productsysno.ToString())) { IsContainsProduct = true; isInProduct = true; } if (isInProduct == true) productbuyAmt += currprice * currqty; } if (IsContainsProduct == false) throw new BizException("您使用的是商品优惠券,只能购买相应的商品时才能使用"); if (productbuyAmt < oCoupon.SaleAmt) throw new BizException("您使用的是商品优惠券,符合优惠商品的购买商品的金额总和不满足使用要求"); } else if (oCoupon.CouponType == (int)AppEnum.CouponType.Manufactory) { string mstr = oCoupon.ManufactorySysNoCom; decimal manufactorybuyAmt = 0; bool IsContainsManufactory = false; foreach (DataRow dr in soItemDS.Tables[0].Rows) { int manufacturerSysNo = Util.TrimIntNull(dr["ManufacturerSysNo"]); int currqty = Util.TrimIntNull(dr["Qty"]); decimal currprice = Util.TrimDecimalNull(dr["Price"]); bool isInManufacturer = false; if (mstr.Contains(manufacturerSysNo.ToString())) { IsContainsManufactory = true; isInManufacturer = true; } if (isInManufacturer == true) manufactorybuyAmt += currprice * currqty; } if (IsContainsManufactory == false) throw new BizException("您使用的是品牌优惠券,只能购买相应的品牌商品时才能使用"); if (manufactorybuyAmt < oCoupon.SaleAmt) throw new BizException("您使用的是品牌优惠券,符合优惠品牌的购买商品的金额总和不满足使用要求"); } else if (oCoupon.CouponType == (int)AppEnum.CouponType.ALL) { decimal productbuyAmt = 0; foreach (DataRow dr in soItemDS.Tables[0].Rows) { int currqty = Util.TrimIntNull(dr["Qty"]); decimal currprice = Util.TrimDecimalNull(dr["Price"]); productbuyAmt += currprice * currqty; } if (productbuyAmt < oCoupon.SaleAmt) throw new BizException("您购买的商品的金额总和不满足优惠券使用要求"); } #endregion //区域 if (oCoupon.UseAreaSysNoCom != "") { Icson.Objects.Basic.AreaInfo oArea = Icson.BLL.Basic.ASPManager.GetInstance().LoadArea(soInfo.ReceiveAreaSysNo); bool isContainsArea = false; if (oArea != null) { if (oCoupon.UseAreaSysNoCom.Contains(oArea.SysNo.ToString())) isContainsArea = true; else if (oCoupon.UseAreaSysNoCom.Contains(oArea.ProvinceSysNo.ToString())) isContainsArea = true; else if (oCoupon.UseAreaSysNoCom.Contains(oArea.CitySysNo.ToString())) isContainsArea = true; } if (isContainsArea == false) throw new BizException("您所在地区不符合优惠券的使用区域"); } //客户 if (oCoupon.UseCustomerSysNo != AppConst.IntNull) { if (soInfo.CustomerSysNo != oCoupon.UseCustomerSysNo) throw new BizException("您不能使用该优惠券"); } //客户等级 if (oCoupon.UseCustomerGradeCom != "") { Icson.Objects.Basic.CustomerInfo oCustomer = Icson.BLL.Basic.CustomerManager.GetInstance().Load(soInfo.CustomerSysNo); if (!oCoupon.UseCustomerGradeCom.Contains(oCustomer.CustomerRank.ToString())) throw new BizException("您的会员等级不能使用当前优惠券"); } }
public void CreateSO(SOInfo soInfo) { try { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { bool HasService = false; int HasExpectQty = (int)AppEnum.YNStatus.No; //���������û��ύ��������Ҫ֧������������ˡ� //soInfo.Status = (int)AppEnum.SOStatus.Origin; soInfo.Status = (int)AppEnum.SOStatus.WaitingPay; soInfo.IsPrintPackageCover = (int)AppEnum.YNStatus.No; soInfo.OrderDate = DateTime.Now; //�˴�д��Ϊ�Ϻ��ֲ֣��պ��зֲ���Ҫ���ٿ���ѡ�� StockInfo shStock = StockManager.GetInstance().Load("0001"); soInfo.StockSysNo = shStock.SysNo; //hawkins 2010-4-20 if (soInfo.CouponType != AppConst.IntNull) { Icson.Objects.Promotion.CouponInfo oCoupon = CouponManager.GetInstance().LoadCouponByPwd(soInfo.CouponCode); if (oCoupon != null) CouponManager.GetInstance().CheckCouponSO(oCoupon, soInfo); else throw new BizException("�Ż�ȯ��Ϣ��ʧ"); } //==================== //���붩������ this.InsertSOMaster(soInfo); //���붩����Ʒ��ϸ int itemCount = 0; foreach (SOItemInfo item in soInfo.ItemHash.Values) { if (item.Quantity > 0) //�ų�����Ϊ������ { item.SOSysNo = soInfo.SysNo; this.InsertSOItem(item, soInfo); if (item.BaseProductType == (int) AppEnum.ProductType.Service) { HasService = true; } if (item.ExpectQty > item.Quantity) { HasExpectQty = (int)AppEnum.YNStatus.Yes; } itemCount++; } } if (itemCount == 0) //������Ʒ { throw new BizException("��ѡ������Ʒ����Ϊ�㣡"); } //���붩�����۹��� if (soInfo.SaleRuleHash.Count > 0) { foreach (SOSaleRuleInfo srInfo in soInfo.SaleRuleHash.Values) { srInfo.SOSysNo = soInfo.SysNo; this.InsertSOSaleRule(srInfo); } } //������Ʊ��Ϣ //if(soInfo.IsVAT==(int)AppEnum.YNStatus.Yes) //{ // soInfo.VatInfo.SOSysNo = soInfo.SysNo; // this.InsertSOVAT(soInfo.VatInfo); //} //���¿ͻ���Ϣ Hashtable paramHash = new Hashtable(); paramHash.Add("SysNo", soInfo.CustomerSysNo); paramHash.Add("ReceiveAddress", soInfo.ReceiveAddress); paramHash.Add("ReceiveContact", soInfo.ReceiveContact); paramHash.Add("ReceiveName", soInfo.ReceiveName); paramHash.Add("ReceivePhone", soInfo.ReceivePhone); paramHash.Add("ReceiveZip", soInfo.ReceiveZip); paramHash.Add("ReceiveAreaSysNo", soInfo.ReceiveAreaSysNo); paramHash.Add("ReceiveCellPhone", soInfo.ReceiveCellPhone); CustomerManager.GetInstance().Update(paramHash); PointManager.GetInstance().SetScore(soInfo.CustomerSysNo, soInfo.PointPay * -1, (int)AppEnum.PointLogType.CreateOrder, soInfo.SysNo.ToString()); //if(soInfo.FreeShipFeePay > 0) //{ // FreeShipFeeManager.GetInstance().SetFreeShipFee(soInfo.CustomerSysNo,soInfo.FreeShipFeePay * -1,(int)AppEnum.FreeShipFeeLogType.CreateOrder,soInfo.SysNo.ToString()); //} //���·������� //soInfo.AllocatedManSysNo = this.GetAllocatedMan(soInfo.SysNo); soInfo.AllocatedManSysNo = UserRatioManager.GetInstance().GetAllocatedMan(soInfo.SysNo); Hashtable paramSOHash = new Hashtable(); paramSOHash.Add("SysNo", soInfo.SysNo); paramSOHash.Add("AllocatedManSysNo", soInfo.AllocatedManSysNo); //�����Ƿ��������������� paramSOHash.Add("HasExpectQty", HasExpectQty); this.UpdateSOMaster(paramSOHash); //�������� //if (soInfo.AdwaysInfo != null && soInfo.AdwaysInfo.AdwaysID.Length > 0) //{ // SOAdwaysInfo adwaysInfo = new SOAdwaysInfo(); // adwaysInfo.AdwaysID = soInfo.AdwaysInfo.AdwaysID; // adwaysInfo.AdwaysEmail = soInfo.AdwaysInfo.AdwaysEmail; // adwaysInfo.ShipPrice = soInfo.AdwaysInfo.ShipPrice; // adwaysInfo.CustomerSysNo = soInfo.CustomerSysNo; // adwaysInfo.SOSysNo = soInfo.SysNo; // this.InsertSOAdways(adwaysInfo); //} //hawkins 2010-4-20 if (soInfo.CouponType != AppConst.IntNull) { CouponManager.GetInstance().UseCoupon(soInfo.CouponCode); } //=============== if (HasService) { soInfo.ServiceInfo.SOSysNo = soInfo.SysNo; this.InsertSOService(soInfo.ServiceInfo); } scope.Complete(); } } catch(Exception ex) { soInfo.SysNo = AppConst.IntNull; throw ex; } }
/// <summary> /// �������salerule��� /// </summary> /// <param name="SO"></param> /// <return></return> public void GetBestSaleRule(SOInfo SO) { if(SO.IsWholeSale==0)//���۲ſ�����SaleRule { //��ʼ��arraylist if(assembleList!=null && assembleList.Count>0) assembleList.Clear(); //��ʼ��������Ч��salerule AllValidSRList= this.GetAllValidSR(); //�����Ч��salerule�б� ArrayList validSaleRuleList=GetValidSaleRule(SO); if(validSaleRuleList==null) { SO.DiscountAmt = 0m; return ; } //��ʼ��������Ʒ�б��������Ʒsysno���������� Hashtable itemList=InitItemList(SO); //��ʼ����ջstackSRList if(StackSRList!=null&&StackSRList.Count>0) StackSRList.Clear(); //��ʼ��SO��ԭ�е�salerule��� if(SO.SaleRuleHash!=null&&SO.SaleRuleHash.Count>0 ) SO.SaleRuleHash.Clear(); //�������п��ܵ�salerule��� SearchAllPath(itemList,validSaleRuleList,0); //�ҳ����ŵ�salerule��� SaleRuleInfo sr=new SaleRuleInfo(); Hashtable ht=new Hashtable(50); decimal mindiscount=0;//��¼��С�ۿ� int optimize=0;//��¼������ for(int i=0;i<assembleList.Count;i++) { ht=(Hashtable)assembleList[i]; decimal discount=0; foreach(int key in ht.Keys) { sr=(SaleRuleInfo)AllValidSRList[key]; //��ô�salerule�����ۿ� discount+=sr.GetTotalDiscount()*(int)ht[key]; } if(discount<mindiscount) //discount<0 { mindiscount=discount; optimize=i; } else { mindiscount=discount; } } //��discount��¼��so�� SO.DiscountAmt=mindiscount; //���������assembleList[optimize]����ΪSOSaleRuleInfo��,����so ht=(Hashtable)assembleList[optimize]; foreach(int key in ht.Keys) { SOSaleRuleInfo ssr= new SOSaleRuleInfo(); sr=(SaleRuleInfo)AllValidSRList[key]; ssr.SaleRuleName=sr.SaleRuleName; ssr.Times=(int)ht[key]; ssr.Discount=sr.GetTotalDiscount(); ssr.Note=sr.GetSRNote(); ssr.SOSysNo=SO.SysNo; ssr.SaleRuleSysNo=sr.SysNo; SO.SaleRuleHash.Add(ssr.SaleRuleSysNo,ssr); } //�������salerule��ϼ���Զ���ÿ����Ʒ��discountamt foreach(SOItemInfo item in SO.ItemHash.Values) { item.DiscountAmt = GetProductDiscount(ht, item.ProductSysNo); } } else//�������ԭ��SaleRule { SO.DiscountAmt = 0; SO.SaleRuleHash.Clear(); foreach(SOItemInfo item in SO.ItemHash.Values) { item.DiscountAmt = 0; } } }
public void CancelOutStock(SOInfo soInfo) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //����δȷ�ϵ���Ч�տ, ����Ѿ�����ȷ�ϻ��׳��쳣 SOIncomeManager.GetInstance().SOCancelOutStock(soInfo.SysNo); //����Ƿ������Ч��rma�������ھͲ�����ȡ������ if(RMAManager.GetInstance().IfExistValidRMA(soInfo.SysNo)) throw new BizException("�ж�Ӧ��SO����ЧRMA�����ڣ��������϶���"); //�鿴�Ƿ���ǰ�³���Ķ��������������ȡ�����⣬����ȡ��ֻ����4����ȡ�� if (soInfo.OutTime.Month != DateTime.Now.Month && soInfo.OutTime <= DateTime.Now.AddDays(-4)) throw new BizException("�DZ��¶��������������ȡ����"); ////���¶���״̬ //1 �鿴������ǰ״̬ //2 ���ø���ֵ������status int currentStatus = this.getCurrentSOStatus(soInfo.SysNo); if (currentStatus != (int)AppEnum.SOStatus.OutStock) throw new BizException("cancel outstock so: the current status is not OutStock, operation of Cancel OutStock SO failed"); soInfo.Status = (int)AppEnum.SOStatus.Origin; //���¶���״̬ UpdateSOStatus(soInfo.SysNo, soInfo.Status, soInfo.UpdateUserSysNo); //������Ʒ��� foreach(SOItemInfo item in soInfo.ItemHash.Values) { InventoryManager.GetInstance().SetSOOutStockQty(soInfo.StockSysNo,item.ProductSysNo,-1*item.Quantity); } //�鿴�Ƿ������ͻ��� if(soInfo.PointAmt>0) { SalePointDelayInfo spInfo = PointManager.GetInstance().LoadValid(soInfo.SysNo); if(spInfo!=null) { if(spInfo.Status==(int)AppEnum.TriStatus.Handled)//�����Ѿ�����ͻ��˻������ȿ۳���Ӧ���� { PointManager.GetInstance().SetScore(soInfo.CustomerSysNo, soInfo.PointAmt*(-1), (int)AppEnum.PointLogType.CancelOutstock,soInfo.SysNo.ToString()); } //���»������ͼ�¼״̬ spInfo.Status = (int)AppEnum.TriStatus.Abandon; PointManager.GetInstance().UpdatePointDelay(spInfo); } } scope.Complete(); } }
private void map(SOInfo oParam, DataRow tempdr) { oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]); oParam.SOID = Util.TrimNull(tempdr["SOID"]); oParam.Status = Util.TrimIntNull(tempdr["Status"]); oParam.CustomerSysNo = Util.TrimIntNull(tempdr["CustomerSysNo"]); oParam.StockSysNo = Util.TrimIntNull(tempdr["StockSysNo"]); oParam.OrderDate = Util.TrimDateNull(tempdr["OrderDate"]); oParam.DeliveryDate = Util.TrimDateNull(tempdr["DeliveryDate"]); oParam.SalesManSysNo = Util.TrimIntNull(tempdr["SalesManSysNo"]); oParam.IsWholeSale = Util.TrimIntNull(tempdr["IsWholeSale"]); oParam.IsPremium = Util.TrimIntNull(tempdr["IsPremium"]); oParam.PremiumAmt = Util.TrimDecimalNull(tempdr["PremiumAmt"]); oParam.ShipTypeSysNo = Util.TrimIntNull(tempdr["ShipTypeSysNo"]); oParam.ShipPrice = Util.TrimDecimalNull(tempdr["ShipPrice"]); oParam.FreeShipFeePay = Util.TrimDecimalNull(tempdr["FreeShipFeePay"]); oParam.PayTypeSysNo = Util.TrimIntNull(tempdr["PayTypeSysNo"]); oParam.PayPrice = Util.TrimDecimalNull(tempdr["PayPrice"]); oParam.SOAmt = Util.TrimDecimalNull(tempdr["SOAmt"]); oParam.DiscountAmt = Util.TrimDecimalNull(tempdr["DiscountAmt"]); oParam.CouponType = Util.TrimIntNull(tempdr["CouponType"]); oParam.CouponCode = Util.TrimNull(tempdr["CouponCode"]); oParam.CouponAmt = Util.TrimDecimalNull(tempdr["CouponAmt"]); oParam.PointAmt = Util.TrimIntNull(tempdr["PointAmt"]); oParam.CashPay = Util.TrimDecimalNull(tempdr["CashPay"]); oParam.PointPay = Util.TrimIntNull(tempdr["PointPay"]); oParam.ReceiveAreaSysNo = Util.TrimIntNull(tempdr["ReceiveAreaSysNo"]); oParam.ReceiveContact = Util.TrimNull(tempdr["ReceiveContact"]); oParam.ReceiveName = Util.TrimNull(tempdr["ReceiveName"]); oParam.ReceivePhone = Util.TrimNull(tempdr["ReceivePhone"]); oParam.ReceiveCellPhone = Util.TrimNull(tempdr["ReceiveCellPhone"]); oParam.ReceiveAddress = Util.TrimNull(tempdr["ReceiveAddress"]); oParam.ReceiveZip = Util.TrimNull(tempdr["ReceiveZip"]); oParam.AllocatedManSysNo = Util.TrimIntNull(tempdr["AllocatedManSysNo"]); oParam.FreightUserSysNo = Util.TrimIntNull(tempdr["FreightUserSysNo"]); oParam.SetDeliveryManTime = Util.TrimDateNull(tempdr["SetDeliveryManTime"]); oParam.UpdateUserSysNo = Util.TrimIntNull(tempdr["UpdateUserSysNo"]); oParam.UpdateTime = Util.TrimDateNull(tempdr["UpdateTime"]); oParam.AuditUserSysNo = Util.TrimIntNull(tempdr["AuditUserSysNo"]); oParam.AuditTime = Util.TrimDateNull(tempdr["AuditTime"]); oParam.ManagerAuditUserSysNo = Util.TrimIntNull(tempdr["ManagerAuditUserSysNo"]); oParam.ManagerAuditTime = Util.TrimDateNull(tempdr["ManagerAuditTime"]); oParam.OutUserSysNo = Util.TrimIntNull(tempdr["OutUserSysNo"]); oParam.OutTime = Util.TrimDateNull(tempdr["OutTime"]); oParam.CheckQtyUserSysNo = Util.TrimIntNull(tempdr["CheckQtyUserSysNo"]); oParam.CheckQtyTime = Util.TrimDateNull(tempdr["CheckQtyTime"]); oParam.Memo = Util.TrimNull(tempdr["Memo"]); oParam.Note = Util.TrimNull(tempdr["Note"]); oParam.InvoiceNote = Util.TrimNull(tempdr["InvoiceNote"]); oParam.IsVAT = Util.TrimIntNull(tempdr["IsVAT"]); oParam.IsPrintPackageCover = Util.TrimIntNull(tempdr["IsPrintPackageCover"]); oParam.DeliveryMemo = Util.TrimNull(tempdr["DeliveryMemo"]); oParam.VATEMSFee = Util.TrimDecimalNull(tempdr["VATEMSFee"]); oParam.ExpectDeliveryDate = Util.TrimDateNull(tempdr["ExpectDeliveryDate"]); oParam.ExpectDeliveryTimeSpan = Util.TrimIntNull(tempdr["ExpectDeliveryTimeSpan"]); oParam.AuditDeliveryDate = Util.TrimDateNull(tempdr["AuditDeliveryDate"]); oParam.AuditDeliveryTimeSpan = Util.TrimIntNull(tempdr["AuditDeliveryTimeSpan"]); oParam.SentDate = Util.TrimDateNull(tempdr["SentDate"]); oParam.SentTimeSpan = Util.TrimIntNull(tempdr["SentTimeSpan"]); oParam.SignByOther = Util.TrimIntNull(tempdr["SignByOther"]); oParam.HasServiceProduct = Util.TrimIntNull(tempdr["HasServiceProduct"]); oParam.CSUserSysNo = Util.TrimIntNull(tempdr["CSUserSysNo"]); oParam.HasExpectQty = Util.TrimIntNull(tempdr["HasExpectQty"]); oParam.IsMergeSO = Util.TrimIntNull(tempdr["IsMergeSO"]); oParam.InvoiceStatus = Util.TrimIntNull(tempdr["InvoiceStatus"]); oParam.InvoiceTime = Util.TrimDateNull(tempdr["InvoiceTime"]); oParam.InvoiceUpdateUserSysNo = Util.TrimIntNull(tempdr["InvoiceUpdateUserSysNo"]); oParam.AbandonInvoiceTime = Util.TrimDateNull(tempdr["AbandonInvoiceTime"]); oParam.RequestInvoiceType = Util.TrimIntNull(tempdr["RequestInvoiceType"]); oParam.RequestInvoiceTime = Util.TrimDateNull(tempdr["RequestInvoiceTime"]); oParam.InvoiceType = Util.TrimIntNull(tempdr["InvoiceType"]); oParam.IsLarge = Util.TrimIntNull(tempdr["IsLarge"]); oParam.PosFee = Util.TrimDecimalNull(tempdr["PosFee"]); oParam.DLSysNo = Util.TrimIntNull(tempdr["DLSysNo"]); }
private void AbandonSO(SOInfo soInfo) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //�����տ SOIncomeManager.GetInstance().SOAbandon(soInfo.SysNo); //���¶���״̬ this.UpdateSOStatus(soInfo.SysNo, soInfo.Status, soInfo.UpdateUserSysNo); //�ͷŶ�����ռ��� foreach(SOItemInfo item in soInfo.ItemHash.Values) { InventoryManager.GetInstance().SetOrderQty(soInfo.StockSysNo,item.ProductSysNo,-1*item.Quantity); } //�����ͻ�֧������ PointManager.GetInstance().SetScore(soInfo.CustomerSysNo, soInfo.PointPay, (int)AppEnum.PointLogType.AbandonSO, soInfo.SysNo.ToString()); //�����ͻ�֧�����˷� //FreeShipFeeManager.GetInstance().SetFreeShipFee(soInfo.CustomerSysNo,soInfo.FreeShipFeePay,(int)AppEnum.FreeShipFeeLogType.AbandonSO,soInfo.SysNo.ToString()); scope.Complete(); } }
private void CalcItemPrice(SOInfo soInfo) { //������ֹ�������������ȡ��Ʒ�趨�������۸���� if(soInfo.IsWholeSale==(int)AppEnum.YNStatus.Yes) { //������������ foreach(SOItemInfo item in soInfo.ItemHash.Values) { item.Point = 0; } return; } Hashtable priceHash = ProductManager.GetInstance().GetSOItemPriceList(soInfo); foreach(SOItemInfo item in soInfo.ItemHash.Values) { if(item.ProductType==(int)AppEnum.SOItemType.ForSale) { foreach(ProductPriceInfo priceInfo in priceHash.Values) { if(priceInfo.ProductSysNo==item.ProductSysNo) { //��Ʒ���Żݼ۸���� if(priceInfo.IsWholeSale==(int)AppEnum.YNStatus.Yes) { if(item.Quantity>=priceInfo.Q1&&item.Quantity<priceInfo.Q2) item.Price = priceInfo.P1; else if(item.Quantity>=priceInfo.Q2&&item.Quantity<priceInfo.Q3) item.Price = priceInfo.P2; else if(item.Quantity>=priceInfo.Q3) item.Price = priceInfo.P3; item.Point = priceInfo.Point; } //��˶�������ʱ,�۸�����,�����¶���ʱ�ļ۸�ͻ��� //else //{ // item.Price = priceInfo.CurrentPrice; // item.Point = priceInfo.Point; //} break; } } } else//����Ʒ��۸�Ϊ0������Ϊ0 { item.Price = 0; item.Point = 0; } } }
public void UpdateSOSaleRule(SOInfo soInfo) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //���ԭ��SOSaleRule new SODac().DeleteSOSaleRule(soInfo.SysNo); if(soInfo.SaleRuleHash.Count!=0) { foreach(SOSaleRuleInfo srInfo in soInfo.SaleRuleHash.Values) { new SODac().InsertSOSaleRule(srInfo); } } scope.Complete(); } }
public void CancelAbandonSO(SOInfo soInfo) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { int currentStatus = this.getCurrentSOStatus(soInfo.SysNo); if (currentStatus != (int)AppEnum.SOStatus.CustomerCancel && currentStatus != (int)AppEnum.SOStatus.EmployeeCancel && currentStatus != (int)AppEnum.SOStatus.ManagerCancel) throw new BizException("cancel abandon so: the current status is not CustomerCancel/EmployeeCancel/ManagerCancel, operation of Cancel Abandon SO failed"); //���¶���״̬ soInfo.Status = (int)AppEnum.SOStatus.Origin; this.UpdateSOStatus(soInfo.SysNo, soInfo.Status, soInfo.UpdateUserSysNo); //���¿�� foreach(SOItemInfo item in soInfo.ItemHash.Values) { InventoryManager.GetInstance().SetOrderQty(soInfo.StockSysNo,item.ProductSysNo,item.Quantity); } //�۳��ͻ�֧������ PointManager.GetInstance().SetScore(soInfo.CustomerSysNo, soInfo.PointPay*-1, (int)AppEnum.PointLogType.CancelAbandonSO,soInfo.SysNo.ToString()); //�۳��ͻ�֧�����˷� //FreeShipFeeManager.GetInstance().SetFreeShipFee(soInfo.CustomerSysNo, soInfo.FreeShipFeePay * -1, (int)AppEnum.FreeShipFeeLogType.CancelAbandonSO, soInfo.SysNo.ToString()); scope.Complete(); } }
public void UpdateSOMaster(SOInfo oParam) { new SODac().UpdateSOMaster(oParam); }
public void UpdateSOItemPriceAndQty(SOInfo soInfo,int productSysNo,int qty,decimal price) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { SOItemInfo item = new SOItemInfo(); if(soInfo.ItemHash.ContainsKey(productSysNo)) item = (SOItemInfo)soInfo.ItemHash[productSysNo]; else throw new BizException("No such product in this order"); //�����Ʒ���� int masterQty = 0; int giftQty = 0; if(item.ProductType==(int)AppEnum.SOItemType.ForSale&&item.GiftSysNo!=AppConst.IntNull&&item.Quantity>qty)//�ڼ�������Ʒ������ʱ����Ҫ���� { foreach(SOItemInfo itemInfo in soInfo.ItemHash.Values) { if(itemInfo.ProductType==(int)AppEnum.SOItemType.ForSale&&itemInfo.ProductSysNo!=item.ProductSysNo&&itemInfo.GiftSysNo==item.GiftSysNo) masterQty += itemInfo.Quantity; else if(itemInfo.ProductType==(int)AppEnum.SOItemType.Gift&&itemInfo.ProductSysNo==item.GiftSysNo) giftQty = itemInfo.Quantity; } if((masterQty+qty)<giftQty) throw new BizException("There is too many gifts,please remove some gifts first"); } else if(item.ProductType==(int)AppEnum.SOItemType.Gift&&item.Quantity<qty)//��������Ʒ������ʱ����Ҫ���� { foreach(SOItemInfo itemInfo in soInfo.ItemHash.Values) { if(itemInfo.ProductType==(int)AppEnum.SOItemType.ForSale&&itemInfo.GiftSysNo==item.ProductSysNo) masterQty += itemInfo.Quantity; } if(masterQty<(giftQty+qty)) throw new BizException("Too many gifts added"); } ((SOItemInfo)soInfo.ItemHash[productSysNo]).Quantity = qty; ((SOItemInfo)soInfo.ItemHash[productSysNo]).ExpectQty = qty; ((SOItemInfo)soInfo.ItemHash[productSysNo]).Price = price; //hawkins 2010-4-20 if (soInfo.CouponCode != "") { soInfo.CouponAmt = 0; Icson.Objects.Promotion.CouponInfo oCoupon = Icson.BLL.Promotion.CouponManager.GetInstance().LoadCouponByPwd(soInfo.CouponCode); if (oCoupon != null) { string errstr = Icson.BLL.Promotion.CouponManager.GetInstance().CheckCouponSOByUpdate(oCoupon, soInfo); if (errstr == "") soInfo.CouponAmt = oCoupon.CouponAmt; } } SaleManager.GetInstance().CalcSO(soInfo); if(soInfo.SysNo!=AppConst.IntNull) { SaleManager.GetInstance().UpdateSO(soInfo); } scope.Complete(); } }
public void CalcVATEMSFee(SOInfo soInfo) { if(soInfo.IsVAT == (int)AppEnum.YNStatus.Yes) { soInfo.VATEMSFee = Util.ToMoney(AppConfig.VATEMSFee); soInfo.VatInfo.VATEMSFee = Util.ToMoney(AppConfig.VATEMSFee); } else { soInfo.VATEMSFee = 0m; soInfo.VatInfo.VATEMSFee = 0; } }
private void InitPageList(SOInfo soInfo,SOInvoiceInfo invoice) { invoice.HasServiceProduct = false; int index = 0; SOInvoicePageInfo page = new SOInvoicePageInfo(); invoice.ItemPageHash.Add(index++,page); if(soInfo.ItemHash.Count>0) { Hashtable sysNoHash = new Hashtable(); foreach(SOItemInfo item in soInfo.ItemHash.Values) { sysNoHash.Add(item.ProductSysNo,item.ProductSysNo); } Hashtable idHash = ProductManager.GetInstance().GetProductBoundle(sysNoHash); Hashtable posHash = InventoryManager.GetInstance().GetInventoryStockBoundle(sysNoHash,soInfo.StockSysNo); foreach(SOItemInfo item in soInfo.ItemHash.Values) { SOInvoicePageItemInfo printItem = new SOInvoicePageItemInfo(); foreach(ProductBasicInfo pbInfo in idHash.Values) { if(pbInfo.SysNo == item.ProductSysNo) { printItem.ProductSysNo = pbInfo.SysNo; printItem.ProductID = pbInfo.ProductID; printItem.ProductName = pbInfo.ProductName; if (item.BaseProductType == (int)AppEnum.ProductType.Service) invoice.HasServiceProduct = true; break; } } foreach(InventoryStockInfo isInfo in posHash.Values) { if(isInfo.ProductSysNo == item.ProductSysNo) { if ( isInfo.Position1 != "00-000-000" ) { //printItem.ProductName += "(��:" + isInfo.Position1 + ")"; printItem.ProductName += "(��:<font size=4>" + isInfo.Position1 + "</font>)"; } else if ( isInfo.Position2 != "00-000-000" ) { //printItem.ProductName += "(��:" + isInfo.Position2 + ")"; printItem.ProductName += "(��:<font size=4>" + isInfo.Position2 + "</font>)"; } break; } } printItem.Quantity = item.Quantity; printItem.Weight = item.Weight; printItem.Price = item.Price; printItem.SubTotal = item.Quantity*item.Price; printItem.IsPoint = false; printItem.IsSOItem = true; printItem.Warranty = item.Warranty; if(page.AddItem(printItem) == true) { continue; } else { page = new SOInvoicePageInfo(); invoice.ItemPageHash.Add(index++,page); page.AddItem(printItem); } } } if(soInfo.ShipPrice != 0) { SOInvoicePageItemInfo printItem = new SOInvoicePageItemInfo(); printItem.ProductID = "�˷�"; printItem.SubTotal = soInfo.ShipPrice; printItem.IsSOItem = false; if(page.AddItem(printItem) == false) { page = new SOInvoicePageInfo(); invoice.ItemPageHash.Add(index++,page); page.AddItem(printItem); } } if (soInfo.FreeShipFeePay != 0) { SOInvoicePageItemInfo printItem = new SOInvoicePageItemInfo(); printItem.ProductID = "���˷ѽ��"; printItem.SubTotal = -soInfo.FreeShipFeePay; printItem.IsSOItem = false; if (page.AddItem(printItem) == false) { page = new SOInvoicePageInfo(); invoice.ItemPageHash.Add(index++, page); page.AddItem(printItem); } } if(soInfo.DiscountAmt!=0) { SOInvoicePageItemInfo printItem = new SOInvoicePageItemInfo(); printItem.ProductID = "�����Ż�"; printItem.SubTotal = -soInfo.DiscountAmt; printItem.IsSOItem = false; if(page.AddItem(printItem) == false) { page = new SOInvoicePageInfo(); invoice.ItemPageHash.Add(index++,page); page.AddItem(printItem); } } if(soInfo.PremiumAmt != 0) { SOInvoicePageItemInfo printItem = new SOInvoicePageItemInfo(); printItem.ProductID = "���۷�"; printItem.SubTotal = soInfo.PremiumAmt; printItem.IsSOItem = false; if(page.AddItem(printItem) == false) { page = new SOInvoicePageInfo(); invoice.ItemPageHash.Add(index++,page); page.AddItem(printItem); } } if(soInfo.PayPrice != 0) { SOInvoicePageItemInfo printItem = new SOInvoicePageItemInfo(); printItem.ProductID = "����������"; printItem.SubTotal = soInfo.PayPrice; printItem.IsSOItem = false; if(page.AddItem(printItem) == false) { page = new SOInvoicePageInfo(); invoice.ItemPageHash.Add(index++,page); page.AddItem(printItem); } } if(soInfo.GetTotalAmt() != this.GetEndMoney(soInfo)) { SOInvoicePageItemInfo printItem = new SOInvoicePageItemInfo(); printItem.ProductID = "ȥ��ͷ"; printItem.SubTotal = soInfo.GetTotalAmt()-this.GetEndMoney(soInfo); printItem.IsSOItem = false; if(page.AddItem(printItem) == false) { page = new SOInvoicePageInfo(); invoice.ItemPageHash.Add(index++,page); page.AddItem(printItem); } } if(soInfo.PointPay != 0) { SOInvoicePageItemInfo printItem= new SOInvoicePageItemInfo(); printItem.ProductID="�������ֵֿ�"; printItem.SubTotal=Convert.ToDecimal(soInfo.PointPay)/AppConst.ExchangeRate*(-1); printItem.IsSOItem = false; if(page.AddItem(printItem) == false) { page = new SOInvoicePageInfo(); invoice.ItemPageHash.Add(index++,page); page.AddItem(printItem); } } if(soInfo.PointAmt != 0) { SOInvoicePageItemInfo printItem = new SOInvoicePageItemInfo(); printItem.ProductID = "�����ɵû���"; printItem.SubTotal = Convert.ToDecimal(soInfo.PointAmt); printItem.IsSOItem= false; printItem.IsPoint = true; if(page.AddItem(printItem) == false) { page = new SOInvoicePageInfo(); invoice.ItemPageHash.Add(index++,page); page.AddItem(printItem); } } }
private void CalcPremiumAmt(SOInfo soInfo) { if(soInfo.IsPremium==(int)AppEnum.YNStatus.Yes) soInfo.PremiumAmt = Util.ToMoney(ASPManager.GetInstance().GetPremuimAmt(soInfo.SOAmt,soInfo.ShipTypeSysNo)); else soInfo.PremiumAmt = 0; }
private void InsertSOItem(SOItemInfo oParam,SOInfo soInfo) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { new SODac().InsertItem(oParam); InventoryManager.GetInstance().SetOrderQty(soInfo.StockSysNo,oParam.ProductSysNo,oParam.Quantity); scope.Complete(); } }
private void CalcShipPrice(SOInfo soInfo) { if (soInfo.ShipTypeSysNo != AppConst.IntNull) { //if (soInfo.AdwaysInfo != null && !soInfo.AdwaysInfo.AdwaysID.Equals(AppConst.StringNull) && soInfo.AdwaysInfo.AdwaysID.Length > 0) //{ // soInfo.ShipPrice = 0m; //} //else //{ // soInfo.ShipPrice = Util.ToMoney(ASPManager.GetInstance().GetShipPrice(soInfo.GetTotalWeight(), soInfo.SOAmt, soInfo.ShipTypeSysNo, soInfo.ReceiveAreaSysNo)); //} soInfo.ShipPrice = Util.ToMoney(ASPManager.GetInstance().GetShipPrice(soInfo.GetTotalWeight(), soInfo.SOAmt, soInfo.ShipTypeSysNo, soInfo.ReceiveAreaSysNo)); CustomerInfo oCustomer = CustomerManager.GetInstance().Load(soInfo.CustomerSysNo); if (oCustomer.CustomerType != (int)AppEnum.CustomerType.Personal) { return; } //ORS�̳ǿ�����ͷ�Χ�ڵģ��������ݣ��Ͼ������ݣ����ݣ��Ϻ�����������100Ԫ���˷ѣ������50Ԫ //�����������Ϻ�����������200Ԫ���˷ѣ������50Ԫ��EMS��˳���ݲ����˷ѡ� AreaInfo areaInfo = ASPManager.GetInstance().LoadArea(soInfo.ReceiveAreaSysNo); if ((soInfo.ShipTypeSysNo == 1 || soInfo.ShipTypeSysNo == 8 || soInfo.ShipTypeSysNo == 9 || soInfo.ShipTypeSysNo == 10 || soInfo.ShipTypeSysNo == 11 || soInfo.ShipTypeSysNo == 13 || soInfo.ShipTypeSysNo == 17) && areaInfo.LocalCode < 5 && soInfo.SOAmt >= 100) //ORS�̳ǿ��(���Ϻ�����)�����������100 { if (soInfo.ShipPrice <= 50) { soInfo.ShipPrice = 0m; } else { soInfo.ShipPrice = soInfo.ShipPrice - 50; } } else if (soInfo.SOAmt >= 200 && soInfo.ShipTypeSysNo != 2 && soInfo.ShipTypeSysNo != 12) { if (soInfo.ShipPrice <= 50) { soInfo.ShipPrice = 0m; } else { soInfo.ShipPrice = soInfo.ShipPrice - 50; } } //if (soInfo.SOAmt >= 50 && soInfo.ShipTypeSysNo != 2) //����������50������EMS //{ // if (soInfo.ShipPrice <= 50) // { // soInfo.ShipPrice = 0m; // } // else // { // soInfo.ShipPrice = soInfo.ShipPrice - 50; // } //} } else soInfo.ShipPrice = 0m; }
private int InsertSOMaster(SOInfo oParam) { oParam.SysNo = SequenceDac.GetInstance().Create("SO_Sequence"); oParam.SOID = this.BuildSOID(oParam.SysNo); return new SODac().InsertMaster(oParam); }
private decimal CalcShipPriceTemp(SOInfo soInfo) { return Util.ToMoney(ASPManager.GetInstance().GetShipPrice(soInfo.GetTotalWeight(), soInfo.SOAmt, soInfo.ShipTypeSysNo, soInfo.ReceiveAreaSysNo)); }
public DataSet CheckItemAccountQty(SOInfo soInfo) { string sql = @"select si.productsysno,(case when isnull(i.accountqty,0)<si.quantity then "+(int)AppEnum.YNStatus.No+" else "+(int)AppEnum.YNStatus.Yes +" end) as Inventory,(case when isnull(s.accountqty,0)<si.quantity then "+(int)AppEnum.YNStatus.No+" else "+(int)AppEnum.YNStatus.Yes +@" end) as stock from so_item si left join inventory i on i.productsysno = si.productsysno left join inventory_stock s on s.productsysno = si.productsysno and s.stocksysno = "+soInfo.StockSysNo +" where sosysno = "+soInfo.SysNo; return SqlHelper.ExecuteDataSet(sql); }
/// <summary> /// ���ݶ�����֧����ʽ�����ڵ�֧��������� ������״̬ /// ����ǻ���������߿�������ҿ����壬����Ϊ"������" /// ������Ϊ"��֧��" /// </summary> /// <param name="soInfo"></param> /// <param name="isForce"></param> private void calcWaitingStatus(SOInfo soInfo,bool isForce) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //����֧����ʽ PayTypeInfo ptInfo = ASPManager.GetInstance().LoadPayType(soInfo.PayTypeSysNo); if(ptInfo.IsPayWhenRecv==(int)AppEnum.YNStatus.Yes)//�����������ֱ�ӳ��� soInfo.Status = (int)AppEnum.SOStatus.WaitingOutStock; else { //����֧����Ϣ SOIncomeInfo soIncome = SOIncomeManager.GetInstance().LoadValid((int)AppEnum.SOIncomeOrderType.SO, soInfo.SysNo); if (soIncome == null)//û����Ч֧����¼ soInfo.Status = (int)AppEnum.SOStatus.WaitingPay; //else if( soIncome.IncomeAmt<soInfo.GetTotalAmt() && !isForce )//֧������ // throw new BizException("calcWaitingStatus: soincome is less than so total amt, please check or do force audit"); else if (soIncome.IncomeAmt != soInfo.GetTotalAmt() && !isForce)//֧������ throw new BizException("calcWaitingStatus: soincome is not equal so total amt, please link AC or do force audit"); else soInfo.Status = (int)AppEnum.SOStatus.WaitingOutStock; } scope.Complete(); } }
public void DeleteSOItem(SOInfo soInfo,int productSysNo) { //��֤��Ʒ���� if(((SOItemInfo)soInfo.ItemHash[productSysNo]).ProductType==(int)AppEnum.SOItemType.ForSale&&((SOItemInfo)soInfo.ItemHash[productSysNo]).GiftSysNo!=AppConst.IntNull) { int giftQty = 0; int masterQty = 0; foreach(SOItemInfo item in soInfo.ItemHash.Values) { if(item.ProductType==(int)AppEnum.SOItemType.ForSale&&item.ProductSysNo!=productSysNo&&item.GiftSysNo==((SOItemInfo)soInfo.ItemHash[productSysNo]).GiftSysNo) masterQty += item.Quantity; else if(item.ProductSysNo==((SOItemInfo)soInfo.ItemHash[productSysNo]).GiftSysNo) giftQty = item.Quantity; } if(masterQty<giftQty) throw new BizException("There is too many gifts,please remove some gifts first"); } if(soInfo.SysNo!=AppConst.IntNull)//�ж��Ƿ����������ɵĶ��� { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { if(getCurrentSOStatus(soInfo.SysNo)!=(int)AppEnum.SOStatus.Origin) throw new BizException("The SOStatus is not origin now,can't be edited"); int rowsAffected = new SODac().DeleteSOItem((SOItemInfo)soInfo.ItemHash[productSysNo]); if(rowsAffected!=1) throw new BizException("Delete item failed"); SOItemInfo itemInfo = (SOItemInfo)soInfo.ItemHash[productSysNo]; InventoryManager.GetInstance().SetOrderQty(soInfo.StockSysNo,itemInfo.ProductSysNo,-1*itemInfo.Quantity); soInfo.ItemHash.Remove(productSysNo); //hawkins 2010-4-20 if (soInfo.CouponCode != "") { soInfo.CouponAmt = 0; Icson.Objects.Promotion.CouponInfo oCoupon = Icson.BLL.Promotion.CouponManager.GetInstance().LoadCouponByPwd(soInfo.CouponCode); if (oCoupon != null) { string errstr = Icson.BLL.Promotion.CouponManager.GetInstance().CheckCouponSOByUpdate(oCoupon, soInfo); if (errstr == "") soInfo.CouponAmt = oCoupon.CouponAmt; } } //============ this.CalcSO(soInfo); this.UpdateSO(soInfo); scope.Complete(); } } else soInfo.ItemHash.Remove(productSysNo); }
private bool CheckGiftQty(SOInfo soInfo) { Hashtable giftHash = new Hashtable(); Hashtable parentHash = new Hashtable(); foreach(SOItemInfo item in soInfo.ItemHash.Values) { if(item.ProductType==(int)AppEnum.SOItemType.ForSale) parentHash.Add(item.ProductSysNo,item); else if(item.ProductSysNo==(int)AppEnum.SOItemType.Gift) giftHash.Add(item.ProductSysNo,item); } foreach(SOItemInfo pitem in parentHash.Values) { if(pitem.GiftSysNo!=AppConst.IntNull) { foreach(SOItemInfo gitem in giftHash.Values) { if(gitem.ProductSysNo==pitem.GiftSysNo) { gitem.Quantity -= pitem.Quantity; break; } } } } foreach(SOItemInfo leftGift in giftHash.Values) { if(leftGift.Quantity>0) { return false; } } return true; }
public void GetBestSaleRuleFor99Bill(SOInfo SO) { if (SO.OrderDate < DateTime.Parse("2008-12-09")) { if (SO.PayTypeSysNo == 10 || SO.PayTypeSysNo == 16) //��Ǯ�˻�����Ǯ����֧�� { decimal discount = 0; Hashtable ht = PromotionManager.GetInstance().GetPromotionProductSysNoHash(16); //����sysno=16 if (ht != null) { foreach (SOItemInfo item in SO.ItemHash.Values) { if (ht.ContainsKey(item.ProductSysNo)) { if (Util.TrimDecimalNull(ht[item.ProductSysNo]) > 0) { if (item.DiscountAmt <= item.Price * (1 - Util.TrimDecimalNull(ht[item.ProductSysNo]))) { item.DiscountAmt = item.Price * (1 - Util.TrimDecimalNull(ht[item.ProductSysNo])); discount += item.Price * (1 - Util.TrimDecimalNull(ht[item.ProductSysNo])) * item.Quantity; } } } } if (discount > SO.DiscountAmt) SO.DiscountAmt = discount; } } } }
public void CancelAuditSO(SOInfo soInfo) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { ////���¶���״̬ //1 �鿴������ǰ״̬ //2 ���ø���ֵ������status int currentStatus = this.getCurrentSOStatus(soInfo.SysNo); if (currentStatus != (int)AppEnum.SOStatus.WaitingManagerAudit && currentStatus != (int)AppEnum.SOStatus.WaitingOutStock && currentStatus != (int)AppEnum.SOStatus.WaitingPay ) throw new BizException("cancel audit so: the current status is not WaitingManagerAudit/WaitingOutStock/WaitingPay, operation of Cancel Audit SO failed"); soInfo.Status = (int)AppEnum.SOStatus.Origin; UpdateSOStatus(soInfo.SysNo, soInfo.Status, soInfo.UpdateUserSysNo); scope.Complete(); } }
private DataSet ConvertSOItemDS(DataSet ds, SOInfo soInfo) { if (!Util.HasMoreRow(ds)) return ds; ds.Tables[0].Columns.Add("Price"); ds.Tables[0].Columns.Add("Qty"); Hashtable hs = soInfo.ItemHash; foreach (DataRow dr in ds.Tables[0].Rows) { int key = Util.TrimIntNull(dr["SysNo"]); SOItemInfo item = (SOItemInfo)hs[key]; dr["Price"] = item.Price; dr["Qty"] = item.Quantity; } return ds; }
//��ʼ�����ڼ���salerule��ϵ���Ʒ�б� private Hashtable InitItemList(SOInfo SO) { Hashtable itemList= new Hashtable(50); foreach(SOItemInfo soitem in SO.ItemHash.Values) { itemList.Add(soitem.ProductSysNo,soitem.Quantity); } return itemList; }
/// <summary> /// 后台修改订单时重新检查优惠券 /// </summary> /// <param name="oCoupon"></param> /// <param name="soInfo"></param> /// <returns></returns> public string CheckCouponSOByUpdate(CouponInfo oCoupon, SOInfo soInfo) { string result = ""; DataSet soItemDS = new DataSet(); //销售单的明细商品(仅主商品),增加大、中、小类,增加品牌 if (soInfo.ItemHash.Count > 0) { string sysNoStr = ""; foreach (SOItemInfo soItem in soInfo.ItemHash.Values) { if (soItem.ProductType == (int)AppEnum.SOItemType.ForSale) { sysNoStr += soItem.ProductSysNo + ","; } } sysNoStr = sysNoStr.TrimEnd(','); if (sysNoStr != "") { string sql = @" SELECT Product.SysNo,Product.ManufacturerSysNo,Product.C3SysNo,Category3.C2SysNo,Category2.C1SysNo FROM Product (NOLOCK) JOIN Category3 (NOLOCK) ON Category3.SysNo = product.C3SysNo JOIN Category2 (NOLOCK) ON Category2.SysNo = Category3.C2SysNo JOIN Category1 (NOLOCK) ON Category1.SysNo = Category2.C1SysNo WHERE Product.SysNo IN(" + sysNoStr + ")"; soItemDS = SqlHelper.ExecuteDataSet(sql); if (Util.HasMoreRow(soItemDS)) { soItemDS = ConvertSOItemDS(soItemDS, soInfo); } } } else { result = "没有订购任何商品"; return result; } #region 优惠券类型 的类别/商品/品牌 检测 if (oCoupon.CouponType == (int)AppEnum.CouponType.Category) { string cstr = oCoupon.CategorySysNoCom; string[] cList = cstr.Split(','); if (cList.Length > 0) { ArrayList c1List = new ArrayList(); ArrayList c2List = new ArrayList(); ArrayList c3List = new ArrayList(); for (int i = 0; i < cList.Length; i++) { string[] cx = cList[i].ToString().Split('_'); switch (cx[0].ToString()) { case "c1": case "C1": c1List.Add(Util.TrimIntNull(cx[1])); break; case "c2": case "C2": c2List.Add(Util.TrimIntNull(cx[1])); break; case "c3": case "C3": c3List.Add(Util.TrimIntNull(cx[1])); break; default: break; } } decimal categorybuyAmt = 0; bool IsContainsCategory = false; foreach (DataRow dr in soItemDS.Tables[0].Rows) { int c1SysNo = Util.TrimIntNull(dr["C1SysNo"]); int c2SysNo = Util.TrimIntNull(dr["C2SysNo"]); int c3SysNo = Util.TrimIntNull(dr["C3SysNo"]); int currqty = Util.TrimIntNull(dr["Qty"]); decimal currprice = Util.TrimDecimalNull(dr["Price"]); bool isInCategory = false; if (c1List.Contains(c1SysNo)) { IsContainsCategory = true; isInCategory = true; } else if (c2List.Contains(c2SysNo)) { IsContainsCategory = true; isInCategory = true; } else if (c3List.Contains(c3SysNo)) { IsContainsCategory = true; isInCategory = true; } if (isInCategory == true) categorybuyAmt += currprice * currqty; } if (IsContainsCategory == false) { result = "使用的类别优惠券,只能针对优惠券指定的类别商品进行优惠"; return result; } if (categorybuyAmt < oCoupon.SaleAmt) { result = "优惠券指定的类别商品的购买总额没有达到优惠券需消费金额要求"; return result; } } } else if (oCoupon.CouponType == (int)AppEnum.CouponType.Product) { string pstr = oCoupon.ProductSysNoCom; decimal productbuyAmt = 0; bool IsContainsProduct = false; foreach (DataRow dr in soItemDS.Tables[0].Rows) { int productsysno = Util.TrimIntNull(dr["SysNo"]); int currqty = Util.TrimIntNull(dr["Qty"]); decimal currprice = Util.TrimDecimalNull(dr["Price"]); bool isInProduct = false; if (pstr.Contains(productsysno.ToString())) { IsContainsProduct = true; isInProduct = true; } if (isInProduct == true) productbuyAmt += currprice * currqty; } if (IsContainsProduct == false) { result = "使用的商品优惠券,只能针对优惠券指定的商品进行优惠"; return result; } if (productbuyAmt < oCoupon.SaleAmt) { result = "优惠券指定的商品的购买总额没有达到优惠券需消费金额要求"; return result; } } else if (oCoupon.CouponType == (int)AppEnum.CouponType.Manufactory) { string mstr = oCoupon.ManufactorySysNoCom; decimal manufactorybuyAmt = 0; bool IsContainsManufactory = false; foreach (DataRow dr in soItemDS.Tables[0].Rows) { int manufacturerSysNo = Util.TrimIntNull(dr["ManufacturerSysNo"]); int currqty = Util.TrimIntNull(dr["Qty"]); decimal currprice = Util.TrimDecimalNull(dr["Price"]); bool isInManufacturer = false; if (mstr.Contains(manufacturerSysNo.ToString())) { IsContainsManufactory = true; isInManufacturer = true; } if (isInManufacturer == true) manufactorybuyAmt += currprice * currqty; } if (IsContainsManufactory == false) { result = "使用的品牌优惠券,只能针对优惠券指定的品牌商品进行优惠"; return result; } if (manufactorybuyAmt < oCoupon.SaleAmt) { result = "优惠券指定的品牌商品的购买总额没有达到优惠券需消费金额要求"; return result; } } else if (oCoupon.CouponType == (int)AppEnum.CouponType.ALL) { decimal productbuyAmt = 0; foreach (DataRow dr in soItemDS.Tables[0].Rows) { int currqty = Util.TrimIntNull(dr["Qty"]); decimal currprice = Util.TrimDecimalNull(dr["Price"]); productbuyAmt += currprice * currqty; } if (productbuyAmt < oCoupon.SaleAmt) { result = "购买商品的总额没有达到优惠券需消费金额要求"; return result; } } #endregion return result; }
public void SetDeliveryDate(SOInfo soInfo) { Hashtable paramHash = new Hashtable(); paramHash.Add("SysNo",soInfo.SysNo); paramHash.Add("DeliveryDate",soInfo.DeliveryDate); this.UpdateSOMaster(paramHash); }