Пример #1
0
    public Model.ReturnValue InitData(Model.ReturnValue returnValue)
    {
        int PageIndex = Common.TypeHelper.ObjectToInt(Request["PageIndex"], 0);
        int PageSize  = Common.TypeHelper.ObjectToInt(Request["PageSize"], 10);

        string CheckInputText   = Request["CheckInputText"];
        string SearchOptionText = Request["SearchOptionText"];
        //string StatusOptionText = Request["StatusOptionText"];
        string PrizeOptionText = Request["PrizeOptionText"];
        string OcrOptionText   = Request["OcrOptionText"];
        string StarTimeText    = Request["StarTimeText"];
        string EndTimeText     = Request["EndTimeText"];
        string OrderStatusType = Request["OrderStatusType"];

        string sqlwhere = "";

        if (string.IsNullOrEmpty(CheckInputText) == false && string.IsNullOrEmpty(SearchOptionText) == false)
        {
            sqlwhere += " and " + SearchOptionText + " like '%" + Common.ReplaceErorrSql.StripSQLInjection(CheckInputText) + "%'";
        }
        if (string.IsNullOrEmpty(OrderStatusType) == false && OrderStatusType != "1")
        {
            sqlwhere += " and a.States =" + (OrderStatusType == "2" ? "0" : OrderStatusType == "3" ? "1" : "-1") + "";
        }
        if (string.IsNullOrEmpty(PrizeOptionText) == false)
        {
            sqlwhere += " and a.Jx='" + PrizeOptionText + "'";
        }
        if (string.IsNullOrEmpty(OcrOptionText) == false && Request["GetType"] != "Export")
        {
            if (OcrOptionText == "是")
            {
                sqlwhere += " and ap.note is not null ";
            }
            else
            {
                sqlwhere += " and ap.note is null ";
            }
        }
        if (string.IsNullOrEmpty(StarTimeText) == false)
        {
            sqlwhere += " and a.CreateTime >= '" + StarTimeText + " 00:00:00'";
        }
        if (string.IsNullOrEmpty(EndTimeText) == false)
        {
            sqlwhere += " and a.CreateTime <= '" + EndTimeText + " 23:59:59'";
        }

        if (Request["GetType"] == "Export")
        {
            string ExportData = string.IsNullOrEmpty(Request["ExportData"]) ? "" : Request["ExportData"].TrimEnd(',');

            Common.NPOIHelper.ExportByWeb(OrderDal.GetVueExcelList(sqlwhere, ExportData, "", "OrderInfo", true), "", DateTime.Now.ToString("yyyyMMdd") + ".xlsx");
            return(null);
        }
        else
        {
            DataTable OrderDt = OrderDal.GetList(sqlwhere, PageIndex, PageSize, true);

            #region 查询订单红包是否过期
            if (string.IsNullOrEmpty(Request["IsRefund"]) == false && Request["IsRefund"] == "是")
            {
                OrderDt.Columns.Add("isRefund", typeof(int));//消费者是否退款
                for (int row = 0; row < OrderDt.Rows.Count; row++)
                {
                    string Jx           = OrderDt.Rows[row]["Jx"].ToString();
                    string HbOrderCode  = OrderDt.Rows[row]["HbOrderCode"].ToString();
                    string SearchStatus = Common.SearchRedPack.SearchOrder(HbOrderCode);
                    OrderDt.Rows[row]["isRefund"] = (HbOrderCode.Length > 0 && (SearchStatus == "已退款" || SearchStatus == "发放失败")) ? 1 : 0;
                }
            }
            #endregion

            returnValue.EffectRows  = OrderDal.GetCount(sqlwhere, "", true);//true 左连接小票表   非小票项目可不传
            returnValue.ObjectValue = Common.JsonHelper.DataTableToJson(OrderDt);
        }

        return(returnValue);
    }