|
|
@@ -31,13 +31,15 @@ public class StoreApplyHelper
|
|
|
OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
|
try
|
|
|
{
|
|
|
- // if(DateTime.Now.Day == 1 && DateTime.Now.Hour > 0 && DateTime.Now.Hour < 3)
|
|
|
- // {
|
|
|
+ if(DateTime.Now.Day == 1 && DateTime.Now.Hour > 0 && DateTime.Now.Hour < 3)
|
|
|
+ {
|
|
|
string check = function.ReadInstance("/StoreApply/" + DateTime.Now.ToString("yyyyMM") + ".txt");
|
|
|
if(string.IsNullOrEmpty(check))
|
|
|
{
|
|
|
function.WritePage("/StoreApply/", DateTime.Now.ToString("yyyyMM") + ".txt", DateTime.Now.ToString());
|
|
|
Dictionary<int, decimal> dataDic = new Dictionary<int, decimal>();
|
|
|
+ Dictionary<int, decimal> dataDic1 = new Dictionary<int, decimal>();
|
|
|
+ Dictionary<int, decimal> dataDic2 = new Dictionary<int, decimal>();
|
|
|
string pre = DateTime.Now.AddMonths(-2).ToString("yyyy-MM") + "-01 00:00:00";
|
|
|
string start = DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01 00:00:00";
|
|
|
string end = DateTime.Parse(start).AddMonths(1).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -60,13 +62,13 @@ public class StoreApplyHelper
|
|
|
int StoreId = int.Parse(function.CheckInt(dr["StoreId"].ToString()));
|
|
|
int Count = int.Parse(function.CheckInt(dr[1].ToString()));
|
|
|
StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
|
|
|
- if(!dataDic.ContainsKey(store.UserId))
|
|
|
+ if(!dataDic1.ContainsKey(store.UserId))
|
|
|
{
|
|
|
- dataDic.Add(store.UserId, Count * 200);
|
|
|
+ dataDic1.Add(store.UserId, Count * 200);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- dataDic[store.UserId] += Count * 200;
|
|
|
+ dataDic1[store.UserId] += Count * 200;
|
|
|
}
|
|
|
}
|
|
|
dt = OtherMySqlConn.dtable("select StoreId,count(Id) from StoreStockChange where CreateDate>='" + start + "' and CreateDate<'" + end + "' and BrandId in (3,5,9) and TransType in (10,11,2) and StoreId>0 group by StoreId");
|
|
|
@@ -75,13 +77,13 @@ public class StoreApplyHelper
|
|
|
int StoreId = int.Parse(function.CheckInt(dr["StoreId"].ToString()));
|
|
|
int Count = int.Parse(function.CheckInt(dr[1].ToString()));
|
|
|
StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
|
|
|
- if(!dataDic.ContainsKey(store.UserId))
|
|
|
+ if(!dataDic2.ContainsKey(store.UserId))
|
|
|
{
|
|
|
- dataDic.Add(store.UserId, Count * 300);
|
|
|
+ dataDic2.Add(store.UserId, Count * 300);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- dataDic[store.UserId] += Count * 300;
|
|
|
+ dataDic2[store.UserId] += Count * 300;
|
|
|
}
|
|
|
}
|
|
|
foreach(int UserId in dataDic.Keys)
|
|
|
@@ -101,9 +103,55 @@ public class StoreApplyHelper
|
|
|
account.ValidAmount = Amount + account.TempAmount;
|
|
|
function.WriteLog("UserId:" + UserId + ";Amount:" + Amount, "计算分仓申请机具额度日志");
|
|
|
}
|
|
|
+ foreach(int UserId in dataDic1.Keys)
|
|
|
+ {
|
|
|
+ decimal Amount = dataDic1[UserId];
|
|
|
+ decimal AmountMore = 0;
|
|
|
+ // DataTable dtmore = OtherMySqlConn.dtable("select count(Id)*200 from PosMachinesTwo pos where StoreId in (select Id from StoreHouse where UserId=" + UserId + ") and BuyUserId=0 and BrandId in (1,2,4,6,7,8) and `Status`>-1");
|
|
|
+ // if(dtmore.Rows.Count > 0)
|
|
|
+ // {
|
|
|
+ // AmountMore = decimal.Parse(function.CheckNum(dtmore.Rows[0][0].ToString()));
|
|
|
+ // }
|
|
|
+ UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
|
|
|
+ if (account == null)
|
|
|
+ {
|
|
|
+ account = db.UserAccount.Add(new UserAccount()
|
|
|
+ {
|
|
|
+ Id = UserId,
|
|
|
+ UserId = UserId,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ account.FixedAmount = Amount;
|
|
|
+ account.ValidAmount = Amount + account.TempAmount - AmountMore;
|
|
|
+ function.WriteLog("UserId:" + UserId + ";Amount:" + Amount, "计算分仓申请机具额度日志");
|
|
|
+ }
|
|
|
+ foreach(int UserId in dataDic2.Keys)
|
|
|
+ {
|
|
|
+ decimal Amount = dataDic2[UserId];
|
|
|
+ decimal AmountMore = 0;
|
|
|
+ // DataTable dtmore = OtherMySqlConn.dtable("select count(Id)*300 from PosMachinesTwo pos where StoreId in (select Id from StoreHouse where UserId=" + UserId + ") and BuyUserId=0 and BrandId in (3,5,9) and `Status`>-1");
|
|
|
+ // if(dtmore.Rows.Count > 0)
|
|
|
+ // {
|
|
|
+ // AmountMore = decimal.Parse(function.CheckNum(dtmore.Rows[0][0].ToString()));
|
|
|
+ // }
|
|
|
+ UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
|
|
|
+ if (account == null)
|
|
|
+ {
|
|
|
+ account = db.UserAccount.Add(new UserAccount()
|
|
|
+ {
|
|
|
+ Id = UserId,
|
|
|
+ UserId = UserId,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ account.FixedAmount = Amount;
|
|
|
+ account.ValidAmount = Amount + account.TempAmount - AmountMore;
|
|
|
+ function.WriteLog("UserId:" + UserId + ";Amount:" + Amount, "计算分仓申请机具额度日志");
|
|
|
+ }
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
- // }
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|