Beispiel #1
0
        /// <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
            });
        }
Beispiel #2
0
        //
        // 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());
        }
Beispiel #3
0
        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
            });
        }
Beispiel #4
0
        /// <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
            });
        }