Exemple #1
0
        private static void SetAbandon(int countdownSysNo)
        {
            //必须是Ready或者VerifyFaild状态
            SecKillEntity entity = SecKillDA.GetCountDownItemBySysno(countdownSysNo);

            if (entity.Status != (int)CountdownStatus.Ready && entity.Status != (int)CountdownStatus.VerifyFaild)
            {
                throw new BusinessException("the current status not allow such opertion");
            }

            int SysNo = SecKillDA.GetProductNotAutoSetVirtualKey(entity.ProductSysNo
                                                                 , (int)NotAutoSetVirtualType.CountDown, entity.SysNo);

            entity.Status = (int)CountdownStatus.Abandon;
            TransactionOptions transactionOptions = new TransactionOptions();

            transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
            {
                if (entity.IsReservedQty == 1)
                {
                    UpdateReservedQTY(entity);
                }
                SetVirtualQty_WhenCountDownAbandon(entity, SysNo);
                if (entity.IsPromotionSchedule == 1)
                {
                    SecKillDA.RollbackMaxPerOrder(entity.ProductSysNo);
                }
                SecKillDA.CountDownEndReleaseWithholdQty(entity.SysNo);
                SecKillDA.UpdateCountdownStatus(entity);
                SecKillDA.UpdateProduct_Ex(entity.ProductSysNo, string.Empty);
                ts.Complete();
            }
        }
Exemple #2
0
        public static void SetFinish(int countdownSysNo)
        {
            //必须是Running
            SecKillEntity oCountdown = SecKillDA.GetCountDownItemBySysno(countdownSysNo);

            if (oCountdown.Status != (int)CountdownStatus.Running)
            {
                throw new BusinessException("the current status not allow such opertion");
            }

            oCountdown.Status = (int)CountdownStatus.Finish;
            //edit by kathy 2009-12-10
            //先更改限时抢购的状态为完成,在调整相应的虚拟库存。
            //SetInventoryVirtualQty_whenCountdownItemIsRun 此job每五分钟会检测运行态的countdownitem:
            //inventory的virtualQty和inventory_stock的virtualQty之和是否相等,如果不等,把inventory的virtualQty更改成inventory_stock的virtualQty之和)


            ItemEntity itemPrice = SecKillDA.LoadItemPrice(oCountdown.ProductSysNo);

            itemPrice.CurrentPrice = oCountdown.SnapShotCurrentPrice;
            itemPrice.CashRebate   = oCountdown.SnapShotCashRebate;
            itemPrice.Point        = oCountdown.SnapShotPoint;
            //限时抢购完成更改虚库信息
            int SysNo = SecKillDA.GetProductNotAutoSetVirtualKey(oCountdown.ProductSysNo
                                                                 , (int)NotAutoSetVirtualType.CountDown, oCountdown.SysNo);
            TransactionOptions transactionOptions = new TransactionOptions();

            transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
            {
                SecKillDA.UpdateCountdown(oCountdown);
                SetVirtualQty_CountDownFinish(oCountdown, SysNo);

                SecKillDA.CountDownEndReleaseWithholdQty(oCountdown.SysNo);
                SecKillDA.UpdateItemPrice(itemPrice);
                SecKillDA.UpdateProduct_Ex(oCountdown.ProductSysNo, string.Empty);
                if (oCountdown.IsPromotionSchedule == 1)
                {
                    SecKillDA.RollbackMaxPerOrder(oCountdown.ProductSysNo);
                }
                ts.Complete();
            }
        }