|
|
@@ -467,14 +467,7 @@ namespace Kitty_Fall.Apis.Business.User
|
|
|
{
|
|
|
// VAS trả "2" (SUCCESS_FOR_THE_FIRST_TIME_REGISTER) khi user đăng ký lần đầu -> vẫn là thành công.
|
|
|
// Đăng ký thẳng (không cần OTP) -> trả kèm danh sách gói để client cập nhật ngay trạng thái thuê bao.
|
|
|
- List<RegInfo> userPackage = await dbContext
|
|
|
- .RegInfos.Where(x => x.Msisdn == msisdn
|
|
|
- && x.Status == true
|
|
|
- && x.Renew == 1
|
|
|
- )
|
|
|
- .OrderByDescending(x => x.RegisterTime)
|
|
|
- .ThenByDescending(x => x.RegisterId)
|
|
|
- .ToListAsync();
|
|
|
+ List<RegInfo> userPackage = await TryLoadActiveRegistrationsAfterSuccessfulCharge(msisdn);
|
|
|
return CommonLogic.BuildResponse(
|
|
|
url,
|
|
|
json,
|
|
|
@@ -579,14 +572,7 @@ namespace Kitty_Fall.Apis.Business.User
|
|
|
{
|
|
|
// VAS trả "2" (SUCCESS_FOR_THE_FIRST_TIME_REGISTER) khi user đăng ký lần đầu -> vẫn là thành công.
|
|
|
// Trả kèm danh sách gói đang dùng để client cập nhật ngay trạng thái thuê bao (không phải gọi lại GetProfileInfo).
|
|
|
- List<RegInfo> userPackage = await dbContext
|
|
|
- .RegInfos.Where(x => x.Msisdn == msisdn
|
|
|
- && x.Status == true
|
|
|
- && x.Renew == 1
|
|
|
- )
|
|
|
- .OrderByDescending(x => x.RegisterTime)
|
|
|
- .ThenByDescending(x => x.RegisterId)
|
|
|
- .ToListAsync();
|
|
|
+ List<RegInfo> userPackage = await TryLoadActiveRegistrationsAfterSuccessfulCharge(msisdn);
|
|
|
return CommonLogic.BuildResponse(
|
|
|
url,
|
|
|
json,
|
|
|
@@ -675,13 +661,7 @@ namespace Kitty_Fall.Apis.Business.User
|
|
|
if (wsRegisterSubQuickResponse.@return.errorCode == CommonErrorCode.Success
|
|
|
|| wsRegisterSubQuickResponse.@return.errorCode == CommonErrorCode.SuccessFirstRegister)
|
|
|
{
|
|
|
- List<RegInfo> userPackage = await dbContext
|
|
|
- .RegInfos.Where(x => x.Msisdn == msisdn
|
|
|
- && x.Status == true
|
|
|
- && x.Renew == 1)
|
|
|
- .OrderByDescending(x => x.RegisterTime)
|
|
|
- .ThenByDescending(x => x.RegisterId)
|
|
|
- .ToListAsync();
|
|
|
+ List<RegInfo> userPackage = await TryLoadActiveRegistrationsAfterSuccessfulCharge(msisdn);
|
|
|
|
|
|
return CommonLogic.BuildResponse(
|
|
|
url,
|
|
|
@@ -1475,6 +1455,29 @@ namespace Kitty_Fall.Apis.Business.User
|
|
|
new BadRequestObjectResult(new { message = Lang.badRequest })
|
|
|
);
|
|
|
}
|
|
|
+ private async Task<List<RegInfo>> TryLoadActiveRegistrationsAfterSuccessfulCharge(string msisdn)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return await dbContext.RegInfos
|
|
|
+ .Where(x => x.Msisdn == msisdn
|
|
|
+ && x.Status == true
|
|
|
+ && x.Renew == 1)
|
|
|
+ .OrderByDescending(x => x.RegisterTime)
|
|
|
+ .ThenByDescending(x => x.RegisterId)
|
|
|
+ .ToListAsync();
|
|
|
+ }
|
|
|
+ catch (Exception exception)
|
|
|
+ {
|
|
|
+ // Charging/registration was already confirmed by VAS. A profile refresh
|
|
|
+ // failure must not turn that completed transaction into a client-visible
|
|
|
+ // failure, which could also encourage a duplicate purchase attempt.
|
|
|
+ log.Warn("VAS registration succeeded, but active package refresh failed. "
|
|
|
+ + "Returning the confirmed success response without regInfos.", exception);
|
|
|
+ return new List<RegInfo>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static object GetHttpSendRequest()
|
|
|
{
|
|
|
return GetHttpSendRequest;
|