Ejemplo n.º 1
0
        /// <summary>
        /// 提交审核
        /// </summary>
        /// <param name="sysNo"></param>
        public virtual void SubmitAudit(int sysNo)
        {
            string userfullname = ObjectFactory <ICommonBizInteract> .Instance.GetUserFullName(ServiceContext.Current.UserSysNo.ToString(), true);

            GroupBuyingInfo infoTemp = Load(sysNo);

            if (infoTemp.Status.Value != GroupBuyingStatus.Init && infoTemp.Status.Value != GroupBuyingStatus.VerifyFaild)
            {
                //throw new BizException(string.Format("团购[{0}]提交审核失败,只有初始状态的团购才能提交审核!", sysNo));
                throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_JustInitCanSubmit"), sysNo));
            }
            if (infoTemp.Status.Value == GroupBuyingStatus.WaitingAudit)
            {
                //throw new BizException(string.Format("团购[{0}]信息状态已变更,请刷新后再试!", sysNo));
                throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_TryAgainAfterF5"), sysNo));
            }

            TransactionScopeFactory.TransactionAction(() =>
            {
                m_GroupBuyingDA.UpdataSatus(sysNo, "W", userfullname);

                // 发送待办消息
                EventPublisher.Publish <GroupBuyAuditMessage>(new GroupBuyAuditMessage
                {
                    GroupBuySysNo    = sysNo,
                    CurrentUserSysNo = ServiceContext.Current.UserSysNo
                });
            });
            ExternalDomainBroker.CreateOperationLog(BizLogType.GroupBuyingSubmitAudit.ToEnumDesc(), BizLogType.GroupBuyingSubmitAudit, sysNo, infoTemp.CompanyCode);
        }
Ejemplo n.º 2
0
        public void Load(string sysNo, EventHandler <RestClientEventArgs <GroupBuyingMaintainVM> > callback)
        {
            string relativeUrl = "/MKTService/GroupBuying/" + sysNo;

            restClient.Query <GroupBuyingInfo>(relativeUrl, (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }

                GroupBuyingInfo entity           = args.Result;
                GroupBuyingMaintainVM _viewModel = null;
                if (entity == null)
                {
                    _viewModel = new GroupBuyingMaintainVM();
                }
                else
                {
                    _viewModel = EtoV(entity);
                }

                callback(obj, new RestClientEventArgs <GroupBuyingMaintainVM>(_viewModel, restClient.Page));
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="info"></param>
        public GroupBuyingInfo Update(GroupBuyingInfo info)
        {
            // 验证团购信息
            //CheckGroupBuyingBase(info);
            ValidateEntity(info);

            // 验证阶梯价格
            CheckPriceRank(info.PriceRankList, info.GroupBuyingTypeSysNo);

            TransactionScopeFactory.TransactionAction(() =>
            {
                if (info.CategoryType != GroupBuyingCategoryType.ZeroLottery)
                {
                    info.LotteryRule = string.Empty;
                }
                if (info.CategoryType != GroupBuyingCategoryType.Virtual)
                {
                    info.CouponValidDate = null;
                }
                // 更新团购信息
                m_GroupBuyingDA.Update(info);

                m_GroupBuyingDA.DeleteGroupBuyingActivityRel(info.SysNo.Value);

                if (info.VendorStoreSysNoList != null && info.CategoryType == GroupBuyingCategoryType.Virtual)
                {
                    info.VendorStoreSysNoList.ForEach(p =>
                    {
                        m_GroupBuyingDA.CreateGroupBuyingActivityRel(info.SysNo.Value, p);
                    });
                }

                //先删除该团购的阶梯价格
                m_GroupBuyingDA.DeleteProductGroupBuyingPrice(info.SysNo.Value);
                // 循环更新阶梯价格
                foreach (var price in info.PriceRankList)
                {
                    if (price.MinQty == null || price.MinQty < 1)
                    {
                        continue;
                    }
                    price.ProductSysNo = m_GroupBuyingDA.CreateProductGroupBuyingPrice(info.SysNo.Value, price.MinQty, price.DiscountValue, info.GroupBuyingPoint, info.CostAmt);
                }

                //更新活动状态
                //ObjectFactory<GroupBuyingPromotionEngine>.Instance.CreateNewGroupBuyingActivity(info);

                // 发送待办消息
                EventPublisher.Publish <GroupBuyUpdateMessage>(new GroupBuyUpdateMessage
                {
                    GroupBuySysNo    = info.SysNo.Value,
                    GroupBuyName     = info.GroupBuyingTitle.Content,
                    CurrentUserSysNo = ServiceContext.Current.UserSysNo
                });
            });

            ExternalDomainBroker.CreateOperationLog(BizLogType.GroupBuyingUpdate.ToEnumDesc(), BizLogType.GroupBuyingUpdate, info.SysNo.Value, info.CompanyCode);

            return(info);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新团购
        /// </summary>
        /// <param name="entity"></param>
        public void Update(GroupBuyingInfo entity)
        {
            DataCommand command = DataCommandManager.GetDataCommand("UpdateProductGroupBuying");

            command.SetParameterValue("@SysNo", entity.SysNo);
            command.SetParameterValue("@ProductSysNo", entity.ProductSysNo);
            command.SetParameterValue("@GroupBuyingTitle", entity.GroupBuyingTitle);
            command.SetParameterValue("@GroupBuyingDesc", entity.GroupBuyingDesc);
            command.SetParameterValue("@GroupBuyingRules", entity.GroupBuyingRules);
            command.SetParameterValue("@GroupBuyingDescLong", entity.GroupBuyingDescLong);
            command.SetParameterValue("@OriginalPrice", entity.CurrentPrice);
            command.SetParameterValue("@DealPrice", entity.GroupBuyPrice);
            command.SetParameterValue("@GroupBuyingPicUrl", entity.GroupBuyingPicUrl);
            command.SetParameterValue("@GroupBuyingMiddlePicUrl", entity.GroupBuyingMiddlePicUrl);
            command.SetParameterValue("@GroupBuyingSmallPicUrl", entity.GroupBuyingSmallPicUrl);
            command.SetParameterValue("@BeginDate", entity.BeginDate);
            command.SetParameterValue("@EndDate", entity.EndDate);
            command.SetParameterValue("@IsByGroup", "N");
            command.SetParameterValue("@MaxPerOrder", entity.MaxPerOrder);
            command.SetParameterValue("@LimitOrderCount", entity.LimitOrderCount);
            command.SetParameterValue("@Priority", entity.Priority);
            command.SetParameterValue("@EditUser", entity.EditUserName);
            command.SetParameterValue("@Status", entity.Status);

            command.ExecuteNonQuery();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新团购
        /// </summary>
        /// <param name="entity"></param>
        public void Update(GroupBuyingInfo entity)
        {
            DataCommand command = DataCommandManager.GetDataCommand("UpdateProductGroupBuying");

            command.SetParameterValue("@SysNo", entity.SysNo);
            command.SetParameterValue("@ProductSysNo", entity.ProductSysNo);
            command.SetParameterValue("@GroupBuyingTitle", entity.GroupBuyingTitle.Content);
            command.SetParameterValue("@GroupBuyingDesc", entity.GroupBuyingDesc.Content);
            command.SetParameterValue("@GroupBuyingRules", entity.GroupBuyingRules.Content);
            command.SetParameterValue("@GroupBuyingDescLong", entity.GroupBuyingDescLong.Content);
            command.SetParameterValue("@GroupBuyingPicUrl", entity.GroupBuyingPicUrl.Content);
            command.SetParameterValue("@GroupBuyingMiddlePicUrl", entity.GroupBuyingMiddlePicUrl.Content);
            command.SetParameterValue("@GroupBuyingSmallPicUrl", entity.GroupBuyingSmallPicUrl.Content);
            command.SetParameterValue("@BeginDate", entity.BeginDate);
            command.SetParameterValue("@EndDate", entity.EndDate);
            command.SetParameterValue("@IsByGroup", entity.IsByGroup.Value ? "Y" : "N");
            command.SetParameterValue("@MaxPerOrder", entity.MaxCountPerOrder ?? 0);
            command.SetParameterValue("@GroupBuyingTypeSysNo", entity.GroupBuyingTypeSysNo);
            command.SetParameterValue("@GroupBuyingAreaSysNo", entity.GroupBuyingAreaSysNo);
            command.SetParameterValue("@LimitOrderCount", entity.LimitOrderCount);
            command.SetParameterValue("@Reasons", "");
            command.SetParameterValue("@Priority", entity.Priority);
            command.SetParameterValue("@EditUser", entity.EditUser);
            command.SetParameterValue("@CompanyCode", entity.CompanyCode);
            command.SetParameterValue("@VendorSysNo", entity.GroupBuyingVendorSysNo);
            command.SetParameterValue("@CouponValidDate", entity.CouponValidDate);
            command.SetParameterValue("@LotteryRule", entity.LotteryRule);
            command.SetParameterValue("@GroupBuyingCategorySysNo", entity.GroupBuyingCategorySysNo);
            command.SetParameterValue("@IsWithoutReservation", entity.IsWithoutReservation ? 1 : 0);
            command.SetParameterValue("@IsVouchers", entity.IsVouchers ? 1 : 0);

            command.ExecuteNonQuery();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 作废
        /// </summary>
        /// <param name="sysNo"></param>
        public virtual void Void(List <int> sysNoList)
        {
            string userfullname = ObjectFactory <ICommonBizInteract> .Instance.GetUserFullName(ServiceContext.Current.UserSysNo.ToString(), true);


            foreach (int sysNo in sysNoList)
            {
                GroupBuyingInfo infoTemp = Load(sysNo);
                if (infoTemp.Status.Value != GroupBuyingStatus.Pending)
                {
                    //throw new BizException(string.Format("团购[{0}]作废失败,只有就绪状态的团购才能作废!",sysNo));
                    throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_JustReadyCanDel"), sysNo));
                }

                TransactionScopeFactory.TransactionAction(() =>
                {
                    m_GroupBuyingDA.UpdataSatus(sysNo, "D", userfullname);
                    //同步Seller Portal团购状态
                    infoTemp.Status = GroupBuyingStatus.VerifyFaild;
                    m_GroupBuyingDA.SyncGroupBuyingStatus(infoTemp);
                    ExternalDomainBroker.CreateOperationLog(BizLogType.GroupBuyingVoid.ToEnumDesc(), BizLogType.GroupBuyingVoid, sysNo, infoTemp.CompanyCode);

                    //促销引擎-更新活动状态 -作废
                    //ObjectFactory<GroupBuyingPromotionEngine>.Instance.UpdateGroupBuyingActivityStatus(sysNo, GroupBuyingStatus.Deactive);

                    // 发送待办消息
                    EventPublisher.Publish <GroupBuyVoidMessage>(new GroupBuyVoidMessage
                    {
                        GroupBuySysNo    = sysNo,
                        CurrentUserSysNo = ServiceContext.Current.UserSysNo
                    });
                });
            }
        }
Ejemplo n.º 7
0
        public void Update(GroupBuyingMaintainVM vm, EventHandler <RestClientEventArgs <GroupBuyingInfo> > callback)
        {
            GroupBuyingInfo entity      = VtoE(vm);
            string          relativeUrl = "/MKTService/GroupBuying/Update";

            restClient.Update(relativeUrl, entity, callback);
        }
Ejemplo n.º 8
0
        private void SuccessfulGroupBuyProcess(GroupBuyingInfo gbInfo)
        {
            List <SOItemInfo> GroupBuyItemList = SODA.GetGroupBuySOItemByGroupBuySysNo(gbInfo.SysNo.Value);
            SOProcessor       soProcessor      = ObjectFactory <SOProcessor> .Instance;

            foreach (SOItemInfo groupBuyItem in GroupBuyItemList)
            {
                //更新订单
                try
                {
                    //修改团购商品价格
                    SOInfo soInfo = SODA.GetSOBySOSysNo(groupBuyItem.SOSysNo.Value);
                    soProcessor.ProcessSO(new SOAction.SOCommandInfo {
                        Command = SOAction.SOCommand.Job, SOInfo = soInfo, Parameter = new object[] { groupBuyItem.ProductSysNo }
                    });
                }
                catch (Exception ex)
                {
                    SODA.UpdateGroupBuySOAndItemSettlementStatus(groupBuyItem.SOSysNo.Value, groupBuyItem.ProductSysNo.Value, SettlementStatus.Fail);
                    ExceptionHelper.HandleException(ex);
                    continue;
                }
            }
            ExternalDomainBroker.UpdateGroupBuySettlementStatus(gbInfo.SysNo.Value, GroupBuyingSettlementStatus.Yes);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 得到随心配的商品在团购里的毛利率
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public string GetProductPromotionMarginByGroupBuying(GroupBuyingInfo info)
        {
            ProductInfo             productInfo = ExternalDomainBroker.GetProductInfo(info.ProductSysNo.Value);
            ProductPriceRequestInfo priceMsg    = new ProductPriceRequestInfo()
            {
                CurrentPrice = info.PriceRankList.OrderBy(s => s.DiscountValue).First().DiscountValue,//最低阶梯价格
                UnitCost     = productInfo.ProductPriceInfo.UnitCost,
                Point        = info.GroupBuyingPoint,
                Category     = productInfo.ProductBasicInfo.ProductCategoryInfo
            };
            string        returnMsgStr = string.Empty;
            StringBuilder checkMsg     = new StringBuilder();
            List <ProductPromotionMarginInfo> marginList = ObjectFactory <IIMBizInteract> .Instance.GetProductPromotionMargin(
                priceMsg, info.ProductSysNo.Value, "", 0m, ref returnMsgStr);

            marginList = marginList.Where(ppm => ppm.PromotionType == PromotionType.OptionalAccessories).ToList();

            foreach (var mgInfo in marginList)
            {
                //checkMsg.Append(string.Format("此商品的最低阶梯价格在在随心配{0}中毛利率{1}%\r", mgInfo.ReferenceSysNo
                //    , (Decimal.Round(mgInfo.Margin, 4) * 100m).ToString("0.00")));
                checkMsg.Append(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_LowestGrossMagin"), mgInfo.ReferenceSysNo
                                              , (Decimal.Round(mgInfo.Margin, 4) * 100m).ToString("0.00")));
            }
            return(checkMsg.ToString());
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 团购业务规则
        /// </summary>
        /// <param name="entity"></param>
        private void ValidateEntity(GroupBuyingInfo entity)
        {
            // TODO:验证商品是否存在

            // 验证团购时间
            if (entity.BeginDate > entity.EndDate)
            {
                // throw new BizException(string.Format("团购开始时间晚于结束时间!", entity.ProductSysNo.Value, entity.BeginDate.Value, entity.EndDate.Value));
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_StartLaterEndDate"));
            }
            if (entity.GroupBuyingTypeSysNo != 6)
            {
                // 验证商品是否存在相冲突时间段的团购中
                CheckGroupBuyConflict(entity.SysNo, entity);

                // 验证商品是否存在相冲突时间段的限时抢购中
                CheckGroupBuyAndCountDownConflict(entity);
            }
            else
            {
                entity.ProductID                      = "";
                entity.ProductSysNo                   = 0;
                entity.GroupBuyingVendorName          = "";
                entity.GroupBuyingVendorSysNo         = 0;
                entity.PriceRankList[0].DiscountValue = 0m;
                entity.PriceRankList                  = new List <PSPriceDiscountRule>()
                {
                    entity.PriceRankList[0]
                };
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 创建团购
        /// </summary>
        public virtual GroupBuyingInfo Create(GroupBuyingInfo item)
        {
            item.InUser = ObjectFactory <ICommonBizInteract> .Instance.GetUserFullName(ServiceContext.Current.UserSysNo.ToString(), true);

            item.CurrentSellCount = item.CurrentSellCount.HasValue ? item.CurrentSellCount.Value : 0;

            return(ObjectFactory <GroupBuyingProcessor> .Instance.Create(item));
        }
Ejemplo n.º 12
0
        public void Create(GroupBuyingMaintainVM vm, EventHandler <RestClientEventArgs <GroupBuyingInfo> > callback)
        {
            vm.CompanyCode = CPApplication.Current.CompanyCode;
            GroupBuyingInfo entity = VtoE(vm);

            string relativeUrl = "/MKTService/GroupBuying/Create";

            restClient.Create(relativeUrl, entity, callback);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 验证商品是否存在相冲突时间段的团购中
        /// </summary>
        private void CheckGroupBuyConflict(GroupBuyingInfo groupBuy)
        {
            List <int> productSysNos = new List <int>();

            productSysNos.Add(groupBuy.ProductSysNo);

            if (m_GroupBuyingDA.CheckConflict(groupBuy.SysNo, productSysNos, groupBuy.BeginDate, groupBuy.EndDate))
            {
                throw new BusinessException(LanguageHelper.GetText("该商品已经存在一个时间冲突的团购!"));
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 更新团购状态,用于审核流程
        /// </summary>
        /// <param name="entity"></param>
        public void UpdateProductGroupBuyingStatus(GroupBuyingInfo entity)
        {
            DataCommand command = DataCommandManager.GetDataCommand("UpdateProductGroupBuyingStatus");

            command.SetParameterValue("@SysNo", entity.SysNo);
            command.SetParameterValue("@Status", entity.Status);
            command.SetParameterValue("@Reasons", entity.Reasons);
            command.SetParameterValue("@AuditUser", entity.AuditUser);

            command.ExecuteNonQuery();
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Check团购基本信息
 /// </summary>
 /// <param name="entity"></param>
 public static void CheckGroupBuyingBase(GroupBuyingInfo entity)
 {
     if (entity.GroupBuyingAreaSysNo < 1)
     {
         //throw new BizException("请先选择城市!");
         throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_CityIsNotNull"));
     }
     if (entity.GroupBuyingTypeSysNo < 0)
     {
         //throw new BizException("请先选择分类!");
         throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_CategoryIsNotNull"));
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 验证商品是否存在相冲突时间段的限时抢购中
        /// </summary>
        private void CheckGroupBuyAndCountDownConflict(GroupBuyingInfo groupBuy)
        {
            List <int> productSysNos = new List <int>();

            productSysNos.Add(groupBuy.ProductSysNo);

            CountdownService countdownService = new CountdownService();

            if (countdownService.CheckGroupBuyAndCountDownConflict(productSysNos, groupBuy.BeginDate, groupBuy.EndDate))
            {
                throw new BusinessException(LanguageHelper.GetText("该商品已经存在一个时间冲突的限时抢购!"));
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 审核通过
        /// </summary>
        /// <param name="sysNo"></param>
        public virtual void AuditApprove(int sysNo, string reasonStr)
        {
            GroupBuyingInfo infoTemp = Load(sysNo);

            if (infoTemp.Status == GroupBuyingStatus.WaitingAudit)
            {
                CheckGroupBuyAndCountDownConflict(infoTemp);
            }

            if (infoTemp.Status.Value != GroupBuyingStatus.WaitingAudit)
            {
                //throw new BizException(string.Format("团购[{0}]审核通过失败,只有待审核状态的团购才能审核通过!", sysNo));
                throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_JustWaitCanAuditPass"), sysNo));
            }
            if (infoTemp.Status.Value == GroupBuyingStatus.Pending || infoTemp.Status.Value == GroupBuyingStatus.WaitHandling)
            {
                //throw new BizException(string.Format("团购[{0}]信息状态已变更,请刷新后再试!", sysNo));
                throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_TryAgainAfterF5"), sysNo));
            }
            if (string.IsNullOrWhiteSpace(reasonStr))
            {
                //throw new BizException(string.Format("审核理由不能为空!", sysNo));
                throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_AuditPassReasonIsNull"), sysNo));
            }
            //if (infoTemp.RequestSysNo == null || infoTemp.RequestSysNo.Value < 1)
            //{
            infoTemp.Status = GroupBuyingStatus.Pending;  //David:不管商家商品或是中商商品,审核通过全部更改为就绪
            //}
            //else
            //{
            //    //商家商品
            //    infoTemp.Status = GroupBuyingStatus.WaitHandling;
            //}
            infoTemp.AuditUser = ObjectFactory <ICommonBizInteract> .Instance.GetUserFullName(ServiceContext.Current.UserSysNo.ToString(), true);

            //if (infoTemp.InUser == infoTemp.AuditUser)
            //{
            //    throw new BizException(string.Format("团购[{0}]审核操作时,审核人不能与创建人相同!", sysNo));
            //}
            infoTemp.Reasons = reasonStr;

            TransactionScopeFactory.TransactionAction(() =>
            {
                m_GroupBuyingDA.UpdateProductGroupBuyingStatus(infoTemp);

                //促销引擎-更新活动状态 -审核通过即为运行
                //ObjectFactory<GroupBuyingPromotionEngine>.Instance.UpdateGroupBuyingActivityStatus(sysNo, GroupBuyingStatus.Active);

                ExternalDomainBroker.CreateOperationLog(BizLogType.GroupBuyingAuditApprove.ToEnumDesc(), BizLogType.GroupBuyingAuditApprove, sysNo, infoTemp.CompanyCode);
            });
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 同步Seller Portal团购状态
        /// </summary>
        /// <param name="entity"></param>
        public void SyncGroupBuyingStatus(GroupBuyingInfo entity)
        {
            if (entity.RequestSysNo > 0)
            {
                DataCommand command = DataCommandManager.GetDataCommand("SyncGroupBuyingStatus");

                command.SetParameterValue("@RequestSysNo", entity.RequestSysNo);
                command.SetParameterValue("@Status", entity.Status);
                command.SetParameterValue("@Reasons", entity.Reasons);
                command.SetParameterValue("@ReplyType", "ChangeGroupBuyingStatus");

                command.ExecuteNonQuery();
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 审核拒绝
        /// </summary>
        /// <param name="sysNo"></param>
        public virtual void AuditRefuse(int sysNo, string reasonStr)
        {
            GroupBuyingInfo infoTemp = Load(sysNo);

            if (infoTemp.Status.Value != GroupBuyingStatus.WaitingAudit)
            {
                //throw new BizException(string.Format("团购[{0}]审核拒绝失败,只有待审核状态的团购才能审核拒绝!", sysNo));
                throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_JustWaitCanRefuse"), sysNo));
            }
            if (infoTemp.Status.Value == GroupBuyingStatus.Deactive)
            {
                //throw new BizException(string.Format("团购[{0}]信息状态已变更,请刷新后再试!", sysNo));
                throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_TryAgainAfterF5"), sysNo));
            }
            if (string.IsNullOrWhiteSpace(reasonStr))
            {
                //throw new BizException(string.Format("审核理由不能为空!", sysNo));
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_AuditPassReasonIsNull"));
            }
            if (infoTemp.RequestSysNo == null || infoTemp.RequestSysNo.Value < 1)
            {
                infoTemp.Status = GroupBuyingStatus.VerifyFaild;
            }
            else
            {
                //商家商品
                infoTemp.Status = GroupBuyingStatus.Deactive;
            }
            infoTemp.AuditUser = ObjectFactory <ICommonBizInteract> .Instance.GetUserFullName(ServiceContext.Current.UserSysNo.ToString(), true);

            //if (infoTemp.InUser == infoTemp.AuditUser)
            //{
            //    throw new BizException(string.Format("团购[{0}]审核操作时,审核人不能与创建人相同!", sysNo));
            //}
            infoTemp.Reasons = reasonStr;

            TransactionScopeFactory.TransactionAction(() =>
            {
                m_GroupBuyingDA.UpdateProductGroupBuyingStatus(infoTemp);

                //促销引擎-更新活动状态 -审核拒绝即为作废
                //ObjectFactory<GroupBuyingPromotionEngine>.Instance.UpdateGroupBuyingActivityStatus(sysNo, GroupBuyingStatus.Deactive);

                //同步Seller Portal团购状态
                infoTemp.Status = GroupBuyingStatus.VerifyFaild;
                m_GroupBuyingDA.SyncGroupBuyingStatus(infoTemp);
                ExternalDomainBroker.CreateOperationLog(BizLogType.GroupBuyingAuditRefuse.ToEnumDesc(), BizLogType.GroupBuyingAuditRefuse, sysNo, infoTemp.CompanyCode);
            });
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 团购业务规则
        /// </summary>
        /// <param name="entity"></param>
        private void ValidateEntity(GroupBuyingInfo entity)
        {
            if (entity.SysNo > 0)
            {
                var item = Load(entity.SysNo);
                if (item == null)
                {
                    throw new BusinessException(LanguageHelper.GetText("单据已不存在。"));
                }
                if (item.SellerSysNo != entity.SellerSysNo)
                {
                    throw new BusinessException(LanguageHelper.GetText("您无权操作此单据。"));
                }
                if (item.Status != GroupBuyingStatus.Init)
                {
                    throw new BusinessException(LanguageHelper.GetText("此单据的状态不是初始态,无法执行编辑或提交审核操作。"));
                }
            }
            // 验证商品是否存在
            var product = ProductService.GetProduct(entity.SellerSysNo.Value, entity.ProductID);

            if (product == null)
            {
                throw new BusinessException(LanguageHelper.GetText("活动商品不存在!"));
            }
            if (product.Status != ProductStatus.Active)
            {
                throw new BusinessException(LanguageHelper.GetText("活动商品为未上架状态,不能设置活动!"));
            }
            entity.ProductSysNo = product.SysNo;
            if (product.CurrentPrice <= entity.GroupBuyPrice)
            {
                throw new BusinessException(LanguageHelper.GetText("团购价格不能大于等于商品卖价!"));
            }
            // 验证团购时间
            if (entity.BeginDate > entity.EndDate)
            {
                throw new BusinessException(LanguageHelper.GetText("团购开始时间晚于结束时间!"));
            }
            if (entity.EndDate <= DateTime.Now)
            {
                throw new BusinessException(LanguageHelper.GetText("团购结束时间不能小于当前时间!"));
            }
            // 验证商品是否存在相冲突时间段的团购中
            CheckGroupBuyConflict(entity);

            // 验证商品是否存在相冲突时间段的限时抢购中
            CheckGroupBuyAndCountDownConflict(entity);
        }
Ejemplo n.º 21
0
        protected override bool NeedProcess(GroupBuyUpdateMessage msg)
        {
            GroupBuyingInfo groupBuy = ObjectFactory <IMKTBizInteract> .Instance.GetGroupBuyInfoBySysNo(msg.GroupBuySysNo);

            if (null == groupBuy)
            {
                return(false);
            }
            if (groupBuy.Status == GroupBuyingStatus.Init)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 取消审核
        /// </summary>
        /// <param name="sysNo"></param>
        public virtual void CancelAudit(int sysNo)
        {
            string userfullname = ObjectFactory <ICommonBizInteract> .Instance.GetUserFullName(ServiceContext.Current.UserSysNo.ToString(), true);

            GroupBuyingInfo infoTemp = Load(sysNo);

            if (infoTemp.Status.Value != GroupBuyingStatus.WaitingAudit)
            {
                //throw new BizException(string.Format("团购[{0}]撤销审核失败,只有待审核状态的团购才能撤销审核!", sysNo));
                throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_JustFaileCanCancel"), sysNo));
            }
            if (infoTemp.Status.Value == GroupBuyingStatus.Init)
            {
                //throw new BizException(string.Format("团购[{0}]信息状态已变更,请刷新后再试!", sysNo));
                throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_TryAgainAfterF5"), sysNo));
            }
            m_GroupBuyingDA.UpdataSatus(sysNo, "O", userfullname);
            ExternalDomainBroker.CreateOperationLog(BizLogType.GroupBuyingCancelAudit.ToEnumDesc(), BizLogType.GroupBuyingCancelAudit, sysNo, infoTemp.CompanyCode);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 创建团购
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(GroupBuyingInfo entity)
        {
            DataCommand command = DataCommandManager.GetDataCommand("CreateProductGroupBuying");

            command.SetParameterValue("@ProductSysNo", entity.ProductSysNo);
            command.SetParameterValue("@GroupBuyingTitle", entity.GroupBuyingTitle);
            command.SetParameterValue("@GroupBuyingDesc", entity.GroupBuyingDesc);
            command.SetParameterValue("@GroupBuyingRules", entity.GroupBuyingRules);
            command.SetParameterValue("@GroupBuyingDescLong", entity.GroupBuyingDescLong);
            command.SetParameterValue("@GroupBuyingPicUrl", entity.GroupBuyingPicUrl);
            command.SetParameterValue("@GroupBuyingMiddlePicUrl", entity.GroupBuyingMiddlePicUrl);
            command.SetParameterValue("@GroupBuyingSmallPicUrl", entity.GroupBuyingSmallPicUrl);
            command.SetParameterValue("@OriginalPrice", entity.CurrentPrice);
            command.SetParameterValue("@DealPrice", entity.GroupBuyPrice);
            command.SetParameterValue("@BeginDate", entity.BeginDate);
            command.SetParameterValue("@EndDate", entity.EndDate);
            command.SetParameterValue("@IsByGroup", "N");
            command.SetParameterValue("@MaxPerOrder", entity.MaxPerOrder);
            command.SetParameterValue("@LimitOrderCount", entity.LimitOrderCount);
            command.SetParameterValue("@Status", entity.Status);
            command.SetParameterValue("@Priority", entity.Priority);
            command.SetParameterValue("@InUser", entity.InUserName);
            command.SetParameterValue("@CompanyCode", entity.CompanyCode);
            command.SetParameterValue("@StoreCompanyCode", entity.CompanyCode);
            command.SetParameterValue("@LanguageCode", entity.LanguageCode);
            command.SetParameterValue("@CurrencySysNo", 1);
            command.SetParameterValue("@VendorSysNo", entity.SellerSysNo);

            command.SetParameterValue("@Reasons", "");
            command.SetParameterValue("@SettlementStatus", "N");
            command.SetParameterValue("@GroupBuyingTypeSysNo", 0);
            command.SetParameterValue("@GroupBuyingAreaSysNo", 0);
            command.SetParameterValue("@CurrentSellCount", 0);
            command.SetParameterValue("@CouponValidDate", null);
            command.SetParameterValue("@LotteryRule", null);
            command.SetParameterValue("@GroupBuyingCategorySysNo", 0);
            command.SetParameterValue("@IsWithoutReservation", 0);
            command.SetParameterValue("@IsVouchers", 0);

            command.ExecuteNonQuery();

            return((int)command.GetParameterValue("@SysNo"));
        }
Ejemplo n.º 24
0
        private GroupBuyingMaintainVM EtoV(GroupBuyingInfo entity)
        {
            GroupBuyingMaintainVM viewmodel = entity.Convert <GroupBuyingInfo, GroupBuyingMaintainVM>((en, vm) =>
            {
                if (en.PriceRankList.Count == 1)
                {
                    vm.SysNo1            = en.PriceRankList[0].ProductSysNo.Value;
                    vm.SellCount1        = en.PriceRankList[0].MinQty.ToString();
                    vm.GroupBuyingPrice1 = en.PriceRankList[0].DiscountValue.ToString();
                    //显示第一个阶梯价格
                    vm.Price = vm.GroupBuyingPrice1;
                }
                if (en.PriceRankList.Count == 2)
                {
                    vm.SysNo1            = en.PriceRankList[0].ProductSysNo.Value;
                    vm.SellCount1        = en.PriceRankList[0].MinQty.ToString();
                    vm.GroupBuyingPrice1 = en.PriceRankList[0].DiscountValue.ToString();

                    vm.SysNo2            = en.PriceRankList[1].ProductSysNo.Value;
                    vm.SellCount2        = en.PriceRankList[1].MinQty.ToString();
                    vm.GroupBuyingPrice2 = en.PriceRankList[1].DiscountValue.ToString();
                }
                if (en.PriceRankList.Count == 3)
                {
                    vm.SysNo1            = en.PriceRankList[0].ProductSysNo.Value;
                    vm.SellCount1        = en.PriceRankList[0].MinQty.ToString();
                    vm.GroupBuyingPrice1 = en.PriceRankList[0].DiscountValue.ToString();

                    vm.SysNo2            = en.PriceRankList[1].ProductSysNo.Value;
                    vm.SellCount2        = en.PriceRankList[1].MinQty.ToString();
                    vm.GroupBuyingPrice2 = en.PriceRankList[1].DiscountValue.ToString();

                    vm.SysNo3            = en.PriceRankList[2].ProductSysNo.Value;
                    vm.SellCount3        = en.PriceRankList[2].MinQty.ToString();
                    vm.GroupBuyingPrice3 = en.PriceRankList[2].DiscountValue.ToString();
                }

                vm.GroupBuyingReason = en.Reasons;
            });

            return(viewmodel);
        }
Ejemplo n.º 25
0
        public ActionResult GroupBuySubmit(GroupBuyingInfo info)
        {
            var loginUser = UserAuthHelper.GetCurrentUser();

            info.Status        = GroupBuyingStatus.WaitingAudit;
            info.SellerSysNo   = loginUser.SellerSysNo;
            info.InUserSysNo   = loginUser.UserSysNo;
            info.InUserName    = loginUser.UserDisplayName;
            info.EditUserSysNo = loginUser.UserSysNo;
            info.EditUserName  = loginUser.UserDisplayName;
            if (info.SysNo > 0)
            {
                _groupBuyService.Update(info);
            }
            else
            {
                _groupBuyService.Create(info);
            }
            return(JsonSuccess(info.SysNo, LanguageHelper.GetText("提交审核成功。")));
        }
Ejemplo n.º 26
0
        public ActionResult GroupBuyMaintain(GroupBuyingInfo info)
        {
            var loginUser = UserAuthHelper.GetCurrentUser();

            info.SellerSysNo   = loginUser.SellerSysNo;
            info.InUserSysNo   = loginUser.UserSysNo;
            info.InUserName    = loginUser.UserDisplayName;
            info.EditUserSysNo = loginUser.UserSysNo;
            info.EditUserName  = loginUser.UserDisplayName;
            if (info.SysNo > 0)
            {
                _groupBuyService.Update(info);
                return(JsonSuccess(info.SysNo, LanguageHelper.GetText("更新成功。")));
            }
            else
            {
                _groupBuyService.Create(info);
                return(JsonSuccess(info.SysNo, LanguageHelper.GetText("创建成功。")));
            }
        }
Ejemplo n.º 27
0
        public void LoadMarginRateInfo(GroupBuyingMaintainVM vm, EventHandler <RestClientEventArgs <List <GroupBuySaveInfoVM> > > callback)
        {
            GroupBuyingInfo entity = VtoE(vm);

            string relativeUrl = "/MKTService/GroupBuying/LoadMarginRateInfo";

            restClient.Query <List <GroupBuySaveInfo> >(relativeUrl, entity, (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }

                List <GroupBuySaveInfoVM> infoVMList = new List <GroupBuySaveInfoVM>();
                foreach (GroupBuySaveInfo info in args.Result)
                {
                    infoVMList.Add(EntityConverter <GroupBuySaveInfo, GroupBuySaveInfoVM> .Convert(info));
                }
                callback(obj, new RestClientEventArgs <List <GroupBuySaveInfoVM> >(infoVMList, _Page));
            });
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public GroupBuyingInfo Create(GroupBuyingInfo info)
        {
            // 验证团购信息
            ValidateEntity(info);

            var ts = new TransactionScope();

            using (ts)
            {
                // 创建团购信息
                info.SysNo = m_GroupBuyingDA.Create(info);

                // 创建价格信息
                m_GroupBuyingDA.CreateProductGroupBuyingPrice(info.SysNo, 1, info.GroupBuyPrice, 0, 0);


                ts.Complete();
            }

            return(info);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 验证商品是否存在相冲突时间段的限时抢购中
        /// </summary>
        private void CheckGroupBuyAndCountDownConflict(GroupBuyingInfo groupBuy)
        {
            List <int> productSysNos = new List <int>();

            productSysNos.Add(groupBuy.ProductSysNo.Value);

            if (groupBuy.IsByGroup.Value)
            {
                List <ProductInfo> products = ExternalDomainBroker.GetProductsInSameGroupWithProductSysNo(groupBuy.ProductSysNo.Value);

                foreach (ProductInfo p in products)
                {
                    productSysNos.Add(p.SysNo);
                }
            }

            if (ObjectFactory <CountdownProcessor> .Instance.CheckGroupBuyAndCountDownConflict(productSysNos, groupBuy.BeginDate.Value, groupBuy.EndDate.Value))
            {
                // throw new BizException("该商品或者同组商品已经存在一个时间冲突的限时抢购!");
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_ExsistTimeConflictCountdown"));
            }
        }
Ejemplo n.º 30
0
        private void FailedGroupBuyProcess(GroupBuyingInfo gbInfo)
        {
            TransactionOptions options = new TransactionOptions
            {
                IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
            };

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                try
                {
                    SODA.UpdateGroupBuySOItemSettlementStatusByGroupBuySysNo(gbInfo.SysNo.Value, BizEntity.SO.SettlementStatus.PlanFail);
                }
                catch
                {
                    SODA.UpdateGroupBuySOItemSettlementStatusByGroupBuySysNo(gbInfo.SysNo.Value, BizEntity.SO.SettlementStatus.Fail);
                    SODA.UpdateGroupBuySOSettlementStatusByGroupBuySysNo(gbInfo.SysNo.Value, BizEntity.SO.SettlementStatus.Fail);
                }
                ExternalDomainBroker.UpdateGroupBuySettlementStatus(gbInfo.SysNo.Value, GroupBuyingSettlementStatus.Yes);
                scope.Complete();
            }
        }