public object GetGoodsInfo(Dictionary <string, object> dicParas) { try { string errMsg = string.Empty; string id = dicParas.ContainsKey("id") ? (dicParas["id"] + "") : string.Empty; if (string.IsNullOrEmpty(id)) { errMsg = "商品ID不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } int iId = Convert.ToInt32(id); IBase_GoodsInfoService base_GoodsInfoService = BLLContainer.Resolve <IBase_GoodsInfoService>(); if (!base_GoodsInfoService.Any(a => a.ID == iId)) { errMsg = "该商品信息不存在"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } var result = from a in base_GoodsInfoService.GetModels(p => p.ID == iId).FirstOrDefault().AsDictionary() select new { name = a.Key, value = a.Value }; return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, result)); } catch (Exception e) { return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message)); } }
public object DelGoodsInfo(Dictionary <string, object> dicParas) { try { string errMsg = string.Empty; string id = dicParas.ContainsKey("id") ? (dicParas["id"] + "") : string.Empty; if (string.IsNullOrEmpty(id)) { errMsg = "商品ID不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } int iId = Convert.ToInt32(id); IBase_GoodsInfoService base_GoodsInfoService = BLLContainer.Resolve <IBase_GoodsInfoService>(); if (!base_GoodsInfoService.Any(a => a.ID == iId)) { errMsg = "该商品信息不存在"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } var base_GoodsInfo = base_GoodsInfoService.GetModels(p => p.ID == iId).FirstOrDefault(); base_GoodsInfo.Status = 0; if (!base_GoodsInfoService.Update(base_GoodsInfo)) { errMsg = "删除游戏机信息失败"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn)); } catch (Exception e) { return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message)); } }
public object SaveGoodsInfo(Dictionary <string, object> dicParas) { try { XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel]; string storeId = (userTokenKeyModel.DataModel as UserDataModel).StoreID; string errMsg = string.Empty; string id = dicParas.ContainsKey("id") ? (dicParas["id"] + "") : string.Empty; string barCode = dicParas.ContainsKey("barCode") ? (dicParas["barCode"] + "") : string.Empty; string goodType = dicParas.ContainsKey("goodType") ? (dicParas["goodType"] + "") : string.Empty; string minValue = dicParas.ContainsKey("minValue") ? (dicParas["minValue"] + "") : string.Empty; string maxValue = dicParas.ContainsKey("maxValue") ? (dicParas["maxValue"] + "") : string.Empty; string goodName = dicParas.ContainsKey("goodName") ? (dicParas["goodName"] + "") : string.Empty; string price = dicParas.ContainsKey("price") ? (dicParas["price"] + "") : string.Empty; string points = dicParas.ContainsKey("points") ? (dicParas["points"] + "") : string.Empty; string note = dicParas.ContainsKey("note") ? (dicParas["note"] + "") : string.Empty; #region 参数验证 if (!string.IsNullOrEmpty(id) && !Utils.isNumber(id)) { errMsg = "商品ID格式不正确"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (string.IsNullOrEmpty(barCode)) { errMsg = "商品条码barCode不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (string.IsNullOrEmpty(goodType)) { errMsg = "商品类别goodType不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (string.IsNullOrEmpty(minValue) || string.IsNullOrEmpty(maxValue)) { errMsg = "库存警戒线不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (!Utils.isNumber(minValue) || !Utils.isNumber(maxValue)) { errMsg = "库存警戒线格式不正确"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (Convert.ToInt32(minValue) < 0 || Convert.ToInt32(maxValue) < 0) { errMsg = "库存警戒线不能为负数"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (Convert.ToInt32(minValue) > Convert.ToInt32(maxValue)) { errMsg = "库存警戒线下限须小于上限"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (!string.IsNullOrEmpty(price) && !Utils.IsDecimal(price)) { errMsg = "零售价格格式不正确"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (!string.IsNullOrEmpty(points) && (!Utils.isNumber(points) || Convert.ToInt32(points) < 0)) { errMsg = "零售积分格式不正确"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } #endregion IBase_StoreInfoService base_StoreInfoService = BLLContainer.Resolve <IBase_StoreInfoService>(); var merchId = base_StoreInfoService.GetModels(p => p.StoreID.Equals(storeId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault().MerchID; IBase_GoodsInfoService base_GoodsInfoService = BLLContainer.Resolve <IBase_GoodsInfoService>(); if (string.IsNullOrEmpty(id)) { if (base_GoodsInfoService.Any(a => a.Barcode.Equals(barCode, StringComparison.OrdinalIgnoreCase))) { errMsg = "该商品条码已使用"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } var base_GoodsInfo = new Base_GoodsInfo(); Utils.GetModel(dicParas, ref base_GoodsInfo); base_GoodsInfo.MerchID = merchId; base_GoodsInfo.Status = 1; if (!base_GoodsInfoService.Add(base_GoodsInfo)) { errMsg = "添加商品信息失败"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } } else { int iId = Convert.ToInt32(id); if (!base_GoodsInfoService.Any(a => a.ID == iId)) { errMsg = "该商品信息不存在"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (base_GoodsInfoService.Any(a => a.ID != iId && a.Barcode.Equals(barCode, StringComparison.OrdinalIgnoreCase))) { errMsg = "该商品条码已使用"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } var base_GoodsInfo = base_GoodsInfoService.GetModels(p => p.ID == iId).FirstOrDefault(); Utils.GetModel(dicParas, ref base_GoodsInfo); if (!base_GoodsInfoService.Update(base_GoodsInfo)) { errMsg = "修改商品信息失败"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } } return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn)); } catch (DbEntityValidationException e) { return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, e.EntityValidationErrors.ToErrors())); } catch (Exception e) { return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message)); } }