Browse Source

调整分润规则

lcl 1 year ago
parent
commit
2228bc3678
1 changed files with 5 additions and 6 deletions
  1. 5 6
      AppStart/Helper/SycnProfitServiceV3.cs

+ 5 - 6
AppStart/Helper/SycnProfitServiceV3.cs

@@ -66,11 +66,11 @@ namespace MySystem
             {
                 StartId = "0";
             }
-            CustomerSqlConn.op("insert into ProfitRecord (CreateDate,CreateMan,SeoTitle,BrandId,UserId,DirectFlag,ProfitAmount) select now(),'root','" + date + "'," + BrandId + ",UserId,ProfitType,sum(CreditTradeProfit+TradeProfit) from ProfitRewardRecord p where Id>=" + StartId + " and CheckStatus=0 and BrandId=" + BrandId + " and UserId>0 and TradeMonth='" + date + "' group by UserId,ProfitType order by UserId", MysqlConn.connstr);
+            CustomerSqlConn.op("insert into ProfitRecord (CreateDate,CreateMan,SeoTitle,UserId,DirectFlag,ProfitAmount) select now(),'root','" + date + "',UserId,sum(CreditTradeProfit+TradeProfit) from ProfitRewardRecord p where Id>=" + StartId + " and CheckStatus=0 and UserId>0 and TradeMonth='" + date + "' group by UserId order by UserId", MysqlConn.connstr);
             
             CustomerSqlConn.op("update ProfitRewardRecord set CheckStatus=1 where Id>=" + StartId + " and CheckStatus=0 and BrandId=" + BrandId + " and UserId>0 and TradeMonth='" + date + "'", MysqlConn.connstr);
 
-            DataTable dt = OtherMySqlConn.dtable("select UserId,sum(ProfitAmount) from ProfitRecord where BrandId=" + BrandId + " and UserId>0 and SeoTitle='" + date + "' group by UserId");
+            DataTable dt = OtherMySqlConn.dtable("select UserId,sum(ProfitAmount) from ProfitRecord where UserId>0 and SeoTitle='" + date + "' group by UserId");
             function.WriteLog("分润:" + BrandId + ":" + dt.Rows.Count, "同步分润数据");
             int index = 0;
             foreach (DataRow dr in dt.Rows)
@@ -99,20 +99,19 @@ namespace MySystem
             string start = date.Substring(0, 4) + "-" + date.Substring(4) + "-01 00:00:00";
             string end = DateTime.Parse(start).AddMonths(1).ToString("yyyy-MM-dd HH:mm:ss");
             string sql = "";
-            DataTable dt = CustomerSqlConn.dtable("select UserId," + BrandId + " ProductType,301 ChangeType,ProfitAmount,(case when DirectFlag=1 then '直拓商户分润' else '品牌推广服务费' end) Remark from ProfitRecord where BrandId=" + BrandId + " and SeoTitle='" + date + "' and Version=0 and UserId>0 order by Id", MysqlConn.connstr);
+            DataTable dt = CustomerSqlConn.dtable("select UserId,301 ChangeType,ProfitAmount,(case when DirectFlag=1 then '直拓商户分润' else '品牌推广服务费' end) Remark from ProfitRecord where SeoTitle='" + date + "' and Version=0 and UserId>0 order by Id", MysqlConn.connstr);
             int num = 0;
             foreach(DataRow dr in dt.Rows)
             {
                 string CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 string UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 string UserId = dr["UserId"].ToString();
-                string ProductType = dr["ProductType"].ToString();
                 string ChangeType = dr["ChangeType"].ToString();
                 string ChangeAmount = dr["ProfitAmount"].ToString();
                 string Remark = dr["Remark"].ToString();
                 num += 1;
                 sql += "update UserAccount set BalanceAmount=BalanceAmount+" + dr[1].ToString() + ",TotalAmount=TotalAmount+" + dr[1].ToString() + " where Id=" + dr["UserId"].ToString() + ";";
-                sql += "insert into UserAccountRecord (CreateDate,UpdateDate,UserId,ProductType,ChangeType,ChangeAmount,Remark) values ('" + CreateDate + "','" + UpdateDate + "'," + UserId + "," + ProductType + "," + ChangeType + "," + ChangeAmount + ",'" + Remark + "');";
+                sql += "insert into UserAccountRecord (CreateDate,UpdateDate,UserId,ChangeType,ChangeAmount,Remark) values ('" + CreateDate + "','" + UpdateDate + "'," + UserId + "," + ChangeType + "," + ChangeAmount + ",'" + Remark + "');";
                 if(num >= 20)
                 {
                     CustomerSqlConn.op(sql, MysqlConn.kxsconnstr);
@@ -125,7 +124,7 @@ namespace MySystem
                 CustomerSqlConn.op(sql, MysqlConn.kxsconnstr);
             }
 
-            CustomerSqlConn.op("update ProfitRecord set Version=1 where BrandId=" + BrandId + " and SeoTitle='" + date + "' and Version=0 and UserId>0", MysqlConn.connstr);
+            CustomerSqlConn.op("update ProfitRecord set Version=1 where SeoTitle='" + date + "' and Version=0 and UserId>0", MysqlConn.connstr);
         }
 
         #region