コード例 #1
0
        public ActionResult Index(int aid = 0, int storeId = 0, string orderId = "", string storeName = "", string goodsName = "", int orderState = -999, string consignee = "", string phone = "", int sendWay = -999, int groupState = -999, int groupId = 0, string startDate = "", string endDate = "", int pageIndex = 0, int pageSize = 20, string act = "")
        {
            PinGoodsOrderBLL pinGoodsOrderBLL = new PinGoodsOrderBLL();

            if (act == "getNewOrder")
            {
                bool isSuccess = pinGoodsOrderBLL.havingNewOrder(storeId, DateTime.Now.AddSeconds(-10)); //检查是否有新订单(10秒前到现在)

                result.code = isSuccess ? 1 : 0;
                result.msg  = isSuccess ? "存在新订单" : "没有新订单";
                return(Json(result));
            }
            if (aid <= 0 || storeId <= 0)
            {
                return(Content($"参数错误 aid:{aid},storeId:{storeId}"));
            }
            ViewModel <PinGoodsOrder> vm = new ViewModel <PinGoodsOrder>();
            int recordCount = 0;

            vm.DataList = pinGoodsOrderBLL.GetListByCondition(aid, storeId, orderId, storeName, goodsName, orderState, consignee, phone, sendWay, groupState, groupId, startDate, endDate, pageIndex, pageSize, out recordCount);
            if (vm.DataList != null && vm.DataList.Count > 0)
            {
                string          groupIds     = string.Join(",", vm.DataList.Select(s => s.groupId).Distinct());
                List <PinGroup> pinGroupList = PinGroupBLL.SingleModel.GetListByIds(groupIds);

                vm.DataList.ForEach(order =>
                {
                    order.groupInfo = pinGroupList?.FirstOrDefault(f => f.id == order.groupId);
                    if (order.sendway == (int)PinEnums.SendWay.到店自取)
                    {
                        PickPlace place = PickPlaceBLL.SingleModel.GetModel(Convert.ToInt32(order.address));
                        if (place != null)
                        {
                            order.storeName = place.name;
                            order.address   = place.address;
                        }
                        else
                        {
                            order.address = string.Empty;
                        }
                    }
                });
            }
            vm.TotalCount      = recordCount;
            vm.aId             = aid;
            vm.storeId         = storeId;
            ViewBag.OrderId    = orderId;
            ViewBag.StoreName  = storeName;
            ViewBag.goodsName  = goodsName;
            ViewBag.OrderState = orderState;
            ViewBag.Consignee  = consignee;
            ViewBag.Phone      = phone;
            ViewBag.SendWay    = sendWay;
            ViewBag.GroupState = groupState;
            ViewBag.GroupId    = groupId;
            ViewBag.StartDate  = startDate;
            ViewBag.EndDate    = endDate;
            return(View(vm));
        }