| | |
| | | using Furion.FriendlyException; |
| | | using Furion.Schedule; |
| | | using Microsoft.AspNetCore.Http.HttpResults; |
| | | using SKIT.FlurlHttpClient.Wechat.TenpayV3.Models; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | } |
| | | |
| | | var WeChatTransferOrderRs = new BaseRepository<WeChatTransferOrder>(); |
| | | var OderList = await WeChatTransferOrderRs.AsQueryable().Includes(x=>x.TransferDetailList).Where(x => (x.BatchId != null && x.BatchId != "") || x.BatchStatus == "ACCEPTED" || x.BatchStatus == "PROCESSING").ToListAsync(); |
| | | var OderList = await WeChatTransferOrderRs.AsQueryable().Includes(x=>x.TransferDetailList).Where(x => (x.BatchId != null && x.BatchId != "")&&(x.BatchStatus==null|| x.BatchStatus == "ACCEPTED" || x.BatchStatus == "PROCESSING")).ToListAsync(); |
| | | |
| | | foreach( var o in OderList ) |
| | | { |
| | | var ret = await payServices.TransferBatches(new SKIT.FlurlHttpClient.Wechat.TenpayV3.Models.GetTransferBatchByBatchIdRequest |
| | | var ret = await payServices.TransferBatches(new GetTransferBatchByOutBatchNumberRequest |
| | | { |
| | | BatchId = o.BatchId |
| | | OutBatchNumber = o.OutBatchNumber |
| | | |
| | | |
| | | |
| | | }); |
| | | }); ; |
| | | if(ret != null) |
| | | { |
| | | if(ret.IsSuccessful()) |
| | | { |
| | | |
| | | { |
| | | |
| | | if (ret.TransferBatch.BatchStatus == "FINISHED") |
| | | { |
| | |
| | | foreach (var item in o.TransferDetailList) |
| | | { |
| | | var del =ret.TransferDetailList.Where(x=>x.OutDetailNumber==item.OutDetailNumber).FirstOrDefault(); |
| | | item.DetailStatus = del?.DetailStatus; |
| | | switch (item.DetailStatus) |
| | | if (del != null) |
| | | |
| | | { |
| | | case "FAIL": |
| | | //失败,获取失败原因 |
| | | var retde = await payServices.TransferBatchesDetails(new SKIT.FlurlHttpClient.Wechat.TenpayV3.Models.GetTransferBatchDetailByDetailIdRequest |
| | | { |
| | | BatchId = o.BatchId, |
| | | DetailId = del.DetailId, |
| | | item.DetailStatus = del?.DetailStatus; |
| | | switch (item.DetailStatus) |
| | | { |
| | | case "FAIL": |
| | | //失败,获取失败原因 |
| | | var retde = await payServices.TransferBatchesDetails(new SKIT.FlurlHttpClient.Wechat.TenpayV3.Models.GetTransferBatchDetailByDetailIdRequest |
| | | { |
| | | BatchId = o.BatchId, |
| | | DetailId = del.DetailId, |
| | | |
| | | }); |
| | | }); |
| | | |
| | | item.FailReason = retde?.FailReason; |
| | | break; |
| | | case "SUCCESS": |
| | | item.DetailStatus = "SUCCESS"; |
| | | item.FailReason = retde?.FailReason; |
| | | break; |
| | | case "SUCCESS": |
| | | item.DetailStatus = "SUCCESS"; |
| | | |
| | | break; |
| | | break; |
| | | |
| | | default: |
| | | item.DetailStatus = del?.DetailStatus; |
| | | break; |
| | | default: |
| | | item.DetailStatus = del?.DetailStatus; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | } |
| | | else |
| | | if(ret.TransferBatch.BatchStatus== "PROCESSING") |
| | | { |
| | | o.BatchStatus = ret.TransferBatch.BatchStatus; |
| | | o.UpDataBy = "ExecuteAsync"; |
| | | o.UpDataTime = DateTime.Now; |
| | | o.CloseReason = ret.TransferBatch.CloseReason; |
| | | o.FailAmount = ret.TransferBatch.FailAmount; |
| | | o.FailNum = ret.TransferBatch.FailNumber; |
| | | o.SuccessNum = ret.TransferBatch.SuccessNumber; |
| | | o.SuccessAmount = ret.TransferBatch.SuccessAmount; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //处理失败 |
| | | o.ErrorCode = ret.ErrorCode; |
| | | o.ErrorMsg = ret.ErrorMessage; |
| | | o.UpDataBy = "ExecuteAsync"; |
| | | o.UpDataTime = DateTime.Now; |
| | | |
| | | |
| | | } |
| | | |
| | | await WeChatTransferOrderRs.UpdateRangeAsync(OderList); |
| | | } |
| | | } |
| | | } |