Bladeren bron

重置仓库额度,品牌数据从品牌表读取,不写死

lcl 1 jaar geleden
bovenliggende
commit
454605e9ec
1 gewijzigde bestanden met toevoegingen van 13 en 10 verwijderingen
  1. 13 10
      AppStart/Timer/StoreApplyHelper.cs

+ 13 - 10
AppStart/Timer/StoreApplyHelper.cs

@@ -101,7 +101,7 @@ public class StoreApplyHelper
             usercondition = " and UserId=" + UId;
         }
         //上月出货额度
-        DataTable dt = CustomerSqlConn.dtable("select StoreId,count(Id) from StoreStockChange where Id>=528358 and CreateDate>='" + start + "' and CreateDate<'" + end + "' and BrandId in (1,2,4,6,7,8,10,12) and TransType in (10,11,2) and StoreId>0" + condition + " group by StoreId", connstr);
+        DataTable dt = CustomerSqlConn.dtable("select StoreId,count(Id) from StoreStockChange where Id>=528358 and CreateDate>='" + start + "' and CreateDate<'" + end + "' and BrandId in (select Id from KqProducts where Kind=1) and TransType in (10,11,2) and StoreId>0" + condition + " group by StoreId", connstr);
         foreach(DataRow dr in dt.Rows)
         {
             int StoreId = int.Parse(function.CheckInt(dr["StoreId"].ToString()));
@@ -117,7 +117,7 @@ public class StoreApplyHelper
                 dataDic[store.UserId] += AmountMore;
             }
         }
-        dt = CustomerSqlConn.dtable("select StoreId,count(Id) from StoreStockChange where Id>=528358 and CreateDate>='" + start + "' and CreateDate<'" + end + "' and BrandId in (3,5,9,11,13) and TransType in (10,11,2) and StoreId>0" + condition + " group by StoreId", connstr);
+        dt = CustomerSqlConn.dtable("select StoreId,count(Id) from StoreStockChange where Id>=528358 and CreateDate>='" + start + "' and CreateDate<'" + end + "' and BrandId in (select Id from KqProducts where Kind=2) and TransType in (10,11,2) and StoreId>0" + condition + " group by StoreId", connstr);
         foreach(DataRow dr in dt.Rows)
         {
             int StoreId = int.Parse(function.CheckInt(dr["StoreId"].ToString()));
@@ -176,23 +176,23 @@ public class StoreApplyHelper
             }
             decimal AmountMore = 0;
             //仓库中机具占用额度+小分仓机具占用额度
-            DataTable dtmore = CustomerSqlConn.dtable("select count(Id)*200 from PosMachinesTwo pos where StoreId in (select Id from StoreHouse where UserId=" + UserId + " and Sort=0) and BuyUserId=0 and BrandId in (1,2,4,6,7,8,10,12) and `Status`>-1", connstr);
+            DataTable dtmore = CustomerSqlConn.dtable("select count(Id)*200 from PosMachinesTwo pos where StoreId in (select Id from StoreHouse where UserId=" + UserId + " and Sort=0) and BuyUserId=0 and BrandId in (select Id from KqProducts where Kind=1) and `Status`>-1", connstr);
             if(dtmore.Rows.Count > 0)
             {
                 AmountMore += decimal.Parse(function.CheckNum(dtmore.Rows[0][0].ToString()));
             }
-            dtmore = CustomerSqlConn.dtable("select count(Id)*300 from PosMachinesTwo pos where StoreId in (select Id from StoreHouse where UserId=" + UserId + " and Sort=0) and BuyUserId=0 and BrandId in (3,5,9,11,13) and `Status`>-1", connstr);
+            dtmore = CustomerSqlConn.dtable("select count(Id)*300 from PosMachinesTwo pos where StoreId in (select Id from StoreHouse where UserId=" + UserId + " and Sort=0) and BuyUserId=0 and BrandId in (select Id from KqProducts where Kind=2) and `Status`>-1", connstr);
             if(dtmore.Rows.Count > 0)
             {
                 AmountMore += decimal.Parse(function.CheckNum(dtmore.Rows[0][0].ToString()));
             }
             //除开小分仓中带“授”标记机具占用额度
-            dtmore = CustomerSqlConn.dtable("select count(Id)*200 from PreSendStockDetail pos where FromStoreId in (select Id from StoreHouse where UserId=" + UserId + " and Sort=0) and BrandId in (1,2,4,6,7,8,10,12) and AuthFlag=1 and ApplyFlag=0 and `Status`>-1 and `Status`<2", connstr);
+            dtmore = CustomerSqlConn.dtable("select count(Id)*200 from PreSendStockDetail pos where FromStoreId in (select Id from StoreHouse where UserId=" + UserId + " and Sort=0) and BrandId in (select Id from KqProducts where Kind=1) and AuthFlag=1 and ApplyFlag=0 and `Status`>-1 and `Status`<2", connstr);
             if(dtmore.Rows.Count > 0)
             {
                 AmountMore -= decimal.Parse(function.CheckNum(dtmore.Rows[0][0].ToString()));
             }
-            dtmore = CustomerSqlConn.dtable("select count(Id)*300 from PreSendStockDetail pos where FromStoreId in (select Id from StoreHouse where UserId=" + UserId + " and Sort=0) and BrandId in (3,5,9,11,13) and AuthFlag=1 and ApplyFlag=0 and `Status`>-1 and `Status`<2", connstr);
+            dtmore = CustomerSqlConn.dtable("select count(Id)*300 from PreSendStockDetail pos where FromStoreId in (select Id from StoreHouse where UserId=" + UserId + " and Sort=0) and BrandId in (select Id from KqProducts where Kind=2) and AuthFlag=1 and ApplyFlag=0 and `Status`>-1 and `Status`<2", connstr);
             if(dtmore.Rows.Count > 0)
             {
                 AmountMore -= decimal.Parse(function.CheckNum(dtmore.Rows[0][0].ToString()));
@@ -228,6 +228,7 @@ public class StoreApplyHelper
                 if(!string.IsNullOrEmpty(data))
                 {
                     function.WriteLog("data:" + data, "分仓向总仓申请机具日志");
+                    List<KqProducts> brands = db.KqProducts.ToList();
                     JsonData jsonObj = JsonMapper.ToObject(data);
                     if(jsonObj["Kind"].ToString() == "1") // 购买临时额度
                     {
@@ -304,11 +305,12 @@ public class StoreApplyHelper
                                 if(prepos.AuthFlag == 0)
                                 {
                                     PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == SnId) ?? new PosMachinesTwo();
-                                    if(pos.BrandId == 1 || pos.BrandId == 2 || pos.BrandId == 4 || pos.BrandId == 6 || pos.BrandId == 7 || pos.BrandId == 8 || pos.BrandId == 10 || pos.BrandId == 12)
+                                    KqProducts brand = brands.FirstOrDefault(m => m.Id == pos.BrandId) ?? new KqProducts();
+                                    if(brand.Kind == 1)
                                     {
                                         Amount += 200;
                                     }
-                                    else if(pos.BrandId == 3 || pos.BrandId == 5 || pos.BrandId == 9 || pos.BrandId == 11 || pos.BrandId == 13)
+                                    else if(brand.Kind == 2)
                                     {
                                         Amount += 300;
                                     }
@@ -331,11 +333,12 @@ public class StoreApplyHelper
                         if(store != null)
                         {
                             decimal Amount = 0;
-                            if(BrandId == 1 || BrandId == 2 || BrandId == 4 || BrandId == 6 || BrandId == 7 || BrandId == 8 || BrandId == 10 || BrandId == 12)
+                            KqProducts brand = brands.FirstOrDefault(m => m.Id == BrandId) ?? new KqProducts();
+                            if(brand.Kind == 1)
                             {
                                 Amount += 200 * OpStoreNum;
                             }
-                            else if(BrandId == 3 || BrandId == 5 || BrandId == 9 || BrandId == 11 || BrandId == 13)
+                            else if(brand.Kind == 2)
                             {
                                 Amount += 300 * OpStoreNum;
                             }