Esempio n. 1
0
        public ApiMessage ExportOrders()
        {
            this.IniRequest();
            ApiMessage message = new ApiMessage();
            int orderId = 0;
            int agencyId = 0;
            int resourceId = 0;
            int resourceTaocanId = 0;
            int status = 0;
            string mobileNumber = null;
            DateTime sDate = DateTime.MinValue;
            DateTime eDate = DateTime.MinValue;
            if (request["OrderId"]!=null)
            {
                int.TryParse(request["OrderId"].ToString(),out orderId);
            }
            if (request["AgencyId"] != null)
            {
                int.TryParse(request["AgencyId"].ToString(), out agencyId);
            }
            if(request["Status"]!=null)
            {
                int.TryParse(request["Status"],out status);
            }
            if (request["ResourceId"] != null)
            {
                int.TryParse(request["ResourceId"].ToString(), out resourceId);
            }
            if (request["ResourceTaocanId"] != null)
            {
                int.TryParse(request["ResourceTaocanId"].ToString(), out resourceTaocanId);
            }
            mobileNumber = request["MobileNumber"];
            if (!string.IsNullOrEmpty(request["StartTime"]))
            {
                DateTime.TryParse(request["StartTime"], out sDate);
            }
            if (!string.IsNullOrEmpty(request["EndTime"]))
            {
                DateTime.TryParse(request["EndTime"], out eDate);
            }
            int total = 0;
            long sintDate = sDate != DateTime.MinValue ? DateTimeUtil.ConvertDateTimeToInt(sDate) : 0;
            long eintDate = eDate != DateTime.MinValue ? DateTimeUtil.ConvertDateTimeToInt(eDate) : 0;
            OrderManagement orderMgr = new OrderManagement(User.Identity.Name);
            List<BOrder> orders = orderMgr.FindOrders(orderId,
                                                      agencyId,
                                                      resourceId,
                                                      resourceTaocanId,
                                                      0,
                                                      null, mobileNumber,
                                                      new int[] { status},
                                                      sintDate,
                                                      eintDate,
                                                      out total,
                                                      0,
                                                      0, false);

            message.Status = "OK";

            string path = request.PhysicalApplicationPath;
            string fileName = orderMgr.CurrentLoginUser.User.Id +"_"+ DateTime.Now.ToString("yyyyMMddHHmm")+".csv";
            string fullPath = System.IO.Path.Combine(path+"\\Temp",fileName);
            FileStream fs = null;
            StreamWriter sw = null;
            try
            {
                fs = new FileStream(fullPath, FileMode.Create);
                sw = new StreamWriter(fs,Encoding.UTF8);
                sw.WriteLine("编号,资源,代理商,手机号,省份,城市,平台成本价,平台售价,代理商代理价,代理商售价,时间,状态");
                foreach (BOrder order in orders)
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append(order.Id.ToString() + ",");
                    builder.Append(order.ReseouceName + ",");
                    builder.Append((order.AgentName != null ? order.AgentName.ToString() : "") + ",");
                    builder.Append(order.MobilePhone + ",");
                    builder.Append((order.MobileProvince != null ? order.MobileProvince : "") + ",");
                    builder.Append((order.MobileCity != null ? order.MobileCity : "") + ",");
                    builder.Append(order.PlatformCostPrice.ToString("0.00") + ",");
                    builder.Append(order.PlatformSalePrice.ToString("0.00") + ",");
                    builder.Append(order.PurchasePrice.ToString("0.00") + ",");
                    builder.Append(order.SalePrice.ToString("0.00") + ",");
                    builder.Append(DateTimeUtil.ConvertToDateTime(order.CreatedTime).ToString("yyyy-MM-dd HH:mm") + ",");
                    builder.Append(order.StatusText != null ? order.StatusText : "");
                    sw.WriteLine(builder.ToString());
                }
            }
            catch(Exception ex)
            {
                logger.Fatal(ex);
            }
            finally
            {
                if(sw!=null)
                {
                    sw.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
            }
            message.Item = "http://"+request.Url.Authority+"/Temp/"+ fileName;
            return message;
        }
Esempio n. 2
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);
 }
Esempio n. 3
0
 public ActionResult OrderDetail(int orderId)
 {
     OrderManagement orderMgt = new OrderManagement(User.Identity.GetUserId<int>());
     if (!orderMgt.CurrentLoginUser.Permission.CHARGE_HISTORY)
     {
         ViewBag.Message = "没有权限查看流量充值记录";
         return View("Error");
     }
     List<BOrder> orders = orderMgt.FindOrders(orderId, 0, 0, 0, 0, null, null, null, 0, 0, out total);
     if(orders==null || orders.Count==0)
     {
         ViewBag.Message = string.Format("编号为:{0}的充值记录不存在",orderId);
         return View("Error");
     }
     return View(orders[0]);
 }
Esempio n. 4
0
        public ActionResult OrderDetail(int orderId)
        {
            OrderManagement orderMgt = new OrderManagement(User.Identity.GetUserId<int>());            
            List<BOrder> orders = orderMgt.FindOrders(orderId, 0, 0, 0, 0, null, null, null, 0, 0, out total);
            if (orders == null || orders.Count == 0)
            {
                ViewBag.Message = string.Format("编号为:{0}的充值记录不存在", orderId);
                return View("Error");
            }

            if(orders[0].AgentId!=orderMgt.CurrentLoginUser.User.Id)
            {
                ViewBag.Message = string.Format("编号为:{0}的充值记录为其他代理商的充值信息,不能查看", orderId);
                return View("Error");
            }

            return View(orders[0]);
        }
Esempio n. 5
0
        public ActionResult ChargeOrders(OrderSearchModel searchModel)
        {
            OrderManagement orderMgt = new OrderManagement(User.Identity.GetUserId<int>());
            agentAdminMgt = new AgentAdminMenagement(orderMgt.CurrentLoginUser);
            resourceMgt = new ResourceManagement(orderMgt.CurrentLoginUser);
            if (!orderMgt.CurrentLoginUser.Permission.CHARGE_HISTORY)
            {
                ViewBag.Message = "没有权限查看流量充值记录";
                return View("Error");
            }
            int pageSize = 40;
            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;
            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<KMBit.Beans.BUser> agencies = agentAdminMgt.FindAgencies(0, null, null, 0, 0, out total, 0, 0, false,null);
            List<BResource> resources = new List<BResource>();
            if(searchModel.AgencyId!=null)
            {
                resources = agentAdminMgt.FindAgentResources((int)searchModel.AgencyId);
            }else
            {
                resources = resourceMgt.FindResources(0,null,0,out total);
            }
            ViewBag.Agencies = new SelectList((from a in agencies select a.User).ToList<Users>(),"Id","Name");
            ViewBag.Resources = new SelectList((from r in resources select r.Resource).ToList<Resource>(), "Id", "Name");

            List<BResourceTaocan> taocans = new List<BResourceTaocan>();
            if(searchModel.ResourceId!=null)
            {
                if(searchModel.AgencyId==null)
                {
                    taocans = resourceMgt.FindResourceTaocans((int)searchModel.ResourceId, 0, false);
                }
                else
                {
                    taocans = agentAdminMgt.FindAgencyResourceTaocans((int)searchModel.AgencyId, (int)searchModel.ResourceId);
                }                
            }
            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);
        }