コード例 #1
0
        /// <summary>
        /// 添加商品
        /// </summary>
        /// <param name="itemEntity"></param>
        /// <param name="ItemCategoryCode"></param>
        public void AddItem(T_ItemEntity itemEntity, out T_SkuEntity skuEntity, string ItemCategoryName, string ItemCategoryCode, string SkuOriginPrice, string SkuSalesPrice)
        {
            var skuBll          = new T_SkuBLL(CurrentUserInfo);
            var skuPriceBll     = new T_Sku_PriceBLL(CurrentUserInfo);
            var skuProperty     = new T_Sku_PropertyBLL(CurrentUserInfo);
            var itemCategoryBll = new T_Item_CategoryBLL(CurrentUserInfo);

            string ItemCategoryId = itemCategoryBll.CreateOrUpdateItemCategory(ItemCategoryName, ItemCategoryCode, CurrentUserInfo.ClientID, "0000", "1");

            T_ItemEntity NewEntity = new T_ItemEntity();

            NewEntity.item_id          = Guid.NewGuid().ToString("N");
            NewEntity.item_category_id = ItemCategoryId;
            NewEntity.item_code        = itemEntity.item_code;
            NewEntity.item_name        = itemEntity.item_name;
            NewEntity.status           = "-1";
            NewEntity.status_desc      = "下架";
            NewEntity.create_user_id   = "open";
            NewEntity.create_time      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            NewEntity.modify_time      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            NewEntity.if_flag          = "0";
            NewEntity.ifservice        = 0;    //  LM,2016/03/30
            NewEntity.IsGB             = 0;    //  LM,2016,03,30
            NewEntity.ifgifts          = 0;
            NewEntity.data_from        = "18"; //线下商品来源
            NewEntity.ifoften          = 0;
            NewEntity.display_index    = 1;
            NewEntity.CustomerId       = CurrentUserInfo.ClientID;
            Create(NewEntity);

            //新增规格|读取规格信息
            skuEntity = skuBll.CreateNewSku(NewEntity.item_id);

            if (!String.IsNullOrEmpty(skuEntity.sku_id))
            {
                //商品规格价格   原价|零售价|库存|销量
                string SaleCount  = "0"; //销量
                string StoreCount = "0"; //库存
                skuPriceBll.CreateNewSkuPrice(skuEntity.sku_id, SkuOriginPrice, SkuSalesPrice, StoreCount, SaleCount, CurrentUserInfo.ClientID);
            }
        }
コード例 #2
0
        /// <summary>
        /// 处理商品销量库存
        /// </summary>
        /// <param name="orderId">订单ID</param>
        /// <param name="inoutDetailList">订单明细</param>
        /// <param name="actionType">操作类型 1=提交订单;2=取消订单</param>
        /// <param name="loggingSessionInfo"></param>
        public void SetStock(string orderId, IList <InoutDetailInfo> inoutDetailList, int actionType, LoggingSessionInfo loggingSessionInfo)
        {
            var itemPropertyBLL = new T_Item_PropertyBLL(loggingSessionInfo);
            var skuPriceBLL     = new T_Sku_PriceBLL(loggingSessionInfo);

            var inoutService = new InoutService(loggingSessionInfo);

            foreach (var item in inoutDetailList)
            {
                //商品总库存
                var stockInfo = itemPropertyBLL.QueryByEntity(new T_Item_PropertyEntity()
                {
                    item_id = item.item_id, prop_id = "34FF4445D39F49AD8174954D18BC1346"
                }, null).FirstOrDefault();
                if (stockInfo != null)
                {
                    decimal stock = decimal.Parse(stockInfo.prop_value);
                    if (actionType == 1)
                    {
                        stock -= item.enter_qty;
                    }
                    else if (actionType == 2)
                    {
                        stock += item.enter_qty;
                    }
                    stockInfo.prop_value = stock.ToString();
                    itemPropertyBLL.Update(stockInfo);
                }
                //商品总销量
                var salesCountInfo = itemPropertyBLL.QueryByEntity(new T_Item_PropertyEntity()
                {
                    item_id = item.item_id, prop_id = "34FF4445D39F49AD8174954D18BC1347"
                }, null).FirstOrDefault();
                if (salesCountInfo != null)
                {
                    decimal salesCount = decimal.Parse(salesCountInfo.prop_value);
                    if (actionType == 1)
                    {
                        salesCount += item.enter_qty;
                    }
                    else if (actionType == 2)
                    {
                        salesCount -= item.enter_qty;
                    }

                    salesCountInfo.prop_value = salesCount.ToString();
                    itemPropertyBLL.Update(salesCountInfo);
                }
                //sku库存
                var skuStockInfo = skuPriceBLL.QueryByEntity(new T_Sku_PriceEntity()
                {
                    sku_id = item.sku_id, item_price_type_id = "77850286E3F24CD2AC84F80BC625859E", status = "1"
                }, null).FirstOrDefault();
                if (skuStockInfo != null)
                {
                    if (actionType == 1)
                    {
                        skuStockInfo.sku_price -= item.enter_qty;
                    }
                    else if (actionType == 2)
                    {
                        skuStockInfo.sku_price += item.enter_qty;
                    }

                    skuPriceBLL.Update(skuStockInfo);
                }
                //sku销量
                var skuSalesCountInfo = skuPriceBLL.QueryByEntity(new T_Sku_PriceEntity()
                {
                    sku_id = item.sku_id, item_price_type_id = "77850286E3F24CD2AC84F80BC625859f", status = "1"
                }, null).FirstOrDefault();
                if (skuSalesCountInfo != null)
                {
                    if (actionType == 1)
                    {
                        skuSalesCountInfo.sku_price += item.enter_qty;
                    }
                    else
                    {
                        skuSalesCountInfo.sku_price -= item.enter_qty;
                    }

                    skuPriceBLL.Update(skuSalesCountInfo);
                }
            }
        }