Ejemplo n.º 1
0
 /// <summary>
 ///     计算该用户的持有价值
 /// </summary>
 /// <param name="numerator"></param>
 /// <param name="demotr"></param>
 /// <param name="onSellAssetDto"></param>
 /// <returns></returns>
 private long GetUserPrentValue(long numerator, long demotr, OnSellAssetDto onSellAssetDto)
 {
     try
     {
         DateTime dateTime = DateTime.UtcNow.ToChinaStandardTime();
         DateTime useTime  = onSellAssetDto.BillDueDate < dateTime ? onSellAssetDto.BillDueDate : dateTime;
         long     days     = 0;
         if (onSellAssetDto.LastGrowthTime != null)
         {
             days = (useTime.Date - onSellAssetDto.LastGrowthTime.Value.Date).Days;
         }
         long assetPresentValue = onSellAssetDto.PresentValue;
         if (days > 0)
         {
             assetPresentValue = (long)(Math.Pow((1 + (double)600 / 3600000), days) * onSellAssetDto.PresentValue);
         }
         //long assetPresentValue = onSellAssetDto.PresentValue * Math.Pow((1 + 0.06), ((useTime - onSellAssetDto.LastGrowthTime).Value.Days));
         decimal amount = (decimal)assetPresentValue / demotr;
         return((long)(amount * numerator));
     }
     catch (Exception e)
     {
         return(onSellAssetDto.PresentValue);
     }
 }
 /// <summary>
 ///     reload
 /// </summary>
 /// <param name="assetId"></param>
 private bool CheckOneTableAssetInfo(string assetId)
 {
     try
     {
         //获取Asset对象
         CloudTable assertIdsTable = this.tableClient.GetTableReference(this.loadAppSettings.SearchAssetAzureTable);
         TableQuery <OnSellAssetDto> queryOnSellAsset = new TableQuery <OnSellAssetDto>()
                                                        .Where($"RowKey eq '{assetId}' and IsLock eq false"); //
         OnSellAssetDto onSellAssetDto = assertIdsTable.ExecuteQuery(queryOnSellAsset).FirstOrDefault();
         //获取融资金额以及剩余金额
         if (onSellAssetDto == null)
         {
             //记录下来
             Logger.LoadData(@"CheckOneRedisUserAssetInfo\ErrorInfo.txt", $"{assetId}:根据assetid拉取AzureTable数据异常" + DateTime.UtcNow.ToChinaStandardTime());
             return(false);
         }
         //获取所有的该资产的资产用户比例
         CloudTable assetUserTable = this.tableClient.GetTableReference(this.loadAppSettings.WriteAssetUserTableName);
         TableQuery <UserAssetRatio> queryAssetUser = new TableQuery <UserAssetRatio>()
                                                      .Where($"PartitionKey eq  '{assetId}' and IsDeleted eq false");
         long sellAmount = assetUserTable.ExecuteQuery(queryAssetUser).Sum(x => x.Capital);
         if (onSellAssetDto.PresentValue - onSellAssetDto.RemainderTotal != sellAmount)
         {
             //记录下来
             Logger.LoadData(@"CheckOneRedisUserAssetInfo\ErrorInfo.txt", $"{assetId}:yuntable中该资产现有总价值不等于剩余金额与卖出金额之和" + DateTime.UtcNow.ToChinaStandardTime());
             return(false);
         }
         return(true);
     }
     catch (Exception e)
     {
         Logger.LoadData(@"CheckOneRedisUserAssetInfo\Error.txt", $"{assetId}:该资产发生异常{e.Message}---" + DateTime.UtcNow.ToChinaStandardTime());
         return(false);
     }
 }
 /// <summary>
 ///     根据资产id查询一个资产是否正确
 /// </summary>
 /// <param name="asseId"></param>
 /// <param name="reidsHelperSpecial"></param>
 /// <param name="dbNumber"></param>
 /// <returns></returns>
 private bool CheckAssetInfo(string asseId, int dbNumber, RedisHelperSpecial reidsHelperSpecial)
 {
     try
     {
         //获取Asset对象
         CloudTable assertIdsTable = this.tableClient.GetTableReference(this.loadAppSettings.SearchAssetAzureTable);
         TableQuery <OnSellAssetDto> queryOnSellAsset = new TableQuery <OnSellAssetDto>()
                                                        .Where($"RowKey eq '{asseId}' and IsLock eq false"); //
         //queryPurchaseOrder = new TableQuery<YemUserProductDto>()
         //    .Where($"PartitionKey eq '{yemUserPurchase}' and RemainingAmount gt 0 and IsLock eq false");
         OnSellAssetDto onSellAssetDto = assertIdsTable.ExecuteQuery(queryOnSellAsset).FirstOrDefault();
         //获取融资金额以及剩余金额
         if (onSellAssetDto == null)
         {
             //记录下来
             Logger.LoadData(@"CheckOneRedisUserAssetInfo\ErrorInfo.txt", $"{asseId}:根据assetid拉取AzureTable数据异常" + DateTime.UtcNow.ToChinaStandardTime());
             return(false);
         }
         long calculatedAmount = onSellAssetDto.PresentValue;
         long remainAmount     = onSellAssetDto.RemainderTotal;
         //再从redis中拉出所有的资产的下对应
         List <UserAssetRatio> listAssetUserInfos = new RedisHelperSpecial(dbNumber).GetRedisAssetUserRatiosAsync(asseId).ToList();
         long sumSellAmount = 0;
         if (listAssetUserInfos.Count > 0)
         {
             sumSellAmount += listAssetUserInfos.Sum(info => info.Capital);
         }
         //从收尾那边拉出所有的资产比例
         List <UserAssetRatio> listEndAssetUserInfos = reidsHelperSpecial.GetRedisAssetUserRatiosAsync(asseId).ToList();
         if (listEndAssetUserInfos.Count > 0)
         {
             sumSellAmount += listEndAssetUserInfos.Sum(info => info.Capital);
         }
         //List<UserAssetRatio>
         if (calculatedAmount - sumSellAmount != remainAmount)
         {
             //记录下来
             Logger.LoadData(@"CheckOneRedisUserAssetInfo\ErrorInfo.txt", $"{asseId}:该资产剩余金额不等于该资产总融资金额减去该资产下用户购买金额之和" + DateTime.UtcNow.ToChinaStandardTime());
             return(false);
         }
         return(true);
     }
     catch (Exception e)
     {
         Logger.LoadData(@"CheckOneRedisUserAssetInfo\Error.txt", $"{asseId}:该资产发生异常{e.Message}");
         return(false);
     }
 }
Ejemplo n.º 4
0
 public static OnSellAssetDto MapToOnSellAsset(this OnSellAssetDto onSellAssetDto)
 {
     return(new OnSellAssetDto
     {
         AssetCategoryCode = onSellAssetDto.AssetCategoryCode,
         AssetCode = onSellAssetDto.AssetCode,
         AssetName = onSellAssetDto.AssetName,
         AssetProductCategory = onSellAssetDto.AssetProductCategory,
         BillAccrualDate = onSellAssetDto.BillAccrualDate,
         PartitionKey = onSellAssetDto.PartitionKey,
         RowKey = onSellAssetDto.RowKey,
         ETag = onSellAssetDto.ETag,
         Timestamp = onSellAssetDto.Timestamp,
         BillDueDate = onSellAssetDto.BillDueDate,
         BillMoney = onSellAssetDto.BillMoney,
         BillNo = onSellAssetDto.BillNo,
         BillRate = onSellAssetDto.BillRate,
         CalculatedAmount = onSellAssetDto.CalculatedAmount,
         EffectiveValue = onSellAssetDto.EffectiveValue,
         EnterpriseRate = onSellAssetDto.EnterpriseRate,
         FinancierId = onSellAssetDto.FinancierId,
         FinancierName = onSellAssetDto.FinancierName,
         GrowthTime = onSellAssetDto.GrowthTime,
         IsLock = onSellAssetDto.IsLock,
         IsNewStatus = onSellAssetDto.IsNewStatus,
         LastGrowthTime = onSellAssetDto.LastGrowthTime,
         OnSellAssetId = onSellAssetDto.OnSellAssetId,
         PresentValue = onSellAssetDto.PresentValue,
         PriorityLevel = onSellAssetDto.PriorityLevel,
         RaiseStatus = onSellAssetDto.RaiseStatus,
         RemainderTotal = onSellAssetDto.RemainderTotal,
         SellAmount = onSellAssetDto.SellAmount,
         SellOutTime = onSellAssetDto.SellOutTime,
         Status = onSellAssetDto.Status,
         ValueStatus = onSellAssetDto.ValueStatus,
         YemBidIsReported = onSellAssetDto.YemBidIsReported,
         CreatedBy = onSellAssetDto.CreatedBy,
         CreatedTime = onSellAssetDto.CreatedTime,
         IsDeleted = onSellAssetDto.IsDeleted,
         UpdatedBy = onSellAssetDto.UpdatedBy,
         UpdatedTime = onSellAssetDto.UpdatedTime
     });
 }
Ejemplo n.º 5
0
        private async void btn_HandleThings_Click(object sender, EventArgs e)
        {
            //执行数量
            try
            {
                ShowUpdateAssetUserInfo updateAssetUserInfo = new ShowUpdateAssetUserInfo();
                DateTime dtDkTime      = Convert.ToDateTime(this.txb_updateTime.Text.Trim());
                string   tbNameByUser  = ConfigurationManager.AppSettings["AssetUserAssetRatios"];
                string   tbNameByAsset = ConfigurationManager.AppSettings["AssetUserRelation"];
                //获取需要执行的数据
                this.lbl_showmsg.Text         = "正在准备数据......";
                this.btn_HandleThings.Enabled = false;
                List <string>            userInfos = this.txb_handleUserIds.Text.Trim().Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
                List <UserReleaseAmount> listUserReleaseAmounts = userInfos.Select(t => t.Split(',')).Select(userInfo => new UserReleaseAmount {
                    Amount = Convert.ToInt64(userInfo[1]), UserId = userInfo[0]
                }).ToList();
                //List<string> userIds = listUserReleaseAmounts.Select(x => x.UserId).ToList();
                //获取赎回订单
                //List<string> redemOrderIds = new List<string>();
                //修改所有的赎回订单数量 //备份修改之前的所有赎回订单数据
                //int count = 0;
                //List<UserRedemptionInfo> listRedemptionInfos = this.GetUserRedemptionOrders(userIds).ToList();
                //updateAssetUserInfo.RedemptionTotalNums = listRedemptionInfos.Count;
                //this.lbl_showmsg.Text = "开始修改这批用户的所有赎回订单数据,需执行数量为" + listRedemptionInfos.Count;
                //foreach (UserRedemptionInfo itemRedemption in listRedemptionInfos)
                //{
                //    bool redeemResult = await this.UpdateYemRedeemInfo(itemRedemption.UserId, itemRedemption.OrderId, itemRedemption.AlreadyDealtAmount, 0, 0, 1);
                //    if (redeemResult)
                //    {
                //        count = count + 1;
                //    }
                //}
                //updateAssetUserInfo.RedemptionSuccessNums = count;
                //this.lbl_showmsg.Text = "该次修改成功的赎回订单数据为" + count;
                //获取所有的资产数据
                List <OnSellAssetDto> onSellAssetInfos = this.GetOnSellAssetInfos();
                //修改比例关系并且插入数据库 //备份之前的比例关系
                this.lbl_showmsg.Text = "开始修改比例以及插入信息数据......";
                ConcurrentBag <int> concurrentBag = new ConcurrentBag <int>();
                //显示结果
                //Dictionary<string, int> dicInfos = new Dictionary<string, int>();
                int countDo = listUserReleaseAmounts.Count;
                this.txb_UserNums.Text = countDo.ToString();
                ConcurrentBag <UpdateUserAssetRatio> concurrentBagUpdateInfos = new ConcurrentBag <UpdateUserAssetRatio>();
                List <Task> listTasks = new List <Task>();
                for (int i = 0; i < this.threadNums; i++)
                {
                    Task task = Task.Run(async() =>
                    {
                        while (listUserReleaseAmounts.Count > 0)
                        {
                            UserReleaseAmount userReleaseAmount = null;
                            int nums = 0;
                            lock (this.objLock)
                            {
                                if (listUserReleaseAmounts.Count > 0)
                                {
                                    userReleaseAmount = listUserReleaseAmounts[0];
                                    if (userReleaseAmount != null)
                                    {
                                        //dicInfos.Add(userReleaseAmount.UserId, 0); //显示信息
                                        listUserReleaseAmounts.Remove(userReleaseAmount);
                                    }
                                }
                            }
                            if (userReleaseAmount != null)
                            {
                                //执行
                                string userId     = userReleaseAmount.UserId;
                                long redeemAmount = userReleaseAmount.Amount; //赎回金额
                                //拉取所有的用户比例关系
                                List <UserAssetRatio> userAssetRatios = await this.GetSortUserAssetRatios(userId, tbNameByUser);
                                //拉取所有的已经成功的userassetRatioids
                                //List<string> successUserAssetRatioIds = this.redisHelperSpecial.GetRedisSuccessInsertUserAssetRatioIdsAsync(userId);
                                //userAssetRatios.RemoveAll(x => successUserAssetRatioIds.Contains(x.UserAssetRatioId));
                                Logger.LoadData(@"UD_log\logInfo" + Guid.NewGuid().ToGuidString() + ".txt", "需要执行的数量:" + userAssetRatios.Count);
                                foreach (UserAssetRatio userAssetRatio in userAssetRatios)
                                {
                                    if (redeemAmount == 0)
                                    {
                                        break;
                                    }
                                    List <UpdateUserAssetRatioInfos> addUserAssetRatioInfoses = new List <UpdateUserAssetRatioInfos>();
                                    //执行操作
                                    OnSellAssetDto onSellItem = onSellAssetInfos.FirstOrDefault(p => p.OnSellAssetId == userAssetRatio.AssetId);
                                    if (onSellItem == null)
                                    {
                                        continue;
                                    }
                                    long userPresentValue = this.GetUserPrentValue1(userAssetRatio, dtDkTime);
                                    if (userPresentValue > 0)
                                    {
                                        if (redeemAmount >= userPresentValue)
                                        {
                                            redeemAmount -= userPresentValue;
                                            addUserAssetRatioInfoses.Add(new UpdateUserAssetRatioInfos //给新用户
                                            {
                                                UserId                   = userAssetRatio.UserId,
                                                AssetId                  = userAssetRatio.AssetId,
                                                DealAmount               = userPresentValue,
                                                Capital                  = userAssetRatio.Capital,
                                                UserAssetRatioId         = userAssetRatio.UserAssetRatioId,
                                                OriginalUserAssetRatioId = userAssetRatio.OriginalUserAssetRatioId,
                                                Denominator              = onSellItem.PresentValue,
                                                Numerator                = userPresentValue //待确认
                                            });
                                            //修改部分东西
                                            userAssetRatio.IsDeleted   = true;
                                            userAssetRatio.Reserve     = "1";
                                            userAssetRatio.Denominator = onSellItem.PresentValue;
                                            //updateUserAssetRatioInfoses.Add(new ModifyUserAssetRatioRequest
                                            //{
                                            //    AssetId = userAssetRatio.AssetId,
                                            //    Capital = userAssetRatio.Capital,
                                            //    Denominator = onSellItem.PresentValue,
                                            //    Numerator = userAssetRatio.Numerator,
                                            //    IsInvestSuccess = userAssetRatio.IsInvestSuccess,
                                            //    IsNotifyTradingSuccess = userAssetRatio.IsNotifyTradingSuccess,
                                            //    IsReturned = userAssetRatio.IsReturned,
                                            //    Status = userAssetRatio.Status,
                                            //    UserAssetRatioId = userAssetRatio.UserAssetRatioId,
                                            //    UserId = userAssetRatio.UserId,
                                            //    IsDeleted = true,
                                            //    Reserve = "1",
                                            //    OriginalUserAssetRatioId = userAssetRatio.OriginalUserAssetRatioId
                                            //}); //老用户
                                        }
                                        else if (redeemAmount < userPresentValue)
                                        {
                                            //计算赎回本金
                                            long capital = this.GetCapital(redeemAmount, userPresentValue, userAssetRatio.Capital);

                                            addUserAssetRatioInfoses.Add(new UpdateUserAssetRatioInfos //给老用户
                                            {
                                                UserId                   = userAssetRatio.UserId,
                                                AssetId                  = userAssetRatio.AssetId,
                                                DealAmount               = redeemAmount,
                                                Capital                  = capital,
                                                UserAssetRatioId         = userAssetRatio.UserAssetRatioId,
                                                OriginalUserAssetRatioId = userAssetRatio.OriginalUserAssetRatioId,
                                                Denominator              = onSellItem.PresentValue,
                                                Numerator                = redeemAmount      //待确认
                                            });
                                            userAssetRatio.Capital               -= capital; //剩余本金
                                            userAssetRatio.Numerator              = userPresentValue - redeemAmount;
                                            userAssetRatio.Denominator            = onSellItem.PresentValue;
                                            userAssetRatio.Status                 = 2;
                                            userAssetRatio.IsReturned             = false;
                                            userAssetRatio.IsInvestSuccess        = true;
                                            userAssetRatio.IsNotifyTradingSuccess = true;
                                            userAssetRatio.Reserve                = "1";
                                            //updateUserAssetRatioInfoses.Add(new ModifyUserAssetRatioRequest
                                            //{
                                            //    AssetId = userAssetRatio.AssetId,
                                            //    Capital = userAssetRatio.Capital,
                                            //    Denominator = onSellItem.PresentValue,
                                            //    Numerator = userPresentValue - redeemAmount,
                                            //    IsInvestSuccess = true,
                                            //    IsNotifyTradingSuccess = true,
                                            //    IsReturned = false,
                                            //    Status = 2,
                                            //    UserAssetRatioId = userAssetRatio.UserAssetRatioId,
                                            //    UserId = userAssetRatio.UserId,
                                            //    IsDeleted = false,
                                            //    Reserve = "1",
                                            //    OriginalUserAssetRatioId = userAssetRatio.OriginalUserAssetRatioId
                                            //}); //老用户
                                            redeemAmount = 0;
                                        }
                                        //插入数据库及更新 addUserAssetRatioInfoses
                                        //修改Azure Table数据
                                        userAssetRatio.ETag      = DateTime.UtcNow.ToChinaStandardTime().UnixTimestamp().ToString();
                                        userAssetRatio.Timestamp = DateTimeOffset.UtcNow.ToLocalTime();
                                        //修改两张表中的数据 1.用户资产比例
                                        bool result1 = this.UpdateAssetUserRatioInfo(userAssetRatio, tbNameByUser);
                                        //2.资产用户比例
                                        userAssetRatio.PartitionKey = userAssetRatio.AssetId;
                                        userAssetRatio.RowKey       = userAssetRatio.UserId + "_" + userAssetRatio.UserAssetRatioId;
                                        bool result2 = this.UpdateAssetUserRatioInfo(userAssetRatio, tbNameByAsset);
                                        if (result2 && result1)
                                        {
                                            //数据库
                                            //数据库
                                            UpdateUserAssetRatioInfos addUserAssetRationInfo = addUserAssetRatioInfoses.FirstOrDefault(x => x.UserAssetRatioId == userAssetRatio.UserAssetRatioId);
                                            bool result = this.InsertAssetUserRatioInfo(addUserAssetRationInfo);
                                            if (result)
                                            {
                                                lock (this.objLock)
                                                {
                                                    nums = nums + 1;
                                                }
                                                //记下redis
                                                //await this.redisHelperSpecial.SetRedisSuccessInsertUserAssetRatioIdsAsync(userAssetRatio.UserAssetRatioId, userAssetRatio.UserId);
                                            }
                                        }
                                        //foreach (ModifyUserAssetRatioRequest model in updateUserAssetRatioInfoses)
                                        //{
                                        //    //修改比例
                                        //    bool modifyRatioResult = await this.ModifyUserAssetRatiosByDisk(model);
                                        //    if (modifyRatioResult)
                                        //    {
                                        //        //数据库
                                        //        UpdateUserAssetRatioInfos addUserAssetRationInfo = addUserAssetRatioInfoses.FirstOrDefault(x => x.UserAssetRatioId == model.UserAssetRatioId);
                                        //        bool result = this.InsertAssetUserRatioInfo(addUserAssetRationInfo);
                                        //        if (result)
                                        //        {
                                        //            lock (this.objLock)
                                        //            {
                                        //                nums = nums + 1;
                                        //            }
                                        //            //记下redis
                                        //            await this.redisHelperSpecial.SetRedisSuccessInsertUserAssetRatioIdsAsync(model.UserAssetRatioId, model.UserAssetRatioId);
                                        //        }
                                        //    }
                                        //}
                                    }
                                }
                                concurrentBagUpdateInfos.Add(new UpdateUserAssetRatio {
                                    SuccessNums = nums, TotalNums = userAssetRatios.Count, UserId = userId
                                });
                                concurrentBag.Add(0);
                                lock (this.objLock)
                                {
                                    this.txb_SuccessNums.Text = ((Convert.ToInt32(this.txb_SuccessNums.Text) + 1)).ToString();
                                }
                            }
                        }
                    });
                    listTasks.Add(task);
                }
                Task.WaitAll(listTasks.ToArray());
                updateAssetUserInfo.UdpateAssetUserInfos = concurrentBagUpdateInfos.ToList();
                //this.txb_SuccessNums.Text = ((Convert.ToInt32(this.txb_SuccessNums.Text)) + 1).ToString();
                //执行完毕
                //记下日志
                Logger.LoadData(@"UD_log\logInfo" + Guid.NewGuid().ToGuidString() + ".txt", updateAssetUserInfo.ToJson());
                this.btn_HandleThings.Enabled = true;
                this.lbl_showmsg.Text         = "全部执行完毕,请查看执行日志";
            }
            catch (Exception exception)
            {
                this.lbl_showmsg.Text         = "提示:发生一个错误" + exception.Message;
                this.btn_HandleThings.Enabled = true;
                Logger.LoadData(@"UD_Eoor\Error.txt", exception.Message + "-------------------" + exception.StackTrace);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取需要分配的资产、订单
        /// </summary>
        /// <returns></returns>
        private static async Task <List <AllocationTransfer> > GetWaitingAssetAndPurchaseOrderAsync(string maxPurchaseAmount)
        {
            string yemUserPurchase = ConfigurationManager.AppSettings["PurchasePartitionKey"];
            string assetId         = ConfigurationManager.AppSettings["AssetId"];

            Console.WriteLine("创建CloudTable对象");
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["BlobConnectionString"]);
            CloudTableClient    tableClient    = storageAccount.CreateCloudTableClient();

            tableClient.DefaultRequestOptions.RetryPolicy          = new ExponentialRetry(2.Seconds(), 6);
            tableClient.DefaultRequestOptions.MaximumExecutionTime = 2.Minutes();
            tableClient.DefaultRequestOptions.ServerTimeout        = 2.Minutes();

            CloudTable cloudOnSellAssetTable = tableClient.GetTableReference("AssetOnSellAssets");

            TableQuery <OnSellAssetDto> queryOnSellYinPiaoAsset = new TableQuery <OnSellAssetDto>()
                                                                  .Where($"PartitionKey eq 'YinPiao' and RemainderTotal gt 0 and OnSellAssetId eq '{assetId}' and IsLock eq false");
            //根据剩余金额排序
            var onYinPiaoSellAssetDtos = cloudOnSellAssetTable.ExecuteQuery(queryOnSellYinPiaoAsset).OrderByDescending(p => p.RemainderTotal)
                                         .ToList();

            //获取购买信息
            CloudTable cloudPurchaseOrderTable = tableClient.GetTableReference("AssetYEMUserProducts");
            TableQuery <YemUserProductDto> queryPurchaseOrder = new TableQuery <YemUserProductDto>()
                                                                .Where($"PartitionKey eq '{yemUserPurchase}' and RemainingAmount gt 0 and RemainingAmount le {maxPurchaseAmount} and IsLock eq false");

            //根据剩余金额排序,因为购买在循环的时候。是倒序的,所以这里如果是倒序的,则循环的时候则是从小到大
            var yemUserProductDtos = cloudPurchaseOrderTable.ExecuteQuery(queryPurchaseOrder).OrderByDescending(p => p.RemainingAmount).ToList();

            List <AllocationTransfer> allocationTransfers = new List <AllocationTransfer>();

            if (onYinPiaoSellAssetDtos.Any())
            {
                AllocationTransfer allocationTransfer = new AllocationTransfer();
                var remainderTotal = 0L;
                //处理银票类资产
                OnSellAssetDto onSellAssetDto = onYinPiaoSellAssetDtos.FirstOrDefault();
                if (onSellAssetDto != null)
                {
                    allocationTransfer.OnYinPiaoSellAssetDtos.Add(new AllocationOnSellAssetDto
                    {
                        OnSellAssetId  = onSellAssetDto.OnSellAssetId,
                        RemainderTotal = onSellAssetDto.RemainderTotal
                    });
                    remainderTotal = onSellAssetDto.RemainderTotal; //银票的待处理金额
                }
                //找购买
                var userTotal = 0L;
                for (int i = yemUserProductDtos.Count - 1; i >= 0; i--)
                {
                    var yemUserProductItem = yemUserProductDtos[i];
                    userTotal += yemUserProductItem.RemainingAmount;

                    allocationTransfer.YemUserProductDtos.Add(new AllocationYemUserProduct
                    {
                        OrderId = yemUserProductItem.OrderId,
                        UserId  = yemUserProductItem.UserId,
                        WaitingBankBackAmount = yemUserProductItem.WaitingBankBackAmount,
                        RemainingAmount       = yemUserProductItem.RemainingAmount
                    });
                    yemUserProductDtos.Remove(yemUserProductItem);
                    if (remainderTotal <= userTotal)
                    {
                        break;
                    }
                }
                allocationTransfers.Add(allocationTransfer);
            }

            return(await Task.FromResult(allocationTransfers));
        }