diff --git a/Services/Hncore.Pass.Vpn/Service/ProductOrderService.cs b/Services/Hncore.Pass.Vpn/Service/ProductOrderService.cs index 529437f..4b204f4 100644 --- a/Services/Hncore.Pass.Vpn/Service/ProductOrderService.cs +++ b/Services/Hncore.Pass.Vpn/Service/ProductOrderService.cs @@ -529,6 +529,7 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel, var accountError = ""; await accountEntitys.ForEachAsync(async accountEntity => { + var ret = new ApiResult(); if(accountEntity.PackageId.Value == 86 || accountEntity.PackageId.Value == 88){ ret = await m_AgentService.NewAccount(order.Id, accountEntity.PackageId.Value, accountEntity.Account, accountEntity.Pwd, accountEntity.ConnectCount,1,2); @@ -538,10 +539,27 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel, if (ret.Code != ResultCode.C_SUCCESS) { - accountEntity.ChargeStatus = AccountChargeStatus.Exception; - accountEntity.Remark = ret.Message; - await m_ProductAccountService.Update(accountEntity); - accountError += $"{accountEntity.Account}{accountEntity.Remark},"; + var ret_exit = await m_AgentService.Exist(accountEntity.ProductId.ToInt(), accountEntity.Account); + await Task.Delay(50); + if (ret_exit != true){ + if(accountEntity.PackageId.Value == 86 || accountEntity.PackageId.Value == 88){ + ret = await m_AgentService.NewAccount(order.Id, accountEntity.PackageId.Value, accountEntity.Account, accountEntity.Pwd, accountEntity.ConnectCount,1,2); + } else { + ret = await m_AgentService.NewAccount(order.Id, accountEntity.PackageId.Value, accountEntity.Account, accountEntity.Pwd, accountEntity.ConnectCount); + } + if (ret.Code != ResultCode.C_SUCCESS) + { + accountEntity.ChargeStatus = AccountChargeStatus.Exception; + accountEntity.Remark = ret.Message; + await m_ProductAccountService.Update(accountEntity); + accountError += $"{accountEntity.Account}{accountEntity.Remark},"; + } + else if (ret.Data != null && ret.Data.ToString().Has()) + { + accountEntity.Raw = ret.Data.ToString(); + await m_ProductAccountService.Update(accountEntity); + } + } } else if (ret.Data != null && ret.Data.ToString().Has()) { @@ -613,10 +631,22 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel, } if (ret.Code != ResultCode.C_SUCCESS) { - accountEntity.ChargeStatus = AccountChargeStatus.Exception; - accountEntity.Remark = ret.Message; - await m_ProductAccountService.Update(accountEntity); - accountError += $"{accountEntity.Account}{accountEntity.Remark},"; + + var accountInfo = await m_AgentService.GetOriginAccountInfo(accountEntity.ProductId.ToInt(), accountEntity.Account); + if(accountEntity.EndTime > accountInfo.Data.RealEndTime.AddMinutes(1)){ + if (order.PackageId == 86){ + ret = await m_AgentService.ReNewAccount(order.Id, order.PackageId, account, order.ConnectCount,2); + } else { + ret = await m_AgentService.ReNewAccount(order.Id, order.PackageId, account, order.ConnectCount); + } + if (ret.Code != ResultCode.C_SUCCESS) + { + accountEntity.ChargeStatus = AccountChargeStatus.Exception; + accountEntity.Remark = ret.Message; + await m_ProductAccountService.Update(accountEntity); + accountError += $"{accountEntity.Account}{accountEntity.Remark},"; + } + } } }); if (accountError.Has())