Пример #1
0
        public void Export(int id = 0, int aId = 0, int storeId = 0, int pageIndex = 0, int pageSize = 20, string nickname = "", string u_name = "", string u_phone = "", string number = "")
        {
            DishStore store = DishStoreBLL.SingleModel.GetModelByAid_Id(aId, storeId);

            if (store == null)
            {
                Response.Write("<script>alert('门店不存在');window.opener=null;window.close();</script>");
            }
            int recordCount            = 0;
            ViewModel <DishVipCard> vm = new ViewModel <DishVipCard>();

            vm.DataList = DishVipCardBLL.SingleModel.GetVipCardList(storeId, pageIndex, pageSize, nickname, u_name, u_phone, number, out recordCount);
            string filename = $"表单导出";

            if (vm.DataList != null && vm.DataList.Count > 0)
            {
                DataTable exportTable = new DataTable();
                exportTable = ExportExcelBLL.GetDishVipData(vm.DataList);
                ExcelHelper <DishVipCard> .Out2Excel(exportTable, filename);//导出
            }
            else
            {
                Response.Write("<script>alert('查无数据');window.opener=null;window.close();</script>");
                return;
            }
        }
Пример #2
0
        public void ExportOrder()
        {
            int appId = Context.GetRequestInt("appId", 0);

            if (appId <= 0)
            {
                Response.Write("<script>alert('系统繁忙appid_null');window.opener=null;window.close();</script>");
                return;
            }
            if (dzaccount == null)
            {
                Response.Write("<script>alert('系统繁忙auth_null');window.opener=null;window.close();</script>");
                return;
            }
            var appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel($"id ={appId}");

            if (appAcountRelation == null)
            {
                Response.Write("<script>alert('系统繁忙relation_null');window.opener=null;window.close();</script>");
                return;
            }
            int storeId = Context.GetRequestInt("storeid", -1);

            if (storeId < 0)
            {
                Response.Write("<script>alert('系统繁忙storeId_null');window.opener=null;window.close();</script>");
                return;
            }
            string storeSqlwhere = $"appid={appId}";

            if (storeId > 0)
            {
                storeSqlwhere = $"id={storeId}";
            }
            FootBath storeModel = FootBathBLL.SingleModel.GetModel(storeSqlwhere);

            if (storeModel == null)
            {
                Response.Write("<script>alert('系统繁忙model_null');window.opener=null;window.close();</script>");
                return;
            }
            string startdate = Context.GetRequest("startdate", string.Empty);
            string enddate   = Context.GetRequest("enddate", string.Empty);
            int    orderType = Context.GetRequestInt("orderType", 0);

            if (orderType <= 0)
            {
                Response.Write("<script>alert('系统繁忙orderType_null');window.opener=null;window.close();</script>");
                return;
            }
            if (string.IsNullOrEmpty(startdate) || string.IsNullOrEmpty(enddate))
            {
                Response.Write("<script>alert('请选择导出订单时间段');window.opener=null;window.close();</script>");
                return;
            }
            string filename = $"表单导出-{storeModel.StoreName}-{startdate}至{enddate}";
            List <MySqlParameter> parameters = new List <MySqlParameter>();

            parameters.Add(new MySqlParameter("@startdate", $"{startdate} 00:00:00"));
            parameters.Add(new MySqlParameter("@enddate", $"{enddate} 23:59:59"));
            string sqlwhere = $"aid={storeModel.appId} and getway={orderType} and CreateDate>=@startdate and CreateDate<=@enddate";

            if (storeId > 0)
            {
                sqlwhere = $"aid={storeModel.appId} and StoreId={storeModel.Id} and getway={orderType}";
            }
            List <EntGoodsOrder> orderList = EntGoodsOrderBLL.SingleModel.GetListByParam(sqlwhere, parameters.ToArray());

            if (orderList != null && orderList.Count > 0)
            {
                string          bathIds      = string.Join(",", orderList.Select(s => s.StoreId).Distinct());
                List <FootBath> footBathList = FootBathBLL.SingleModel.GetListByIds(bathIds);

                string            userIds      = string.Join(",", orderList.Select(s => s.UserId).Distinct());
                List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds);

                string orderIds = string.Join(",", orderList.Select(s => s.Id));
                List <EntGoodsCart> entGoodsCartList = EntGoodsCartBLL.SingleModel.GetListByOrderIds(orderIds);

                string          goodsIds     = string.Join(",", entGoodsCartList?.Select(s => s.FoodGoodsId).Distinct());
                List <EntGoods> entGoodsList = EntGoodsBLL.SingleModel.GetListByIds(goodsIds);
                orderList.ForEach(o =>
                {
                    FootBath store = footBathList?.FirstOrDefault(f => f.Id == o.StoreId);
                    if (store != null)
                    {
                        o.storeName = store.StoreName;
                    }
                    C_UserInfo userInfo = userInfoList?.FirstOrDefault(f => f.Id == o.UserId);
                    string sql          = $"select * from viprelation as a left join viplevel as b on a.levelid = b.id where a.uid={o.UserId}";
                    o.vipLevelName      = SqlMySql.ExecuteScalar(dbEnum.MINIAPP.ToString(), CommandType.Text, sql).ToString();//获取会员等级
                    if (userInfo != null)
                    {
                        o.nickName = userInfo.NickName;
                    }
                    //获取购买的商品
                    o.goodsCarts = entGoodsCartList?.Where(w => w.GoodsOrderId == o.Id).ToList();
                    if (o.goodsCarts != null && o.goodsCarts.Count > 0)
                    {
                        o.goodsNames = string.Empty;
                        foreach (var goodsCart in o.goodsCarts)
                        {
                            EntGoods goods = entGoodsList?.FirstOrDefault(f => f.id == goodsCart.FoodGoodsId);
                            if (goods == null)
                            {
                                continue;
                            }
                            if (!string.IsNullOrEmpty(goodsCart.SpecInfo))
                            {
                                o.goodsNames += $"{goods.name}({goodsCart.SpecInfo}),";
                            }
                            else
                            {
                                o.goodsNames += $"{goods.name}";
                            }
                        }
                    }
                });
                DataTable exportTable = new DataTable();
                switch (orderType)
                {
                case (int)multiStoreOrderType.到店自取:
                    exportTable = ExportExcelBLL.GetDaoDianZiquData(orderList);
                    break;

                case (int)multiStoreOrderType.城配送:
                    exportTable = ExportExcelBLL.GetTongChengPeisongData(orderList);
                    break;

                case (int)multiStoreOrderType.快递配送:
                    exportTable = ExportExcelBLL.GetKuaiDiPeisongData(orderList);
                    break;
                }
                ExcelHelper <EntUserForm> .Out2Excel(exportTable, filename);//导出
            }
            else
            {
                Response.Write("<script>alert('查无数据');window.opener=null;window.close();</script>");
                return;
            }
        }