Example #1
0
        public APIResult GetRechangeResult([FromBody] GetRechangeResultArgsModel args)
        {
            if (string.IsNullOrEmpty(args.TradeNo))
            {
                throw new ArgumentNullException("TradeNo");
            }

            var memberId = GetMemberId();
            var rechange = db.Query <MemberTradeForRechange>()
                           .Where(m => m.MemberId == memberId && m.TradeNo == args.TradeNo)
                           .FirstOrDefault();

            if (rechange == null)
            {
                throw new Exception("指定的纪录不存在");
            }
            _logger.LogInformation($"获取到rechange{rechange.Id},状态 {rechange.Status}");

            if (rechange.Status == MemberTradeForRechangeStatus.未完成)
            {
                var result = payProxy.GetPayResult(rechange);
                _logger.LogInformation($"获取到result{result.Xml}");
                //rechange.SetFinish(db, result);
                db.SaveChanges();
            }
            return(Success(rechange));
        }
Example #2
0
        public APIResult GetRechangeResult([FromBody] GetRechangeResultArgsModel args)
        {
            if (string.IsNullOrEmpty(args.TradeNo))
            {
                throw new ArgumentNullException("TradeNo");
            }
            if (args.ShopFlag == null)
            {
                throw new ArgumentNullException("ShopFlag");
            }
            var         memberId    = GetMemberId();
            ShopPayInfo shopPayInfo = shopDb.Query <ShopPayInfo>()
                                      .Where(m => !m.IsDel)
                                      .Where(m => m.ShopFlag == args.ShopFlag)
                                      .FirstOrDefault();

            if (shopPayInfo == null)
            {
                throw new Exception("当前商铺没有设置好支付信息。");
            }
            PayProxyBase payProxy = proxyFactory.GetProxy(shopPayInfo);
            var          rechange = db.Query <MemberTradeForRechange>()
                                    .Where(m => m.MemberId == memberId && m.TradeNo == args.TradeNo)
                                    .FirstOrDefault();

            if (rechange == null)
            {
                throw new Exception("指定的纪录不存在");
            }
            _logger.LogInformation($"获取到rechange{rechange.Id},状态 {rechange.Status}");

            if (rechange.Status == MemberTradeForRechangeStatus.未完成)
            {
                var result = payProxy.GetPayResult(rechange);
                _logger.LogInformation($"获取到result{result.Xml}");
                //rechange.SetFinish(shopDb,db,options, result,_logger);
                db.SaveChanges();
            }
            return(Success(rechange));
        }