Пример #1
0
        //[Authorize]
        public APIResult OnRefund([FromBody] ConglomerationOrderRequestModel input)
        {
            var order = db.ConglomerationOrder.Find(input.ConglomerationOrderId);

            if (order == null)
            {
                return(Error("未找到订单数据"));
            }
            _logger.LogInformation($"退款订单信息:{order.Id}");

            try
            {
                if (!order.ShopId.Equals(input.ShopId))
                {
                    return(Error("订单与商铺不匹配"));
                }
                if (order.Status.Equals(ShopOrderStatus.待成团) || order.Status.Equals(ShopOrderStatus.待自提) || order.Status.Equals(ShopOrderStatus.待配送) || order.Status.Equals(ShopOrderStatus.退款审批))
                {
                    var     shop    = db.Shops.Find(order.ShopId);
                    Refunds refunds = new Refunds(_proxyFactory);
                    var     memberTradeForRechange = db.MemberTradeForRechange.FirstOrDefault(m => m.Status.Equals(MemberTradeForRechangeStatus.成功) && m.ConglomerationOrderId.Equals(order.Id));
                    if (memberTradeForRechange == null)
                    {
                        return(Error("无法找到支付记录"));
                    }
                    var isOk = refunds.RefundAction(new RefundArgsModel()
                    {
                        ShopFlag = shop.Flag, TradeNo = memberTradeForRechange.TradeNo
                    });
                    if (isOk.Status == MemberTradeForRefundStatus.成功)
                    {
                        order.Status = ShopOrderStatus.已退款;
                        db.SaveChanges();
                        return(Success("您的退款申请已提交,银行处理退款中"));
                    }
                    if (isOk.Status == MemberTradeForRefundStatus.退款中)
                    {
                        order.Status = ShopOrderStatus.退款中;
                        db.SaveChanges();
                        return(Success("您的退款申请已提交,银行处理退款中"));
                    }
                }
                order.Status = ShopOrderStatus.退款中;
                return(Error("退款失败请联系管理员"));
            }
            catch (Exception e)
            {
                _logger.LogInformation($"退款订单信息:{e}");
                return(Error(e.Message));
            }
        }
Пример #2
0
        public APIResult NoRefund([FromBody] ConglomerationOrderRequestModel input)
        {
            var order = db.ConglomerationOrder.Find(input.ConglomerationOrderId);

            if (order == null)
            {
                return(Error("未找到订单数据"));
            }
            if (order.Status != ShopOrderStatus.退款审批)
            {
                return(Error("订单状态错误"));
            }

            order.Status = ShopOrderStatus.已完成;
            db.SaveChanges();
            return(Success());
        }