コード例 #1
0
        public JsonResult EditUpLoadFastOrder()
        {
            JsonResult json = new JsonResult();

            try
            {
                //上传
                var file     = HttpContext.Request.Files.Get("UpLoadFile");
                var savePath = "/UpLoadFiles/FastOrder/";
                var param    = new UpLoadFileParam(file, savePath, false);
                param.AllowType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                json.Data       = UpLoadFileHelpOld.UpLoadFileExcel(param);
                string filename = param.SaveFileName;
                //获取数据
                string       path    = Server.MapPath("//UpLoadFiles/FastOrder") + "\\" + filename;
                ExcelPackage package = new ExcelPackage(new FileInfo(path), true);
                var          sheet   = package.Workbook.Worksheets[1];
                int          rows    = sheet.Dimension.End.Row;
                string       TNums   = "";
                for (int i = 2; i < rows + 1; i++)
                {
                    if (TNums.IsNullOrEmpty())
                    {
                        if (sheet.Cells[i, 1].Value != null)
                        {
                            TNums = "'" + sheet.Cells[i, 1].Value.ToString().Replace(" ", "") + "'";
                        }
                    }
                    else
                    {
                        if (sheet.Cells[i, 1].Value != null)
                        {
                            TNums = TNums + "," + "'" + sheet.Cells[i, 1].Value.ToString().Replace(" ", "") + "'";
                        }
                    }
                }

                string sql = "UPDATE FastOrder SET FastOrder.AgentState = 1,FastOrder.AgentTime = getdate() Where FastOrder.AgentState != 1 AND FastOrder.TNum In(" + TNums + ");";
                this.Entity.ExecuteStoreCommand(sql);
                return(json);
            }
            catch {
                json = new JsonResult();
                return(json);
            }
        }
コード例 #2
0
        public JsonResult EditUpLoadUsers()
        {
            JsonResult json = new JsonResult();
            try
            {
                //上传
                var file = HttpContext.Request.Files.Get("UpLoadFile");
                var savePath = "/UpLoadFiles/Users/";
                var param = new UpLoadFileParam(file, savePath, false);
                param.AllowType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                json.Data = UpLoadFileHelpOld.UpLoadFileExcel(param);
                //var sjson = JsonConvert.SerializeObject(json.Data);
                //var djson = JsonConvert.DeserializeObject(sjson) as JObject;
                //JToken Result = djson["Result"];
                //string filename = Result["SaveFileName"].ToString();
                string filename = param.SaveFileName;
                //获取数据
                string path = Server.MapPath("//UpLoadFiles/Users") + "\\" + filename;
                ExcelPackage package = new ExcelPackage(new FileInfo(path), true);
                var sheet = package.Workbook.Worksheets[1];
                int rows = sheet.Dimension.End.Row;
                int OpType = 0;
                for (int i = 2; i < rows + 1; i++)
                {
                    Users baseUsers = new Users();
                    if (sheet.Cells[i,1].Value != null)
                    {
                        string mobile=sheet.Cells[i, 1].Value.ToString().Replace(" ", "");
                        baseUsers = Entity.Users.FirstOrNew(o => o.Mobile == mobile);
                    }
                    else if(sheet.Cells[i,2].Value!=null)
                    {
                        string cardid = sheet.Cells[i, 2].Value.ToString().Replace(" ", "");
                        baseUsers = Entity.Users.FirstOrNew(o => o.CardId == cardid && o.CardStae == 2);
                    }
                    if (!baseUsers.Id.IsNullOrEmpty()&&sheet.Cells[i,3].Value!=null)
                    {
                        decimal StopPayMoney = 0;
                        #region 部分止付
                        if (sheet.Cells[i, 3].Value.ToString() == "部分止付")//部份
                        {
                            OpType = 3;
                          
                            if (sheet.Cells[i, 4].Value != null)
                            {
                                StopPayMoney =Math.Round(Convert.ToDecimal(sheet.Cells[i, 4].Value),2);
                                if (StopPayMoney < 0)
                                { continue; }
                            }

                            //帐户变动记录
                            string SP_Ret = Entity.SP_UsersMoney(baseUsers.Id, "部分止付", StopPayMoney, 9, "部分止付");
                            if (SP_Ret != "3")
                            {
                                Utils.WriteLog(string.Format("U{0},O{1},T{2}:{3}【{4}】", baseUsers.Id, "部分止付", 9, StopPayMoney, SP_Ret), "SP_UsersMoney");
                            }
                            baseUsers = this.Entity.Users.FirstOrDefault(o => o.Id == baseUsers.Id);
                            if (baseUsers.StopPayState == 0)
                            {
                                baseUsers.StopPayMoney = StopPayMoney;
                            }
                            else if (baseUsers.StopPayState == 1)
                            {
                                baseUsers.StopPayMoney += StopPayMoney;
                            }
                            else if (baseUsers.StopPayState == 2)
                            {
                                baseUsers.StopPayMoney = StopPayMoney;
                            }
                            baseUsers.StopPayState = 1;
                            //日记写入
                            var UserFrozenLog = new UserFrozenLog()
                            {
                                AddTime = DateTime.Now,
                                OpName = AdminUser.TrueName,
                                AId = AdminUser.Id,
                                OpType = OpType,
                                LogType = 2,
                                UId = baseUsers.Id,
                                StopPayMoney = StopPayMoney,
                                Remark = sheet.Cells[i, 5].Value == null ? "" : sheet.Cells[i, 5].Value.ToString().Length > 1999 ? sheet.Cells[i, 5].Value.ToString().Substring(0, 1999) : sheet.Cells[i, 5].Value.ToString(),
                                Platform = 2,
                                InteriorRemark = sheet.Cells[i, 6].Value == null ? "" : sheet.Cells[i, 6].Value.ToString().Length > 1999 ? sheet.Cells[i, 6].Value.ToString().Substring(0, 1999) : sheet.Cells[i, 6].Value.ToString(),
                            };
                            Entity.UserFrozenLog.AddObject(UserFrozenLog);
                            //Entity.SaveChanges();
                        }
                        #endregion
                        #region 全止付
                        if (sheet.Cells[i, 3].Value.ToString() == "全止付")//全帐户
                        {
                            OpType = 1;
                            if (baseUsers.StopPayState == 0)
                            {
                                baseUsers.StopPayState = 2;
                                baseUsers.AutoBao = 0;
                                baseUsers.AutoCash = 0;
                            }
                            else if (baseUsers.StopPayState == 1)
                            {
                                StopPayMoney = baseUsers.StopPayMoney;
                                if (StopPayMoney > 0)
                                {
                                    //帐户变动记录
                                    string SP_Ret = Entity.SP_UsersMoney(baseUsers.Id, "解除部分止付", StopPayMoney, 10, "解除部分止付");
                                    if (SP_Ret != "3")
                                    {
                                        Utils.WriteLog(string.Format("U{0},O{1},T{2}:{3}【{4}】", baseUsers.Id, "解除部分止付", 10, StopPayMoney, SP_Ret), "SP_UsersMoney");
                                    }
                                    baseUsers = this.Entity.Users.FirstOrDefault(o => o.Id == baseUsers.Id);

                                    baseUsers.StopPayState = 2;
                                    baseUsers.AutoBao = 0;
                                    baseUsers.AutoCash = 0;
                                    baseUsers.StopPayMoney = 0;
                                }
                            }
                            else if (baseUsers.StopPayState == 2)
                            {
                                continue;
                            }
                            
                            //日记写入
                            var UserFrozenLog = new UserFrozenLog()
                            {
                                AddTime = DateTime.Now,
                                OpName = AdminUser.TrueName,
                                AId = AdminUser.Id,
                                OpType = OpType,
                                LogType = 2,
                                UId = baseUsers.Id,
                                StopPayMoney = StopPayMoney,
                                Remark = sheet.Cells[i, 5].Value == null ? "" : sheet.Cells[i, 5].Value.ToString().Length>1999?sheet.Cells[i, 5].Value.ToString().Substring(0,1999):sheet.Cells[i, 5].Value.ToString(),
                                Platform = 2,
                                InteriorRemark = sheet.Cells[i, 6].Value == null ? "" : sheet.Cells[i, 6].Value.ToString().Length > 1999 ? sheet.Cells[i, 6].Value.ToString().Substring(0, 1999) : sheet.Cells[i, 6].Value.ToString(),
                            };
                            Entity.UserFrozenLog.AddObject(UserFrozenLog);
                           
                        }
                        #endregion   
                    }
                }
                Entity.SaveChanges();
              return json;
            }
            catch
            {
                json = new JsonResult();
                return json;
            }
        }