|
@@ -27,6 +27,7 @@ public class StoreApplyHelper
|
|
while (true)
|
|
while (true)
|
|
{
|
|
{
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
|
|
+ OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
try
|
|
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)
|
|
@@ -35,7 +36,51 @@ public class StoreApplyHelper
|
|
if(string.IsNullOrEmpty(check))
|
|
if(string.IsNullOrEmpty(check))
|
|
{
|
|
{
|
|
function.WritePage("/StoreApply/", DateTime.Now.ToString("yyyyMM") + ".txt", DateTime.Now.ToString());
|
|
function.WritePage("/StoreApply/", DateTime.Now.ToString("yyyyMM") + ".txt", DateTime.Now.ToString());
|
|
- // OtherMySqlConn.connstr =
|
|
|
|
|
|
+ Dictionary<int, decimal> dataDic = new Dictionary<int, decimal>();
|
|
|
|
+ string start = DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00";
|
|
|
|
+ string end = DateTime.Parse(start).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ DataTable dt = OtherMySqlConn.dtable("select StoreId,count(Id) from PosMachinesTwo where TransferTime>='" + start + "' and TransferTime<'" + end + "' and BrandId in (1,2,4,6,7,8) and Status>-1 group by StoreId");
|
|
|
|
+ foreach(DataRow dr in dt.Rows)
|
|
|
|
+ {
|
|
|
|
+ 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))
|
|
|
|
+ {
|
|
|
|
+ dataDic.Add(store.UserId, Count * 200);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ dt = OtherMySqlConn.dtable("select StoreId,count(Id) from PosMachinesTwo where TransferTime>='" + start + "' and TransferTime<'" + end + "' and BrandId in (3,5,9) and Status>-1 group by StoreId");
|
|
|
|
+ foreach(DataRow dr in dt.Rows)
|
|
|
|
+ {
|
|
|
|
+ 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))
|
|
|
|
+ {
|
|
|
|
+ dataDic.Add(store.UserId, Count * 300);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ dataDic[store.UserId] += Count * 300;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ foreach(int UserId in dataDic.Keys)
|
|
|
|
+ {
|
|
|
|
+ decimal Amount = dataDic[UserId];
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
db.SaveChanges();
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -77,34 +122,74 @@ public class StoreApplyHelper
|
|
if(order != null)
|
|
if(order != null)
|
|
{
|
|
{
|
|
function.WriteLog("2", "分仓向总仓申请机具日志");
|
|
function.WriteLog("2", "分仓向总仓申请机具日志");
|
|
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == order.UserId);
|
|
|
|
|
|
+ decimal TotalPrice = order.TotalPrice * 2;
|
|
|
|
+ AddAmount(db, order.UserId, TotalPrice, 1, order.Id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if(jsonObj["Kind"].ToString() == "2")
|
|
|
|
+ {
|
|
|
|
+ int UserId = int.Parse(jsonObj["Data"]["UserId"].ToString());
|
|
|
|
+ int Amount = int.Parse(jsonObj["Data"]["Amount"].ToString());
|
|
|
|
+ int OperateType = int.Parse(jsonObj["Data"]["OperateType"].ToString());
|
|
|
|
+ AddAmount(db, UserId, Amount, OperateType);
|
|
|
|
+ }
|
|
|
|
+ else if(jsonObj["Kind"].ToString() == "3")
|
|
|
|
+ {
|
|
|
|
+ int ApplyId = int.Parse(jsonObj["Data"]["ApplyId"].ToString());
|
|
|
|
+ StoreHouseAmountRecord record = db.StoreHouseAmountRecord.FirstOrDefault(m => m.Id == ApplyId);
|
|
|
|
+ if(record != null)
|
|
|
|
+ {
|
|
|
|
+ int GetUserId = record.UserId;
|
|
|
|
+ decimal Amount = record.UseAmount / 2;
|
|
|
|
+ UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == GetUserId);
|
|
if (account == null)
|
|
if (account == null)
|
|
{
|
|
{
|
|
account = db.UserAccount.Add(new UserAccount()
|
|
account = db.UserAccount.Add(new UserAccount()
|
|
{
|
|
{
|
|
- Id = order.UserId,
|
|
|
|
- UserId = order.UserId,
|
|
|
|
|
|
+ Id = GetUserId,
|
|
|
|
+ UserId = GetUserId,
|
|
}).Entity;
|
|
}).Entity;
|
|
db.SaveChanges();
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
- decimal TotalPrice = order.TotalPrice * 2;
|
|
|
|
- decimal BeforeTotalAmount = account.TempAmount; //变更前总金额
|
|
|
|
- account.TempAmount += TotalPrice;
|
|
|
|
- account.ValidAmount += TotalPrice;
|
|
|
|
- decimal AfterTotalAmount = account.TempAmount; //变更后总金额
|
|
|
|
- StoreHouseAmountRecord record = db.StoreHouseAmountRecord.Add(new StoreHouseAmountRecord()
|
|
|
|
|
|
+ decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
|
|
|
|
+ decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
|
|
|
|
+ decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
|
|
|
|
+ account.BalanceAmount += Amount;
|
|
|
|
+ account.TotalAmount += Amount;
|
|
|
|
+ decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
|
+ decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
|
+ decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
|
+ UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
{
|
|
{
|
|
CreateDate = DateTime.Now,
|
|
CreateDate = DateTime.Now,
|
|
UpdateDate = DateTime.Now,
|
|
UpdateDate = DateTime.Now,
|
|
- OperateType = 1,
|
|
|
|
- AmountType = 1,
|
|
|
|
- AfterAmount = AfterTotalAmount,
|
|
|
|
- BeforeAmount = BeforeTotalAmount,
|
|
|
|
- UseAmount = TotalPrice,
|
|
|
|
- UserId = order.UserId,
|
|
|
|
- QueryCount = order.Id,
|
|
|
|
|
|
+ UserId = GetUserId, //创客
|
|
|
|
+ ChangeType = 119, //变动类型
|
|
|
|
+ ChangeAmount = Amount, //变更金额
|
|
|
|
+ BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
|
+ AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
|
+ BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
|
+ AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
|
+ BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
|
+ AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
}).Entity;
|
|
}).Entity;
|
|
- db.SaveChanges();
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if(jsonObj["Kind"].ToString() == "4")
|
|
|
|
+ {
|
|
|
|
+ int StoreId = int.Parse(jsonObj["Data"]["StoreId"].ToString());
|
|
|
|
+ string SnIds = jsonObj["Data"]["SnIds"].ToString();
|
|
|
|
+ StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId);
|
|
|
|
+ if(store != null)
|
|
|
|
+ {
|
|
|
|
+ decimal
|
|
|
|
+ string[] SnIdList = SnIds.Split(',');
|
|
|
|
+ foreach(string SnIdString in SnIdList)
|
|
|
|
+ {
|
|
|
|
+ int SnId = int.Parse(SnIdString);
|
|
|
|
+ PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnId) ?? new PosMachinesTwo();
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
db.SaveChanges();
|
|
db.SaveChanges();
|
|
@@ -117,4 +202,43 @@ public class StoreApplyHelper
|
|
db.Dispose();
|
|
db.Dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public void AddAmount(WebCMSEntities db, int UserId, decimal Amount, int OperateType = 1, int OrderId = 0)
|
|
|
|
+ {
|
|
|
|
+ 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();
|
|
|
|
+ }
|
|
|
|
+ decimal BeforeTotalAmount = account.TempAmount; //变更前总金额
|
|
|
|
+ if(OperateType == 1)
|
|
|
|
+ {
|
|
|
|
+ account.TempAmount += Amount;
|
|
|
|
+ account.ValidAmount += Amount;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ account.TempAmount -= Amount;
|
|
|
|
+ account.ValidAmount -= Amount;
|
|
|
|
+ }
|
|
|
|
+ decimal AfterTotalAmount = account.TempAmount; //变更后总金额
|
|
|
|
+ StoreHouseAmountRecord record = db.StoreHouseAmountRecord.Add(new StoreHouseAmountRecord()
|
|
|
|
+ {
|
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
|
+ OperateType = OperateType,
|
|
|
|
+ AmountType = 1,
|
|
|
|
+ AfterAmount = AfterTotalAmount,
|
|
|
|
+ BeforeAmount = BeforeTotalAmount,
|
|
|
|
+ UseAmount = Amount,
|
|
|
|
+ UserId = UserId,
|
|
|
|
+ QueryCount = OrderId,
|
|
|
|
+ }).Entity;
|
|
|
|
+ db.SaveChanges();
|
|
|
|
+ }
|
|
}
|
|
}
|