|
@@ -13,13 +13,16 @@ using JiaZhiQuan.Common.Models.PO;
|
|
using NPOI.XWPF.UserModel;
|
|
using NPOI.XWPF.UserModel;
|
|
using CSRedis;
|
|
using CSRedis;
|
|
|
|
|
|
-namespace JiaZhiQuan.Common {
|
|
|
|
- public static partial class RepositoryExtension {
|
|
|
|
|
|
+namespace JiaZhiQuan.Common
|
|
|
|
+{
|
|
|
|
+ public static partial class RepositoryExtension
|
|
|
|
+ {
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 首次完善资料至100%
|
|
/// 首次完善资料至100%
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- private static async Task CompleteSelfDataTask(DbRESTFulRepository repository, long userId, DateTime completeTime) {
|
|
|
|
|
|
+ private static async Task CompleteSelfDataTask(DbRESTFulRepository repository, long userId, DateTime completeTime)
|
|
|
|
+ {
|
|
//插入并更新
|
|
//插入并更新
|
|
OnceTaskLog onceTaskLog = new OnceTaskLog() { userId = userId, completeSelfDataTime = completeTime, now = DateTime.Now };
|
|
OnceTaskLog onceTaskLog = new OnceTaskLog() { userId = userId, completeSelfDataTime = completeTime, now = DateTime.Now };
|
|
await repository.QuerySingleOrDefaultAsync<dynamic>(@$" insert into n_user_grow_once_task_log
|
|
await repository.QuerySingleOrDefaultAsync<dynamic>(@$" insert into n_user_grow_once_task_log
|
|
@@ -30,7 +33,8 @@ namespace JiaZhiQuan.Common {
|
|
/// 首次完成实名认证
|
|
/// 首次完成实名认证
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- private static async Task RealNameAuth(DbRESTFulRepository repository, long userId, DateTime completeTime) {
|
|
|
|
|
|
+ private static async Task RealNameAuth(DbRESTFulRepository repository, long userId, DateTime completeTime)
|
|
|
|
+ {
|
|
OnceTaskLog onceTaskLog = new OnceTaskLog() { userId = userId, realNameAuthTime = completeTime, now = DateTime.Now };
|
|
OnceTaskLog onceTaskLog = new OnceTaskLog() { userId = userId, realNameAuthTime = completeTime, now = DateTime.Now };
|
|
await repository.QuerySingleOrDefaultAsync<dynamic>(@$" insert into n_user_grow_once_task_log
|
|
await repository.QuerySingleOrDefaultAsync<dynamic>(@$" insert into n_user_grow_once_task_log
|
|
(userId,realNameAuthTime,createAt,updateAt) values(@userId,@realNameAuthTime,@now,@now)
|
|
(userId,realNameAuthTime,createAt,updateAt) values(@userId,@realNameAuthTime,@now,@now)
|
|
@@ -40,7 +44,8 @@ namespace JiaZhiQuan.Common {
|
|
/// 首次通过创作者认证或优质创作者认证
|
|
/// 首次通过创作者认证或优质创作者认证
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- private static async Task AuthorAuth(DbRESTFulRepository repository, long userId, DateTime completeTime) {
|
|
|
|
|
|
+ private static async Task AuthorAuth(DbRESTFulRepository repository, long userId, DateTime completeTime)
|
|
|
|
+ {
|
|
OnceTaskLog onceTaskLog = new OnceTaskLog() { userId = userId, authorAuthTime = completeTime, now = DateTime.Now };
|
|
OnceTaskLog onceTaskLog = new OnceTaskLog() { userId = userId, authorAuthTime = completeTime, now = DateTime.Now };
|
|
await repository.QuerySingleOrDefaultAsync<dynamic>(@$" insert into n_user_grow_once_task_log
|
|
await repository.QuerySingleOrDefaultAsync<dynamic>(@$" insert into n_user_grow_once_task_log
|
|
(userId,authorAuthTime,createAt,updateAt) values(@userId,@authorAuthTime,@now,@now)
|
|
(userId,authorAuthTime,createAt,updateAt) values(@userId,@authorAuthTime,@now,@now)
|
|
@@ -50,7 +55,8 @@ namespace JiaZhiQuan.Common {
|
|
/// 申请提现一次
|
|
/// 申请提现一次
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- private static async Task Withdrawal(DbRESTFulRepository repository, long userId, DateTime completeTime) {
|
|
|
|
|
|
+ private static async Task Withdrawal(DbRESTFulRepository repository, long userId, DateTime completeTime)
|
|
|
|
+ {
|
|
string objStr = "withdrawalTime";
|
|
string objStr = "withdrawalTime";
|
|
//插入并更新,看看这种写法有没有问题。
|
|
//插入并更新,看看这种写法有没有问题。
|
|
OnceTaskLog onceTaskLog = new OnceTaskLog() { userId = userId, withdrawalTime = completeTime, now = DateTime.Now };
|
|
OnceTaskLog onceTaskLog = new OnceTaskLog() { userId = userId, withdrawalTime = completeTime, now = DateTime.Now };
|
|
@@ -59,13 +65,15 @@ namespace JiaZhiQuan.Common {
|
|
ON DUPLICATE KEY UPDATE {objStr}= @{objStr} ,updateAt=@now ", onceTaskLog);
|
|
ON DUPLICATE KEY UPDATE {objStr}= @{objStr} ,updateAt=@now ", onceTaskLog);
|
|
}
|
|
}
|
|
|
|
|
|
- public static async Task<TaskCompleteResult> DoOnceTask(this DbRESTFulRepository repository, long userId, Dictionary<string,object> data,
|
|
|
|
- TaskEvent taskEvent, Producer producer, RedisCacheProvider redis) {
|
|
|
|
- using var redisLock = redis.Lock($"{userId}_{(int)taskEvent}",1);
|
|
|
|
|
|
+ public static async Task<TaskCompleteResult> DoOnceTask(this DbRESTFulRepository repository, long userId, Dictionary<string, object> data,
|
|
|
|
+ TaskEvent taskEvent, Producer producer, RedisCacheProvider redis)
|
|
|
|
+ {
|
|
|
|
+ using var redisLock = redis.Lock($"{userId}_{(int)taskEvent}", 1);
|
|
if (redisLock == null) return new TaskCompleteResult { isComplete = false };
|
|
if (redisLock == null) return new TaskCompleteResult { isComplete = false };
|
|
- if (await repository.OnceTaskCheckComplete(userId, taskEvent)) {
|
|
|
|
|
|
+ if (await repository.OnceTaskCheckComplete(userId, taskEvent))
|
|
|
|
+ {
|
|
//LoggerManager.Logger.Info($"一次性任务{taskEvent}已完成过,请不要重复完成。");
|
|
//LoggerManager.Logger.Info($"一次性任务{taskEvent}已完成过,请不要重复完成。");
|
|
- return new TaskCompleteResult { isComplete=false};
|
|
|
|
|
|
+ return new TaskCompleteResult { isComplete = false };
|
|
}
|
|
}
|
|
DateTime completeTime = ((DateTime?)data?["completeTime"]) ?? DateTime.Now;
|
|
DateTime completeTime = ((DateTime?)data?["completeTime"]) ?? DateTime.Now;
|
|
//加经验
|
|
//加经验
|
|
@@ -74,7 +82,8 @@ namespace JiaZhiQuan.Common {
|
|
var res = await UserAddExperience(repository, userId, taskInfo, producer);
|
|
var res = await UserAddExperience(repository, userId, taskInfo, producer);
|
|
if (!res) return new TaskCompleteResult { isComplete = false };
|
|
if (!res) return new TaskCompleteResult { isComplete = false };
|
|
//任务完成
|
|
//任务完成
|
|
- switch (taskEvent) {
|
|
|
|
|
|
+ switch (taskEvent)
|
|
|
|
+ {
|
|
case TaskEvent.CompleteSelfData:
|
|
case TaskEvent.CompleteSelfData:
|
|
await CompleteSelfDataTask(repository, userId, completeTime);
|
|
await CompleteSelfDataTask(repository, userId, completeTime);
|
|
break;
|
|
break;
|
|
@@ -93,11 +102,13 @@ namespace JiaZhiQuan.Common {
|
|
}
|
|
}
|
|
|
|
|
|
public static async Task<bool> OnceTaskCheckComplete(
|
|
public static async Task<bool> OnceTaskCheckComplete(
|
|
- this DbRESTFulRepository repository, long userId, TaskEvent taskEvent) {
|
|
|
|
|
|
+ this DbRESTFulRepository repository, long userId, TaskEvent taskEvent)
|
|
|
|
+ {
|
|
OnceTaskLog onceTaskLog = await repository.QuerySingleOrDefaultAsync<OnceTaskLog>
|
|
OnceTaskLog onceTaskLog = await repository.QuerySingleOrDefaultAsync<OnceTaskLog>
|
|
(@$"select userId,completeSelfDataTime,realNameAuthTime,authorAuthTime,withdrawalTime
|
|
(@$"select userId,completeSelfDataTime,realNameAuthTime,authorAuthTime,withdrawalTime
|
|
from n_user_grow_once_task_log where userId={userId}");
|
|
from n_user_grow_once_task_log where userId={userId}");
|
|
- return taskEvent switch {
|
|
|
|
|
|
+ return taskEvent switch
|
|
|
|
+ {
|
|
TaskEvent.CompleteSelfData => CheckTimeComplete(onceTaskLog?.completeSelfDataTime),
|
|
TaskEvent.CompleteSelfData => CheckTimeComplete(onceTaskLog?.completeSelfDataTime),
|
|
TaskEvent.RealNameAuth => CheckTimeComplete(onceTaskLog?.realNameAuthTime),
|
|
TaskEvent.RealNameAuth => CheckTimeComplete(onceTaskLog?.realNameAuthTime),
|
|
TaskEvent.AuthorAuth => CheckTimeComplete(onceTaskLog?.authorAuthTime),
|
|
TaskEvent.AuthorAuth => CheckTimeComplete(onceTaskLog?.authorAuthTime),
|
|
@@ -108,7 +119,8 @@ namespace JiaZhiQuan.Common {
|
|
|
|
|
|
//公司成立时间
|
|
//公司成立时间
|
|
public static readonly DateTime minTime = DateTime.Parse("2020-01-01");
|
|
public static readonly DateTime minTime = DateTime.Parse("2020-01-01");
|
|
- public static bool CheckTimeComplete(DateTime? completeTime) {
|
|
|
|
|
|
+ public static bool CheckTimeComplete(DateTime? completeTime)
|
|
|
|
+ {
|
|
return completeTime != null && completeTime > minTime;
|
|
return completeTime != null && completeTime > minTime;
|
|
}
|
|
}
|
|
}
|
|
}
|