/// <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)); }
/// <summary> /// 检查渠道商品信息实体 /// </summary> /// <param name="entity"></param> public static void CheckProductChannelInfoInfo(ProductChannelInfo entity) { int result = _ProductChannelInfoDA.CheckProductChannelInfo(entity); if (result == -1) { //该渠道已存在该商品! throw new BizException(ResouceManager.GetMessageString("IM.ProductChannelInfo", "ProductChannelInfoIsExists")); } if (result == -2) { //不存在该商品! throw new BizException(ResouceManager.GetMessageString("IM.ProductChannelInfo", "ProductNotExists")); } if (entity.SysNo > 0 && entity.IsAppointInventory == BooleanEnum.Yes && entity.ChannelSellCount > entity.MaxStockQty) { //指定库存必须小于等于最大分仓数! throw new BizException(ResouceManager.GetMessageString("IM.ProductChannelInfo", "ProductChannelSellCountError")); } if (entity.Status == ProductChannelInfoStatus.Active && string.IsNullOrEmpty(entity.SynProductID)) { //有效状态渠道商品编号不能为空! throw new BizException(ResouceManager.GetMessageString("IM.ProductChannelInfo", "ProductChannelActiveError")); } }
/// <summary> /// Check渠道商品信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int CheckProductChannelInfo(ProductChannelInfo entity) { DataCommand cmd = DataCommandManager.GetDataCommand("CheckProductChannelInfo"); cmd.SetParameterValue("@ProductSysNo", entity.ProductSysNo); cmd.SetParameterValue("@ChannelSysNo", entity.ChannelInfo.SysNo); cmd.SetParameterValue("@SysNo", entity.SysNo); cmd.ExecuteNonQuery(); return(int.Parse(cmd.GetParameterValue("@Flag").ToString())); }
/// <summary> /// 转换分类视图和分类实体 /// </summary> /// <param name="data"></param> /// <returns></returns> private ProductChannelInfo CovertVMtoEntity(ProductChannelVM data) { ProductChannelInfo msg = data.ConvertVM <ProductChannelVM, ProductChannelInfo>(); msg.CreateUser = new UserInfo { SysNo = CPApplication.Current.LoginUser.userSysNo, UserName = CPApplication.Current.LoginUser.LoginName, UserDisplayName = CPApplication.Current.LoginUser.DisplayName }; msg.EditUser = new UserInfo { SysNo = CPApplication.Current.LoginUser.userSysNo, UserName = CPApplication.Current.LoginUser.LoginName, UserDisplayName = CPApplication.Current.LoginUser.DisplayName }; msg.SysNo = data.SysNo; return(msg); }
/// <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)); }
/// <summary> /// 修改渠道商品信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public ProductChannelInfo UpdateProductChannelInfo(ProductChannelInfo entity) { DataCommand cmd = DataCommandManager.GetDataCommand("UpdateProductChannelInfo"); cmd.SetParameterValue("@ChannelSysNo", entity.ChannelInfo.SysNo); cmd.SetParameterValue("@ProductSysNo", entity.ProductSysNo); cmd.SetParameterValue("@SynProductID", entity.SynProductID); cmd.SetParameterValue("@InventoryPercent", Convert.ToDecimal(entity.InventoryPercent) / 100); cmd.SetParameterValue("@ChannelSellCount", entity.ChannelSellCount); cmd.SetParameterValue("@SafeInventoryQty", entity.SafeInventoryQty); cmd.SetParameterValue("@IsAppointInventory", entity.IsAppointInventory); cmd.SetParameterValue("@ChannelPricePercent", Convert.ToDecimal(entity.ChannelPricePercent) / 100); cmd.SetParameterValue("@IsUsePromotionPrice", entity.IsUsePromotionPrice); cmd.SetParameterValue("@Status", entity.Status); cmd.SetParameterValue("@EditUser", entity.EditUser.UserDisplayName); cmd.SetParameterValue("@SysNo", entity.SysNo); cmd.ExecuteNonQuery(); return(entity); }
/// <summary> /// 创建渠道商品信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public ProductChannelInfo CreateProductChannelInfo(ProductChannelInfo entity) { DataCommand cmd = DataCommandManager.GetDataCommand("CreateProductChannelInfo"); cmd.SetParameterValue("@ChannelSysNo", entity.ChannelInfo.SysNo); cmd.SetParameterValue("@ProductSysNo", entity.ProductSysNo); cmd.SetParameterValue("@SynProductID", entity.SynProductID); cmd.SetParameterValue("@InventoryPercent", entity.InventoryPercent); cmd.SetParameterValue("@ChannelSellCount", entity.ChannelSellCount); cmd.SetParameterValue("@SafeInventoryQty", entity.SafeInventoryQty); cmd.SetParameterValue("@IsAppointInventory", entity.IsAppointInventory); cmd.SetParameterValue("@ChannelPricePercent", entity.ChannelPricePercent); cmd.SetParameterValue("@IsUsePromotionPrice", entity.IsUsePromotionPrice); cmd.SetParameterValue("@Status", entity.Status); cmd.SetParameterValue("@CreateUser", entity.CreateUser.UserDisplayName); cmd.ExecuteNonQuery(); entity.SysNo = int.Parse(cmd.GetParameterValue("@SysNo").ToString()); return(entity); }
/// <summary> /// 批量设置多渠道商品记录状态 /// </summary> /// <param name="sysNoList"></param> /// <param name="entity"></param> /// <returns></returns> public void BatchUpdateChannelProductInfoStatus(ProductChannelInfo entity) { StringBuilder result = new StringBuilder(); int successCount = 0; int errorCount = 0; if (entity == null) { throw new BizException("BatchUpdateChannelProductInfoStatus param entity is null"); } if (entity.SysNoList == null || entity.SysNoList.Count < 1) { throw new BizException("BatchUpdateChannelProductInfoStatus param entity.SysNoList is null"); } foreach (var sysNo in entity.SysNoList) { var channelProduct = ObjectFactory <ProductChannelInfoProcessor> .Instance.GetProductChannelInfoBySysNo(sysNo); if (channelProduct != null) { if (channelProduct.Status != entity.Status) { channelProduct.Status = entity.Status; channelProduct.EditUser = entity.EditUser; if (entity.Status == ProductChannelInfoStatus.DeActive) { channelProduct.ChannelSellCount = 0; channelProduct.IsAppointInventory = BooleanEnum.No; } try { ObjectFactory <ProductChannelInfoProcessor> .Instance.UpdateProductChannelInfo(channelProduct, false); successCount++; } catch (BizException ex) { string message = ResouceManager.GetMessageString("IM.Category", "ProductID"); message += ":{0},"; message += ResouceManager.GetMessageString("IM.Category", "FailReason"); message += ":{1}"; result.AppendLine(string.Format(message, channelProduct.ProductID, ex.Message)); errorCount++; } } } } string resMessage = ResouceManager.GetMessageString("IM.ProductChannelInfo", "ModifySuccess"); resMessage += ":{0},"; resMessage += ResouceManager.GetMessageString("IM.Category", "NumberUnit"); resMessage += ResouceManager.GetMessageString("IM.ProductChannelInfo", "ModifyFail"); resMessage += ":{1}"; resMessage += ResouceManager.GetMessageString("IM.Category", "NumberUnit"); resMessage += "。\r\n"; result.Insert(0, string.Format(resMessage, successCount, errorCount)); throw new BizException(result.ToString()); }
/// <summary> /// 修改渠道商品信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public ProductChannelInfo UpdateProductChannelInfo(ProductChannelInfo entity) { var result = ObjectFactory <ProductChannelInfoProcessor> .Instance.UpdateProductChannelInfo(entity, false); return(result); }
public void BatchUpdateChannelProductInfoStatus(ProductChannelInfo entity) { ObjectFactory <ProductChannelInfoAppService> .Instance.BatchUpdateChannelProductInfoStatus(entity); }
public ProductChannelInfo UpdateProductChannelInfo(ProductChannelInfo request) { var entity = ObjectFactory <ProductChannelInfoAppService> .Instance.UpdateProductChannelInfo(request); return(entity); }