|
@@ -0,0 +1,114 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Data;
|
|
|
+using MySystem.Models.Main;
|
|
|
+using Library;
|
|
|
+using System.Threading;
|
|
|
+using Microsoft.Extensions.Hosting;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using LitJson;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+namespace MySystem
|
|
|
+{
|
|
|
+ public class GetStoreNoHelper
|
|
|
+ {
|
|
|
+ public readonly static GetStoreNoHelper Instance = new GetStoreNoHelper();
|
|
|
+ private GetStoreNoHelper()
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ #region
|
|
|
+ public void Start()
|
|
|
+ {
|
|
|
+ Thread th = new Thread(StartDo);
|
|
|
+ th.IsBackground = true;
|
|
|
+ th.Start();
|
|
|
+ }
|
|
|
+ public void StartDo()
|
|
|
+ {
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ string MerchantId = RedisDbconn.Instance.RPop<string>("UnionPayGetStoreNoQueue");
|
|
|
+ if (!string.IsNullOrEmpty(MerchantId))
|
|
|
+ {
|
|
|
+ DoSomeThing(MerchantId);
|
|
|
+ Thread.Sleep(2000);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Thread.Sleep(60000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void DoSomeThing(string MerchantId)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ int Id = int.Parse(function.CheckInt(MerchantId));
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
+ MerchantAddInfo AddInfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
|
|
|
+ MerchantInfo merInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
|
|
|
+ if (string.IsNullOrEmpty(AddInfo.StoreNo) && string.IsNullOrEmpty(AddInfo.OutMchtNo))
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ var returnInfo = HaoDaHelper.Instance.QueryMerchantStatus(HaoDaHelper.BrhCode, AddInfo.MchtNo);
|
|
|
+ var check = false;
|
|
|
+ JsonData jsonObj = JsonMapper.ToObject(returnInfo);
|
|
|
+ if (jsonObj["resultCode"].ToString() == "1")
|
|
|
+ {
|
|
|
+ var StoreNo = jsonObj["data"]["storeNo"].ToString();
|
|
|
+ var OutMchtNo = jsonObj["data"]["outMchtNo"].ToString();
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(StoreNo) && !string.IsNullOrEmpty(OutMchtNo))
|
|
|
+ {
|
|
|
+ AddInfo.StoreNo = StoreNo;
|
|
|
+ AddInfo.OutMchtNo = OutMchtNo;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var result = HaoDaHelper.Instance.QueryAuthStatus(AddInfo.OutMchtNo, AddInfo.StoreNo);
|
|
|
+ JsonData jsonData = JsonMapper.ToObject(result);
|
|
|
+
|
|
|
+ if (jsonData["resultCode"].ToString() == "1")
|
|
|
+ {
|
|
|
+ var AliMerchantId = jsonObj["aliMerchantId"].ToString();
|
|
|
+ var WeChatMerchantId = jsonObj["wechatMerchantId"].ToString();
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(AliMerchantId) && !string.IsNullOrEmpty(WeChatMerchantId))
|
|
|
+ {
|
|
|
+ AddInfo.AliMerchantId = AliMerchantId;
|
|
|
+ AddInfo.WeChatMerchantId = WeChatMerchantId;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ check = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (check)
|
|
|
+ {
|
|
|
+ AddInfo.Status = 0;
|
|
|
+ merInfo.Status = 0;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ RedisDbconn.Instance.AddList("UnionPayGetStoreNoQueue", MerchantId.ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ db.Dispose();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "获取商户门店号队列异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+}
|