zhengyuxuan
2025-03-19 82831a86d529817e51f5b6e3cec636d21cef3c9b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using LifePayment.Domain.Models;
using LifePayment.Domain.Shared;
using Microsoft.Extensions.Logging;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Repositories;
using static LifePayment.Domain.Shared.LifePaymentConstant;
 
namespace LifePayment.Domain
{
    public class AlipayManager : IAlipayManager
    {
        private readonly ILogger<AlipayManager> _logger;
        private readonly IAlipayInterfaceManager _alipayInterfaceManager;
 
        public AlipayManager(ILogger<AlipayManager> logger, IAlipayInterfaceManager alipayInterfaceManager)
        {
            _logger = logger;
            _alipayInterfaceManager = alipayInterfaceManager;
        }
 
        public async Task<WalletSingleApplicationSuspensionPaymentOutput> AlipayTransUniTransferToCard(WalletSingleApplicationSuspensionPaymentInput input, bool isToCard)
        {
            var result = new WalletSingleApplicationSuspensionPaymentOutput() { Stt = LifePaymentConstant.AlipayOrderStatus.支付失败 };
            //var walletMainEntity = _walletMainRepository.Where(r => r.Id == input.WalletMainId).FirstOrDefault();
            //CheckExtensions.IfTrueThrowUserFriendlyException(walletMainEntity == null,
            //                                      "查询支付宝记账本出错");
            //FundAccountBookQueryInput inputQuery = new FundAccountBookQueryInput
            //{
            //    AccountBookId = input.OutAcctNo,
            //    SceneCode = AlipayConstant.SceneCode,
            //    ExtInfo = "{\"agreement_no\":\"" + walletMainEntity.AlipayAgreementNo + "\"}"
 
            //};
            //var queryReusult = await _alipayInterfaceManager.FundAccountBookQuery(inputQuery);
            //CheckExtensions.IfTrueThrowUserFriendlyException(queryReusult == null,
            //                                       "查询支付宝记账本出错");
            //if (queryReusult != null)
            //{
 
            //    CheckExtensions.IfTrueThrowUserFriendlyException(Convert.ToDecimal(queryReusult.AvaliableAmount) < input.TranAmount,
            //                                       "记账本余额不足");
            //}
 
            //try
            //{
            //    FundTransUniTransferInput inputNew = new FundTransUniTransferInput
            //    {
            //        TransAmount = input.TranAmount.ToString(),
            //        ProductCode = "SINGLE_TRANSFER_NO_PWD",
            //        BizScene = "ENTRUST_TRANSFER",
 
            //        OrderTitle = input.UseEx,
            //        Remark = input.UseEx,
            //        PayerInfo = new Participant
            //        {
            //            IdentityType = "ACCOUNT_BOOK_ID",
            //            Identity = input.OutAcctNo,
            //            ExtInfo = "{\"agreement_no\":\"" + walletMainEntity.AlipayAgreementNo + "\"}"
            //        },
            //        BusinessParams = "{\"withdraw_timeliness\":\"" + "T0" + "\"}"
 
            //    };
            //    if (isToCard)
            //    {
            //        inputNew.OutBizNo = input.CnsmrSeqNo;
            //        inputNew.PayeeInfo = new Participant
            //        {
            //            IdentityType = "BANKCARD_ACCOUNT",
            //            Identity = input.InAcctNo,
            //            Name = input.InAcctName,
            //            BankCardExtInfo = new BankcardExtInfo
            //            {
            //                AccountType = "2",
            //                BankCode = input.InAcctBankNode,
            //                InstName = input.InAcctBankName,
            //            },
 
            //        };
            //    }
            //    else
            //    {
            //        inputNew.OutBizNo = input.CnsmrSeqNo;
            //        inputNew.PayeeInfo = new Participant
            //        {
            //            IdentityType = "ALIPAY_LOGON_ID",
            //            Identity = input.InAcctNo,
            //            Name = input.InAcctName,
            //        };
            //    }
            //    var output = await _alipayInterfaceManager.FundTransUniTransfer(inputNew);
            //    if (output != null && output.Code == AlipayResultCode.Success)
            //    {
 
            //        result = new WalletSingleApplicationSuspensionPaymentOutput
            //        {
            //            FrontLogNo = output.OrderId,
            //            InAcctName = input.InAcctName,
            //            InAcctNo = input.InAcctNo,
            //            TranAmount = input.TranAmount.ToString(),
            //            OutAcctNo = input.OutAcctNo,
            //            AlipayStatus = output.Stauts,
            //            ThirdVoucher = output.OutBizNo,
            //            CstInnerFlowNo = output.PayFundOrderId,
            //            InAcctBankName = input.InAcctBankName,
            //            OutAcctName = input.OutAcctName,
            //            HostFlowNo = output.PayFundOrderId,
            //            Stt = output.Stauts
            //        };
            //    }
            //    else
            //    {
            //        result = new WalletSingleApplicationSuspensionPaymentOutput
            //        {
            //            AlipayStatus = LifePaymentConstant.AlipayOrderStatus.支付失败
            //        };
            //    }
            //}
            //catch (Exception ex)
            //{
            //    _logger.LogError(ex, "发起扣款异常");
            //    result = new WalletSingleApplicationSuspensionPaymentOutput
            //    {
            //        AlipayStatus = LifePaymentConstant.AlipayOrderStatus.支付失败
            //    };
            //}
 
            return result;
        }
 
    }
}