Example #1
0
 public ApiMessage SearchDirectChargeTaocans()
 {
     this.IniRequest();
     ApiMessage message = new ApiMessage();
     AgentManagement baseMgt = new AgentManagement(User.Identity.Name);
     if(request["scope"]==null || (request["scope"].ToLower()!="global" && request["scope"].ToLower()!="local"))
     {
         message.Status = "ERROR";
         message.Message = "scope must be global or local and in lower case.";
         return message;
     }
     if (request["sp"] == null || string.IsNullOrEmpty(request["sp"]))
     {
         message.Status = "ERROR";
         message.Message = "Unknow mobile phone sp name";
         return message;
     }
     if (request["province"] == null || string.IsNullOrEmpty(request["province"]))
     {
         message.Status = "ERROR";
         message.Message = "Unknow mobile phone province name";
         return message;
     }
     BitScope scope = BitScope.Global;
     if (request["scope"].Trim().ToLower() == "local") {
         scope = BitScope.Local;
     }
     List<BAgentRoute> tcs = baseMgt.FindTaocans(0,request["sp"],request["province"], scope, true);
     message.Status = "OK";
     message.Item = tcs;
     return message;
 }
Example #2
0
 public ActionResult EditTaocan(int routeId)
 {
     agentMgt = new AgentManagement(User.Identity.GetUserId<int>());
     List<BAgentRoute> routes= agentMgt.FindTaocans(routeId);
     if (routes == null || routes.Count == 0)
     {
         ViewBag.Message = string.Format("编号为 {0} 的路由不存在", routeId);
         return View("Error");
     }
     BAgentRoute route = routes[0];
     EditAgentRouteModel model = new EditAgentRouteModel()
     {
         Id = route.Route.Id,
         AgencyId = route.Route.User_id,
         Discount = route.Route.Discount,
         Enabled = route.Route.Enabled,
         ResouceTaocans = new int[] { route.Route.Resource_taocan_id },
         ResourceId = route.Route.Resource_Id,
         SalePrice=route.Route.Sale_price
     };
     ViewBag.Ruote = route;           
     return View(model);
 }
Example #3
0
        public List<BAgentRoute> FindAvailableAgentRoutes(int agentId=0,int customerId=0,int activityId=0)
        {
            agentId = agentId > 0 ? agentId : CurrentLoginUser.User.Id;
            AgentManagement agentMgr = new AgentManagement(CurrentLoginUser);
            List<BAgentRoute> routes = agentMgr.FindTaocans(0, true);
            List<BAgentRoute> tmp = new List<BAgentRoute>();
            if(activityId==0)
            {
                tmp = routes;
            }else
            {
                using (chargebitEntities db = new chargebitEntities())
                {
                    //List<Resource_taocan> rtaocans = (from t in db.Resource_taocan
                    //                                  join mt in db.Marketing_Activity_Taocan on t.Id equals mt.ResourceTaocanId
                    //                                  where mt.ActivityId == activityId
                    //                                  select t).ToList<Resource_taocan>();

                    List<BActivityTaocan> aTaocans = FindActivityTaocans(activityId, customerId, agentId);

                    int[] rts = (from rt in aTaocans where rt.UsedCount<rt.ATaocan.Quantity select rt.ATaocan.ResourceTaocanId).ToArray<int>();
                    int[] spIds = (from rt in aTaocans where rt.UsedCount < rt.ATaocan.Quantity select rt.Route.Taocan.Taocan.Sp_id).ToArray<int>();
                    tmp = (from t in routes where !rts.Contains(t.Taocan.Taocan.Id) && !spIds.Contains(t.Taocan.Taocan.Sp_id) select t).ToList<BAgentRoute>();
                }
            }
            return tmp;
        }
Example #4
0
        public ActionResult EditTaocan(EditAgentRouteModel model)
        {
            agentMgt = new AgentManagement(User.Identity.GetUserId<int>());
            if(agentMgt.CurrentLoginUser.User.Id!=model.AgencyId)
            {
                ViewBag.Message = "你没有代理此套餐,无法修改套餐信息";
                return View("Error");
            }
            if (ModelState.IsValid)
            {
                try
                {
                    if(agentMgt.UpdateTaocanPrice(model.Id, model.SalePrice,model.Enabled))
                    {
                        return RedirectToAction("Taocan");
                    }else
                    {
                        ViewBag.Message = "更新失败";
                        return View(model);
                    }
                    
                }
                catch (KMBitException ex)
                {
                    ViewBag.Message = ex.Message;
                }catch(Exception eex)
                {
                    ViewBag.Message = eex.Message;
                }
                return View("Error");
            }

            return View(model);
        }
Example #5
0
 // GET: Agent
 public ActionResult Index()
 {
     AgentManagement agentMgt = new AgentManagement(User.Identity.GetUserId<int>());          
     return View(agentMgt.CurrentLoginUser);
 }
Example #6
0
 public ActionResult CreateCustomerActivity(int customerId)
 {
     CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId<int>());
     List<BCustomer> customers = customerMgr.FindCustomers(User.Identity.GetUserId<int>(), customerId, out total);
     if (customers.Count == 0)
     {
         ViewBag.Message = string.Format("编号为:{0}的客户不是你的客户");
         return View("Error");
     }
     AgentManagement agentMgr = new AgentManagement(customerMgr.CurrentLoginUser);
     List<BAgentRoute> routes = agentMgr.FindTaocans(0,true);
     ViewBag.Customer = customers[0];
     ViewBag.Routes = new SelectList((from r in routes select new {Id=r.Route.Id,Name=r.Taocan.Taocan2.Name+" - "+(r.Taocan.Taocan.Sale_price*r.Route.Discount).ToString("0.00")+"元" }),"Id","Name");
     List<DictionaryTemplate> scanTypes = StaticDictionary.GetScanTypeList();
     ViewBag.ScanTypes = new SelectList(from st in scanTypes select new { Id=st.Id,Name=st.Value},"Id","Name");
     CustomerActivityModel model = new CustomerActivityModel() { Id=0,CustomerId=customerId,Enable=true };
     return View(model);
 }
Example #7
0
 public ActionResult ChargeOrders(OrderSearchModel searchModel)
 {
     OrderManagement orderMgt = new OrderManagement(User.Identity.GetUserId<int>());  
     int pageSize = 30;
     DateTime sDate = DateTime.MinValue;
     DateTime eDate = DateTime.MinValue;
     if (!string.IsNullOrEmpty(searchModel.StartTime))
     {
         DateTime.TryParse(searchModel.StartTime, out sDate);
     }
     if (!string.IsNullOrEmpty(searchModel.EndTime))
     {
         DateTime.TryParse(searchModel.EndTime, out eDate);
     }
     long sintDate = sDate != DateTime.MinValue ? DateTimeUtil.ConvertDateTimeToInt(sDate) : 0;
     long eintDate = eDate != DateTime.MinValue ? DateTimeUtil.ConvertDateTimeToInt(eDate) : 0;
     int page = 1;
     if (Request["page"] != null)
     {
         int.TryParse(Request["page"], out page);
     }
     searchModel.Page = page;
     searchModel.AgencyId = User.Identity.GetUserId<int>();
     List<BOrder> orders = orderMgt.FindOrders(searchModel.OrderId != null ? (int)searchModel.OrderId : 0,
                                               searchModel.AgencyId != null ? (int)searchModel.AgencyId : 0,
                                               searchModel.ResourceId != null ? (int)searchModel.ResourceId : 0,
                                               searchModel.ResourceTaocanId != null ? (int)searchModel.ResourceTaocanId : 0,
                                               searchModel.RuoteId != null ? (int)searchModel.RuoteId : 0,
                                               searchModel.SPName, searchModel.MobileNumber,
                                               searchModel.Status,
                                               sintDate,
                                               eintDate,
                                               out total,
                                               pageSize,
                                               searchModel.Page, true);
     PageItemsResult<BOrder> result = new PageItemsResult<BOrder>() { CurrentPage = searchModel.Page, Items = orders, PageSize = pageSize, TotalRecords = total, EnablePaging = true };
     KMBit.Grids.KMGrid<BOrder> grid = new Grids.KMGrid<BOrder>(result);
     BigOrderSearchModel model = new BigOrderSearchModel() { SearchModel = searchModel, OrderGrid = grid };  
     List<BResourceTaocan> taocans = new List<BResourceTaocan>();
     agentMgt = new AgentManagement(orderMgt.CurrentLoginUser);
     List<BAgentRoute> routes = agentMgt.FindTaocans(0);
     taocans = (from r in routes select r.Taocan).ToList<BResourceTaocan>();
     ViewBag.Taocans = new SelectList((from t in taocans select new { Id = t.Taocan.Id, Name = t.Taocan2.Name }), "Id", "Name");
     ViewBag.StatusList = new SelectList((from s in StaticDictionary.GetChargeStatusList() select new { Id = s.Id, Name = s.Value }), "Id", "Name");
     return View(model);
 }
Example #8
0
 public ActionResult Taocan()
 {
     agentMgt = new AgentManagement(User.Identity.GetUserId<int>());
     List<BAgentRoute> routes = agentMgt.FindTaocans(0);
     total = routes.Count();
     PageItemsResult<BAgentRoute> result = new PageItemsResult<BAgentRoute>() { CurrentPage = 1, Items = routes, PageSize = total, TotalRecords = total };
     KMBit.Grids.KMGrid<BAgentRoute> grid = new KMBit.Grids.KMGrid<BAgentRoute>(result);
     return View(grid);
 }