Beispiel #1
0
        /// <summary>
        /// 运行-->结束
        /// </summary>
        /// <param name="GroupBuyingSysNo"></param>
        public static void SetFinish(ProductGroupBuyingEntity groupBuyingItem)
        {
            //必须是Running
            if (groupBuyingItem.Status != "A")
            {
                throw new BusinessException("the current status not allow such opertion");
            }
            else
            {
                //设置阶梯价格
                SetStepPrice(groupBuyingItem);
            }

            groupBuyingItem = GroupBuyingDA.GetGroupBuyingItemBySysno(groupBuyingItem.SysNo);

            groupBuyingItem.Status = "F";

            decimal gbCurentPrice = 0;

            List <ProductGroupBuying_SnapShotPriceEntity> snapShotList = GroupBuyingDA.GetSnapShotPriceList(groupBuyingItem.SysNo);

            using (TransactionScope ts = new TransactionScope())
            {
                foreach (ProductGroupBuying_SnapShotPriceEntity snapShot in snapShotList)
                {
                    ProductPriceInfoEntity itemPrice = GroupBuyingDA.LoadItemPrice(snapShot.ProductSysNo);

                    gbCurentPrice = itemPrice.CurrentPrice;

                    itemPrice.BasicPrice   = snapShot.SnapshotBasicPrice;
                    itemPrice.CurrentPrice = snapShot.SnapShotCurrentPrice;
                    itemPrice.CashRebate   = snapShot.SnapShotCashRebate;
                    itemPrice.Point        = snapShot.SnapShotPoint;
                    itemPrice.MaxPerOrder  = snapShot.SnapShotMaxPerOrder;


                    //GroupBuyingDA.UpdateItemPrice(itemPrice);
                    GroupBuyingDA.UpdateItemPrice(itemPrice, groupBuyingItem, groupBuyingItem.InDate, "IPPSystemAdmin", DateTime.Now, "团购调价就绪-->运行", "JobConsole", "GroupBuying");

                    GroupBuyingDA.UpdateProductEx(snapShot.ProductSysNo, string.Empty);


                    //验证一个规则内差价是否小于0
                    if (snapShot != null && snapShot.ProductSysNo != 0)
                    {
                        CheckSaleRule(snapShot.ProductSysNo);
                    }

                    //decimal offset = 0;
                    //decimal point = (itemPrice.Point - 0) / 10m;
                    //offset = itemPrice.CurrentPrice - gbCurentPrice - point;

                    //类型PriceLogType:记录为“限时促销调价”;
                    //申请时间CreateDate:dbo.ProductGroupBuying .CreateTime;
                    //生效时间UpdateDate: EndTime;
                    //申请人CreateUser:dbo.ProductGroupBuying.Createusersysno对应的username;
                    //审核人UpdateUser:dbo.ProductGroupBuying.Audituser;
                    //商品原价OldPrice:GroupBuyingCurrentPrice;
                    //调后价格NewPrice:SnapShotCurrentPrice;
                    //调整幅度offset:调后价格减去商品原价;
                    //返现金额CashRebate:SnapShotCashRebate;


                    //2011-12-1 删除-该功能移入SP Rik.K.Li
                    //GroupBuyingDA.InsertGroupBuyingProductPricechangeLog(itemPrice.ProductSysNo.ToString(),
                    //                                                 snapShot.SnapShotCurrentPrice.ToString(),
                    //                                                 gbCurentPrice.ToString(),
                    //                                                 offset.ToString(),
                    //                                                 itemPrice.UnitCost,
                    //                                                 snapShot.SnapShotCashRebate,
                    //                                                 snapShot.SnapShotPoint,
                    //                                                 groupBuyingItem.InUser,
                    //                                                 groupBuyingItem.InDate,
                    //                                                 groupBuyingItem.AuditUser,
                    //                                                 groupBuyingItem.EndDate,
                    //                                                 "团购调价运行-->结束",
                    //                                                 "JobConsole",
                    //                                                 "GroupBuying");
                }


                if (groupBuyingItem.SuccessDate != null)
                {
                    groupBuyingItem.DealPrice = gbCurentPrice;
                }
                else
                {
                    groupBuyingItem.DealPrice = 0;
                }

                GroupBuyingDA.UpdateProductGroupBuyingFinish(groupBuyingItem);
                SyncGroupBuyingStatus(groupBuyingItem);


                ts.Complete();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 就绪-->运行
        /// </summary>
        /// <param name="groupBuyingItem"></param>
        /// <returns></returns>
        private static bool SetRunning(ProductGroupBuyingEntity groupBuyingItem)
        {
            if (groupBuyingItem.Status != "P")
            {
                throw new BusinessException("不是就绪状态");
            }

            using (TransactionScope ts = new TransactionScope())
            {
                List <ProductPriceInfoEntity> priceInfoList = GroupBuyingDA.GetProductPriceInfoList(groupBuyingItem.ProductSysNo, groupBuyingItem.IsByGroup);

                groupBuyingItem.Status = "A";

                if (groupBuyingItem.GroupBuyingTypeSysNo != 6)
                {
                    #region 如果团购类型为抽奖(6),则不需下列操作
                    ProductGroupBuying_PriceEntity gbPrice = GroupBuyingDA.GetProductGroupBuying_PriceList(groupBuyingItem).OrderBy(e => e.SellCount).ToList()[0];

                    //设置原价
                    groupBuyingItem.OriginalPrice = GroupBuyingDA.GetOriginalPrice(groupBuyingItem.ProductSysNo, groupBuyingItem.IsByGroup);

                    //设置团购为原始价格并记录团购最低阶价格
                    foreach (ProductPriceInfoEntity priceinfo in priceInfoList)
                    {
                        ProductGroupBuying_SnapShotPriceEntity snapShotPrice = new ProductGroupBuying_SnapShotPriceEntity();
                        snapShotPrice.SnapShotCashRebate      = priceinfo.CashRebate;
                        snapShotPrice.SnapShotCurrentPrice    = priceinfo.CurrentPrice;
                        snapShotPrice.SnapShotMaxPerOrder     = priceinfo.MaxPerOrder;
                        snapShotPrice.SnapShotPoint           = priceinfo.Point;
                        snapShotPrice.ProductSysNo            = priceinfo.ProductSysNo;
                        snapShotPrice.ProductGroupBuyingSysNo = groupBuyingItem.SysNo;
                        snapShotPrice.SnapshotBasicPrice      = priceinfo.BasicPrice;

                        //插入快照价格
                        GroupBuyingDA.CreateSnapShotPrice(snapShotPrice);


                        ProductPriceInfoEntity itemPrice = new ProductPriceInfoEntity();
                        itemPrice              = GroupBuyingDA.LoadItemPrice(priceinfo.ProductSysNo);
                        itemPrice.CashRebate   = 0;
                        itemPrice.BasicPrice   = groupBuyingItem.OriginalPrice;
                        itemPrice.CurrentPrice = gbPrice.GroupBuyingPrice;
                        itemPrice.Point        = 0;


                        groupBuyingItem.BasicPrice = itemPrice.BasicPrice;

                        //判断MaxPerOrder是否输入
                        if (groupBuyingItem.MaxPerOrder > 0)
                        {
                            itemPrice.MaxPerOrder = groupBuyingItem.MaxPerOrder;
                        }

                        //修改价格
                        //GroupBuyingDA.UpdateItemPrice(itemPrice);
                        GroupBuyingDA.UpdateItemPrice(itemPrice, groupBuyingItem, groupBuyingItem.InDate, "IPPSystemAdmin", DateTime.Now, "团购调价就绪-->运行", "JobConsole", "GroupBuying");

                        //修改商品信息促销类型为团购“GB”
                        GroupBuyingDA.UpdateProductEx(itemPrice.ProductSysNo, "GB");

                        //验证一个规则内差价是否小于0
                        if (groupBuyingItem.ProductSysNo != 0)
                        {
                            CheckSaleRule(groupBuyingItem.ProductSysNo);
                        }


                        //类型PriceLogType:记录为“限时促销调价”;
                        //申请时间CreateDate:dbo.ProductGroupBuying .InDate;
                        //生效时间UpdateDate:dbo.ProductGroupBuying .BeginDate;
                        //申请人CreateUser:InUser;
                        //审核人UpdateUser:dbo.ProductGroupBuying.Audituser;
                        //商品原价OldPrice:SnapShotCurrentPrice;
                        //调后价格NewPrice:GroupBuyingCurrentPrice;
                        //调整幅度offset:调后价格减去商品原价减去积分
                        //返现金额CashRebate:GroupBuyingCashRebate;
                        //积分Point: GroupBuyingPoint

                        //2011-12-1 删除-该功能移入SP Rik.K.Li
                        //decimal offset = 0;
                        //decimal point = (0 - snapShotPrice.SnapShotPoint) / 10m;
                        //offset = itemPrice.CurrentPrice - snapShotPrice.SnapShotCurrentPrice - point;

                        //string userName = groupBuyingItem.InUser;

                        //GroupBuyingDA.InsertGroupBuyingProductPricechangeLog(itemPrice.ProductSysNo.ToString(),
                        //                                                 gbPrice.GroupBuyingPrice.ToString(),
                        //                                                 snapShotPrice.SnapShotCurrentPrice.ToString(),
                        //                                                 offset.ToString(),
                        //                                                 itemPrice.UnitCost,
                        //                                                 0,
                        //                                                 0,
                        //                                                 groupBuyingItem.InUser,
                        //                                                 groupBuyingItem.InDate,
                        //                                                 groupBuyingItem.AuditUser,
                        //                                                 groupBuyingItem.BeginDate,
                        //                                                 "团购调价就绪-->运行",
                        //                                                 "JobConsole",
                        //                                                 "GroupBuying");
                    }
                    #endregion
                }


                GroupBuyingDA.UpdateProductGroupBuyingRun(groupBuyingItem);
                groupBuyingItem.Reasons = "";
                SyncGroupBuyingStatus(groupBuyingItem);

                ts.Complete();
            }
            return(true);
        }