Ejemplo n.º 1
0
        public IActionResult SetIDCard(IdCardInfo info)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (string.IsNullOrEmpty(info.Openid) || string.IsNullOrEmpty(info.IdCard))
            {
                response.SetFailed("openid或身份证号为空");
                return(Ok(response));
            }
            var entity = _dbContext.SystemUser.FirstOrDefault(x => x.Wechat == info.Openid);

            if (entity != null)
            {
                entity.UserIdCard = info.IdCard;
                entity.IdcardMd5  = YunSendMsg.GenerateMD5(info.IdCard);
                _dbContext.SaveChanges();
                response.SetSuccess("绑定成功");
                return(Ok(response));
            }
            else
            {
                response.SetFailed("绑定失败");
                return(Ok(response));
            }
        }
Ejemplo n.º 2
0
 //百姓码
 public string Common(string result)
 {
     if (string.IsNullOrEmpty(result))
     {
         return("请求参数存在空值");
     }
     else
     {
         //设置请求接口
         var request = (HttpWebRequest)WebRequest.Create("https://api.bechangedt.com/api/healthcode/verify");
         //请求参数
         var postData = "{" + '"' + "healthQrCode" + '"' + ":" + '"' + result + '"' + "}";
         var data     = Encoding.ASCII.GetBytes(postData);
         //请求方式
         request.Method = "POST";
         //请求头参数设置
         request.Headers.Add("organizationId", "002504421");
         request.Headers.Add("appId", "6737FDA2D");
         request.Headers.Add("dataSources", "3");
         request.Headers.Add("tradeCode", "60002");
         var requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         request.Headers.Add("requestTime", requestTime);
         string md5 = YunSendMsg.GenerateMD5("002504421" + "6737FDA2D" + "840CA391C69950D13514A2A3CD572506" + "3" + "60002" + requestTime).ToUpper();
         request.Headers.Add("sign", md5);
         request.ContentType           = "application/json;charset=UTF-8";
         request.ContentLength         = data.Length;
         request.UseDefaultCredentials = true;
         using (var stream = request.GetRequestStream())
         {
             stream.Write(data, 0, data.Length);
         }
         //结果返回
         var responses = (HttpWebResponse)request.GetResponse();
         //转字符串
         var responseString = new StreamReader(responses.GetResponseStream(), Encoding.UTF8).ReadToEnd();
         //转换为json对象
         CommonCard commodel = JsonConvert.DeserializeObject <CommonCard>(responseString);
         if (commodel.code != 1 || commodel.data == null)
         {
             return(commodel.msg);
         }
         else
         {
             var           card      = AESHelper.Decrypt(commodel.data.verifyResp, "HEALTHCODEVERIFY");
             CommonCardMan commodels = JsonConvert.DeserializeObject <CommonCardMan>(card);
             return(commodels.idCardValue);
         }
     }
 }