//[HttpPost] //public RestfulResult UnBind(BindingRequest request, int? authuid, UserModel authUser) //{ // request.AuthUser = authUser; // request.AuthUid = authuid.Value; // return new RestfulResult { Data = this._cardDataService.UnBinding(request) }; //} public RestfulResult Detail(GetCardInfoRequest request, int? authuid, UserModel authUser) { request.AuthUser = authUser; request.AuthUid = authuid.Value; return new RestfulResult { Data = this._cardDataService.GetInfo(request) }; }
public ExecuteResult<CardInfoResponse> GetInfo(GetCardInfoRequest request) { return GetInfo(request, null); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="okMessage"></param> /// <returns></returns> private ExecuteResult<CardInfoResponse> GetInfo(GetCardInfoRequest request, string okMessage) { if (request == null || request.AuthUser == null) { return new ExecuteResult<CardInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "参数错误" }; } var entities = _cardRepository.GetListForUserId(request.AuthUser.Id, CardType.YintaiMemberCard, DataStatus.Normal).ToList(); if (entities.Count == 0) { return new ExecuteResult<CardInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "你还没有绑定会员卡,请您先绑定" }; } if (entities.Count > 1) { return new ExecuteResult<CardInfoResponse>(null) { StatusCode = StatusCode.InternalServerError, Message = "服务器开小差了,请您等等再试" }; } var entity = entities[0]; var pointResult = _groupCardService.GetPoint(new GroupCardPointRequest { CardNo = entity.CardNo }); var cardProfile = JsonExtension.FromJson_<CardProfile>(entity.CardProfile); if (pointResult.Success) { var response = new CardInfoResponse { Point = pointResult.Point, CardLvl = cardProfile.Lvl, CardNo = entity.CardNo, CardType = cardProfile.Type, User_Id = entity.User_Id, LastDate = DateTime.Now, Id = entity.Id }; var result = new ExecuteResult<CardInfoResponse>(response); if (!String.IsNullOrEmpty(okMessage)) { result.Message = okMessage; } return result; } return new ExecuteResult<CardInfoResponse>(null) { StatusCode = StatusCode.InternalServerError, Message = String.Concat("查询积点失败,", pointResult.Desc) }; }