public IHttpActionResult ChangeDrawMoenyState([FromBody] JObject value) { int result = 0; int id = (int)value["Id"]; int state = (int)value["State"]; var query = entities.DrawMoney.Where(d => d.Id == id).FirstOrDefault(); if (query != null && state == 2) { //提现成功 query.State = 2; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); //日志表记录 if (result > 0) { var model = entities.AroundUserFinance.Where(c => c.UserId == query.UserId).FirstOrDefault(); if (model != null) { model.AccountBalance = model.AccountBalance - query.RemoveMoeny; model.AccumulatedExpenditure = model.AccumulatedExpenditure + query.RemoveMoeny; DbEntityEntry entry1 = entities.Entry(model); entry1.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); AroundUserFinanceLog log = new AroundUserFinanceLog { BusinessNumber = Convert.ToInt64(ts.TotalMilliseconds).ToString(), UserId = model.UserId, PaymentState = 3, TransactionType = 1, TransactionTime = DateTime.Now, TransactionAmount = query.RemoveMoeny, Remarks = "提现支出" }; entities.AroundUserFinanceLog.Add(log); result = entities.SaveChanges(); } } } else { query.State = 3; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); return(Ok(Respone.Success("提现失败"))); } if (result > 0) { return(Ok(Respone.Success("提现成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult EndAddShopCartTask([FromBody] JObject value) { try { int result = 0; decimal total = 0; int id = (int)value["Id"]; int number = (int)value["Number"]; var query = entities.AddShopCart.Where(e => e.Id == id).FirstOrDefault(); if (query != null) { using (TransactionScope scope = new TransactionScope()) { total = Convert.ToDecimal(query.Price) * number; query.State = 3; query.TotalPrice = total; query.Actual = number; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; //账户扣款 var customerFinance = entities.AroundUserFinance.Where(t => t.UserId == query.UserId).FirstOrDefault(); customerFinance.AccountBalance = customerFinance.AccountBalance - query.TotalPrice; customerFinance.AccumulatedExpenditure = customerFinance.AccumulatedExpenditure + query.TotalPrice; DbEntityEntry entryc = entities.Entry(customerFinance); entryc.State = System.Data.Entity.EntityState.Modified; //日志 TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); AroundUserFinanceLog log = new AroundUserFinanceLog { BusinessNumber = Convert.ToInt64(ts.TotalMilliseconds).ToString(), UserId = query.UserId, PaymentState = 21, TransactionType = 1, //1扣款,2:充值,3退款 TransactionTime = DateTime.Now, TransactionAmount = query.TotalPrice, Remarks = "任务:" + query.Id + " 加购总额支出" }; entities.AroundUserFinanceLog.Add(log); result = entities.SaveChanges(); scope.Complete(); } } if (result > 0) { return(Ok(Respone.Success("加购任务已完成"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } } catch (Exception ex) { return(Ok(ex.ToString())); } }
public IHttpActionResult ExcelBugQuery() { int s = 0; int sum = 0; try { var filelist = HttpContext.Current.Request.Files; var bad = new List <ExcelBugQueryModel>(); if (filelist.Count > 0) { for (var i = 0; i < filelist.Count; i++) { var file = filelist[i]; var dataTable = ExcelHelp.ExcelToTableForXLSX(file.InputStream); //excel转成datatable bad = dataTable.ToDataList <ExcelBugQueryModel>(); //datatable转成list } } sum = bad.Count(); using (TransactionScope scope = new TransactionScope()) { foreach (var item in bad) { var bid = entities.BugQuery.Where(b => b.Id == item.编号).FirstOrDefault(); if (item.状态.Equals("0")) { if (bid != null) { bid.State = 4; DbEntityEntry entry = entities.Entry(bid); entry.State = System.Data.Entity.EntityState.Modified; //entities.SaveChanges(); //退款 var customerFinance = entities.AroundUserFinance.Where(t => t.UserId == bid.UserId).FirstOrDefault(); customerFinance.AccountBalance = customerFinance.AccountBalance + bid.Price; customerFinance.AccumulatedExpenditure = customerFinance.AccumulatedExpenditure - bid.Price; DbEntityEntry entryc = entities.Entry(customerFinance); entryc.State = System.Data.Entity.EntityState.Modified; //entities.SaveChanges(); //记录流水 TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); AroundUserFinanceLog log = new AroundUserFinanceLog { BusinessNumber = Convert.ToInt64(ts.TotalMilliseconds).ToString(), UserId = bid.UserId, PaymentState = 16, TransactionType = 3, TransactionTime = DateTime.Now, TransactionAmount = bid.Price, Remarks = "任务:" + bid.Id + " 死因查询退款" }; entities.AroundUserFinanceLog.Add(log); //entities.SaveChanges(); } } else if (item.状态.Equals("1")) { if (bid != null) { bid.State = 3; DbEntityEntry entry = entities.Entry(bid); entry.State = System.Data.Entity.EntityState.Modified; //entities.SaveChanges(); } } else { return(Ok(Respone.No("上传失败"))); } s++; } entities.SaveChanges(); scope.Complete(); } if (s == sum) { return(Ok(Respone.Success("导入成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } } catch (Exception ex) { return(Ok(ex.ToString())); } }
public IHttpActionResult ChangeUserByBugQueryStateOrMoney(ChangeBadEvaluateModel model) { int result = 0; if (model.State == 1) { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.BugQuery.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.State = 2; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); var customerFinance = entities.AroundUserFinance.Where(t => t.UserId == query.UserId).FirstOrDefault(); customerFinance.AccountBalance = customerFinance.AccountBalance - query.Price; customerFinance.AccumulatedExpenditure = customerFinance.AccumulatedExpenditure + query.Price; DbEntityEntry entryc = entities.Entry(customerFinance); entryc.State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); //记录流水 TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); AroundUserFinanceLog log = new AroundUserFinanceLog { BusinessNumber = Convert.ToInt64(ts.TotalMilliseconds).ToString(), UserId = query.UserId, PaymentState = 9, TransactionType = 1, TransactionTime = DateTime.Now, TransactionAmount = query.Price, Remarks = "任务:" + query.Id + " 死因查询支出" }; entities.AroundUserFinanceLog.Add(log); result = entities.SaveChanges(); } } } else if (model.State == 2) { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.BugQuery.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.State = 5; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } } } else { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.BugQuery.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.Price = model.Price; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } } } if (result > 0) { return(Ok(Respone.Success("修改成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult ChangeAccountbalance([FromBody] JObject value) { int result = 0; int sum = 0; int id = (int)value["Id"]; decimal accountbalance = (decimal)value["Accountbalance"]; string state = value["State"].ToString(); var query = entities.AroundUserFinance.Where(c => c.UserId == id).FirstOrDefault(); if (query != null) { if (state == "0") //扣款 { query.AccountBalance = query.AccountBalance - accountbalance; query.AccumulatedExpenditure = query.AccumulatedExpenditure + accountbalance; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); if (result > 0) { TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); AroundUserFinanceLog log = new AroundUserFinanceLog { BusinessNumber = Convert.ToInt64(ts.TotalMilliseconds).ToString(), UserId = query.UserId, PaymentState = 2, //具体状态 TransactionType = 1, //1扣款,2:充值,3退款 TransactionTime = DateTime.Now, TransactionAmount = accountbalance, Remarks = "扣款支出" }; entities.AroundUserFinanceLog.Add(log); sum = entities.SaveChanges(); } } else //充值 { query.AccountBalance = query.AccountBalance + accountbalance; query.AccumulatedIncome = query.AccumulatedIncome + accountbalance; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); if (result > 0) { TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); AroundUserFinanceLog log = new AroundUserFinanceLog { BusinessNumber = Convert.ToInt64(ts.TotalMilliseconds).ToString(), UserId = query.UserId, PaymentState = 1, TransactionType = 2, TransactionTime = DateTime.Now, TransactionAmount = accountbalance, Remarks = "充值收入" }; entities.AroundUserFinanceLog.Add(log); sum = entities.SaveChanges(); } } } if (result > 0 && sum > 0) { return(Ok(Respone.Success("修改成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult EndEvaluateTask(EvaluateTaskModel task) { try { int result = 0; using (TransactionScope scope = new TransactionScope()) { if (task.State == 0) { foreach (var item in task.Id) { var query = entities.Evaluate.Where(e => e.Id == item).FirstOrDefault(); if (query != null) { query.State = 4; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; } } result = entities.SaveChanges(); scope.Complete(); } else { foreach (var item in task.Id) { var query = entities.Evaluate.Where(e => e.Id == item).FirstOrDefault(); if (query != null) { query.State = 3; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; //账户扣款 var customerFinance = entities.AroundUserFinance.Where(t => t.UserId == query.UserId).FirstOrDefault(); customerFinance.AccountBalance = customerFinance.AccountBalance - query.Price; customerFinance.AccumulatedExpenditure = customerFinance.AccumulatedExpenditure + query.Price; DbEntityEntry entryc = entities.Entry(customerFinance); entryc.State = System.Data.Entity.EntityState.Modified; //日志 TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); AroundUserFinanceLog log = new AroundUserFinanceLog { BusinessNumber = Convert.ToInt64(ts.TotalMilliseconds).ToString(), UserId = query.UserId, PaymentState = 25, TransactionType = 1, //1扣款,2:充值,3退款 TransactionTime = DateTime.Now, TransactionAmount = query.Price, Remarks = "任务:" + query.Id + " 上评总额支出" }; entities.AroundUserFinanceLog.Add(log); } } result = entities.SaveChanges(); scope.Complete(); } } if (result > 0) { return(Ok(Respone.Success("任务已完成"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } } catch (Exception ex) { return(Ok(ex.ToString())); } }