public void GetOrderInfo(OrderDto order) { if (order != null) { PayInfo info = new PayInfo(); info.Id = Guid.NewGuid().ToString("N"); info.OrderId = order.OrderId; info.Money = order.Money; info.stauts = 0; info.CrateTime = DateTime.Now; _payInfoContext.PayInfo.Add(info); _payInfoContext.SaveChanges(); } }
public object ReceiveProductInfo(object obj) { PayInfo payInfo = new PayInfo(); payInfo.Id = Guid.NewGuid().ToString("N"); payInfo.Money = "100"; payInfo.OrderId += 1; payInfo.stauts = 1; payInfo.CrateTime = DateTime.Now; payInfo.UpdateTime = DateTime.Now; db.PayInfo.Add(payInfo); db.SaveChanges(); // 具体业务 throw new NullReferenceException("空指针异常."); //return obj; }
public IActionResult PubPay(string id) { using (var tran = _payInfoContext.Database.BeginTransaction()) { PayInfo pay = _payInfoContext.PayInfo.Where(e => e.OrderId == id).FirstOrDefault(); pay.stauts = 1; pay.UpdateTime = DateTime.Now; _payInfoContext.SaveChanges(); OrderDto dto = new OrderDto(); dto.OrderId = pay.OrderId; dto.Money = pay.Money; dto.Status = pay.stauts; _publisher.Publish("pay", dto); } return(Ok(id)); }