コード例 #1
0
        /// <summary>
        /// 修改渠道商品信息信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public virtual ProductChannelInfo UpdateProductChannelInfo(ProductChannelInfo entity, bool isBatchUpdate)
        {
            if (entity != null)
            {
                CheckProductChannelInfoProcessor.CheckProductChannelInfoSysNo(entity.SysNo);
            }

            CheckProductChannelInfoProcessor.CheckProductChannelInfoInfo(entity);

            //判断是否为批量更新
            if (!isBatchUpdate)
            {
                var oldEntity = _ProductChannelInfoDA.GetProductChannelInfoBySysNo(entity.SysNo.Value);


                if (oldEntity.Status == ProductChannelInfoStatus.DeActive &&
                    entity.Status == ProductChannelInfoStatus.Active &&
                    !string.IsNullOrEmpty(oldEntity.SynProductID))
                {
                    entity.IsClearInventory = BooleanEnum.No;
                    _ProductChannelInfoDA.SetClearInventoryStatus(entity);
                }

                if (oldEntity.Status == ProductChannelInfoStatus.DeActive &&
                    entity.Status == ProductChannelInfoStatus.Active)
                {
                    entity.IsClearInventory = BooleanEnum.Yes;
                    _ProductChannelInfoDA.SetClearInventoryStatus(entity);
                }

                if (entity.IsAppointInventory == BooleanEnum.No)
                {
                    entity.ChannelSellCount = 0;
                }

                //如果指定库存,必须同步库存,如果由指定库粗修改为非指定库存需要清楚库存
                if (!entity.IsAppointInventory.Equals(oldEntity.IsAppointInventory) || entity.IsAppointInventory == BooleanEnum.Yes)
                {
                    bool result = true;
                    if (entity.IsAppointInventory == BooleanEnum.Yes)
                    {
                        //指定库存,需要设置渠道库存
                        result = ExternalDomainBroker.SetChannelProductInventory(entity.ChannelInfo.SysNo.Value, entity.ProductSysNo.Value, entity.ChannelSellCount.Value);
                    }
                    else
                    {
                        //不指定库存,需要清除库存
                        result = ExternalDomainBroker.AbandonChannelProductInventory(entity.ChannelInfo.SysNo.Value, entity.ProductSysNo.Value, entity.ChannelSellCount.Value);
                    }

                    if (!result)
                    {
                        //同步库存失败,请稍后再试
                        throw new BizException(ResouceManager.GetMessageString("IM.ProductChannelInfo", "ProductChannelSetInventoryError"));
                    }
                }
            }

            return(_ProductChannelInfoDA.UpdateProductChannelInfo(entity));
        }
コード例 #2
0
        /// <summary>
        /// 创建渠道商品信息信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public virtual ProductChannelInfo CreatetProductChannelInfo(ProductChannelInfo entity)
        {
            entity.SynProductID        = "";
            entity.InventoryPercent    = 1;
            entity.ChannelSellCount    = 0;
            entity.SafeInventoryQty    = 5;
            entity.IsAppointInventory  = BooleanEnum.No;
            entity.ChannelPricePercent = 1;
            entity.IsUsePromotionPrice = BooleanEnum.No;
            entity.Status = ProductChannelInfoStatus.DeActive;
            entity.SysNo  = 0;

            CheckProductChannelInfoProcessor.CheckProductChannelInfoInfo(entity);
            return(_ProductChannelInfoDA.CreateProductChannelInfo(entity));
        }