Explorar o código

每天生成商机个数可单独配置

lichunlei %!s(int64=2) %!d(string=hai) anos
pai
achega
611dfa89d0

+ 8 - 2
AppStart/Helper/Profit/HelpProfitPreMerchantHelper.cs

@@ -48,13 +48,19 @@ namespace MySystem
             string Month3 = start.AddMonths(-2).ToString("yyyyMM");
             OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
             string GetCount = function.ReadInstance("/PublicParam/HelpProfitMerCount.txt");
+            string BrandId = function.ReadInstance("/PublicParam/HelpProfitMerBrandId.txt");
             if(string.IsNullOrEmpty(GetCount))
             {
-                GetCount = "1000";
+                GetCount = "500";
                 function.WritePage("/PublicParam/", "HelpProfitMerCount.txt", GetCount);
             }
+            if(string.IsNullOrEmpty(BrandId))
+            {
+                BrandId = "1";
+                function.WritePage("/PublicParam/", "HelpProfitMerBrandId.txt", BrandId);
+            }
             RedisDbconn.Instance.Clear("HelpProfitMerchantIds");
-            DataTable dt = OtherMySqlConn.dtable("SELECT MerchantId,sum FROM( SELECT MerchantId,SUM(TradeAmount) sum FROM PosMerchantTradeSummay WHERE MerchantId not in (select MerchantId from HelpProfitMerIds) AND TradeMonth in ('" + Month1 + "','" + Month2 + "','" + Month3 + "') GROUP BY MerchantId)a WHERE a.sum/3 >= 35000 and a.sum/3 <= 50000 limit " + GetCount);
+            DataTable dt = OtherMySqlConn.dtable("SELECT MerchantId,sum FROM( SELECT MerchantId,SUM(TradeAmount) sum FROM PosMerchantTradeSummay WHERE MerchantId not in (select MerchantId from HelpProfitMerIds) AND BrandId in (" + BrandId + ") AND TradeMonth in ('" + Month1 + "','" + Month2 + "','" + Month3 + "') GROUP BY MerchantId)a WHERE a.sum/3 >= 35000 and a.sum/3 <= 50000 limit " + GetCount);
             foreach(DataRow dr in dt.Rows)
             {
                 RedisDbconn.Instance.AddList("HelpProfitMerchantIds", int.Parse(function.CheckInt(dr["MerchantId"].ToString())));

+ 23 - 1
AppStart/Helper/TestService.cs

@@ -17,7 +17,7 @@ namespace MySystem
 
         public void Start()
         {
-            Thread th = new Thread(statTrade);
+            Thread th = new Thread(helpprofit);
             th.IsBackground = true;
             th.Start();
         }
@@ -391,5 +391,27 @@ namespace MySystem
             // }
             return result;
         }
+    
+    
+        public void helpprofit()
+        {
+            OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
+            DataTable dt = OtherMySqlConn.dtable("select Id,KqMerNo from PosMerchantInfo where Id in (select MerchantId from HelpProfitMerchantForUser) and BrandId!=1");
+            foreach(DataRow dr in dt.Rows)
+            {
+                int MerchantId = int.Parse(dr["Id"].ToString());
+                string KqMerNo = dr["KqMerNo"].ToString();
+                int Id = RedisDbconn.Instance.RPop<int>("HelpProfitMerchantIds");
+                if(Id > 0)
+                {
+                    OtherMySqlConn.op("update HelpProfitMerIds set MerchantId=" + Id + " where MerchantId=" + MerchantId + "");
+                    OtherMySqlConn.op("update PosMerchantInfo set SeoKeyword='' where Id=" + MerchantId);
+                    OtherMySqlConn.op("update PosMerchantInfo set SeoKeyword='已被申领为商机' where Id=" + Id);
+                    OtherMySqlConn.op("update PosCoupons set HelpProfitMerchantId=" + Id + " where HelpProfitMerchantId=" + MerchantId + "");
+                    OtherMySqlConn.op("update HelpProfitMerchantForUser set MerchantId=" + Id + ",Sort=1,MerNo='" + KqMerNo + "' where MerchantId=" + MerchantId + "");
+                }
+            }
+        }
+    
     }
 }