mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 21:21:34 +00:00
63 lines
1.6 KiB
C#
63 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AppleBatch_June.Domain
|
|
{
|
|
public class GiftcardBalanceManage
|
|
{
|
|
public static Dictionary<string, GiftcardBalanceStandby> nationGiftcardBalance = new Dictionary<string, GiftcardBalanceStandby>();
|
|
|
|
public static object loginLockObj = new object();
|
|
|
|
public static bool AddGifStandby(string _storeAppleHostLists, string appleId, string applePwd)
|
|
{
|
|
string text = _storeAppleHostLists;
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
text = "us";
|
|
}
|
|
string text2 = text + "_" + appleId;
|
|
lock (loginLockObj)
|
|
{
|
|
if (nationGiftcardBalance.ContainsKey(text2))
|
|
{
|
|
_ = nationGiftcardBalance[text2];
|
|
}
|
|
List<string> list = new List<string>();
|
|
foreach (KeyValuePair<string, GiftcardBalanceStandby> item in nationGiftcardBalance)
|
|
{
|
|
if (item.Key.StartsWith(text + "_") && item.Key != text2)
|
|
{
|
|
list.Add(item.Key);
|
|
}
|
|
}
|
|
foreach (string item2 in list)
|
|
{
|
|
nationGiftcardBalance.Remove(item2);
|
|
}
|
|
if (!nationGiftcardBalance.ContainsKey(text2))
|
|
{
|
|
nationGiftcardBalance.Add(text2, new GiftcardBalanceStandby(_storeAppleHostLists, appleId, applePwd));
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public static GiftcardBalanceStandby GetStandby(string nation, string appleId)
|
|
{
|
|
if (string.IsNullOrEmpty(nation))
|
|
{
|
|
nation = "us";
|
|
}
|
|
string key = nation + "_" + appleId;
|
|
if (nationGiftcardBalance.ContainsKey(key))
|
|
{
|
|
GiftcardBalanceStandby giftcardBalanceStandby = nationGiftcardBalance[key];
|
|
giftcardBalanceStandby.upTime = DateTime.Now;
|
|
return giftcardBalanceStandby;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|