增加Shop API
This commit is contained in:
1 parent
3769193696
commit
5d017740c6
83 files changed
+4451
-696
No files matched your search
@@ -75,8 +75,19 @@ internal sealed class ShopRenewCommandHandler(UnitOfWorkExecutionContext executi
|
||||
if (currentTime > expireBase)
|
||||
expireBase = currentTime;
|
||||
}
|
||||
int newExpireTime = CalculateNewExpireTime(expireBase, request.RenewDuration);
|
||||
|
||||
DateTime newExpireDate;
|
||||
try
|
||||
{
|
||||
newExpireDate = expireBase.AddMonths(request.RenewDuration);
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
throw new AppException("续费时长超出允许范围");
|
||||
}
|
||||
long timestamp = DateHelper.GetUnixTimestampInSeconds(newExpireDate);
|
||||
if (timestamp > int.MaxValue || timestamp < 0)
|
||||
throw new AppException("续费时间超出系统支持范围");
|
||||
int newExpireTime = (int)timestamp;
|
||||
|
||||
int affected = await orm.Update<UserEntity>().Set(a => a.Points, newPoints)
|
||||
.Where(a => a.Id == user.Id && a.Points == user.Points)
|
||||
@@ -94,7 +105,7 @@ internal sealed class ShopRenewCommandHandler(UnitOfWorkExecutionContext executi
|
||||
UserName = userName,
|
||||
UserNick = user.NickName,
|
||||
DeltaPoints = pointsPerMonth,
|
||||
NewPoints = user.Points - (decimal)pointsPerMonth * (i + 1),
|
||||
NewPoints = user.Points - pointsPerMonth * (i + 1),
|
||||
ShopId = shop.ShopId,
|
||||
ShopAccount = shop.ShopAccount,
|
||||
Remark = remark,
|
||||
@@ -127,21 +138,4 @@ internal sealed class ShopRenewCommandHandler(UnitOfWorkExecutionContext executi
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new ShopRenewResponse { ShopId = shopId, UserPoints = newPoints, ExpireTime = newExpireTime };
|
||||
}
|
||||
|
||||
private static int CalculateNewExpireTime(DateTime expireBase, int duration)
|
||||
{
|
||||
DateTime newExpireDate;
|
||||
try
|
||||
{
|
||||
newExpireDate = expireBase.AddMonths(duration);
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
throw new AppException("续费时长超出允许范围");
|
||||
}
|
||||
long timestamp = DateHelper.GetUnixTimestampInSeconds(newExpireDate);
|
||||
if (timestamp > int.MaxValue || timestamp < 0)
|
||||
throw new AppException("续费时间超出系统支持范围");
|
||||
return (int)timestamp;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user