示例#1
0
        public object GetCoinDestory(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string destroyTime = dicParas.ContainsKey("destroyTime") ? (dicParas["destroyTime"] + "") : string.Empty;
                XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel];
                string storeId = (userTokenKeyModel.DataModel as UserDataModel).StoreID;

                if (!string.IsNullOrEmpty(destroyTime))
                {
                    try
                    {
                        Convert.ToDateTime(destroyTime);
                    }
                    catch
                    {
                        errMsg = "销毁时间参数格式不正确";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }

                IData_CoinDestoryService data_CoinDestoryService = BLLContainer.Resolve <IData_CoinDestoryService>();
                var query = data_CoinDestoryService.GetModels(p => p.StoreID.Equals(storeId, StringComparison.OrdinalIgnoreCase));
                if (!string.IsNullOrEmpty(destroyTime))
                {
                    var dt = Convert.ToDateTime(destroyTime);
                    query = query.Where(w => DbFunctions.DiffDays(w.DestroyTime, dt) == 0);
                }

                IBase_UserInfoService base_UserInfoService = BLLContainer.Resolve <IBase_UserInfoService>();
                var linq = base_UserInfoService.GetModels(p => p.UserType == (int)UserType.Store).Select(o => new { UserID = o.UserID, LogName = o.LogName, RealName = o.RealName });

                var result = query.ToList().Select(o => new
                {
                    ID           = o.ID,
                    StoreID      = o.StoreID,
                    StorageCount = o.StorageCount,
                    DestroyTime  = o.DestroyTime,
                    UserID       = o.UserID,
                    Note         = o.Note,
                    LogName      = linq.SingleOrDefault(p => p.UserID == o.UserID).LogName,
                    RealName     = linq.SingleOrDefault(p => p.UserID == o.UserID).RealName
                });

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn, result.ToList()));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
示例#2
0
        public object AddCoinDestory(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg       = string.Empty;
                string storageCount = dicParas.ContainsKey("storageCount") ? (dicParas["storageCount"] + "") : string.Empty;
                string note         = dicParas.ContainsKey("note") ? (dicParas["note"] + "") : string.Empty;
                XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel];
                int    userId  = Convert.ToInt32(userTokenKeyModel.LogId);
                string storeId = (userTokenKeyModel.DataModel as UserDataModel).StoreID;

                if (string.IsNullOrEmpty(storageCount))
                {
                    errMsg = "销毁数量不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!Utils.isNumber(storageCount))
                {
                    errMsg = "销毁数量参数格式不正确";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                int iStorageCount = Convert.ToInt32(storageCount);
                if (iStorageCount < 0)
                {
                    errMsg = "销毁数量必不能为负数";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                IData_CoinDestoryService data_CoinDestoryService = BLLContainer.Resolve <IData_CoinDestoryService>();
                Data_CoinDestory         data_CoinDestory        = new Data_CoinDestory();
                data_CoinDestory.DestroyTime  = DateTime.Now;
                data_CoinDestory.Note         = note;
                data_CoinDestory.StorageCount = iStorageCount;
                data_CoinDestory.UserID       = userId;
                data_CoinDestory.StoreID      = storeId;
                if (!data_CoinDestoryService.Add(data_CoinDestory))
                {
                    errMsg = "更新数据库失败";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }