Procházet zdrojové kódy

调整盟主申请机具券打标记
修复分润bug

lichunlei před 2 roky
rodič
revize
dc524708ab

+ 5 - 0
AppStart/Helper/LeaderApplyCouponsHelper.cs

@@ -62,6 +62,7 @@ namespace MySystem
                         }
 
                         JsonData ApplyList = JsonMapper.ToObject(queryList.SeoTitle);
+                        var SnList = "";
                         for (int i = 0; i < ApplyList.Count; i++)
                         {
                             int num = Convert.ToInt32(ApplyList[i]["Num"].ToString());
@@ -75,6 +76,7 @@ namespace MySystem
                                     var posCoupon = db.PosCoupons.FirstOrDefault(m => m.Id == item.Id) ?? new PosCoupons();
                                     posCoupon.UserId = queryList.UserId;
                                     posCoupon.LeaderUserId = LeaderUserId;
+                                    SnList += posCoupon.ExchangeCode + ",";
                                 }
                             }
                             //大机
@@ -86,10 +88,13 @@ namespace MySystem
                                     var posCoupon = db.PosCoupons.FirstOrDefault(m => m.Id == items.Id) ?? new PosCoupons();
                                     posCoupon.UserId = queryList.UserId;
                                     posCoupon.LeaderUserId = LeaderUserId;
+                                    SnList += posCoupon.ExchangeCode + ",";
                                 }
                             }
                             db.SaveChanges();
                         }
+                        queryList.SeoDescription = SnList.TrimEnd(',');
+                        db.SaveChanges();
                     }
                     catch (Exception ex)
                     {

+ 252 - 267
AppStart/Helper/Profit/ProfitHelperV2.cs

@@ -57,261 +57,268 @@ namespace MySystem
                 return;
             }
             function.WritePage("/ProfitStat/", Month + "-1.txt", DateTime.Now.ToString());
-            WebCMSEntities db = new WebCMSEntities();
-            for (int i = 1; i <= 9; i++) //品牌
+            try
             {
-                for (int j = 0; j <= 1; j++) //卡类型
+                WebCMSEntities db = new WebCMSEntities();
+                for (int i = 1; i <= 9; i++) //品牌
                 {
-                    int PageNum = 1;
-                    bool op = true;
-                    while(op)
+                    for (int j = 0; j <= 1; j++) //卡类型
                     {
-                        function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + "BrandId:" + i + ",BankCardType:" + j + ",Month:" + Month + ",PageNum:" + PageNum, "分润监控日志");
-                        List<ProfitResult> result = StartProftForPosByDate(i, j, Month, PageNum);
-                        function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + "result:" + result.Count, "分润监控日志");
-                        function.WriteLog("\r\n", "分润监控日志");
-                        if(result.Count > 0)
+                        int PageNum = 1;
+                        bool op = true;
+                        while(op)
                         {
-                            foreach (ProfitResult sub in result)
+                            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + "BrandId:" + i + ",BankCardType:" + j + ",Month:" + Month + ",PageNum:" + PageNum, "分润监控日志");
+                            List<ProfitResult> result = StartProftForPosByDate(i, j, Month, PageNum);
+                            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + "result:" + result.Count, "分润监控日志");
+                            function.WriteLog("\r\n", "分润监控日志");
+                            if(result.Count > 0)
                             {
-                                int TopUserId = 0;
-                                if (!string.IsNullOrEmpty(sub.UserNav))
+                                foreach (ProfitResult sub in result)
                                 {
-                                    string[] UserNavList = sub.UserNav.Trim(',').Replace(",,", ",").Split(',');
-                                    if (UserNavList.Length > 1)
+                                    int TopUserId = 0;
+                                    if (!string.IsNullOrEmpty(sub.UserNav))
                                     {
-                                        TopUserId = int.Parse(UserNavList[1]);
+                                        string[] UserNavList = sub.UserNav.Trim(',').Replace(",,", ",").Split(',');
+                                        if (UserNavList.Length > 1)
+                                        {
+                                            TopUserId = int.Parse(UserNavList[1]);
+                                        }
+                                        else
+                                        {
+                                            TopUserId = int.Parse(UserNavList[0]);
+                                        }
                                     }
-                                    else
+                                    string RecordNo = "P" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
+                                    decimal ProfitAmt = sub.Money;
+                                    decimal TradeAmt = sub.TradeAmount;
+                                    decimal ProfitRate = sub.ProfitRate;
+                                    if (sub.IsSubsidy == 1 && j == 1)
                                     {
-                                        TopUserId = int.Parse(UserNavList[0]);
                                     }
-                                }
-                                string RecordNo = "P" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
-                                decimal ProfitAmt = sub.Money;
-                                decimal TradeAmt = sub.TradeAmount;
-                                decimal ProfitRate = sub.ProfitRate;
-                                if (sub.IsSubsidy == 1 && j == 1)
-                                {
-                                }
-                                else
-                                {
-                                    decimal CreditTradeAmt = 0;
-                                    decimal CreditTradeProfit = 0;
-                                    decimal QrCreditTradeAmt = 0;
-                                    decimal QrCreditProfitRate = 0;
-                                    decimal QrCreditProfitStandardRate = 0;
-                                    decimal QrCreditAddOrSubRate = 0;
-                                    decimal QrCreditTradeProfit = 0;
-                                    decimal NonQrCreditTradeAmt = 0;
-                                    decimal NotHelpCreditTradeAmt = 0;
-                                    decimal NotHelpCreditTradeProfit = 0;
-                                    decimal NotHelpCreditProfitRate = 0;
-                                    decimal NotHelpCreditProfitStandardRate = 0;
-                                    decimal NotHelpCreditAddOrSubRate = 0;
-                                    decimal HelpCreditTradeAmt = 0;
-                                    decimal NonQrCreditTradeProfit = 0;
-                                    decimal HelpCreditTradeProfit = 0;
-                                    decimal HelpCreditProfitRate = 0;
-                                    decimal HelpCreditProfitStandardRate = 0;
-                                    decimal HelpCreditAddOrSubRate = 0;
-                                    decimal DebitNonCapTradeAmt = 0;
-                                    decimal DebitCapTradeAmt = 0;
-                                    decimal QrDebitNotCapTradeAmt = 0;
-                                    decimal NonQrDebitNotCapTradeAmt = 0;
-                                    decimal NotHelpDebitNonCapTradeAmt = 0;
-                                    decimal HelpDebitNonCapTradeAmt = 0;
-                                    decimal DebitNonTradeCapProfit = 0;
-                                    decimal QrDebitNonTradeCapProfit = 0;
-                                    decimal NonQrDebitNonTradeCapProfit = 0;
-                                    decimal NotHelpDebitNonTradeCapProfit = 0;
-                                    decimal HelpDebitNonTradeCapProfit = 0;
-                                    decimal DebitTradeCapProfit = 0;
-                                    decimal NotHelpDebitProfitRate = 0;
-                                    decimal NotHelpDebitProfitStandardRate = 0;
-                                    decimal NotHelpDebitAddOrSubRate = 0;
-                                    decimal HelpDebitProfitRate = 0;
-                                    decimal HelpDebitProfitStandardRate = 0;
-                                    decimal HelpDebitAddOrSubRate = 0;
-                                    decimal DebitCapSingleReward = 0;
-                                    decimal QrDebitProfitRate = 0;
-                                    decimal QrDebitProfitStandardRate = 0;
-                                    decimal QrDebitAddOrSubRate = 0;
-                                    decimal ProfitCreditTradeProfit = 0;
-                                    decimal ProfitCreditProfitRate = 0;
-                                    decimal ProfitCreditTradeAmt = 0;
-                                    decimal ProfitDebitNonCapTradeAmt = 0;
-                                    decimal ProfitDebitNonTradeCapProfit = 0;
-                                    decimal ProfitDebitProfitRate = 0;
-                                    if (j == 1)
+                                    else
                                     {
-                                        CreditTradeAmt = TradeAmt; //贷记卡交易总金额
-                                        CreditTradeProfit = ProfitAmt; //贷记卡分润总金额
-                                        if (sub.QrPayFlag == 1)
-                                        {
-                                            QrCreditTradeAmt = TradeAmt; //(云闪付)贷记卡交易总金额
-                                            QrCreditProfitRate = ProfitRate; //(云闪付)贷记卡交易分润比例
-                                            QrCreditTradeProfit = ProfitAmt; //(云闪付)贷记卡交易分润
-                                        }
-                                        else
+                                        decimal CreditTradeAmt = 0;
+                                        decimal CreditTradeProfit = 0;
+                                        decimal QrCreditTradeAmt = 0;
+                                        decimal QrCreditProfitRate = 0;
+                                        decimal QrCreditProfitStandardRate = 0;
+                                        decimal QrCreditAddOrSubRate = 0;
+                                        decimal QrCreditTradeProfit = 0;
+                                        decimal NonQrCreditTradeAmt = 0;
+                                        decimal NotHelpCreditTradeAmt = 0;
+                                        decimal NotHelpCreditTradeProfit = 0;
+                                        decimal NotHelpCreditProfitRate = 0;
+                                        decimal NotHelpCreditProfitStandardRate = 0;
+                                        decimal NotHelpCreditAddOrSubRate = 0;
+                                        decimal HelpCreditTradeAmt = 0;
+                                        decimal NonQrCreditTradeProfit = 0;
+                                        decimal HelpCreditTradeProfit = 0;
+                                        decimal HelpCreditProfitRate = 0;
+                                        decimal HelpCreditProfitStandardRate = 0;
+                                        decimal HelpCreditAddOrSubRate = 0;
+                                        decimal DebitNonCapTradeAmt = 0;
+                                        decimal DebitCapTradeAmt = 0;
+                                        decimal QrDebitNotCapTradeAmt = 0;
+                                        decimal NonQrDebitNotCapTradeAmt = 0;
+                                        decimal NotHelpDebitNonCapTradeAmt = 0;
+                                        decimal HelpDebitNonCapTradeAmt = 0;
+                                        decimal DebitNonTradeCapProfit = 0;
+                                        decimal QrDebitNonTradeCapProfit = 0;
+                                        decimal NonQrDebitNonTradeCapProfit = 0;
+                                        decimal NotHelpDebitNonTradeCapProfit = 0;
+                                        decimal HelpDebitNonTradeCapProfit = 0;
+                                        decimal DebitTradeCapProfit = 0;
+                                        decimal NotHelpDebitProfitRate = 0;
+                                        decimal NotHelpDebitProfitStandardRate = 0;
+                                        decimal NotHelpDebitAddOrSubRate = 0;
+                                        decimal HelpDebitProfitRate = 0;
+                                        decimal HelpDebitProfitStandardRate = 0;
+                                        decimal HelpDebitAddOrSubRate = 0;
+                                        decimal DebitCapSingleReward = 0;
+                                        decimal QrDebitProfitRate = 0;
+                                        decimal QrDebitProfitStandardRate = 0;
+                                        decimal QrDebitAddOrSubRate = 0;
+                                        decimal ProfitCreditTradeProfit = 0;
+                                        decimal ProfitCreditProfitRate = 0;
+                                        decimal ProfitCreditTradeAmt = 0;
+                                        decimal ProfitDebitNonCapTradeAmt = 0;
+                                        decimal ProfitDebitNonTradeCapProfit = 0;
+                                        decimal ProfitDebitProfitRate = 0;
+                                        if (j == 1)
                                         {
-                                            NonQrCreditTradeAmt = TradeAmt; //(非云闪付)贷记卡交易总金额
-                                            NonQrCreditTradeProfit = ProfitAmt; //(非云闪付)贷记卡交易分润
-                                            if(sub.HelpFlag == 1)
+                                            CreditTradeAmt = TradeAmt; //贷记卡交易总金额
+                                            CreditTradeProfit = ProfitAmt; //贷记卡分润总金额
+                                            if (sub.QrPayFlag == 1)
                                             {
-                                                HelpCreditTradeProfit = ProfitAmt; //(扶持期)(非云闪付)贷记卡分润总金额
-                                                HelpCreditProfitRate = ProfitRate; //(扶持期)(非云闪付)贷记卡商户交易对应分润比例
-                                                HelpCreditTradeAmt = TradeAmt; //(扶持期)(非云闪付)贷记卡交易总金额
-                                            }
-                                            else if(sub.HelpFlag == 2)
-                                            {
-                                                ProfitCreditTradeProfit = ProfitAmt; //(扶持期)(非云闪付)贷记卡分润总金额
-                                                ProfitCreditProfitRate = ProfitRate; //(扶持期)(非云闪付)贷记卡商户交易对应分润比例
-                                                ProfitCreditTradeAmt = TradeAmt; //(扶持期)(非云闪付)贷记卡交易总金额
+                                                QrCreditTradeAmt = TradeAmt; //(云闪付)贷记卡交易总金额
+                                                QrCreditProfitRate = ProfitRate; //(云闪付)贷记卡交易分润比例
+                                                QrCreditTradeProfit = ProfitAmt; //(云闪付)贷记卡交易分润
                                             }
                                             else
                                             {
-                                                NotHelpCreditTradeAmt = TradeAmt; //(非扶持期)(非云闪付)贷记卡交易总金额
-                                                NotHelpCreditTradeProfit = ProfitAmt; //(非扶持期)(非云闪付)贷记卡分润总金额
-                                                NotHelpCreditProfitRate = ProfitRate; //(非扶持期)(非云闪付)贷记卡商户交易对应分润比例
+                                                NonQrCreditTradeAmt = TradeAmt; //(非云闪付)贷记卡交易总金额
+                                                NonQrCreditTradeProfit = ProfitAmt; //(非云闪付)贷记卡交易分润
+                                                if(sub.HelpFlag == 1)
+                                                {
+                                                    HelpCreditTradeProfit = ProfitAmt; //(扶持期)(非云闪付)贷记卡分润总金额
+                                                    HelpCreditProfitRate = ProfitRate; //(扶持期)(非云闪付)贷记卡商户交易对应分润比例
+                                                    HelpCreditTradeAmt = TradeAmt; //(扶持期)(非云闪付)贷记卡交易总金额
+                                                }
+                                                else if(sub.HelpFlag == 2)
+                                                {
+                                                    ProfitCreditTradeProfit = ProfitAmt; //(扶持期)(非云闪付)贷记卡分润总金额
+                                                    ProfitCreditProfitRate = ProfitRate; //(扶持期)(非云闪付)贷记卡商户交易对应分润比例
+                                                    ProfitCreditTradeAmt = TradeAmt; //(扶持期)(非云闪付)贷记卡交易总金额
+                                                }
+                                                else
+                                                {
+                                                    NotHelpCreditTradeAmt = TradeAmt; //(非扶持期)(非云闪付)贷记卡交易总金额
+                                                    NotHelpCreditTradeProfit = ProfitAmt; //(非扶持期)(非云闪付)贷记卡分润总金额
+                                                    NotHelpCreditProfitRate = ProfitRate; //(非扶持期)(非云闪付)贷记卡商户交易对应分润比例
+                                                }
                                             }
                                         }
-                                    }
-                                    if (j == 0)
-                                    {
-                                        if (sub.Money < 1)
-                                        {
-                                            DebitNonCapTradeAmt = TradeAmt; //商户非封顶借记卡交易总额
-                                            DebitNonTradeCapProfit = ProfitAmt; //借记卡非封顶交易分润总金额
-                                        }
-                                        else
-                                        {
-                                            DebitCapTradeAmt = TradeAmt; //商户借记卡封顶交易总额
-                                            DebitCapSingleReward = ProfitAmt; //借记卡合伙人直营封顶交易奖励金额
-                                            DebitTradeCapProfit = ProfitAmt; //借记卡封顶交易分润总金额
-                                        }
-                                        if (sub.QrPayFlag == 1)
+                                        if (j == 0)
                                         {
                                             if (sub.Money < 1)
                                             {
-                                                QrDebitNotCapTradeAmt = TradeAmt; //(云闪付)商户非封顶借记卡交易总额
-                                                QrDebitProfitRate = ProfitRate; //(云闪付)借记卡非封顶交易分润比例
-                                                QrDebitNonTradeCapProfit = ProfitAmt; //(云闪付)借记卡非封顶交易分润总金额
+                                                DebitNonCapTradeAmt = TradeAmt; //商户非封顶借记卡交易总额
+                                                DebitNonTradeCapProfit = ProfitAmt; //借记卡非封顶交易分润总金额
                                             }
-                                        }
-                                        else
-                                        {
-                                            if (sub.Money < 1)
+                                            else
                                             {
-                                                NonQrDebitNonTradeCapProfit = ProfitAmt; //(非云闪付)借记卡非封顶交易分润总金额
-                                                NonQrDebitNotCapTradeAmt = TradeAmt; //(非云闪付)商户非封顶借记卡交易总额
+                                                DebitCapTradeAmt = TradeAmt; //商户借记卡封顶交易总额
+                                                DebitCapSingleReward = ProfitAmt; //借记卡合伙人直营封顶交易奖励金额
+                                                DebitTradeCapProfit = ProfitAmt; //借记卡封顶交易分润总金额
                                             }
-                                            if (sub.HelpFlag == 1)
+                                            if (sub.QrPayFlag == 1)
                                             {
                                                 if (sub.Money < 1)
                                                 {
-                                                    HelpDebitNonCapTradeAmt = TradeAmt; //(扶持期)(非云闪付)借记卡非封顶交易总金额
-                                                    HelpDebitNonTradeCapProfit = ProfitAmt; //(扶持期)(非云闪付)借记卡非封顶交易分润总金额
+                                                    QrDebitNotCapTradeAmt = TradeAmt; //(云闪付)商户非封顶借记卡交易总额
+                                                    QrDebitProfitRate = ProfitRate; //(云闪付)借记卡非封顶交易分润比例
+                                                    QrDebitNonTradeCapProfit = ProfitAmt; //(云闪付)借记卡非封顶交易分润总金额
                                                 }
-                                                HelpDebitProfitRate = ProfitRate; //(扶持期)(非云闪付)借记卡商户交易对应分润比例
                                             }
-                                            else if (sub.HelpFlag == 2)
+                                            else
                                             {
                                                 if (sub.Money < 1)
                                                 {
-                                                    ProfitDebitNonCapTradeAmt = TradeAmt; //(盈利期)(非云闪付)借记卡非封顶交易总金额
-                                                    ProfitDebitNonTradeCapProfit = ProfitAmt; //(盈利期)(非云闪付)借记卡非封顶交易分润总金
+                                                    NonQrDebitNonTradeCapProfit = ProfitAmt; //(非云闪付)借记卡非封顶交易分润总金额
+                                                    NonQrDebitNotCapTradeAmt = TradeAmt; //(非云闪付)商户非封顶借记卡交易总
                                                 }
-                                                ProfitDebitProfitRate = ProfitRate; //(盈利期)(非云闪付)借记卡商户交易对应分润比例
-                                            }
-                                            else
-                                            {
-                                                if (sub.Money < 1)
+                                                if (sub.HelpFlag == 1)
+                                                {
+                                                    if (sub.Money < 1)
+                                                    {
+                                                        HelpDebitNonCapTradeAmt = TradeAmt; //(扶持期)(非云闪付)借记卡非封顶交易总金额
+                                                        HelpDebitNonTradeCapProfit = ProfitAmt; //(扶持期)(非云闪付)借记卡非封顶交易分润总金额
+                                                    }
+                                                    HelpDebitProfitRate = ProfitRate; //(扶持期)(非云闪付)借记卡商户交易对应分润比例
+                                                }
+                                                else if (sub.HelpFlag == 2)
+                                                {
+                                                    if (sub.Money < 1)
+                                                    {
+                                                        ProfitDebitNonCapTradeAmt = TradeAmt; //(盈利期)(非云闪付)借记卡非封顶交易总金额
+                                                        ProfitDebitNonTradeCapProfit = ProfitAmt; //(盈利期)(非云闪付)借记卡非封顶交易分润总金额
+                                                    }
+                                                    ProfitDebitProfitRate = ProfitRate; //(盈利期)(非云闪付)借记卡商户交易对应分润比例
+                                                }
+                                                else
                                                 {
-                                                    NotHelpDebitNonCapTradeAmt = TradeAmt; //(非扶持期)(非云闪付)借记卡非封顶交易总金额
-                                                    NotHelpDebitNonTradeCapProfit = ProfitAmt; //(非扶持期)(非云闪付)借记卡非封顶交易分润总金额
+                                                    if (sub.Money < 1)
+                                                    {
+                                                        NotHelpDebitNonCapTradeAmt = TradeAmt; //(非扶持期)(非云闪付)借记卡非封顶交易总金额
+                                                        NotHelpDebitNonTradeCapProfit = ProfitAmt; //(非扶持期)(非云闪付)借记卡非封顶交易分润总金额
+                                                    }
+                                                    NotHelpDebitProfitRate = ProfitRate; //(非扶持期)(非云闪付)借记卡商户交易对应分润比例
                                                 }
-                                                NotHelpDebitProfitRate = ProfitRate; //(非扶持期)(非云闪付)借记卡商户交易对应分润比例
                                             }
                                         }
+                                        db.ProfitRewardRecord.Add(new ProfitRewardRecord()
+                                        {
+                                            CreateDate = DateTime.Now,
+                                            UpdateDate = DateTime.Now,
+                                            UserId = sub.UserId, //创客
+                                            MerchantId = sub.MerchantId, //商户
+                                            BrandId = sub.BrandId, //品牌
+                                            ProfitType = sub.DirectFlag, //创客分润类型
+                                            TradeAmt = sub.TradeAmount, //商户交易总额
+                                            TradeProfit = sub.Money, //交易分润
+                                            TradeMonth = Month, //交易月
+                                            RecordNo = RecordNo, //记录单号
+                                            TopUserId = TopUserId, //顶级创客
+                                            CreditTradeAmt = CreditTradeAmt, //贷记卡交易总金额
+                                            QrCreditTradeAmt = QrCreditTradeAmt, //(云闪付)贷记卡交易总金额
+                                            NonQrCreditTradeAmt = NonQrCreditTradeAmt, //(非云闪付)贷记卡交易总金额
+                                            NotHelpCreditTradeAmt = NotHelpCreditTradeAmt, //(非扶持期)(非云闪付)贷记卡交易总金额
+                                            HelpCreditTradeAmt = HelpCreditTradeAmt, //(扶持期)(非云闪付)贷记卡交易总金额
+                                            DebitNonCapTradeAmt = DebitNonCapTradeAmt, //商户非封顶借记卡交易总额
+                                            QrDebitNotCapTradeAmt = QrDebitNotCapTradeAmt, //(云闪付)商户非封顶借记卡交易总额
+                                            NonQrDebitNotCapTradeAmt = NonQrDebitNotCapTradeAmt, //(非云闪付)商户非封顶借记卡交易总额
+                                            NotHelpDebitNonCapTradeAmt = NotHelpDebitNonCapTradeAmt, //(非扶持期)(非云闪付)借记卡非封顶交易总金额
+                                            HelpDebitNonCapTradeAmt = HelpDebitNonCapTradeAmt, //(扶持期)(非云闪付)借记卡非封顶交易总金额
+                                            DebitCapTradeAmt = DebitCapTradeAmt, //商户借记卡封顶交易总额
+                                            CreditTradeProfit = CreditTradeProfit, //贷记卡分润总金额
+                                            QrCreditTradeProfit = QrCreditTradeProfit, //(云闪付)贷记卡交易分润
+                                            NonQrCreditTradeProfit = NonQrCreditTradeProfit, //(非云闪付)贷记卡交易分润
+                                            NotHelpCreditTradeProfit = NotHelpCreditTradeProfit, //(非扶持期)(非云闪付)贷记卡分润总金额
+                                            HelpCreditTradeProfit = HelpCreditTradeProfit, //(扶持期)(非云闪付)贷记卡分润总金额
+                                            DebitNonTradeCapProfit = DebitNonTradeCapProfit, //借记卡非封顶交易分润总金额
+                                            QrDebitNonTradeCapProfit = QrDebitNonTradeCapProfit, //(云闪付)借记卡非封顶交易分润总金额
+                                            NonQrDebitNonTradeCapProfit = NonQrDebitNonTradeCapProfit, //(非云闪付)借记卡非封顶交易分润总金额
+                                            NotHelpDebitNonTradeCapProfit = NotHelpDebitNonTradeCapProfit, //(非扶持期)(非云闪付)借记卡非封顶交易分润总金额
+                                            HelpDebitNonTradeCapProfit = HelpDebitNonTradeCapProfit, //(扶持期)(非云闪付)借记卡非封顶交易分润总金额
+                                            DebitTradeCapProfit = DebitTradeCapProfit, //借记卡封顶交易分润总金额
+                                            NotHelpCreditProfitRate = NotHelpCreditProfitRate, //(非扶持期)(非云闪付)贷记卡商户交易对应分润比例
+                                            NotHelpCreditProfitStandardRate = NotHelpCreditProfitStandardRate, //(非扶持期)(非云闪付)贷记卡标准分润比例
+                                            NotHelpCreditAddOrSubRate = NotHelpCreditAddOrSubRate, //(非扶持期)(非云闪付)贷记卡成本或增或减比例
+                                            HelpCreditProfitRate = HelpCreditProfitRate, //(扶持期)(非云闪付)贷记卡商户交易对应分润比例
+                                            HelpCreditProfitStandardRate = HelpCreditProfitStandardRate, //(扶持期)(非云闪付)贷记卡-标准分润比例
+                                            HelpCreditAddOrSubRate = HelpCreditAddOrSubRate, //(扶持期)(非云闪付)贷记卡成本或增或减比例
+                                            NotHelpDebitProfitRate = NotHelpDebitProfitRate, //(非扶持期)(非云闪付)借记卡商户交易对应分润比例
+                                            NotHelpDebitProfitStandardRate = NotHelpDebitProfitStandardRate, //(非扶持期)(非云闪付)借记卡标准分润比例
+                                            NotHelpDebitAddOrSubRate = NotHelpDebitAddOrSubRate, //(非扶持期)(非云闪付)借记卡成本或增或减比例
+                                            HelpDebitProfitRate = HelpDebitProfitRate, //(扶持期)(非云闪付)借记卡商户交易对应分润比例
+                                            HelpDebitProfitStandardRate = HelpDebitProfitStandardRate, //(扶持期)(非云闪付)借记卡-标准分润比例
+                                            HelpDebitAddOrSubRate = HelpDebitAddOrSubRate, //(扶持期)(非云闪付)借记卡成本或增或减比例
+                                            DebitCapSingleReward = DebitCapSingleReward, //借记卡合伙人直营封顶交易奖励金额
+                                            QrCreditProfitRate = QrCreditProfitRate, //(云闪付)贷记卡交易分润比例
+                                            QrCreditProfitStandardRate = QrCreditProfitStandardRate, //(云闪付)贷记卡分润基准
+                                            QrCreditAddOrSubRate = QrCreditAddOrSubRate, //(云闪付)贷记卡分润比例或增或减
+                                            QrDebitProfitRate = QrDebitProfitRate, //(云闪付)借记卡非封顶交易分润比例
+                                            QrDebitProfitStandardRate = QrDebitProfitStandardRate, //(云闪付)借记卡非封顶交易分润基准
+                                            QrDebitAddOrSubRate = QrDebitAddOrSubRate, //(云闪付)借记卡非封顶交易分润比例或增或减
+                                            ProfitCreditTradeProfit = ProfitCreditTradeProfit,  //(盈利期)(非云闪付)贷记卡分润总金额
+                                            ProfitCreditProfitRate = ProfitCreditProfitRate, //(盈利期)(非云闪付)贷记卡商户交易对应分润比例
+                                            ProfitCreditTradeAmt = ProfitCreditTradeAmt, //(盈利期)(非云闪付)贷记卡交易总金额
+                                            ProfitDebitNonCapTradeAmt = ProfitDebitNonCapTradeAmt, //(盈利期)(非云闪付)借记卡非封顶交易总金额
+                                            ProfitDebitNonTradeCapProfit = ProfitDebitNonTradeCapProfit, //(盈利期)(非云闪付)借记卡非封顶交易分润总金额
+                                            ProfitDebitProfitRate = ProfitDebitProfitRate, //(盈利期)(非云闪付)借记卡商户交易对应分润比例
+                                        });
+                                        // db.SaveChanges();
                                     }
-                                    db.ProfitRewardRecord.Add(new ProfitRewardRecord()
-                                    {
-                                        CreateDate = DateTime.Now,
-                                        UpdateDate = DateTime.Now,
-                                        UserId = sub.UserId, //创客
-                                        MerchantId = sub.MerchantId, //商户
-                                        BrandId = sub.BrandId, //品牌
-                                        ProfitType = sub.DirectFlag, //创客分润类型
-                                        TradeAmt = sub.TradeAmount, //商户交易总额
-                                        TradeProfit = sub.Money, //交易分润
-                                        TradeMonth = Month, //交易月
-                                        RecordNo = RecordNo, //记录单号
-                                        TopUserId = TopUserId, //顶级创客
-                                        CreditTradeAmt = CreditTradeAmt, //贷记卡交易总金额
-                                        QrCreditTradeAmt = QrCreditTradeAmt, //(云闪付)贷记卡交易总金额
-                                        NonQrCreditTradeAmt = NonQrCreditTradeAmt, //(非云闪付)贷记卡交易总金额
-                                        NotHelpCreditTradeAmt = NotHelpCreditTradeAmt, //(非扶持期)(非云闪付)贷记卡交易总金额
-                                        HelpCreditTradeAmt = HelpCreditTradeAmt, //(扶持期)(非云闪付)贷记卡交易总金额
-                                        DebitNonCapTradeAmt = DebitNonCapTradeAmt, //商户非封顶借记卡交易总额
-                                        QrDebitNotCapTradeAmt = QrDebitNotCapTradeAmt, //(云闪付)商户非封顶借记卡交易总额
-                                        NonQrDebitNotCapTradeAmt = NonQrDebitNotCapTradeAmt, //(非云闪付)商户非封顶借记卡交易总额
-                                        NotHelpDebitNonCapTradeAmt = NotHelpDebitNonCapTradeAmt, //(非扶持期)(非云闪付)借记卡非封顶交易总金额
-                                        HelpDebitNonCapTradeAmt = HelpDebitNonCapTradeAmt, //(扶持期)(非云闪付)借记卡非封顶交易总金额
-                                        DebitCapTradeAmt = DebitCapTradeAmt, //商户借记卡封顶交易总额
-                                        CreditTradeProfit = CreditTradeProfit, //贷记卡分润总金额
-                                        QrCreditTradeProfit = QrCreditTradeProfit, //(云闪付)贷记卡交易分润
-                                        NonQrCreditTradeProfit = NonQrCreditTradeProfit, //(非云闪付)贷记卡交易分润
-                                        NotHelpCreditTradeProfit = NotHelpCreditTradeProfit, //(非扶持期)(非云闪付)贷记卡分润总金额
-                                        HelpCreditTradeProfit = HelpCreditTradeProfit, //(扶持期)(非云闪付)贷记卡分润总金额
-                                        DebitNonTradeCapProfit = DebitNonTradeCapProfit, //借记卡非封顶交易分润总金额
-                                        QrDebitNonTradeCapProfit = QrDebitNonTradeCapProfit, //(云闪付)借记卡非封顶交易分润总金额
-                                        NonQrDebitNonTradeCapProfit = NonQrDebitNonTradeCapProfit, //(非云闪付)借记卡非封顶交易分润总金额
-                                        NotHelpDebitNonTradeCapProfit = NotHelpDebitNonTradeCapProfit, //(非扶持期)(非云闪付)借记卡非封顶交易分润总金额
-                                        HelpDebitNonTradeCapProfit = HelpDebitNonTradeCapProfit, //(扶持期)(非云闪付)借记卡非封顶交易分润总金额
-                                        DebitTradeCapProfit = DebitTradeCapProfit, //借记卡封顶交易分润总金额
-                                        NotHelpCreditProfitRate = NotHelpCreditProfitRate, //(非扶持期)(非云闪付)贷记卡商户交易对应分润比例
-                                        NotHelpCreditProfitStandardRate = NotHelpCreditProfitStandardRate, //(非扶持期)(非云闪付)贷记卡标准分润比例
-                                        NotHelpCreditAddOrSubRate = NotHelpCreditAddOrSubRate, //(非扶持期)(非云闪付)贷记卡成本或增或减比例
-                                        HelpCreditProfitRate = HelpCreditProfitRate, //(扶持期)(非云闪付)贷记卡商户交易对应分润比例
-                                        HelpCreditProfitStandardRate = HelpCreditProfitStandardRate, //(扶持期)(非云闪付)贷记卡-标准分润比例
-                                        HelpCreditAddOrSubRate = HelpCreditAddOrSubRate, //(扶持期)(非云闪付)贷记卡成本或增或减比例
-                                        NotHelpDebitProfitRate = NotHelpDebitProfitRate, //(非扶持期)(非云闪付)借记卡商户交易对应分润比例
-                                        NotHelpDebitProfitStandardRate = NotHelpDebitProfitStandardRate, //(非扶持期)(非云闪付)借记卡标准分润比例
-                                        NotHelpDebitAddOrSubRate = NotHelpDebitAddOrSubRate, //(非扶持期)(非云闪付)借记卡成本或增或减比例
-                                        HelpDebitProfitRate = HelpDebitProfitRate, //(扶持期)(非云闪付)借记卡商户交易对应分润比例
-                                        HelpDebitProfitStandardRate = HelpDebitProfitStandardRate, //(扶持期)(非云闪付)借记卡-标准分润比例
-                                        HelpDebitAddOrSubRate = HelpDebitAddOrSubRate, //(扶持期)(非云闪付)借记卡成本或增或减比例
-                                        DebitCapSingleReward = DebitCapSingleReward, //借记卡合伙人直营封顶交易奖励金额
-                                        QrCreditProfitRate = QrCreditProfitRate, //(云闪付)贷记卡交易分润比例
-                                        QrCreditProfitStandardRate = QrCreditProfitStandardRate, //(云闪付)贷记卡分润基准
-                                        QrCreditAddOrSubRate = QrCreditAddOrSubRate, //(云闪付)贷记卡分润比例或增或减
-                                        QrDebitProfitRate = QrDebitProfitRate, //(云闪付)借记卡非封顶交易分润比例
-                                        QrDebitProfitStandardRate = QrDebitProfitStandardRate, //(云闪付)借记卡非封顶交易分润基准
-                                        QrDebitAddOrSubRate = QrDebitAddOrSubRate, //(云闪付)借记卡非封顶交易分润比例或增或减
-                                        ProfitCreditTradeProfit = ProfitCreditTradeProfit,  //(盈利期)(非云闪付)贷记卡分润总金额
-                                        ProfitCreditProfitRate = ProfitCreditProfitRate, //(盈利期)(非云闪付)贷记卡商户交易对应分润比例
-                                        ProfitCreditTradeAmt = ProfitCreditTradeAmt, //(盈利期)(非云闪付)贷记卡交易总金额
-                                        ProfitDebitNonCapTradeAmt = ProfitDebitNonCapTradeAmt, //(盈利期)(非云闪付)借记卡非封顶交易总金额
-                                        ProfitDebitNonTradeCapProfit = ProfitDebitNonTradeCapProfit, //(盈利期)(非云闪付)借记卡非封顶交易分润总金额
-                                        ProfitDebitProfitRate = ProfitDebitProfitRate, //(盈利期)(非云闪付)借记卡商户交易对应分润比例
-                                    });
-                                    // db.SaveChanges();
                                 }
+                                db.SaveChanges();
+                                PageNum += 1;
+                            }
+                            else
+                            {
+                                op = false;
                             }
-                            db.SaveChanges();
-                            PageNum += 1;
-                        }
-                        else
-                        {
-                            op = false;
                         }
                     }
                 }
+                db.Dispose();
+            }
+            catch(Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "分润监控异常");
             }
-            db.Dispose();
 
-            ProfitHelper.Instance.StatProfit();
+            // ProfitHelper.Instance.StatProfit();
         }
         public List<ProfitResult> StartProftForPosByDate(int BrandId, int BankCardType, string Month, int PageNum = 1)
         {
@@ -402,9 +409,9 @@ namespace MySystem
                 {
                     sqlstr = "select UserId,QrPayFlag,HelpDirectDebitTradeAmt,NotHelpDirectDebitTradeAmt,HelpDirectDebitCapTradeAmt,NotHelpDirectDebitCapTradeAmt,HelpDirectDebitCapNum,NotHelpDirectDebitCapNum,ProfitDirectDebitTradeAmt,ProfitDirectDebitCapTradeAmt,ProfitDirectDebitCapNum from DebitTradeDaySummary" + Month + " where BrandId=" + BrandId + LimitString;
                 }
-                function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + sqlstr, "分润监控日志");
+                // function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + sqlstr, "分润监控日志");
                 DataTable dt = GetDataTable(sqlstr);
-                function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + dt.Rows.Count.ToString(), "分润监控日志");
+                // function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + dt.Rows.Count.ToString(), "分润监控日志");
                 if(dt.Rows.Count > 0)
                 {
                     foreach (DataRow dr in dt.Rows)
@@ -419,7 +426,7 @@ namespace MySystem
                             int Days = int.Parse(RedisDbconn.Instance.Get<string>("pobjrule:" + BrandId + ":HelpPolicy:Days")); //天数
                             if (BankCardType == 0)
                             {
-                                function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":借记卡", "分润监控日志");
+                                // function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":借记卡", "分润监控日志");
                                 decimal HelpDirectDebitTradeAmt = decimal.Parse(dr[2].ToString()); //借记卡扶持期交易额
                                 decimal NotHelpDirectDebitTradeAmt = decimal.Parse(dr[3].ToString()); //借记卡稳定期交易额
                                 decimal ProfitDirectDebitTradeAmt = decimal.Parse(dr[8].ToString()); //借记卡扶持期交易额
@@ -460,7 +467,7 @@ namespace MySystem
                                 {
                                     ParentNav = ",0,";
                                 }
-                                function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + ParentNav, "分润监控日志");
+                                // function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + ParentNav, "分润监控日志");
                                 if (!string.IsNullOrEmpty(ParentNav))
                                 {
                                     ParentNav += "," + UserId + ",";
@@ -472,6 +479,11 @@ namespace MySystem
                                     function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":扶持期:" + HelpDirectTradeAmt, "分润监控日志");
                                     if (HelpDirectTradeAmt > 0)
                                     {
+                                        level = 0;
+                                        curLevel = 0;
+                                        diffLevelProfit = 0;  //等级级差
+                                        decimal checkProfit = HelpDirectTradeAmt * 0.0012M;
+                                        decimal curProfit = 0;
                                         foreach (string UserIdString in ParentNavList)
                                         {
                                             level += 1;
@@ -506,6 +518,7 @@ namespace MySystem
                                                     }
                                                     if (getLevelProfit >= obj.MinProfitVal)
                                                     {
+                                                        int DirectFlag = selfUser.Id == user.Id ? 1 : 0;
                                                         result.Add(new ProfitResult()
                                                         {
                                                             UserId = user.Id,
@@ -515,65 +528,30 @@ namespace MySystem
                                                             Message = "交易分润",
                                                             BankCardType = BankCardType,
                                                             QrPayFlag = QrPayFlag,
-                                                            DirectFlag = selfUser.Id == user.Id ? 1 : 0,
+                                                            DirectFlag = DirectFlag,
                                                             BrandId = BrandId,
                                                             IsSubsidy = 0,
                                                             TradeAmount = HelpDirectTradeAmt,
                                                             HelpFlag = 1,
                                                         });
+                                                        curProfit += getLevelProfit;
+                                                        function.WriteLog(user.Id + "-" + UserLevel + "-" + HelpDirectTradeAmt + "-" + DirectFlag + "-扶持期分润:" + getLevelProfit, "分润监控日志");
                                                     }
-
-                                                    // 分润补贴
-                                                    // if (level == 1)
-                                                    // {
-                                                    //     int SubsidyUserId = selfUser.ParentUserId;
-                                                    //     Users subuser = dbnew.Users.FirstOrDefault(m => m.Id == SubsidyUserId) ?? new Users();
-                                                    //     int subUserLevel = subuser.UserLevel;
-                                                    //     if (subUserLevel < 5)
-                                                    //     {
-                                                    //         UserRankWhite subrank = dbnew.UserRankWhite.FirstOrDefault(m => m.Id == subuser.Id && m.CreateDate < ThisMonth && m.UpdateDate > ThisMonth);
-                                                    //         if (subrank != null)
-                                                    //         {
-                                                    //             if (subrank.Rank > subUserLevel)
-                                                    //             {
-                                                    //                 subUserLevel = subrank.Rank;
-                                                    //             }
-                                                    //         }
-                                                    //         if (subUserLevel < 5)
-                                                    //         {
-                                                    //             ProfitObjectLevels sublevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + subUserLevel); //获取当前等级参数
-                                                    //             if (sublevel != null)
-                                                    //             {
-                                                    //                 decimal otherPercent = 0.001M - sublevel.Percents;
-                                                    //                 decimal otherMoney = HelpDirectTradeAmt * otherPercent;
-                                                    //                 if (otherMoney >= obj.MinProfitVal)
-                                                    //                 {
-                                                    //                     result.Add(new ProfitResult()
-                                                    //                     {
-                                                    //                         UserId = subuser.Id,
-                                                    //                         UserNav = subuser.ParentNav,
-                                                    //                         Money = PublicFunction.NumberFormat(otherMoney),
-                                                    //                         ProfitRate = otherPercent,
-                                                    //                         Message = "分润补贴",
-                                                    //                         BankCardType = BankCardType,
-                                                    //                         QrPayFlag = QrPayFlag,
-                                                    //                         DirectFlag = 1,
-                                                    //                         BrandId = BrandId,
-                                                    //                         IsSubsidy = 1,
-                                                    //                         TradeAmount = HelpDirectTradeAmt,
-                                                    //                         HelpFlag = 1,
-                                                    //                     });
-                                                    //                 }
-                                                    //             }
-                                                    //         }
-                                                    //     }
-                                                    // }
                                                 }
                                             }
-                                            curLevel = UserLevel;
+                                            if(curLevel < UserLevel)
+                                            {
+                                                curLevel = UserLevel;
+                                            }
+                                        }
+                                        if(curProfit > checkProfit)
+                                        {
+                                            decimal more = curProfit - checkProfit;
+                                            function.WriteLog("超标了:" + more, "分润监控日志");
                                         }
                                     }
-                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":稳定期:" + NotHelpDirectTradeAmt, "分润监控日志");
+                                    function.WriteLog("------------------------", "分润监控日志");
+                                    // function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":稳定期:" + NotHelpDirectTradeAmt, "分润监控日志");
                                     if (NotHelpDirectTradeAmt > 0)
                                     {
                                         level = 0;
@@ -631,10 +609,14 @@ namespace MySystem
                                                     }
                                                 }
                                             }
-                                            curLevel = UserLevel;
+                                            if(curLevel < UserLevel)
+                                            {
+                                                curLevel = UserLevel;
+                                            }
                                         }
                                     }
-                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":盈利期:" + ProfitDirectTradeAmt, "分润监控日志");
+                                    // function.WriteLog("------------------------", "分润监控日志");
+                                    // function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":盈利期:" + ProfitDirectTradeAmt, "分润监控日志");
                                     if (ProfitDirectTradeAmt > 0)
                                     {
                                         level = 0;
@@ -691,12 +673,15 @@ namespace MySystem
                                                     }
                                                 }
                                             }
-                                            curLevel = UserLevel;
+                                            if(curLevel < UserLevel)
+                                            {
+                                                curLevel = UserLevel;
+                                            }
                                         }
                                     }
                                 }
                             }
-                            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":over", "分润监控日志");
+                            // function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":over", "分润监控日志");
                         }
                         catch (Exception ex)
                         {

+ 2 - 2
AppStart/PublicFunction.cs

@@ -16,9 +16,9 @@ namespace MySystem
             if (str.Contains("."))
             {
                 string[] list = str.Split('.');
-                if (list[1].Length > 2)
+                if (list[1].Length > floatCount)
                 {
-                    str = list[0] + "." + list[1].Substring(0, 2);
+                    str = list[0] + "." + list[1].Substring(0, floatCount);
                 }
             }
             else

+ 6 - 6
appsettings.json

@@ -17,12 +17,12 @@
     "Host": "http://localhost:5047/",
     "SourceHost": "http://bs.kexiaoshuang.com/",
     "Database": "KxsMainServer",
-    "SqlConnStr": "server=47.108.231.170;port=3306;user=KxsMain;password=mzeqjriUWore0dwT;database=KxsMainServer;charset=utf8;",
-    "Pxc1SqlConnStr": "server=47.108.231.170;port=3306;user=KxsMain;password=mzeqjriUWore0dwT;database=KxsMainServer;charset=utf8;",
-    "MainSqlConnStr": "server=47.108.231.170;port=3306;user=KxsMain;password=mzeqjriUWore0dwT;database=KxsStatServer;charset=utf8;",
-    "SpSqlConnStr": "server=47.108.229.115;port=3306;user=KxsSpServer;password=jJ9qKsvwWgQA9xWG;database=KxsSpServer;charset=utf8;",
-    "OpSqlConnStr": "server=47.108.231.170;port=3306;user=KxsOpServer;password=r7jwZ8ydLoeswDR4;database=KxsOpServer;charset=utf8;",
-    "RedisConnStr": "47.108.207.184:6379,password=skb@redis2022,DefaultDatabase=0,poolsize=500,preheat=50,asyncPipeline=true",
+    "SqlConnStr": "server=47.109.31.237;port=3306;user=KxsMainServer2;password=FrW8ZfxlcaVdm1r0;database=KxsMainServer2;charset=utf8;",
+    "Pxc1SqlConnStr": "server=47.109.31.237;port=3306;user=KxsMainServer2;password=FrW8ZfxlcaVdm1r0;database=KxsMainServer2;charset=utf8;",
+    "MainSqlConnStr": "server=47.109.31.237;port=3306;user=KxsMainServer2;password=FrW8ZfxlcaVdm1r0;database=KxsStatServer;charset=utf8;",
+    "SpSqlConnStr": "server=47.109.31.237;port=3306;user=KxsSpServer;password=jJ9qKsvwWgQA9xWG;database=KxsSpServer;charset=utf8;",
+    "OpSqlConnStr": "server=47.109.31.237;port=3306;user=KxsOpServer;password=r7jwZ8ydLoeswDR4;database=KxsOpServer;charset=utf8;",
+    "RedisConnStr": "47.109.31.237:6379,password=klm@redis,DefaultDatabase=1,poolsize=500,preheat=50,asyncPipeline=true",
     "IOSAppVersion": "1.0.0",
     "AndroidAppVersion": "1.0.0",
     "OSSKey": "iL9dWgBunZRwGbHQ",