|
@@ -126,10 +126,10 @@ namespace MySystem
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
- string orderidstring = RedisDbconn.Instance.RPop<string>("ConsumerOrders:Divi:List");
|
|
|
+ string orderidstring = RedisDbconn.Instance.RPop<string>("ConsumerOrders:Divi:1:List");
|
|
|
if (!string.IsNullOrEmpty(orderidstring))
|
|
|
{
|
|
|
- ReturnStat(orderidstring);
|
|
|
+ ReturnStat(orderidstring, 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -138,7 +138,29 @@ namespace MySystem
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void ReturnStat(string orderidstring)
|
|
|
+ public void StartListenWxTrade()
|
|
|
+ {
|
|
|
+ Thread th = new Thread(StartListenWxTradeDo);
|
|
|
+ th.IsBackground = true;
|
|
|
+ th.Start();
|
|
|
+ }
|
|
|
+ public void StartListenWxTradeDo()
|
|
|
+ {
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ string orderidstring = RedisDbconn.Instance.RPop<string>("ConsumerOrders:Divi:2:List");
|
|
|
+ if (!string.IsNullOrEmpty(orderidstring))
|
|
|
+ {
|
|
|
+ ReturnStat(orderidstring, 2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Thread.Sleep(60000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void ReturnStat(string orderidstring, int PayMode)
|
|
|
{
|
|
|
int OrderId = int.Parse(function.CheckInt(orderidstring));
|
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
@@ -149,7 +171,6 @@ namespace MySystem
|
|
|
ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == OrderId);
|
|
|
if (order != null)
|
|
|
{
|
|
|
- int PayMode = order.PayMode;
|
|
|
decimal PayMoney = order.PayMoney;
|
|
|
int MerchantId = order.MerchantId;
|
|
|
MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId);
|
|
@@ -181,7 +202,7 @@ namespace MySystem
|
|
|
DiviMoney = DiviMoney / DiviPersons;
|
|
|
List<int> deletes = new List<int>();
|
|
|
long CurDiviPersons = DiviPersons;
|
|
|
- long QueueCount = RedisDbconn.Instance.Count("ConsumerOrders:Divi:" + MerchantId);
|
|
|
+ long QueueCount = RedisDbconn.Instance.Count("ConsumerOrders:Divi:" + PayMode + ":" + MerchantId);
|
|
|
long CurQueueCount = QueueCount;
|
|
|
// int CheckNum = 0; //判断活动人数是否大于当前队列订单数来确认while循环的数量,如果是就少循环一次,判处自己的订单名额
|
|
|
if (CurDiviPersons >= CurQueueCount)
|
|
@@ -198,7 +219,7 @@ namespace MySystem
|
|
|
int OutCount = 0; // 出局人数
|
|
|
while (CurDiviPersons > 0)
|
|
|
{
|
|
|
- ConsumerOrders suborder = RedisDbconn.Instance.RPop<ConsumerOrders>("ConsumerOrders:Divi:" + MerchantId);
|
|
|
+ ConsumerOrders suborder = RedisDbconn.Instance.RPop<ConsumerOrders>("ConsumerOrders:Divi:" + PayMode + ":" + MerchantId);
|
|
|
if (suborder != null)
|
|
|
{
|
|
|
MerchantParamSet subset = Newtonsoft.Json.JsonConvert.DeserializeObject<MerchantParamSet>(order.SeoDescription);
|
|
@@ -243,7 +264,7 @@ namespace MySystem
|
|
|
Dictionary<string, string> dic = WeChatFunction.Instance.Refund(merchantAdd.SubMchid, GetMoney, suborder.PayMoney, suborder.OrderNo, DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8));
|
|
|
if (suborder.CurDivi < suborder.MaxDivi)
|
|
|
{
|
|
|
- RedisDbconn.Instance.AddList("ConsumerOrders:Divi:" + MerchantId, suborder);
|
|
|
+ RedisDbconn.Instance.AddList("ConsumerOrders:Divi:" + PayMode + ":" + MerchantId, suborder);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -259,7 +280,7 @@ namespace MySystem
|
|
|
}
|
|
|
}
|
|
|
CurDiviPersons -= 1;
|
|
|
- QueueCount = RedisDbconn.Instance.Count("ConsumerOrders:Divi:" + MerchantId);
|
|
|
+ QueueCount = RedisDbconn.Instance.Count("ConsumerOrders:Divi:" + PayMode + ":" + MerchantId);
|
|
|
if (QueueCount == 0)
|
|
|
{
|
|
|
CurDiviPersons = 0;
|
|
@@ -681,42 +702,6 @@ namespace MySystem
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- #region 待分账队列
|
|
|
-
|
|
|
- public void StartListenSplitAccount()
|
|
|
- {
|
|
|
- bool op = true;
|
|
|
- while (op)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- string orderidstring = RedisDbconn.Instance.Get<string>("ConsumerOrders:Divi:List");
|
|
|
- if (!string.IsNullOrEmpty(orderidstring))
|
|
|
- {
|
|
|
- int OrderId = int.Parse(function.CheckInt(orderidstring));
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
- ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == OrderId && m.Status == 1);
|
|
|
- if (order != null)
|
|
|
- {
|
|
|
- // TODO:
|
|
|
- }
|
|
|
- db.Dispose();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- op = false;
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- op = false;
|
|
|
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + ex.ToString(), "待分账队列异常");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
|
|
|
|
|
|
|