Esempio n. 1
0
        public JsonResult GetCludCardList()
        {
            DatatablesResult<ClubCardVO> result = new DatatablesResult<ClubCardVO>();
            try{
                int start = NullHelper.Convert<int>(Request[Constants.PAGE_START], 0);
                int length = NullHelper.Convert<int>(Request[Constants.PAGE_LENGTH], 10);
                int draw = NullHelper.Convert<int>(Request[Constants.REQ_DRAW], 1);
                string sortOrder = NullHelper.Convert<string>(Request[Constants.SORT_ORDER], "asc");
                int sortIdx = NullHelper.Convert<int>(Request[Constants.SORT_IDX], 0);
                string columnKey = string.Format(Constants.SORT_NAME, sortIdx);
                string sortName = NullHelper.Convert<string>(Request[columnKey], "ClubcardNO");

                string cardno = NullHelper.Convert<string>(Request["ClubcardNO"], "");
                int cardtype = NullHelper.Convert<int>(Request["ClubcardType"], -1);
                string custName = NullHelper.Convert<string>(Request["CustomerName"], "");
                string mobileNo = NullHelper.Convert<string>(Request["MobileNo"], "");
                int cardstatus = NullHelper.Convert<int>(Request["CardStatus"], -1);
                string storename = NullHelper.Convert<string>(Request["SaleCardStore"], "");

                if(sortName=="MobileNo"||sortName=="CardStatusDesc")
                {
                    sortName="ClubcardNO";
                }

                ClubCardTypeMgm clucardbMgm = new ClubCardTypeMgm();
                ClubCardTypeVO clubcardtype = clucardbMgm.GetCardTypeByID(cardtype);
                IClubCardMgm clubcardMgm = new ClubCardMgm();

                ClubCardQueryEntity filter = new ClubCardQueryEntity()
                {
                    Start = start, Length = length, SortOrder= sortOrder,SortName=sortName, ClubCardNo = cardno,
                    ClubCardTypeID = cardtype,ClubCardTypeName ="", MobileNo=mobileNo, Name=custName,
                    StoreName = storename,CardStatus = cardstatus
                };

                var list = clubcardMgm.GetClubCards(filter);

                int recordsTotal = clubcardMgm.GetClubCardRecordCount(filter);
                list.ForEach(i => i.MobileNo = new CustomerMgm().GetCustomerByID(i.CustomerID).MobileNO);
                foreach (var item in list)
                {
                    item.DT_RowId = item.ClubCardID.ToString();

                    switch(item.CardStatus)
                    {
                        case (int)ClubCardStatus.OpenCard: item.CardStatusDesc = "已开卡";
                            break;
                        case (int)ClubCardStatus.Froze: item.CardStatusDesc = "已冻结";
                            break;
                        case (int)ClubCardStatus.ReportLoss: item.CardStatusDesc = "已挂失";
                            break;
                        case (int)ClubCardStatus.LogOff: item.CardStatusDesc = "已注销";
                            break;
                        case (int)ClubCardStatus.Expire: item.CardStatusDesc = "已过期";
                            break;
                    }
                    item.Operation = " <div class='btn-group'><button onclick='ClubCard.Operation("
                        + item.DT_RowId + ")' class='btn blue dropdown-toggle' type='button' data-toggle='dropdown'>操作 <i class='fa fa-angle-down'></i></button> <ul class='dropdown-menu pull-right' role='menu'><li><a href='" + @Url.Action("ClubCardDetails", "ClubCard") + "?type=card&id=" + item.DT_RowId + "'>查看</a></li><li><a href='#'>套餐余额</a></li><li><a href='" + @Url.Action("ResetPassword", "ClubCard") + "?id=" + item.DT_RowId + "'>修改密码</a></li><li class='divider'></li><li><a href='" + @Url.Action("SetCardStatus", "ClubCard") + "?id=" + item.DT_RowId + "'>挂失/冻结</a></li>{0}<li><a href='" + @Url.Action("Index", "Recharge") + "?id=" + item.DT_RowId + "'>会员充值</a></li> <li><a href=''>会员消费</a></li><li><a href=''>已完结套餐查询</a></li></ul></div>";
                    string strChangeno = "<li><a href='javascript:;' onclick='alert(\"该会员卡不处于挂失状态,不能补办会员卡\")' >补办会员卡</a></li>";
                    if (item.CardStatus == 1)
                    {

                        strChangeno = "<li><a href='" + @Url.Action("ChangeCardNo", "ClubCard") + "?id=" + item.DT_RowId + "'>补办会员卡</a></li>";
                    }
                    item.Operation = string.Format(item.Operation, strChangeno);
                }

                result.draw = draw;
                result.recordsTotal = recordsTotal;
                result.recordsFiltered = recordsTotal;
                result.data = list;
             }
            catch (Exception ex)
            {
                result.data = new List<ClubCardVO>();
                LogHandler.Error(ex.Message.ToString());
                result.error = ex.ToString();
            }

            return Json(result, JsonRequestBehavior.AllowGet);
        }