/// <summary> /// 实时投保,需要实时返回保单号 /// </summary> /// <param name="entity"></param> /// <returns></returns> public static IssuingResultEntity Issue(IssueEntity entity) { int interfaceId_bak = entity.InterfaceId;//暂存 IssuingFacade facade = new IssuingFacade(); IssuingResultEntity result = facade.Issue(entity); if (string.IsNullOrEmpty(result.Trace.ErrorMsg)) { if (string.IsNullOrEmpty(result.PolicyNo)) //没有保单号 { result.Trace.ErrorMsg = "投保失败:没有返回保单号!"; } else { //主键更新,不会阻塞 保存返回的正式保单号 string strSql = "update t_case set certNo = '{0}', [isIssued] = 1 {1} where caseNo = '{2}'"; string interfacIdSql = string.Empty; if (entity.InterfaceId != interfaceId_bak) //如果中途转投了别的接口 { interfacIdSql = ",[interface_Id] = " + entity.InterfaceId; } strSql = string.Format(strSql, result.PolicyNo, interfacIdSql, entity.CaseNo); entity.DbCommand.CommandText = strSql; entity.DbCommand.ExecuteNonQuery(); } return(result); } else { return(result); } }
/// <summary> /// 延迟投保(追溯?) /// </summary> /// <param name="entityObj"></param> public static IssuingResultEntity IssueAsync(object entityObj) { string strSql = ""; IssuingResultEntity result = new IssuingResultEntity(); try { IssueEntity entity = (IssueEntity)entityObj; int interfaceId_bak = entity.InterfaceId;//暂存 t_Case policy = Case.Get(entity.CaseNo, entity.ConnectionString); if (!string.IsNullOrEmpty(policy.CertNo)) { result.Trace.Detail = "已有保单号。"; } else if (!policy.enabled) { result.Trace.Detail = "已撤销。"; } else { entity.ID = entity.ID.ToUpper(); //有些第三方接口无法通过身份证中小写的x字母 IssuingFacade facade = new IssuingFacade(); result = facade.Issue(entity); if (string.IsNullOrEmpty(result.Trace.ErrorMsg)) { if (!string.IsNullOrEmpty(result.Trace.Detail)) //有特殊情况 { strSql = "update t_case set IssuingFailed = @IssuingFailed where caseNo = @caseNo"; SqlHelper.ExecuteNonQuery(entity.ConnectionString, CommandType.Text, strSql, new string[] { "@IssuingFailed", "@caseNo" }, new object[] { result.Trace.Detail, entity.CaseNo }); } if (!string.IsNullOrEmpty(result.PolicyNo)) { //主键更新,不会阻塞 保存返回的正式保单号 strSql = "update t_case set certNo = '{0}', [isIssued] = 1 {1} where caseNo = '{2}'"; string interfacIdSql = string.Empty; if (entity.InterfaceId != interfaceId_bak) //如果中途转投了别的接口 { interfacIdSql = ",[interface_Id] = " + entity.InterfaceId; } strSql = string.Format(strSql, result.PolicyNo, interfacIdSql, entity.CaseNo); int eff = SqlHelper.ExecuteNonQuery(entity.ConnectionString, CommandType.Text, strSql); if (eff == 0) { Common.LogIt("ExecuteNonQuery影响行数为0 : " + strSql); } } } else { int len = result.Trace.ErrorMsg.Length; len = len > 100 ? 100 : len; strSql = "update t_case set IssuingFailed = @IssuingFailed where caseNo = @caseNo"; SqlHelper.ExecuteNonQuery(entity.ConnectionString, CommandType.Text, strSql, new string[] { "@IssuingFailed", "@caseNo" }, new object[] { result.Trace.ErrorMsg.Substring(0, len), entity.CaseNo }); } } return(result); } catch (Exception e) { //Common.LogIt(e.ToString()); throw; } }