Exemplo n.º 1
0
 public static YemUserProductDto MapToYemUserProductDto(this YemUserProductDto yemUserProductDto)
 {
     return(new YemUserProductDto
     {
         Allocated = yemUserProductDto.Allocated,
         Cellphone = yemUserProductDto.Cellphone,
         CredentialNo = yemUserProductDto.CredentialNo,
         InvestSuccessAmount = yemUserProductDto.InvestSuccessAmount,
         IsLock = yemUserProductDto.IsLock,
         PartitionKey = yemUserProductDto.PartitionKey,
         RowKey = yemUserProductDto.RowKey,
         ETag = yemUserProductDto.ETag,
         Timestamp = yemUserProductDto.Timestamp,
         IsSendTrade = yemUserProductDto.IsSendTrade,
         OrderBatchBookInvestInfos = yemUserProductDto.OrderBatchBookInvestInfos,
         OrderId = yemUserProductDto.OrderId,
         OrderInvestStatus = yemUserProductDto.OrderInvestStatus,
         OrderTime = yemUserProductDto.OrderTime,
         ProductId = yemUserProductDto.ProductId,
         ProductIdentifier = yemUserProductDto.ProductIdentifier,
         PurchaseMoney = yemUserProductDto.PurchaseMoney,
         WaitingBankBackAmount = yemUserProductDto.WaitingBankBackAmount,
         RemainingAmount = yemUserProductDto.RemainingAmount,
         SequenceNo = yemUserProductDto.SequenceNo,
         UserId = yemUserProductDto.UserId,
         UserName = yemUserProductDto.UserName,
         Status = yemUserProductDto.Status,
         CreatedBy = yemUserProductDto.CreatedBy,
         CreatedTime = yemUserProductDto.CreatedTime,
         IsDeleted = yemUserProductDto.IsDeleted,
         UpdatedBy = yemUserProductDto.UpdatedBy,
         UpdatedTime = yemUserProductDto.UpdatedTime
     });
 }
 /// <summary>
 ///     reload
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="yemUserProductDtos"></param>
 private bool CheckOneTableUserInfo(string userId, List <YemUserProductDto> yemUserProductDtos)
 {
     try
     {
         //获取购买订单对象
         YemUserProductDto yemUserProductDto = yemUserProductDtos.FirstOrDefault(p => p.UserId == userId);
         //获取融资金额以及剩余金额
         if (yemUserProductDto == null)
         {
             //记录下来 待修改
             Logger.LoadData(@"CheckOneRedisUserAssetInfo\ErrorInfo.txt", $"{userId}:根据assetid拉取AzureTable数据异常" + DateTime.UtcNow.ToChinaStandardTime());
             return(false);
         }
         //购买-剩余
         long waitAllot = yemUserProductDto.PurchaseMoney - yemUserProductDto.RemainingAmount;
         //用户资产比例
         CloudTable assetUserTable = this.tableClient.GetTableReference(this.loadAppSettings.WriteUserAssetTableName);
         TableQuery <UserAssetRatio> queryAssetUser = new TableQuery <UserAssetRatio>()
                                                      .Where($"PartitionKey eq  '{userId}' and IsDeleted eq false");
         long sellAmount = assetUserTable.ExecuteQuery(queryAssetUser).Sum(x => x.Numerator);
         if (waitAllot != sellAmount)
         {
             //记录下来
             Logger.LoadData(@"CheckOneRedisUserAssetInfo\ErrorInfo.txt", $"{userId}:yuntable中该用户订单总购买金额不等于剩余购买金额加上已经分配金额" + DateTime.UtcNow.ToChinaStandardTime());
             return(false);
         }
         return(true);
     }
     catch (Exception e)
     {
         Logger.LoadData(@"CheckOneRedisUserAssetInfo\Error.txt", $"{userId}:该用户订单发生异常{e.Message}---" + DateTime.UtcNow.ToChinaStandardTime());
         return(false);
     }
 }
Exemplo n.º 3
0
 private static async Task AddYemUserPurchase(CloudTableClient tableClient, YemUserProductDto yemUserProductDto, string writeYemUserProductAzureTable)
 {
     if (yemUserProductDto != null)
     {
         CloudTable yemProductTable = tableClient.GetTableReference(writeYemUserProductAzureTable);
         await yemProductTable.ExecuteAsync(TableOperation.InsertOrReplace(yemUserProductDto));
     }
 }
 /// <summary>
 ///     根据用户id查看用户购买订单是否正确
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="dbNumber"></param>
 /// <param name="redisHelperSpecial"></param>
 /// <returns></returns>
 private bool CheckPurchaseOrderInfo(string userId, int dbNumber, List <YemUserProductDto> yemUserProductDtos, RedisHelperSpecial redisHelperSpecial)
 {
     try
     {
         //获取Asset对象
         //string oldPurchaseOrder = "OldPurchaseOrder";
         //CloudTable assertIdsTable = this.tableClient.GetTableReference(this.loadAppSettings.SearchUserInfoAzureTable);
         //TableQuery<YemUserProductDto> queryYemProduct = new TableQuery<YemUserProductDto>()
         //    .Where($"PartitionKey eq  '{oldPurchaseOrder}'  and IsLock eq false and UserId eq '{userId}'");
         //YemUserProductDto yemUserProductDto = assertIdsTable.ExecuteQuery(queryYemProduct).FirstOrDefault();
         YemUserProductDto yemUserProductDto = yemUserProductDtos.FirstOrDefault(p => p.UserId == userId);
         //获取融资金额以及剩余金额
         if (yemUserProductDto == null)
         {
             //记录下来
             Logger.LoadData(@"CheckOneRedisUserAssetInfo\ErrorInfoUserInfo.txt", $"{userId}:根据userId拉取AzureTable数据异常---" + DateTime.UtcNow.ToChinaStandardTime());
             return(false);
         }
         long purchaseAmount  = yemUserProductDto.PurchaseMoney;
         long remainingAmount = yemUserProductDto.RemainingAmount;
         //再从reedis中拉出所有的资产的下对应
         List <UserAssetRatio> listUserAssetInfos = new RedisHelperSpecial(dbNumber).GetRedisUserAssetRatiosAsync(userId).ToList();
         long sumPurchaseAmount = 0;
         if (listUserAssetInfos.Count > 0)
         {
             sumPurchaseAmount += listUserAssetInfos.Sum(info => info.Capital);
         }
         //最后的节点
         List <UserAssetRatio> listEndUserAssetinfos = redisHelperSpecial.GetRedisUserAssetRatiosAsync(userId).ToList();
         if (listEndUserAssetinfos.Count > 0)
         {
             sumPurchaseAmount += listEndUserAssetinfos.Sum(info => info.Capital);
         }
         if (purchaseAmount - sumPurchaseAmount != remainingAmount)
         {
             //记录下来
             Logger.LoadData(@"CheckOneRedisUserAssetInfo\ErrorInfoUserInfo.txt", $"{userId}:该用户购买订单总购买金额减去所有本金不等于剩余金额" + DateTime.UtcNow.ToChinaStandardTime());
             return(false);
         }
         return(true);
     }
     catch (Exception e)
     {
         Logger.LoadData(@"CheckOneRedisUserAssetInfo\Error.txt", $"{userId}:该资产发生异常{e.Message}");
         return(false);
     }
 }
Exemplo n.º 5
0
        //购买订单还原
        public static async Task <bool> ResetPurchase(CloudTableClient tableClient, string writeYemUserProductAzureTable, YemUserProductDto yemUserProductDto, long currentDealPurchaseAmount)
        {
            try
            {
                YemUserProductDto resetPurchase = yemUserProductDto;
                resetPurchase.RemainingAmount      += currentDealPurchaseAmount;
                resetPurchase.Allocated            -= currentDealPurchaseAmount;
                resetPurchase.Status                = resetPurchase.PurchaseMoney == resetPurchase.Allocated ? PurchaseOrderStatus.AllocationComplete.ToEnumInteger() : PurchaseOrderStatus.AllocationOn.ToEnumInteger();
                resetPurchase.WaitingBankBackAmount = 0;
                resetPurchase.UpdatedTime           = DateTime.UtcNow.ToChinaStandardTime();
                await AddYemUserPurchase(tableClient, yemUserProductDto, writeYemUserProductAzureTable);

                return(true);
            }
            catch (Exception e)
            {
                Logger.LoadData(@"Rollback\Error.txt", e.Message + "----" + e.StackTrace);
                return(false);
            }
        }