public JsonResult GetAgentActionReportsByClientID(string keyword, string startDate, string endDate, int pageIndex, string clientID = "") { var list = AgentsBusiness.GetAgentActionReport(keyword, startDate, endDate, clientID); JsonDictionary.Add("Items", list); return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
/// <summary> /// 客户行为统计 /// </summary> public JsonResult GetAgentActionReports(string keyword, string startDate, string endDate, int type, int pageIndex, string orderBy = "SUM(a.CustomerCount) desc") { int totalCount = 0, pageCount = 0; var list = AgentsBusiness.GetAgentActionReport(keyword, startDate, endDate, type, orderBy, 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 }); }
/// <summary> /// 获取客户详情 /// </summary> public JsonResult GetClientDetail() { var client = ClientBusiness.GetClientDetail(CurrentUser.ClientID); var agent = AgentsBusiness.GetAgentDetail(CurrentUser.AgentID); JsonDictionary.Add("Client", client); JsonDictionary.Add("Agent", agent); JsonDictionary.Add("Days", (agent.EndTime - DateTime.Now).Days); return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
// // GET: /Home/ public ActionResult Index() { if (Session["ClientManager"] == null) { return(Redirect("/Home/Login")); } CloudSalesEntity.Users CurrentUser = (CloudSalesEntity.Users)Session["ClientManager"]; ViewBag.UserCount = OrganizationBusiness.GetUsers(CurrentUser.AgentID).Count; var agent = AgentsBusiness.GetAgentDetail(CurrentUser.AgentID); ViewBag.RemainderDays = (agent.EndTime - DateTime.Now).Days; ViewBag.UserQuantity = agent.UserQuantity; return(View()); }
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 }); }
public JsonResult GetAgentInfo() { Dictionary <string, object> JsonDictionary = new Dictionary <string, object>(); int remainderDays = 0; int authorizeType = 0; if (Session["ClientManager"] != null) { var CurrentUser = (CloudSalesEntity.Users)Session["ClientManager"]; var agent = AgentsBusiness.GetAgentDetail(CurrentUser.AgentID); remainderDays = (agent.EndTime - DateTime.Now).Days; authorizeType = agent.AuthorizeType; } JsonDictionary.Add("remainderDays", remainderDays); JsonDictionary.Add("authorizeType", authorizeType); return(new JsonResult() { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
//明道登录回掉 public ActionResult MDCallBack(string code) { string operateip = string.IsNullOrEmpty(Request.Headers.Get("X-Real-IP")) ? Request.UserHostAddress : Request.Headers["X-Real-IP"]; var user = OauthBusiness.GetMDUser(code); if (user.error_code <= 0) { var model = OrganizationBusiness.GetUserByMDUserID(user.user.id, user.user.project.id, operateip); //已注册云销账户 if (model != null) { //未注销 if (model.Status.Value != 9) { model.MDToken = user.user.token; if (string.IsNullOrEmpty(model.Avatar)) { model.Avatar = user.user.avatar; } Session["ClientManager"] = model; return(Redirect("/Home/Index")); } } else { int error = 0; bool isAdmin = MD.SDK.Entity.App.AppBusiness.IsAppAdmin(user.user.token, user.user.id, out error); if (isAdmin) { bool bl = AgentsBusiness.IsExistsMDProject(user.user.project.id); //明道网络未注册 if (!bl) { int result = 0; Clients clientModel = new Clients(); clientModel.CompanyName = user.user.project.name; clientModel.ContactName = user.user.name; clientModel.MobilePhone = user.user.mobile_phone; var clientid = ClientBusiness.InsertClient(clientModel, "", "", "", out result, user.user.email, user.user.id, user.user.project.id); if (!string.IsNullOrEmpty(clientid)) { var current = OrganizationBusiness.GetUserByMDUserID(user.user.id, user.user.project.id, operateip); current.MDToken = user.user.token; if (string.IsNullOrEmpty(current.Avatar)) { current.Avatar = user.user.avatar; } Session["ClientManager"] = current; return(Redirect("/Home/Index")); } } else { int result = 0; var current = OrganizationBusiness.CreateUser("", "", user.user.name, user.user.mobile_phone, user.user.email, "", "", "", "", "", "", "", "", user.user.id, user.user.project.id, 1, "", out result); if (current != null) { current.MDToken = user.user.token; if (string.IsNullOrEmpty(current.Avatar)) { current.Avatar = user.user.avatar; } Session["ClientManager"] = current; return(Redirect("/Home/Index")); } } } else { return(Redirect("/Home/InfoPage")); } } } return(Redirect("/Home/Login")); }
/// <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; log.Type = buyType; if (serviceType == 1) //赠送 { if (giveType == 1) //赠送人数 { flag = AgentsBusiness.AddClientAgentUserQuantity(client.AgentID, userQuantity); log.BeginTime = agent.EndTime; log.UserQuantity = userQuantity; log.Type = 2; } else//赠送时间 { flag = AgentsBusiness.SetClientAgentEndTime(client.AgentID, DateTime.Parse(endTime)); log.BeginTime = DateTime.Parse(endTime); log.UserQuantity = agent.UserQuantity; log.Type = 3; } } else//购买生成订单 { int remainderMonths = 12;//剩余月份 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.UserQuantity = userQuantity; } else { years = buyUserYears; log.BeginTime = 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 = decimal.Parse((float.Parse(model.RealAmount.ToString()) * remainderYears).ToString("f2")); } 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; } if (flag) { ClientBusiness.InsertClientAuthorizeLog(log); } JsonDictionary.Add("Result", flag?1:0); 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 || total_fee == decimal.Parse("0.01")) { //订单支付及后台客户授权 bool flag = ClientOrderBusiness.PayOrderAndAuthorizeClient(order.OrderID); if (flag) { AgentsBusiness.UpdatetAgentCache(order.AgentID); } } } } } } }