コード例 #1
0
        public void ReturnRO(ROInfo roInfo)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if (this.GetROCurrentStatus(roInfo.SysNo) != (int)AppEnum.ROStatus.Audited)
                {
                    throw new BizException("This RO is not Audited now ,can't be returned");
                }
                roInfo.Status = (int)AppEnum.ROStatus.Returned;
                //update ro status
                Hashtable paramHash = new Hashtable(4);
                paramHash.Add("Status", roInfo.Status);
                paramHash.Add("ReturnTime", roInfo.ReturnTime);
                paramHash.Add("ReturnUserSysNo", roInfo.ReturnUserSysNo);
                paramHash.Add("SysNo", roInfo.SysNo);
                this.UpdateROMaster(paramHash);
                //update inventory
                foreach (ROItemInfo roItem in roInfo.ItemHash.Values)
                {
                    //UnitCostManager.GetInstance().SetCost(roItem.ProductSysNo, roItem.Quantity, roItem.Cost); //Serious bug 2007-07-21
                    //退货时不影响一手商品的成本,只需要修改二手商品的成本
                    UnitCostManager.GetInstance().SetCost(roItem.ReturnSysNo, roItem.Quantity, roItem.Cost);
                    InventoryManager.GetInstance().SetInStockQty(roInfo.StockSysNo, roItem.ReturnSysNo, roItem.Quantity);
                }
                //update customer score
                RMAInfo oRMA = RMAManager.GetInstance().LoadMaster(roInfo.RMASysNo);
                //先将销售单所得积分加上
                PointManager.GetInstance().DoDelayPointSingle(oRMA.SOSysNo);
                //然后减去退货对应积分
                if (roInfo.PointAmt != 0)
                {
                    PointManager.GetInstance().SetScore(oRMA.CustomerSysNo, roInfo.PointAmt * (-1), (int)AppEnum.PointLogType.ReturnProduct, roInfo.SysNo.ToString());
                }
                //生成收款单
                //如果无有效的收款单-->生成soincome(normal, origin)
                SOIncomeInfo soIncome = SOIncomeManager.GetInstance().LoadValid((int)AppEnum.SOIncomeOrderType.RO, roInfo.SysNo);
                if (soIncome == null)//无有效收款单,生成收款单
                {
                    soIncome                 = new SOIncomeInfo();
                    soIncome.OrderType       = (int)AppEnum.SOIncomeOrderType.RO;
                    soIncome.OrderSysNo      = roInfo.SysNo;
                    soIncome.OrderAmt        = soIncome.IncomeAmt = Util.TruncMoney(roInfo.CashAmt + roInfo.RedeemAmt);
                    soIncome.IncomeStyle     = (int)AppEnum.SOIncomeStyle.Normal;
                    soIncome.IncomeUserSysNo = roInfo.ReturnUserSysNo;
                    soIncome.IncomeTime      = DateTime.Now;
                    soIncome.Status          = (int)AppEnum.SOIncomeStatus.Origin;
                    SOIncomeManager.GetInstance().Insert(soIncome);
                }
                scope.Complete();
            }
        }
コード例 #2
0
        public void CancelReturnRO(ROInfo roInfo)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if (this.GetROCurrentStatus(roInfo.SysNo) != (int)AppEnum.ROStatus.Returned)
                {
                    throw new BizException("This RO is not returned now ,can't cancel return");
                }
                roInfo.Status = (int)AppEnum.ROStatus.Audited;
                //update ro status
                Hashtable paramHash = new Hashtable(4);
                paramHash.Add("Status", roInfo.Status);
                paramHash.Add("ReturnTime", roInfo.ReturnTime);
                paramHash.Add("ReturnUserSysNo", roInfo.ReturnUserSysNo);
                paramHash.Add("SysNo", roInfo.SysNo);
                this.UpdateROMaster(paramHash);
                //update inventory
                foreach (ROItemInfo roItem in roInfo.ItemHash.Values)
                {
                    //UnitCostManager.GetInstance().SetCost(roItem.ProductSysNo, roItem.Quantity*(-1), roItem.Cost);
                    UnitCostManager.GetInstance().SetCost(roItem.ReturnSysNo, roItem.Quantity * (-1), roItem.Cost);
                    InventoryManager.GetInstance().SetInStockQty(roInfo.StockSysNo, roItem.ReturnSysNo, roItem.Quantity * (-1));
                }
                //update customer score
                if (roInfo.PointAmt != 0)
                {
                    RMAInfo oRMA = RMAManager.GetInstance().LoadMaster(roInfo.RMASysNo);
                    PointManager.GetInstance().SetScore(oRMA.CustomerSysNo, roInfo.PointAmt, (int)AppEnum.PointLogType.CancelReturn, roInfo.SysNo.ToString());
                }
                //abandon soincome
                SOIncomeManager.GetInstance().ROCancelReturn(roInfo.SysNo);
                scope.Complete();
            }
        }