/// <summary> /// 审核通过客户订单 /// </summary> /// <param name="id"></param> /// <param name="agentID"></param> /// <returns></returns> public JsonResult PayOrderAndAuthorizeClient(string id) { //订单支付及后台客户授权 ClientOrder order = ClientOrderBusiness.GetClientOrderInfo(id); if (order.Status == 0) { bool flag = ClientOrderBusiness.PayOrderAndAuthorizeClient(id, CurrentUser.UserID, -1, EnumOrderPayType.Cash); JsonDictionary.Add("Result", flag ? 1 : 0); if (flag) { ClientBusiness.UpdateClientCache(order.ClientID); ClearClientCache(order.ClientID); } } else { JsonDictionary.Add("Result", order.Status == 1 ? 1001 : 1002); } return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult GoAlipayPay(string id) { string url = string.Empty; if (Session["ClientManager"] == null) { return(Redirect("/Home/Login")); } else { ClientOrder order = ClientOrderBusiness.GetClientOrderInfo(id); if (order != null && !string.IsNullOrEmpty(order.OrderID)) { //订单未支付 if (order.Status == 0) { url = ToPayOrderUrl(order.UserQuantity, order.Years, order.OrderID, order.RealAmount.ToString(), 1); return(Redirect(url)); } } } return(View()); }
public JsonResult GetClientOrderDetail(string orderid) { var item = ClientOrderBusiness.GetClientOrderInfo(orderid); JsonDictionary.Add("Item", item); JsonDictionary.Add("Result", 1); return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult UpdateOrderAmount(string id, string amount) { bool flag = ClientOrderBusiness.UpdateOrderAmount(id, decimal.Parse(amount)); JsonDictionary.Add("Result", flag ? 1 : 0); return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult CloseClientOrder(string id) { bool flag = ClientOrderBusiness.UpdateClientOrderStatus(id, CloudSalesEnum.EnumClientOrderStatus.Delete); JsonDictionary.Add("Result", flag ? 1 : 0); return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult GetOrderInfo(string id) { int result = 0; if (!string.IsNullOrEmpty(id)) { ClientOrder order = ClientOrderBusiness.GetClientOrderInfo(id); if (order != null && !string.IsNullOrEmpty(order.OrderID)) { //订单已支付 if (order.Status == 0) { result = -2; } else { result = 1; JsonDictionary.Add("type", order.Type); JsonDictionary.Add("nowUserCount", CurrentClient.UserQuantity); JsonDictionary.Add("nowEndTime", CurrentClient.EndTime.ToString("yyyy-MM-dd")); if (order.Type == 1 || order.Type == 3) { JsonDictionary.Add("preUserCount", 0); JsonDictionary.Add("preEndTime", CurrentClient.EndTime.AddYears(-order.Years).ToString("yyyy-MM-dd")); } else if (order.Type == 2) { JsonDictionary.Add("preUserCount", CurrentClient.UserQuantity - order.UserQuantity); JsonDictionary.Add("preEndTime", CurrentClient.EndTime.ToString("yyyy-MM-dd")); } } } //订单不存在 else { result = -1; } } else { result = 2; } JsonDictionary.Add("result", result); return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
/// <summary> /// 根据订单clientID获取订单 /// </summary> public JsonResult GetClientOrders(string keyWords, string clientID, int status, int type, string beginDate, string endDate, int pageSize, int pageIndex, int userType = 0) { int pageCount = 0; int totalCount = 0; List <ClientOrder> list = ClientOrderBusiness.GetBase(keyWords.Trim(), status, type, beginDate, endDate, clientID, userType, pageSize, pageIndex, ref totalCount, ref pageCount); JsonDictionary.Add("Items", list); JsonDictionary.Add("TotalCount", totalCount); JsonDictionary.Add("PageCount", pageCount); return(new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult GetClientOrders(int status, int type, string beginDate, string endDate, int pageSize, int pageIndex) { int pageCount = 0; int totalCount = 0; List <ClientOrder> list = ClientOrderBusiness.GetClientOrders(status, type, beginDate, endDate, CurrentUser.ClientID, pageSize, pageIndex, ref totalCount, ref pageCount); JsonDictionary.Add("Items", list); JsonDictionary.Add("TotalCount", totalCount); JsonDictionary.Add("PageCount", pageCount); return(new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult PayOrderAndAuthorizeClient(string id, string agentID) { //订单支付及后台客户授权 bool flag = ClientOrderBusiness.PayOrderAndAuthorizeClient(id); JsonDictionary.Add("Result", flag ? 1 : 0); if (flag) { AgentsBusiness.UpdatetAgentCache(agentID); } return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
/// <summary> /// 关闭客户订单 /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult CloseClientOrder(string id) { ClientOrder order = ClientOrderBusiness.GetClientOrderInfo(id); if (order.Status == 0) { bool flag = ClientOrderBusiness.UpdateClientOrderStatus(id, IntFactoryEnum.EnumClientOrderStatus.Delete); JsonDictionary.Add("Result", flag ? 1 : 0); } else { JsonDictionary.Add("Result", order.Status == 1 ? 1001 : 1002); } return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult PayClientOrder(string id) { ClientOrder order = ClientOrderBusiness.GetClientOrderInfo(id); if (order.PayStatus == 0 || order.PayStatus == 2) { bool flag = ClientOrderBusiness.PayClientOrder(id, (int)IntFactoryEnum.EnumClientOrderPay.Pay); JsonDictionary.Add("Result", flag ? 1 : 0); } else { JsonDictionary.Add("Result", 1001); } return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
/// <summary> /// 修改客户订单支付金额 /// </summary> /// <param name="id"></param> /// <param name="amount"></param> /// <returns></returns> public JsonResult UpdateOrderAmount(string id, string amount) { ClientOrder order = ClientOrderBusiness.GetClientOrderInfo(id); if (order.Status == 0) { bool flag = ClientOrderBusiness.UpdateOrderAmount(id, decimal.Parse(amount)); JsonDictionary.Add("Result", flag ? 1 : 0); } else { JsonDictionary.Add("Result", order.Status == 1 ? 1001 : 1002); } return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
/// <summary> /// 获取客户订单信息 /// </summary> /// <param name="id"></param> public int GetClientOrderInfo(ref string id) { ViewBag.OrderID = id ?? string.Empty; if (!string.IsNullOrEmpty(id)) { ClientOrder order = ClientOrderBusiness.GetClientOrderInfo(id); if (order != null && !string.IsNullOrEmpty(order.OrderID)) { //订单已支付 if (order.Status == 1) { return(-2); } else { ViewBag.RealAmount = decimal.Round(order.RealAmount, 2); } } //订单不存在 else { return(-1); } } else { int pageCount = 0; int totalCount = 0; List <ClientOrder> list = ClientOrderBusiness.GetClientOrders(0, -1, string.Empty, string.Empty, CurrentUser.ClientID, int.MaxValue, 1, ref totalCount, ref pageCount); if (list.Count > 0) { id = list[0].OrderID; return(2); } } return(1); }
/// <summary> /// 获取客户订单信息 /// </summary> /// <param name="id"></param> public void GetClientOrderInfo(string id) { ViewBag.Years = 1; ViewBag.RealAmount = "0,00"; ViewBag.ClientOrdersCount = 0;//客户订单数 ViewBag.OrderID = id ?? string.Empty; if (!string.IsNullOrEmpty(id)) { ClientOrder order = ClientOrderBusiness.GetClientOrderInfo(id); if (order != null && !string.IsNullOrEmpty(order.OrderID)) { //订单已支付 if (order.Status == 1) { ViewBag.OrderID = "-2"; } else { ViewBag.Years = order.Years; ViewBag.UserQuantity = order.UserQuantity; ViewBag.RealAmount = decimal.Round(order.RealAmount, 2); } } else //订单不存在 { ViewBag.OrderID = "-1"; } } else { int pageCount = 0; int totalCount = 0; List <ClientOrder> list = ClientOrderBusiness.GetClientOrders(0, -1, string.Empty, string.Empty, CurrentUser.AgentID, CurrentUser.ClientID, int.MaxValue, 1, ref totalCount, ref pageCount); ViewBag.ClientOrdersCount = list.Count; } }
/// <summary> /// 根据人数、年数生成客户订单 /// </summary> public JsonResult AddClientOrder(int quantity, int years, int type) { int remainderMonths = 12;//剩余月份 //购买人数 if (type == 2) { remainderMonths = (CurrentClient.EndTime.Year - DateTime.Now.Year) * 12 + (CurrentClient.EndTime.Month - DateTime.Now.Month) - 1; if (CurrentClient.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; //if (!string.IsNullOrEmpty(CurrentUser.Client.AliMemberID)) //{ // if (type == 1 || type == 2) // { // discount = 0.50M; // } // else // { // discount = 0.88M; // } //} //else //{ // if (type == 1 || type == 2) // { // discount = 0.5M; // } //} model.RealAmount = way.TotalMoney * OrderDiscount; //购买人数 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.ClientID = CurrentUser.ClientID; model.CreateUserID = CurrentUser.UserID; model.SourceType = 0; 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> public void Notify() { SortedDictionary <string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); if (verifyResult)//验证成功 { //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //商户订单号 string out_trade_no = Request.Form["out_trade_no"]; //支付宝交易号 string trade_no = Request.Form["trade_no"]; //交易状态 string trade_status = Request.Form["trade_status"]; if (Request.Form["trade_status"] == "TRADE_FINISHED") { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //请务必判断请求时的total_fee、seller_id与通知时获取的total_fee、seller_id为一致的 //如果有做过处理,不执行商户的业务程序 //注意: //退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知 } else if (Request.Form["trade_status"] == "TRADE_SUCCESS") { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //请务必判断请求时的total_fee、seller_id与通知时获取的total_fee、seller_id为一致的 //如果有做过处理,不执行商户的业务程序 //注意: //付款完成后,支付宝系统发送该交易状态通知 //获取订单详情 ClientOrder order = ClientOrderBusiness.GetClientOrderInfo(out_trade_no); if (order != null && !string.IsNullOrEmpty(order.OrderID)) { decimal total_fee = decimal.Parse(Request.Form["total_fee"]); if (order.RealAmount == total_fee) { //订单支付及后台客户授权 bool flag = ClientOrderBusiness.PayOrderAndAuthorizeClient(order.OrderID, string.Empty, 1, IntFactoryEnum.EnumOrderPayType.AliPay); if (flag) { ClientBusiness.UpdateClientCache(order.ClientID); Response.Write("success"); //请不要修改或删除 } } } } } } }
/// <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); ClientAuthorizeLog log = new ClientAuthorizeLog(); log.CreateUserID = CurrentUser.UserID; log.ClientID = clientID; log.OrderID = string.Empty; if (serviceType == 1) //赠送 { if (giveType == 1) //赠送人数 { flag = ClientBusiness.AddClientUserQuantity(client.ClientID, userQuantity); log.BeginTime = client.EndTime; log.EndTime = client.EndTime; log.UserQuantity = userQuantity; log.Type = 2; } else//赠送时间 { log.BeginTime = client.EndTime; flag = ClientBusiness.SetClientEndTime(client.ClientID, DateTime.Parse(endTime)); log.EndTime = DateTime.Parse(endTime); log.UserQuantity = client.UserQuantity; log.Type = 3; } ClientBusiness.UpdateClientCache(client.ClientID); ClientBusiness.InsertClientAuthorizeLog(log); ClearClientCache(client.ClientID); } else//购买生成订单 { log.Type = buyType; int remainderMonths = 0;//剩余月份 int years = 1; if (buyType == 2)//购买人数 { remainderMonths = (client.EndTime.Year - DateTime.Now.Year) * 12 + (client.EndTime.Month - DateTime.Now.Month) - 1; if (client.EndTime.Day >= DateTime.Now.Day) { remainderMonths += 1; } years = remainderMonths / 12 == 0 ? 1 : remainderMonths / 12; log.BeginTime = client.EndTime; log.EndTime = client.EndTime; log.UserQuantity = userQuantity; } else { years = buyUserYears; log.BeginTime = client.EndTime; log.EndTime = client.EndTime.AddYears(years); log.UserQuantity = client.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; model.SourceType = 1; //购买人数 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.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 }); }