Beispiel #1
0
        public List<BAgentRoute> FindTaocans(int agencyId, string sp, string province, BitScope scope, bool? enable = null)
        {
            if (agencyId <= 0)
            {
                if (CurrentLoginUser != null)
                {
                    agencyId = CurrentLoginUser.User.Id;
                }
            }
            AgentAdminMenagement agentAdminMgt = new AgentAdminMenagement(this.CurrentLoginUser);

            int total = 0;
            List<BAgentRoute> routes = agentAdminMgt.FindRoutes(0, agencyId, 0, 0, out total, enable);
            //根据资源对号码归属省的限制
            routes = (from r in routes where r.Taocan.NumberProvince == null || (r.Taocan.NumberProvince.Name.Contains(province)) select r).ToList<BAgentRoute>();

            List<BAgentRoute> globalRoutes = (from r in routes where r.Taocan.SP == null select r).ToList<BAgentRoute>();
            List<BAgentRoute> spRoutes = new List<BAgentRoute>();
            List<BAgentRoute> returnRoutes = new List<BAgentRoute>();
            if (!string.IsNullOrEmpty(sp))
            {
                spRoutes = (from r in routes where r.Taocan.SP != null && r.Taocan.SP.Name == sp select r).ToList<BAgentRoute>();
            }
            globalRoutes = globalRoutes.Concat<BAgentRoute>(spRoutes).ToList<BAgentRoute>();
            returnRoutes = globalRoutes;
            if (scope == BitScope.Local)
            {
                //本地流量
                returnRoutes = (from r in globalRoutes
                                where
                                 (
                                 r.Taocan.Province != null && r.Taocan.Province.Name.Contains(province))
                                 //||
                                 //(r.Taocan.NumberProvince != null && r.Taocan.NumberProvince.Name.Contains(province)))
                                select r).ToList<BAgentRoute>();
            }
            else if (scope == BitScope.Global)
            {
                returnRoutes = (from r in globalRoutes
                                where
                                 (r.Taocan.Province == null)
                                select r).ToList<BAgentRoute>();
            }

            return returnRoutes;
        }
Beispiel #2
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);
        }
Beispiel #3
0
        /// <summary>
        /// Return the available packages for the gaving mobile phone number
        /// </summary>
        /// <param name="spName">SP Name</param>
        /// <param name="province">The Province the mobile number belongs to</param>
        /// <param name="scope">Global or local bit</param>
        /// <returns></returns>
        public List<BResourceTaocan> SearchResourceTaocans(string spName, string province,BitScope scope)
        {
            List<BResourceTaocan> taocans = new List<BResourceTaocan>();
            using (chargebitEntities db = new chargebitEntities())
            {
                int spId = 0;
                if(!string.IsNullOrEmpty(spName))
                {
                    spId = (from s in db.Sp where s.Name==spName select s.Id).FirstOrDefault<int>();
                }
                int provinceId = 0;
                if(!string.IsNullOrEmpty(province))
                {
                    provinceId = (from p in db.Area where p.Name.Contains(province) select p.Id).FirstOrDefault<int>();
                }

                var tmp = from rta in db.Resource_taocan
                          join r in db.Resource on rta.Resource_id equals r.Id
                          join cu in db.Users on rta.CreatedBy equals cu.Id into lcu
                          from llcu in lcu.DefaultIfEmpty()
                          join uu in db.Users on rta.UpdatedBy equals uu.Id into luu
                          from lluu in luu.DefaultIfEmpty()
                          join city in db.Area on rta.Area_id equals city.Id into lcity
                          from llcity in lcity.DefaultIfEmpty()
                          join sp in db.Sp on rta.Sp_id equals sp.Id into lsp
                          from llsp in lsp.DefaultIfEmpty()
                          join tt in db.Taocan on rta.Taocan_id equals tt.Id
                          where rta.Enabled==true && rta.Sale_price>0 && r.Enabled==true
                          select new BResourceTaocan
                          {
                              Taocan = rta,
                              Taocan2 = tt,
                              CreatedBy = llcu,
                              UpdatedBy = lluu,
                              Province = llcity,
                              SP = llsp,
                              Resource = new BResource() { Resource = r }
                          };

                if(spId>0)
                {
                    tmp = tmp.Where(t => t.Taocan.Sp_id == spId || t.Taocan.Sp_id == 0);
                }else
                {
                    tmp = tmp.Where(t => t.Taocan.Sp_id == 0);
                }

                //全国还是本地流量
                if(scope== BitScope.Local)
                {
                    tmp = tmp.Where(t => t.Taocan.Area_id == provinceId);
                }
                else
                {
                    tmp = tmp.Where(t => t.Taocan.Area_id == 0);
                }

                //限制号码归属地
                if (provinceId > 0)
                {
                    tmp = tmp.Where(t => (t.Taocan.NumberProvinceId == provinceId || t.Taocan.NumberProvinceId==0));
                }

                List<BResourceTaocan> tmpTaocans = tmp.OrderBy(t=>t.Taocan.Quantity).ToList<BResourceTaocan>();
                List<int> ts = (from t in tmpTaocans select t.Taocan.Quantity).Distinct<int>().ToList<int>();
                List<BResourceTaocan> globalTaocans = (from t in tmpTaocans where t.Taocan.Area_id == 0 select t).ToList<BResourceTaocan>();
                List<BResourceTaocan> localTaocans = (from t in tmpTaocans where t.Taocan.Area_id > 0 select t).ToList<BResourceTaocan>();
                foreach (int t in ts)
                {
                    BResourceTaocan st = (from tc in globalTaocans where tc.Taocan.Quantity==t orderby tc.Taocan.Resource_Discount ascending select tc).FirstOrDefault<BResourceTaocan>();
                    BResourceTaocan st2 = (from tc in localTaocans where tc.Taocan.Quantity == t orderby tc.Taocan.Resource_Discount ascending select tc).FirstOrDefault<BResourceTaocan>();
                    if (st != null)
                    {
                        taocans.Add(st);
                    }
                    if (st2 != null)
                    {
                        taocans.Add(st2);
                    }
                }
            }
            return taocans;
        }
Beispiel #4
0
        public List <BAgentRoute> FindTaocans(int agencyId, string sp, string province, BitScope scope, bool?enable = null)
        {
            if (agencyId <= 0)
            {
                if (CurrentLoginUser != null)
                {
                    agencyId = CurrentLoginUser.User.Id;
                }
            }
            AgentAdminMenagement agentAdminMgt = new AgentAdminMenagement(this.CurrentLoginUser);

            int total = 0;
            List <BAgentRoute> routes = agentAdminMgt.FindRoutes(0, agencyId, 0, 0, out total, enable);

            //根据资源对号码归属省的限制
            routes = (from r in routes where r.Taocan.NumberProvince == null || (r.Taocan.NumberProvince.Name.Contains(province)) select r).ToList <BAgentRoute>();

            List <BAgentRoute> globalRoutes = (from r in routes where r.Taocan.SP == null select r).ToList <BAgentRoute>();
            List <BAgentRoute> spRoutes     = new List <BAgentRoute>();
            List <BAgentRoute> returnRoutes = new List <BAgentRoute>();

            if (!string.IsNullOrEmpty(sp))
            {
                spRoutes = (from r in routes where r.Taocan.SP != null && r.Taocan.SP.Name == sp select r).ToList <BAgentRoute>();
            }
            globalRoutes = globalRoutes.Concat <BAgentRoute>(spRoutes).ToList <BAgentRoute>();
            returnRoutes = globalRoutes;
            if (scope == BitScope.Local)
            {
                //本地流量
                returnRoutes = (from r in globalRoutes
                                where
                                (
                                    r.Taocan.Province != null && r.Taocan.Province.Name.Contains(province))
                                //||
                                //(r.Taocan.NumberProvince != null && r.Taocan.NumberProvince.Name.Contains(province)))
                                select r).ToList <BAgentRoute>();
            }
            else if (scope == BitScope.Global)
            {
                returnRoutes = (from r in globalRoutes
                                where
                                (r.Taocan.Province == null)
                                select r).ToList <BAgentRoute>();
            }

            return(returnRoutes);
        }
Beispiel #5
0
        /// <summary>
        /// Return the available packages for the gaving mobile phone number
        /// </summary>
        /// <param name="spName">SP Name</param>
        /// <param name="province">The Province the mobile number belongs to</param>
        /// <param name="scope">Global or local bit</param>
        /// <returns></returns>
        public List <BResourceTaocan> SearchResourceTaocans(string spName, string province, BitScope scope)
        {
            List <BResourceTaocan> taocans = new List <BResourceTaocan>();

            using (chargebitEntities db = new chargebitEntities())
            {
                int spId = 0;
                if (!string.IsNullOrEmpty(spName))
                {
                    spId = (from s in db.Sp where s.Name == spName select s.Id).FirstOrDefault <int>();
                }
                int provinceId = 0;
                if (!string.IsNullOrEmpty(province))
                {
                    provinceId = (from p in db.Area where p.Name.Contains(province) select p.Id).FirstOrDefault <int>();
                }

                var tmp = from rta in db.Resource_taocan
                          join r in db.Resource on rta.Resource_id equals r.Id
                          join cu in db.Users on rta.CreatedBy equals cu.Id into lcu
                          from llcu in lcu.DefaultIfEmpty()
                          join uu in db.Users on rta.UpdatedBy equals uu.Id into luu
                          from lluu in luu.DefaultIfEmpty()
                          join city in db.Area on rta.Area_id equals city.Id into lcity
                          from llcity in lcity.DefaultIfEmpty()
                          join sp in db.Sp on rta.Sp_id equals sp.Id into lsp
                          from llsp in lsp.DefaultIfEmpty()
                          join tt in db.Taocan on rta.Taocan_id equals tt.Id
                          where rta.Enabled == true && rta.Sale_price > 0 && r.Enabled == true
                          select new BResourceTaocan
                {
                    Taocan    = rta,
                    Taocan2   = tt,
                    CreatedBy = llcu,
                    UpdatedBy = lluu,
                    Province  = llcity,
                    SP        = llsp,
                    Resource  = new BResource()
                    {
                        Resource = r
                    }
                };

                if (spId > 0)
                {
                    tmp = tmp.Where(t => t.Taocan.Sp_id == spId || t.Taocan.Sp_id == 0);
                }
                else
                {
                    tmp = tmp.Where(t => t.Taocan.Sp_id == 0);
                }

                //全国还是本地流量
                if (scope == BitScope.Local)
                {
                    tmp = tmp.Where(t => t.Taocan.Area_id == provinceId);
                }
                else
                {
                    tmp = tmp.Where(t => t.Taocan.Area_id == 0);
                }

                //限制号码归属地
                if (provinceId > 0)
                {
                    tmp = tmp.Where(t => (t.Taocan.NumberProvinceId == provinceId || t.Taocan.NumberProvinceId == 0));
                }

                List <BResourceTaocan> tmpTaocans    = tmp.OrderBy(t => t.Taocan.Quantity).ToList <BResourceTaocan>();
                List <int>             ts            = (from t in tmpTaocans select t.Taocan.Quantity).Distinct <int>().ToList <int>();
                List <BResourceTaocan> globalTaocans = (from t in tmpTaocans where t.Taocan.Area_id == 0 select t).ToList <BResourceTaocan>();
                List <BResourceTaocan> localTaocans  = (from t in tmpTaocans where t.Taocan.Area_id > 0 select t).ToList <BResourceTaocan>();
                foreach (int t in ts)
                {
                    BResourceTaocan st  = (from tc in globalTaocans where tc.Taocan.Quantity == t orderby tc.Taocan.Resource_Discount ascending select tc).FirstOrDefault <BResourceTaocan>();
                    BResourceTaocan st2 = (from tc in localTaocans where tc.Taocan.Quantity == t orderby tc.Taocan.Resource_Discount ascending select tc).FirstOrDefault <BResourceTaocan>();
                    if (st != null)
                    {
                        taocans.Add(st);
                    }
                    if (st2 != null)
                    {
                        taocans.Add(st2);
                    }
                }
            }
            return(taocans);
        }