Пример #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);
        }
Пример #2
0
        public bool GiveScoreBtpShare(Guid userId, Guid appId, int srore, Guid commodityOrderId, string commodityOrderCode, Jinher.AMP.Sign.Deploy.Enum.ScoringType scoringType, decimal money, int scale, ScoreTypeEnum scoreType)
        {
            bool   result          = false;
            string scoringTypeName = string.Empty;
            //设置积分显示名称
            string bizName = commodityOrderCode;

            if (scoringType == Jinher.AMP.Sign.Deploy.Enum.ScoringType.BtpDistributeSale)
            {
                scoringTypeName = "分销";
                bizName         = "分销佣金" + money + "元(1元=" + scale + "积分)";
            }
            else if (scoringType == Jinher.AMP.Sign.Deploy.Enum.ScoringType.BtpShareSale)
            {
                scoringTypeName = "众销";
                bizName         = "众销佣金" + money + "元(1元=" + scale + "积分)";
            }
            else if (scoringType == Jinher.AMP.Sign.Deploy.Enum.ScoringType.BtpChannelBrokerage)
            {
                scoringTypeName = "渠道";
                bizName         = "渠道佣金" + money + "元(1元=" + scale + "积分)";
            }
            try
            {
                //获取用户账号,那边显示用
                var          jsonr        = CBCSV.GetUserNameAndCode(userId);
                var          userCode     = jsonr.Item2;
                GiveScoreDTO giveScoreDTO = new GiveScoreDTO()
                {
                    Account   = userCode,
                    AppId     = appId,
                    UserId    = userId,
                    BizId     = commodityOrderId,
                    BizName   = bizName,
                    BizType   = Jinher.AMP.Sign.Deploy.Enum.BizType.CustomBtp,
                    Scores    = srore,
                    SubId     = userId,
                    ScoreType = scoringType
                };
                Jinher.AMP.Sign.IBP.Facade.GiveRewardsFacade grFacade = new GiveRewardsFacade();
                grFacade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
                LogHelper.Info(scoringTypeName + string.Format("发放积分GiveScoreBtpShare。giveScoreDTO:{0};scoreType:{1}", JsonHelper.JsonSerializer(giveScoreDTO), scoreType));
                Jinher.AMP.Sign.Deploy.CustomDTO.ReturnInfoDTO signResult = grFacade.GiveScoreBtpShareNew(giveScoreDTO, DateTime.Now, scoreType == ScoreTypeEnum.Currency);
                if (!signResult.IsSuccess)
                {
                    LogHelper.Error(scoringTypeName + string.Format("发放积分失败。giveScoreDTO:{0}", JsonHelper.JsonSerializer(giveScoreDTO)));
                    return(result);
                }
                result = true;
            }
            catch (Exception ex)
            {
                LogHelper.Error(scoringTypeName + string.Format("发放积分异常。userId:{0},appId:{1},srore:{2},commodityOrderId:{3},commodityOrderCode:{4},scoringType:{5},money:{6},scale:{7}", userId, appId, srore, commodityOrderId, commodityOrderCode, (int)scoringType, money, scale), ex);
            }
            return(result);
        }
Пример #3
0
        public bool GiveScoreBtpComment(Guid userId, Guid appId, string bizUrl, Guid commodityOrderId, string commodityOrderCode, Guid reviewId)
        {
            bool result = false;

            try
            {
                //获取用户账号,那边显示用
                var          jsonr        = CBCSV.GetUserNameAndCode(userId);
                var          userCode     = jsonr.Item2;
                GiveScoreDTO giveScoreDTO = new GiveScoreDTO()
                {
                    Account   = userCode,
                    AppId     = appId,
                    UserId    = userId,
                    BizId     = commodityOrderId,
                    BiztId    = reviewId,
                    BizName   = commodityOrderCode,
                    BizType   = Jinher.AMP.Sign.Deploy.Enum.BizType.CustomBtp,
                    BizUrl    = bizUrl,
                    ScoreType = Jinher.AMP.Sign.Deploy.Enum.ScoringType.Comment
                };
                Jinher.AMP.Sign.IBP.Facade.GiveRewardsFacade grFacade = new GiveRewardsFacade();
                grFacade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
                LogHelper.Info(string.Format("评价送积分GiveScoreBtpComment。giveScoreDTO:{0}", JsonHelper.JsonSerializer(giveScoreDTO)));
                Jinher.AMP.Sign.Deploy.CustomDTO.ReturnInfoDTO signResult = grFacade.GiveScoreBtpComment(giveScoreDTO);
                if (!signResult.IsSuccess)
                {
                    LogHelper.Error(string.Format("评价送积分失败。giveScoreDTO:{0}", JsonHelper.JsonSerializer(giveScoreDTO)));
                    return(result);
                }
                result = true;
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("评价送积分异常。userId:{0},appId:{1},bizUrl:{2},commodityOrderId:{3},commodityOrderCode:{4},reviewId:{5}", userId, appId, bizUrl, commodityOrderId, commodityOrderCode, reviewId), ex);
            }
            return(result);
        }
Пример #4
0
        public bool RefundScore(Guid userId, Guid appId, int srore, Guid commodityOrderId, string commodityOrderCode, ScoreTypeEnum type)
        {
            bool result = false;

            try
            {
                //获取用户账号,那边显示用
                var          jsonr        = CBCSV.GetUserNameAndCode(userId);
                var          userCode     = jsonr.Item2;
                GiveScoreDTO giveScoreDTO = new GiveScoreDTO()
                {
                    Account = userCode,
                    AppId   = appId,
                    UserId  = userId,
                    BizId   = commodityOrderId,
                    BizName = commodityOrderCode,
                    BizType = Jinher.AMP.Sign.Deploy.Enum.BizType.CustomBtp,
                    Scores  = srore,
                    SubId   = userId
                };
                Jinher.AMP.Sign.IBP.Facade.GiveRewardsFacade grFacade = new GiveRewardsFacade();
                grFacade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
                LogHelper.Info(string.Format("回退积分GiveScoreBtpBackNew。giveScoreDTO:{0}", JsonHelper.JsonSerializer(giveScoreDTO)));
                Jinher.AMP.Sign.Deploy.CustomDTO.ReturnInfoDTO signResult = grFacade.GiveScoreBtpBackNew(giveScoreDTO, DateTime.Now, type == ScoreTypeEnum.Currency);
                if (!signResult.IsSuccess)
                {
                    LogHelper.Error(string.Format("回退积分失败。giveScoreDTO:{0}", JsonHelper.JsonSerializer(giveScoreDTO)));
                    return(result);
                }
                result = true;
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("回退积分异常。userId:{0},appId:{1},srore:{2},commodityOrderId:{3},commodityOrderCode:{4},type:{5}", userId, appId, srore, commodityOrderId, commodityOrderCode, type), ex);
            }
            return(result);
        }
Пример #5
0
        public bool GiveScoreBtp(CommodityOrder commodityOrder)
        {
            #region
            //bool result = false;
            //if (!commodityOrder.EsAppId.HasValue)
            //{
            //    return result;
            //}
            //string url = string.Format("{0}btp.iuoooo.com/Mobile/ShareMyOrderDetail?appId={1}&type=tuwen&source=share&orderId={2}&SrcType=0", Common.CustomConfig.UrlPrefix, commodityOrder.AppId, commodityOrder.Id);

            ////获取用户账号,那边显示用
            //var jsonr = CBCSV.GetUserNameAndCode(commodityOrder.UserId);
            //var userCode = jsonr.Item2;
            //var dto = new GiveScoreDTO
            //{
            //    Account = userCode,
            //    AppId = commodityOrder.EsAppId.Value,
            //    BizId = commodityOrder.Id,
            //    BizName = "电商",
            //    BiztId = Guid.Empty,
            //    BizType = BizType.CustomBtp,
            //    BizUrl = url,
            //    ScoreType = ScoringType.ShareOrder,
            //    Scores = Convert.ToDouble(commodityOrder.RealPrice),
            //    SubId = commodityOrder.UserId,
            //    UserId = commodityOrder.UserId
            //};
            //try
            //{
            //    Jinher.AMP.Sign.IBP.Facade.GiveRewardsFacade facade = new GiveRewardsFacade();
            //    facade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
            //    LogHelper.Info(string.Format("售后完成加积分GiveScoreBtp。dto:{0}", JsonHelper.JsonSerializer(dto)));
            //    var giveScoreBtpResult = facade.GiveScoreBtp(dto);

            //    if (giveScoreBtpResult == null || !giveScoreBtpResult.IsSuccess)
            //    {
            //        LogHelper.Error(string.Format("售后完成加积分失败。dto:{0}", JsonHelper.JsonSerializer(dto)));
            //        return result;
            //    }
            //    result = true;
            //}
            //catch (Exception ex)
            //{
            //    LogHelper.Error(string.Format("售后完成加积分异常。订单入参:{0}", JsonHelper.JsonSerializer(dto)), ex);
            //}
            //return result;
            #endregion

            #region 售后完成加积分(20170615积分比例版本)
            bool result = false;
            if (!commodityOrder.EsAppId.HasValue)
            {
                return(false);
            }
            try
            {
                Jinher.AMP.Sign.IBP.Facade.GiveRewardsFacade facade = new GiveRewardsFacade
                {
                    ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo()
                };
                //订单商品id集合
                var commodityIds = OrderItem.ObjectSet().Where(t => t.CommodityOrderId == commodityOrder.Id).Select(t => t.CommodityId);
                //订单金额积分比例额度
                decimal sumRefundScoreMoney = 0;
                foreach (var commodityId in commodityIds)
                {
                    var commodity = Commodity.FindByID(commodityId);
                    if (commodity.ScoreScale != null && commodity.ScoreScale > 0)
                    {
                        sumRefundScoreMoney += (decimal)(commodity.ScoreScale * commodity.Price * (decimal)0.01);
                        LogHelper.Info(string.Format("获取商品积分比例commodity.Id:{0},RefundScoreMoney:{1}", commodity.Id, (decimal)(commodity.ScoreScale * commodity.Price * (decimal)0.01)));
                    }
                    else
                    {
                        //获取店铺积分比例
                        Sign.Deploy.CustomDTO.ReturnInfoDTO <ScoreSettingsDTO> sInfoDto = facade.GetScoreSetting(commodityOrder.EsAppId.Value, ScoringType.Product);
                        LogHelper.Info(string.Format("获取店铺积分比例GetScoreSetting:{0},commodityOrder.EsAppId:{1}", JsonHelper.JsonSerializer(sInfoDto), commodityOrder.EsAppId.Value));
                        if (sInfoDto.IsSuccess && sInfoDto.Data != null)
                        {
                            sumRefundScoreMoney += (decimal)(sInfoDto.Data.GiveScores * (double)commodity.Price);
                        }
                    }
                }

                LogHelper.Info(string.Format("订单金额积分比例额度sumRefundScoreMoney:{0}", sumRefundScoreMoney));

                //只有当积分金额>0时 调用保存积分接口
                if (sumRefundScoreMoney > 0)
                {
                    var sumSrore = 0;
                    //获取当时的积分汇率
                    CostScoreInfoDTO scoreCostDto;
                    if (new ScoreSV().GetScoreCost(commodityOrder.EsAppId.Value, out scoreCostDto, commodityOrder.SubTime))
                    {
                        sumSrore = (int)(sumRefundScoreMoney * scoreCostDto.Cost);
                    }

                    string url = string.Format("{0}btp.iuoooo.com/Mobile/ShareMyOrderDetail?appId={1}&type=tuwen&source=share&orderId={2}&SrcType=0", Common.CustomConfig.UrlPrefix, commodityOrder.AppId, commodityOrder.Id);
                    //获取用户账号,那边显示用
                    var jsonr    = CBCSV.GetUserNameAndCode(commodityOrder.UserId);
                    var userCode = jsonr.Item2;
                    var dto      = new GiveScoreDTO
                    {
                        Account   = userCode,
                        AppId     = commodityOrder.EsAppId.Value,
                        BizId     = commodityOrder.Id,
                        BizName   = "电商",
                        BiztId    = Guid.Empty,
                        BizType   = BizType.CustomBtp,
                        BizUrl    = url,
                        ScoreType = ScoringType.Product,
                        Scores    = sumSrore,
                        SubId     = commodityOrder.UserId,
                        UserId    = commodityOrder.UserId
                    };

                    LogHelper.Info(string.Format("售后完成加积分GiveScoreBtp。dto:{0},添加积分sumSrore:{1}", JsonHelper.JsonSerializer(dto), sumSrore));
                    var giveScoreBtpResult = facade.GiveScoreBtpNew(dto);
                    if (giveScoreBtpResult == null || !giveScoreBtpResult.IsSuccess)
                    {
                        LogHelper.Error(string.Format("售后完成加积分失败。dto:{0},giveScoreBtpResult:{1}", JsonHelper.JsonSerializer(dto), JsonHelper.JsonSerializer(giveScoreBtpResult)));
                        return(false);
                    }
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("售后完成加积分异常。"), ex);
            }
            return(result);

            #endregion
        }