瀏覽代碼

删除登记信息

jeremy 8 月之前
父節點
當前提交
c9e8cb5445

+ 41 - 6
src/HealthExamBookingService/HealthExamBookingService.cs

@@ -525,7 +525,23 @@ public partial class HealthExamBookingService : JsonRpcService, IVitalHealthExam
     /// <returns></returns>
     public async Task<bool> DeleteRegiterInfoAsync(DeleteRegiterInfoRequest request)
     {
-        return true;
+        var registerCode = request.RegisterCode;
+        var registerInfo = await _registerInfoDBService.FindRegisterInfoByCodeAsync(registerCode);
+        if (registerInfo != null && registerInfo.JingQiExamInfos != null && registerInfo.JingQiExamInfos.Any())
+        {
+            try
+            {
+                var jingQiRes = await _vitalFacturyUserService.FacturyExamDeleteAsync(new FacturyExamDeleteRequest
+                {
+                    Token = request.Token,
+                    PhyId = "",
+                });
+            }
+            catch (Exception ex)
+            {
+            }
+        }
+        return await _registerInfoDBService.DeleteRegisterInfoAsync(registerCode);
     }
 
     private async Task<Dictionary<string, string>> JingQiExamRegisterAsync(AddRegiterInfoRequest request)
@@ -533,15 +549,34 @@ public partial class HealthExamBookingService : JsonRpcService, IVitalHealthExam
         var jingQiExamInfos = new Dictionary<string, string>();
         if (await IsJingQiRequiredAsync(request))
         {
-            var jingQiRes = await _vitalFacturyUserService.FacturyExamRegisterAsync(new FacturyExamRegisterRequest
+            FacturyExamRegisterResult jingQiRes = null;
+            try
             {
-                Token = request.Token,
-                Identity = request.IDCardNo,
-            });
+                jingQiRes = await _vitalFacturyUserService.FacturyExamRegisterAsync(new FacturyExamRegisterRequest
+                {
+                    Token = request.Token,
+                    Identity = request.IDCardNo,
+                });
+            }
+            catch (Exception ex)
+            {
+                return jingQiExamInfos;
+            }
             if (jingQiRes.Status != "0")
             {
                 Logger.WriteLineError($"HealthExamBookingService JingQiExamRegisterAsync failed, cardNo:{request.IDCardNo}, Status:{jingQiRes.Status}, ErroMsg:{jingQiRes.ErroMsg}");
-                ThrowCustomerException(CustomerRpcCode.JingQiApiFailed, jingQiRes.ErroMsg);
+                if (jingQiRes.Status == "2")
+                {
+                    ThrowCustomerException(CustomerRpcCode.JingQiNonArea, "JingQiNonArea");
+                }
+                else if (jingQiRes.Status == "3")
+                {
+                    ThrowCustomerException(CustomerRpcCode.JingQiExamedInYear, "JingQiExamedInYear");
+                }
+                else
+                {
+                    ThrowCustomerException(CustomerRpcCode.JingQiApiFailed, jingQiRes.ErroMsg);
+                }
             }
             PropertyInfo[] properties = typeof(FacturyExamRegisterResult).GetProperties();
             foreach (PropertyInfo property in properties)

+ 41 - 1
src/VitalMixtureService/FrontService/Service/FacturyUserService.cs

@@ -136,7 +136,7 @@ namespace VitalService.Service
         /// <returns></returns>
         public async Task<FacturyExamRegisterResult> FacturyExamRegisterAsync(FacturyExamRegisterRequest request)
         {
-            var userCode = string.Empty;
+            var userCode = await GetClientIdByTokenAsync(request.Token);
             var userInfo = await _userDBService.GetUserDetailAsync(new GetUserDBRequest
             {
                 Code = userCode,
@@ -200,6 +200,46 @@ namespace VitalService.Service
         /// <returns></returns>
         public async Task<FacturyExamDeleteResult> FacturyExamDeleteAsync(FacturyExamDeleteRequest request)
         {
+            var userCode = await GetClientIdByTokenAsync(request.Token);
+            var userInfo = await _userDBService.GetUserDetailAsync(new GetUserDBRequest
+            {
+                Code = userCode,
+            });
+            if (userInfo == null || string.IsNullOrWhiteSpace(userInfo.FacturyUserCode) || _jingQiApiHelper == null)
+            {
+                // 不推送晶奇系统
+                ThrowRpcException((int)CustomerRpcCode.JingQiNotRequired, "JingQiNotRequired", "");
+            }
+            else
+            {
+                var facturyUser = await _vitalFacturyUserDBService.GetFacturyUserDBAsync(new GetFacturyUserDBRequest
+                {
+                    Code = userInfo.FacturyUserCode,
+                });
+                var facturyOrg = await _vitalFacturyUserDBService.GetFacturyUserDBAsync(new GetFacturyUserDBRequest
+                {
+                    Code = facturyUser.FatherCode,
+                });
+                if (facturyUser == null || string.IsNullOrWhiteSpace(facturyUser.FacturyCode)
+                    || facturyOrg == null || string.IsNullOrWhiteSpace(facturyOrg.FacturyCode))
+                {
+                    // 不推送晶奇系统
+                    ThrowRpcException((int)CustomerRpcCode.JingQiNotRequired, "JingQiNotRequired", "");
+                }
+                else
+                {
+                    var jingQiRes = await _jingQiApiHelper.ExamDeleteAsync(new Factury.JingQiExamDeleteRequest
+                    {
+                        phyid = request.PhyId,
+                    }, facturyOrg.FacturyData);
+                    return new FacturyExamDeleteResult
+                    {
+                        Status = jingQiRes.status,
+                        ErroMsg = jingQiRes.ErroMsg,
+                    };
+                }
+
+            }
             return null;
         }
     }