/// <summary> /// 根据人数、年数生成客户订单 /// </summary> public JsonResult AddClientOrder(int quantity, int periodQuantity) { int pageCount = 0; int totalCount = 0; List<ModulesProduct> list = ModulesProductBusiness.GetModulesProducts(string.Empty, int.MaxValue, 1, ref totalCount, ref pageCount); //获取订单产品的最佳组合 var way = ModulesProductBusiness.GetBestWay(quantity, list.OrderByDescending(m => m.UserQuantity).Where(m => m.PeriodQuantity == periodQuantity).ToList()); //获取订单参数 ClientOrder model=new ClientOrder(); model.UserQuantity=way.TotalQuantity; model.Years=periodQuantity; model.Amount=way.TotalMoney; model.RealAmount = way.TotalMoney; model.AgentID=CurrentUser.AgentID; model.ClientID=CurrentUser.ClientID; model.CreateUserID=CurrentUser.UserID; model.Details=new List<ClientOrderDetail>(); foreach (var p in way.Products) { ClientOrderDetail detail = new ClientOrderDetail(); detail.ProductID = p.Key; detail.Qunatity = p.Value; detail.CreateUserID = CurrentUser.CreateUserID; detail.Price = list.Find(m => m.ProductID == p.Key).Price; model.Details.Add(detail); } string orderID= ClientOrderBusiness.AddClientOrder(model); JsonDictionary.Add("ID", orderID); if (!string.IsNullOrEmpty(orderID)) { string productUrl = "http://90cloudsales.com/Home/Login"; string orderTitle = "您购买了云销系统 人数:" + model.UserQuantity + "人 时间:" + model.Years+"年 "+"金额:"+model.RealAmount; string orderDes=""; string amount = decimal.Round(model.RealAmount, 2).ToString(); JsonDictionary.Add("AlipayUrl", GetAlipayUrl(productUrl, orderTitle, orderDes, amount, orderID)); } return new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
/// <summary> /// 根据人数、年数生成客户订单 /// </summary> public JsonResult AddClientOrder(int quantity, int periodQuantity) { int pageCount = 0; int totalCount = 0; List<ModulesProduct> list = ModulesProductBusiness.GetModulesProducts(string.Empty, int.MaxValue, 1, ref totalCount, ref pageCount); //获取订单产品的最佳组合 var way = ModulesProductBusiness.GetBestWay(quantity, list.OrderByDescending(m => m.UserQuantity).Where(m => m.PeriodQuantity == periodQuantity).ToList()); //获取订单参数 ClientOrder model=new ClientOrder(); model.UserQuantity=way.TotalQuantity; model.Years=periodQuantity; model.Amount=way.TotalMoney; model.RealAmount = way.TotalMoney; model.AgentID=CurrentUser.AgentID; model.ClientID=CurrentUser.ClientID; model.CreateUserID=CurrentUser.UserID; model.Details=new List<ClientOrderDetail>(); foreach (var p in way.Products) { ClientOrderDetail detail = new ClientOrderDetail(); detail.ProductID = p.Key; detail.Qunatity = p.Value; detail.CreateUserID = CurrentUser.CreateUserID; detail.Price = list.Find(m => m.ProductID == p.Key).Price; model.Details.Add(detail); } string orderID= ClientOrderBusiness.AddClientOrder(model); JsonDictionary.Add("ID", orderID); return new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
/// <summary> /// 根据人数、年数生成客户订单 /// </summary> public JsonResult AddClientOrder(int quantity, int years, int type) { int remainderMonths = 12;//剩余月份 //购买人数 if (type == 2) { remainderMonths = (CurrentAgent.EndTime.Year - DateTime.Now.Year) * 12 + (CurrentAgent.EndTime.Month - DateTime.Now.Month) - 1; if (CurrentAgent.EndTime.Day >= DateTime.Now.Day) remainderMonths += 1; years = remainderMonths / 12 == 0 ? 1 : remainderMonths / 12; } int pageCount = 0; int totalCount = 0; List<ModulesProduct> list = ModulesProductBusiness.GetModulesProducts(string.Empty, int.MaxValue, 1, ref totalCount, ref pageCount); //获取订单产品的最佳组合 var way = ModulesProductBusiness.GetBestWay(quantity, list.OrderByDescending(m => m.UserQuantity).Where(m => m.PeriodQuantity == years).ToList()); //获取订单参数 ClientOrder model = new ClientOrder(); model.UserQuantity = way.TotalQuantity; model.Type = type; model.Years = years; model.Amount = way.TotalMoney; decimal discount = 1M; if (!string.IsNullOrEmpty(CurrentUser.MDUserID)) { if (type == 1 || type == 2) { discount = 0.50M; } else { discount = 0.88M; } } else { if (type == 1 || type == 2) { discount = 0.66M; } } model.RealAmount = way.TotalMoney * discount; //购买人数 float remainderYears = 1; if (type == 2) { remainderYears = (float)remainderMonths / (12 * years); model.Amount = decimal.Parse((float.Parse(model.Amount.ToString()) * remainderYears).ToString("f2")); model.RealAmount = decimal.Parse((float.Parse(model.RealAmount.ToString()) * remainderYears).ToString("f2")); } model.AgentID = CurrentUser.AgentID; model.ClientID = CurrentUser.ClientID; model.CreateUserID = CurrentUser.UserID; model.Details = new List<ClientOrderDetail>(); foreach (var p in way.Products) { ClientOrderDetail detail = new ClientOrderDetail(); detail.ProductID = p.Key; detail.Qunatity = p.Value; detail.CreateUserID = CurrentUser.CreateUserID; detail.Price = list.Find(m => m.ProductID == p.Key).Price; //购买人数 if (type == 2) { detail.Price = decimal.Parse((float.Parse(detail.Price.ToString()) * remainderYears).ToString("f2")); } model.Details.Add(detail); } string orderID = ClientOrderBusiness.AddClientOrder(model); JsonDictionary.Add("ID", orderID); JsonDictionary.Add("RealAmount", model.RealAmount); return new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
/// <summary> /// 升级客户服务 /// </summary> /// <param name="client"></param> public JsonResult SaveClientAuthorize(string clientID, int serviceType, int giveType, int userQuantity, string endTime, int buyType, int buyUserQuantity, int buyUserYears) { bool flag = false; var client = ClientBusiness.GetClientDetail(clientID); var agent = AgentsBusiness.GetAgentDetail(client.AgentID); ClientAuthorizeLog log = new ClientAuthorizeLog(); log.CreateUserID = CurrentUser.UserID; log.ClientID = clientID; log.AgentID = client.AgentID; log.OrderID = string.Empty; if (serviceType == 1)//赠送 { if (giveType == 1)//赠送人数 { flag = AgentsBusiness.AddClientAgentUserQuantity(client.AgentID, userQuantity); log.BeginTime = agent.EndTime; log.EndTime = agent.EndTime; log.UserQuantity = userQuantity; log.Type = 2; } else//赠送时间 { log.BeginTime = agent.EndTime; flag = AgentsBusiness.SetClientAgentEndTime(client.AgentID, DateTime.Parse(endTime)); log.EndTime = DateTime.Parse(endTime); log.UserQuantity = agent.UserQuantity; log.Type = 3; } ClientBusiness.InsertClientAuthorizeLog(log); } else//购买生成订单 { log.Type = buyType; int remainderMonths = 0;//剩余月份 int years = 1; if (buyType == 2)//购买人数 { remainderMonths = (agent.EndTime.Year - DateTime.Now.Year) * 12 + (agent.EndTime.Month - DateTime.Now.Month) - 1; if (agent.EndTime.Day >= DateTime.Now.Day) remainderMonths += 1; years = remainderMonths / 12 == 0 ? 1 : remainderMonths / 12; log.BeginTime = agent.EndTime; log.EndTime = agent.EndTime; log.UserQuantity = userQuantity; } else { years = buyUserYears; log.BeginTime = agent.EndTime; log.EndTime = agent.EndTime.AddYears(years); log.UserQuantity = agent.UserQuantity; } int pageCount = 0; int totalCount = 0; List<ModulesProduct> list = ModulesProductBusiness.GetModulesProducts(string.Empty, int.MaxValue, 1, ref totalCount, ref pageCount); //获取订单产品的最佳组合 var way = ModulesProductBusiness.GetBestWay(buyUserQuantity, list.OrderByDescending(m => m.UserQuantity).Where(m => m.PeriodQuantity == years).ToList()); //获取订单参数 ClientOrder model = new ClientOrder(); model.UserQuantity = way.TotalQuantity; model.Type = buyType; model.Years = years; model.Amount = way.TotalMoney; model.RealAmount = way.TotalMoney; //购买人数 float remainderYears = 1; if (buyType == 2) { remainderYears = (float)remainderMonths / (12 * years); model.Amount = decimal.Parse((float.Parse(model.Amount.ToString()) * remainderYears).ToString("f2")); model.RealAmount = model.Amount; } model.AgentID = client.AgentID; model.ClientID = client.ClientID; model.CreateUserID = CurrentUser.UserID; model.Details = new List<ClientOrderDetail>(); foreach (var p in way.Products) { ClientOrderDetail detail = new ClientOrderDetail(); detail.ProductID = p.Key; detail.Qunatity = p.Value; detail.CreateUserID = CurrentUser.CreateUserID; detail.Price = list.Find(m => m.ProductID == p.Key).Price; //购买人数 if (buyType == 2) { detail.Price = decimal.Parse((float.Parse(detail.Price.ToString()) * remainderYears).ToString("f2")); } model.Details.Add(detail); } string orderID = ClientOrderBusiness.AddClientOrder(model); log.OrderID = orderID; flag=string.IsNullOrEmpty(orderID)?false:true; } JsonDictionary.Add("Result", flag?1:0); return new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }