//充值(不一定有订单) //return true-微信充值履历保存成功 false-微信充值履历保存失败 public bool chargePayment(string UserID, int?Amount, string PayOrderID, int?Type) { Recharge charge = new Recharge() { ID = Guid.NewGuid().ToString(), UserID = UserID, //单位:分 Amount = (int)Amount, Creater = Commons.orderHandler.USER.ToString(), CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), PayOrderID = PayOrderID, Remark = "微信充值", Type = (int)Commons.PayType.RECHARGE }; Messages msg = new Messages() { userid = UserID, content = string.Format("尊敬的用户你好!本条信息为系统确认消息,您于:{0}成功充值{1}元.", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Amount / 100.00), time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), type = Convert.ToInt32(Commons.MessagesType.serviceType).ToString() }; if (paysDb.Addpay(charge) != null && alipayDb.AddMsg(msg) != null) { return(true); } return(false); }
public Order createOrder(Order order, out string Msg) { if (order.UserID != null && order.Time != null && !String.IsNullOrWhiteSpace(order.CarID)) { //用户是否审核 User user = UserDb_manager.findUserId(order.UserID); if (user != null) { if (!user.UserStatus.Equals(((int)(Commons.Authentication.APPLY)).ToString())) { //用户未审核 Msg = "用户审核中,不能预约"; return(null); } } //如果有预约订单,不能再次创建 IList <Order> ORDER = db_manager.Select(order.UserID); if (ORDER.Count() > 0) { foreach (var x in ORDER) { if (x.State == (int)Commons.Type.BOOK) { Msg = "存在已预约订单,不能重复预约"; return(null); } } } //如果用户账户余额低于500,不能租车 if (db_manager.QueryMoney(order.UserID) < 1) { Msg = "账户余额不足,请充值"; return(null); } order.ID = OrderIdUtil.create(); order.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); order.State = (int)Commons.Type.BOOK; //生成公私钥 //RSAHelper.RSAKey(secKey, pubKey); string pubKey = null, secKey = null; RSAHelper.GenerateRSAKey(out secKey, out pubKey); order.Pubkey = pubKey; order.SecKey = secKey; order.Creater = Commons.orderHandler.USER.ToString(); Car c = zsc_manager.findCarByCarId(order.CarID); if (c != null) { order.TerminalId = c.TermID; order.CarType = c.CarType; order.CarNo = c.CarNo; } UserAuthorization auth = new UserAuthorization(); auth.Id = Guid.NewGuid().ToString().Replace("-", ""); auth.OrderId = order.ID; auth.UserId = order.UserID; auth.Status = (int)Commons.Authorized.BASED; auth.Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //1.发送到消息队列 2.存入缓存 // cache_manager.Create(order); msmq_manager.Send(order); msmq_manager.SendUserAuth(auth); string type = null; string carNo = null; Car CAR = zsc_manager.findCarByCarId(order.CarID); if (c != null) { type = CAR.CarType; carNo = CAR.CarNo; } Messages msg = new Messages() { userid = order.UserID, content = new StringBuilder(). Append(Commons.orderMsg1) .Append(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")). Append(Commons.orderMsg2). Append(type). Append(Commons.orderMsg3).Append(carNo).Append(Commons.orderMsg4).ToString(), time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), type = Convert.ToInt32(Commons.MessagesType.serviceType).ToString() }; db_manager.AddMsg(msg); //修改车状态 Msg = "预约成功"; return(order); } Msg = "预约失败"; return(null); }