Example #1
0
        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));
            }
        }
Example #2
0
        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));
            }
        }
Example #3
0
        public object GetJackpotInfo(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);
                IData_JackpotInfoService data_JackpotInfoService = BLLContainer.Resolve <IData_JackpotInfoService>();
                var data_JackpotInfo = data_JackpotInfoService.GetModels(p => p.ID == iId).FirstOrDefault();
                if (data_JackpotInfo == null)
                {
                    errMsg = "该抽奖规则不存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                IData_Jackpot_LevelService data_Jackpot_LevelService = BLLContainer.Resolve <IData_Jackpot_LevelService>(resolveNew: true);
                IBase_GoodsInfoService     base_GoodsInfoService     = BLLContainer.Resolve <IBase_GoodsInfoService>(resolveNew: true);
                var JackpotLevels = from a in data_Jackpot_LevelService.GetModels(p => p.ActiveID == iId)
                                    join b in base_GoodsInfoService.GetModels() on a.GoodID equals b.ID
                                    select new
                {
                    LevelName   = a.LevelName,
                    GoodCount   = a.GoodCount,
                    Probability = a.Probability,
                    GoodID      = a.GoodID,
                    GoodName    = b.GoodName
                };

                var result = new
                {
                    ID            = data_JackpotInfo.ID,
                    ActiveName    = data_JackpotInfo.ActiveName,
                    Threshold     = data_JackpotInfo.Threshold,
                    Concerned     = data_JackpotInfo.Concerned,
                    StartTime     = data_JackpotInfo.StartTime,
                    EndTime       = data_JackpotInfo.EndTime,
                    JackpotLevels = JackpotLevels
                };

                return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, result));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
Example #4
0
        public object QueryGoodsInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel];
                string storeId = (userTokenKeyModel.DataModel as UserDataModel).StoreID;

                string   errMsg     = string.Empty;
                object[] conditions = dicParas.ContainsKey("conditions") ? (object[])dicParas["conditions"] : null;

                SqlParameter[] parameters = new SqlParameter[0];
                string         sqlWhere   = string.Empty;

                if (conditions != null && conditions.Length > 0)
                {
                    if (!QueryBLL.GenDynamicSql(conditions, "a.", ref sqlWhere, ref parameters, out errMsg))
                    {
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }

                string sql = @"select a.ID, a.GoodName, a.Price, a.Points, a.Note, c.DictKey as GoodTypeStr from Base_GoodsInfo a " +
                             " left join Base_StoreInfo b on a.MerchID=b.MerchID " +
                             " left join (select b.* from Dict_System a inner join Dict_System b on a.ID=b.PID where a.DictKey='商品类别' and a.PID=0) c on convert(varchar, a.GoodType)=c.DictValue " +
                             " where a.Status=1 and b.StoreID='" + storeId + "'";
                sql = sql + sqlWhere;
                IBase_GoodsInfoService base_GoodsInfoService = BLLContainer.Resolve <IBase_GoodsInfoService>();
                var base_GoodsInfo = base_GoodsInfoService.SqlQuery <Base_GoodsInfoList>(sql, parameters).ToList();

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn, base_GoodsInfo));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
Example #5
0
        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));
            }
        }