| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Linq;
- using Microsoft.Extensions.Hosting;
- using MySystem;
- using MySystem.Models;
- using LitJson;
- using Library;
- using MySystem.Models.Main;
- using System.Data;
- public class HaoDaAuthQueryHelper
- {
- public readonly static HaoDaAuthQueryHelper Instance = new HaoDaAuthQueryHelper();
- private HaoDaAuthQueryHelper()
- {
- }
- public void Start()
- {
- Thread th = new Thread(StartDo);
- th.IsBackground = true;
- th.Start();
- }
- private void StartDo()
- {
- while (true)
- {
- DataTable dt = CustomerSqlConn.dtable("select Id,OutMchtNo,StoreNo from MerchantAddInfo where HdStatus=3 and BrandId=0 and OutMchtNo is not null and StoreNo is not null and ((`Status`=1 and WeChatMerchantId is null) or (`QueryCount`=1 and AliMerchantId is null)) order by Id desc", AppConfig.Base.SqlConnStr);
- foreach (DataRow dr in dt.Rows)
- {
- QueryAuthStatus(dr["Id"].ToString(), dr["OutMchtNo"].ToString(), dr["StoreNo"].ToString());
- Thread.Sleep(2000);
- }
- Thread.Sleep(10000);
- }
- }
- public void QueryAuthStatus(string MerchantId, string MchtNo, string StoreNo)
- {
- try
- {
- var Id = int.Parse(MerchantId);
- WebCMSEntities db = new WebCMSEntities();
- MerchantAddInfo info = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
- string result = HaoDaHelper.Instance.QueryAuthStatus(MchtNo, StoreNo, info.BrandId);
- var jsonObj = JsonMapper.ToObject(result);
- //成功(已认证)
- if (jsonObj["resultCode"].ToString() == "1")
- {
- // MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
- // var wxcheck = jsonObj["wechatVerifyState"].ToString();
- // var alicheck = jsonObj["aliVerifyState"].ToString();
- if(result.Contains("\"wechatMerchantId\"")) info.WeChatMerchantId = jsonObj["wechatMerchantId"].ToString();
- if(result.Contains("\"aliMerchantId\"")) info.AliMerchantId = jsonObj["aliMerchantId"].ToString();
- // if (wxcheck == "1")
- // {
- // info.Status = 2;
- // info.WeChatMerchantId = jsonObj["wechatMerchantId"].ToString();
- // merchant.Status = 2;
- // info.WeChatRemark = "";
- // }
- // if (alicheck == "1")
- // {
- // info.QueryCount = 2;
- // info.AliMerchantId = jsonObj["aliMerchantId"].ToString();
- // merchant.QueryCount = 2;
- // info.AlipayRemark = "";
- // }
- // if (wxcheck != "1" || alicheck != "1")
- // {
- // RedisDbconn.Instance.AddList("HaoDaAuthQueryHelper", "{\"MerchantId\":\"" + MerchantId + "\",\"MchtNo\":\"" + info.OutMchtNo + "\",\"StoreNo\":\"" + info.StoreNo + "\"}");
- // }
- db.SaveChanges();
- }
- }
- catch (Exception ex)
- {
- LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "查询实名认证状态异常");
- }
- }
- }
|