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(); } } } }
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; } } } } }
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(); } } } }