Exemplo n.º 1
0
        public bool SpendScore(Guid userId, Guid appId, int score, Guid commodityOrderId, string commodityOrderCode)
        {
            bool result = false;

            try
            {
                //获取用户账号,那边显示用
                var             jsonr           = CBCSV.GetUserNameAndCode(userId);
                var             userCode        = jsonr.Item2;
                ConsumeScoreDTO consumeScoreDTO = new ConsumeScoreDTO()
                {
                    ConsumeAccount = userCode,
                    AppId          = appId,
                    UserId         = userId,
                    BizId          = commodityOrderId,
                    BizName        = commodityOrderCode,
                    ConsumeScore   = score,
                    ConsumeTime    = DateTime.Now
                };
                Jinher.AMP.Sign.IBP.Facade.GiveRewardsFacade grFacade = new GiveRewardsFacade();
                grFacade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
                Jinher.AMP.Sign.Deploy.CustomDTO.ReturnInfoDTO <int> signResult = grFacade.ConsumeScoreBtp(consumeScoreDTO);
                if (!signResult.IsSuccess)
                {
                    LogHelper.Error(string.Format("消费积分失败。consumeScoreDTO:{0}", JsonHelper.JsonSerializer(consumeScoreDTO)));
                    return(result);
                }
                result = true;
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("消费积分异常。。userId:{0},appId:{1},score:{2},commodityOrderId:{3},commodityOrderCode:{4}", userId, appId, score, commodityOrderId, commodityOrderCode), ex);
            }
            return(result);
        }
Exemplo n.º 2
0
        public int GiveUserScore(Guid userId, Guid appId)
        {
            int result = 0;

            if (appId == Guid.Empty || userId == Guid.Empty)
            {
                return(result);
            }
            try
            {
                Jinher.AMP.Sign.IBP.Facade.GiveRewardsFacade grFacade = new GiveRewardsFacade();
                grFacade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
                Jinher.AMP.Sign.Deploy.CustomDTO.ReturnInfoDTO <ReturnScoreDTO> signResult = grFacade.QueryCurrentScores(appId, userId);
                //如果用户没有积分,接口返回的IsSuccess是false ,所以我们只判断返回值是不是空
                if (signResult == null || signResult.Data == null)
                {
                    LogHelper.Error(string.Format("获取用户在应用下的积分失败。userId:{0},appId:{1},返回结果:{2}", userId, appId, JsonHelper.JsonSerializer(signResult)));
                    return(result);
                }
                result = signResult.Data.AvailableScore;
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("获取用户在应用下的积分异常。userId:{0},appId:{1}", userId, appId), ex);
            }
            return(result);
        }