Esempio n. 1
0
        internal static void ProcessOrderRefundment(RefundFailedRecord refundInfo)
        {
            var refundBill = DistributionQueryService.QueryNormalRefundBill(refundInfo.ApplyformId);

            if (refundBill != null)
            {
                var refundResults = Refund(refundBill, refundInfo.BusinessType);
                if (refundResults.Any(item => item.Success))
                {
                    var purchaserSucceed = refundBill.Purchaser.Success;
                    DistributionProcessService.NormalRefundSuccess(refundBill, refundResults);
                    using (var command = Order.Repository.Factory.CreateCommand()) {
                        command.BeginTransaction();
                        try {
                            var distributionRepository = Order.Repository.Factory.CreateDistributionRepository(command);
                            distributionRepository.UpdateRefundBillForRefundSuccess(refundBill);
                            command.CommitTransaction();
                        } catch (Exception ex) {
                            command.RollbackTransaction();
                            LogService.SaveExceptionLog(ex, "交易分润退款");
                            throw;
                        }
                    }
                    if (!purchaserSucceed && refundBill.Purchaser.Success)
                    {
                        var applyform = ApplyformQueryService.QueryRefundOrScrapApplyform(refundInfo.ApplyformId);
                        var notifier  = new Order.Notify.RefundApplyformNotifier(applyform);
                        notifier.RefundSuccess();
                    }
                }
            }
        }
Esempio n. 2
0
        internal static void ProcessPostponeRefundment(RefundFailedRecord refundInfo)
        {
            var refundBill = DistributionQueryService.QueryPostponeRefundBill(refundInfo.ApplyformId);

            if (refundBill != null)
            {
                var refundResult = Refund(refundInfo.OrderId, refundBill);
                if (refundResult.Success)
                {
                    DistributionProcessService.PostponeRefundSuccess(refundBill, refundResult.RefundTime.Value);
                    using (var command = Order.Repository.Factory.CreateCommand()) {
                        command.BeginTransaction();
                        try {
                            var distributionRepository = Order.Repository.Factory.CreateDistributionRepository(command);
                            distributionRepository.UpdateRefundBillForRefundSuccess(refundBill);
                            command.CommitTransaction();
                        } catch (Exception ex) {
                            command.RollbackTransaction();
                            LogService.SaveExceptionLog(ex, "申请单退款");
                            throw;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        internal static void ProcessTradeRefundemnt(RefundFailedRecord refundInfo)
        {
            //if(refundInfo.BusinessType == RefundBusinessType.PayTimeout) {
            //    var order = OrderQueryService.QueryOrder(refundInfo.OrderId);
            //    if(order != null) {
            //        TradeRefund(order, refundInfo.PayTradeNo);
            //    }
            //    return;
            //}
            var refundBill = DistributionQueryService.QueryNormalRefundBill(refundInfo.ApplyformId);

            if (refundBill != null)
            {
                var refundResult = TradeRefund(refundBill, refundInfo.BusinessType);
                if (refundResult != null && refundResult.Success)
                {
                    DistributionProcessService.NormalRefundSuccess(refundBill, new[] { refundResult });
                    using (var command = Order.Repository.Factory.CreateCommand()) {
                        command.BeginTransaction();
                        try {
                            var distributionRepository = Order.Repository.Factory.CreateDistributionRepository(command);
                            distributionRepository.UpdateRefundBillForRefundSuccess(refundBill);
                            command.CommitTransaction();
                        } catch (Exception ex) {
                            command.RollbackTransaction();
                            LogService.SaveExceptionLog(ex, "交易退款");
                            throw;
                        }
                        var order = OrderQueryService.QueryOrder(refundInfo.OrderId);
                        //发取消出票退款成功通知
                        var notifier = new Order.Notify.OrderNotifier(order);
                        notifier.SendRefundSuccessNotify();
                    }
                }
            }
        }