CrazyIter_Bin 1 éve
szülő
commit
dfde3a9746

+ 3 - 1
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -234,6 +234,7 @@ namespace TEAMModelOS.SDK
                             school= school,
                             school= school,
                             year = year,
                             year = year,
                             groupId = item.id,
                             groupId = item.id,
+                            groupScope=item.scope,
                             name = name,
                             name = name,
                             picture = picture,
                             picture = picture,
                             lang = lang,
                             lang = lang,
@@ -282,6 +283,7 @@ namespace TEAMModelOS.SDK
             public string school { get; set; }
             public string school { get; set; }
             public int  year { get; set; }
             public int  year { get; set; }
             public string groupId { get; set; }
             public string groupId { get; set; }
+            public string groupScope { get; set; }
             public string name { get; set; }
             public string name { get; set; }
             public string picture { get; set; }
             public string picture { get; set; }
             public string lang { get; set; }
             public string lang { get; set; }
@@ -289,7 +291,7 @@ namespace TEAMModelOS.SDK
             public string groupName { get; set; }
             public string groupName { get; set; }
             public long applyTime{ get; set; }
             public long applyTime{ get; set; }
             /// <summary>
             /// <summary>
-            /// 申请状态,-1 申请中,0 通过,1 拒绝。 
+            /// 申请状态,-1 申请中,0 通过,1 拒绝,2 已过期
             /// </summary>
             /// </summary>
             public int status { get; set; } = -1;
             public int status { get; set; } = -1;
         }
         }

+ 69 - 13
TEAMModelOS/Controllers/Both/GroupListController.cs

@@ -1204,39 +1204,95 @@ namespace TEAMModelOS.Controllers
                         if (data != default && !data.IsNullOrEmpty)
                         if (data != default && !data.IsNullOrEmpty)
                         {
                         {
                             var value = data.ToString().ToObject<GroupWaitingList>();
                             var value = data.ToString().ToObject<GroupWaitingList>();
+                            string stuKey = !string.IsNullOrWhiteSpace(school) ? $"GroupList:StudentWaitinglist:{school}_{_userid}" : $"GroupList:StudentWaitinglist:{_userid}";
+                            string sutFiled = $"{_scope}:{_id}";
+                            long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                             if ($"{_pass}".Equals("0"))
                             if ($"{_pass}".Equals("0"))
                             {
                             {
                                 //通过
                                 //通过
                                 value.status=0;
                                 value.status=0;
-                                await _azureRedis.GetRedisClient(8).HashDeleteAsync(key, filed);
-
-                                string stuKey = !string.IsNullOrWhiteSpace(school) ? $"GroupList:StudentWaitinglist:{school}_{_userid}" : $"GroupList:StudentWaitinglist:{_userid}";
-                                string sutFiled = $"{_scope}:{_id}";
-                                await _azureRedis.GetRedisClient(8).HashSetAsync(stuKey, sutFiled, value.ToJsonString());
+                                string msg = "";
+                                Azure.Response response=  await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReadItemStreamAsync(_id.ToString(),new PartitionKey(code));
+                                if (response.Status==200) {
+                                  
+                                    GroupList groupList=JsonDocument.Parse(response.Content).RootElement.ToObject<GroupList>();
+                                    if (now>value.qrcodeExpire) {
+                                        value.status=2;
+                                        msg="申请已经过期";
+                                    }
+                                    else
+                                    {
+                                        if (groupList!=null)
+                                        {
+                                            var mb = groupList.members.Find(x => x.type==value.type  && x.id.Equals(value.userid));
+                                            if (mb== null)
+                                            {
+                                                var joindata = GroupListService.JoinList(groupList, value.userid, value.type, value.school, value.year);
+                                                //加入成功
+                                                if (joindata.status == 0)
+                                                {
+                                                    await GroupListService.UpsertList(joindata.stuList, _azureCosmos, _configuration, _serviceBus);
+                                                }
+                                            }
+                                           
+                                        }
+                                    }
+                                    msg = "已经通过";
+                                    await _azureRedis.GetRedisClient(8).HashDeleteAsync(key, filed);
+                                    await _azureRedis.GetRedisClient(8).HashSetAsync(stuKey, sutFiled, value.ToJsonString());
+                                }
+                                return Ok(new { code = value.status, msg  });
                             }
                             }
                             else if ($"{_pass}".Equals("1"))
                             else if ($"{_pass}".Equals("1"))
                             {
                             {
                                 //拒绝
                                 //拒绝
                                 value.status=1;
                                 value.status=1;
                                 await _azureRedis.GetRedisClient(8).HashDeleteAsync(key, filed);
                                 await _azureRedis.GetRedisClient(8).HashDeleteAsync(key, filed);
+                                await _azureRedis.GetRedisClient(8).HashSetAsync(stuKey, sutFiled, value.ToJsonString());
+                                return Ok(new { code = value.status, msg = "已拒绝加入" });
                             }
                             }
                             else {
                             else {
                                 return BadRequest(new { code = 1, msg = "参数错误" });
                                 return BadRequest(new { code = 1, msg = "参数错误" });
                             }
                             }
-                           
-                         
                         }
                         }
                         else {
                         else {
-                            return Ok(new { code = 0, msg = "未找到申请人" }) ;
+                            return Ok(new { code = 404, msg = "未找到申请人" }) ;
                         }
                         }
-                        break;
+                       
                     }
                     }
-                    //审核结果,学生端获取到被拒绝的,或者过期的自动删除,未被审核的保存
+                //审核结果,学生端获取到被拒绝的,或者过期的自动删除,未被审核的保存
                 case bool when $"{grant_type}".Equals("result", StringComparison.OrdinalIgnoreCase):
                 case bool when $"{grant_type}".Equals("result", StringComparison.OrdinalIgnoreCase):
-                    break;
-
+                    {
+                        string stuKey = !string.IsNullOrWhiteSpace(school) ? $"GroupList:StudentWaitinglist:{school}_{userId}" : $"GroupList:StudentWaitinglist:{userId}";
+                        var datas = await _azureRedis.GetRedisClient().HashGetAllAsync(stuKey);
+                        List<GroupWaitingList> waitingLists = new List<GroupWaitingList>();
+                        long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                        if (datas!=null && datas.Length>0)
+                        {
+                            foreach (var data in datas)
+                            {
+                                var group = data.ToString().ToObject<GroupWaitingList>();
+                                if (group!=null)
+                                {
+                                    waitingLists.Add(group);
+                                    if (group.status!=-1)
+                                    {
+                                        await _azureRedis.GetRedisClient(8).HashDeleteAsync(stuKey, $"{group.groupScope}:{group.groupId}");
+                                    }
+                                    else {
+                                        if (now>group.qrcodeExpire) 
+                                        {
+                                            group.status=2;
+                                            await _azureRedis.GetRedisClient(8).HashDeleteAsync(stuKey, $"{group.groupScope}:{group.groupId}");
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                        return Ok(new { waitingLists });
+                    }
             }
             }
-            return Ok();
+            return BadRequest();
         }
         }
     }
     }
 }
 }