|
@@ -0,0 +1,758 @@
|
|
|
|
+using System;
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
+using System.Linq;
|
|
|
|
+using System.Data;
|
|
|
|
+using MySystem.PxcModels;
|
|
|
|
+using Library;
|
|
|
|
+
|
|
|
|
+namespace MySystem
|
|
|
|
+{
|
|
|
|
+ public class ProfitWifiHelper
|
|
|
|
+ {
|
|
|
|
+ public readonly static ProfitWifiHelper Instance = new ProfitWifiHelper();
|
|
|
|
+ private ProfitWifiHelper()
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #region 获取分润规则Id
|
|
|
|
+
|
|
|
|
+ public int GetLevelKindId(int BrandId, int Help, int BankCardType)
|
|
|
|
+ {
|
|
|
|
+ return RedisDbconn.Instance.Get<int>("pobjlv:kid:" + BrandId + ":" + Help + ":" + BankCardType);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region POS分润算法
|
|
|
|
+ public void StatProfiting()
|
|
|
|
+ {
|
|
|
|
+ string Month = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
|
|
|
|
+ string check = function.ReadInstance("/ProfitStat/" + Month + "-1-wifi.txt");
|
|
|
|
+ if (!string.IsNullOrEmpty(check))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ function.WritePage("/ProfitStat/", Month + "-1-wifi.txt", DateTime.Now.ToString());
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
|
+ List<int> BrandIds = new List<int>();
|
|
|
|
+ BrandIds.Add(23);
|
|
|
|
+ BrandIds.Add(24);
|
|
|
|
+ BrandIds.Add(25);
|
|
|
|
+ BrandIds.Add(26);
|
|
|
|
+ foreach (int i in BrandIds) //品牌
|
|
|
|
+ {
|
|
|
|
+ int PageNum = 1;
|
|
|
|
+ bool op = true;
|
|
|
|
+ while(op)
|
|
|
|
+ {
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + "BrandId:" + i + ",BankCardType:" + j + ",Month:" + Month + ",PageNum:" + PageNum, "WIFI分润监控日志");
|
|
|
|
+ List<ProfitResult> result = result = StartProftForPosByDate(i, Month, PageNum);
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + "result:" + result.Count, "WIFI分润监控日志");
|
|
|
|
+ function.WriteLog("\r\n", "WIFI分润监控日志");
|
|
|
|
+ if(result.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (ProfitResult sub in result)
|
|
|
|
+ {
|
|
|
|
+ int TopUserId = 0;
|
|
|
|
+ if (!string.IsNullOrEmpty(sub.UserNav))
|
|
|
|
+ {
|
|
|
|
+ string[] UserNavList = sub.UserNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
|
+ if (UserNavList.Length > 1)
|
|
|
|
+ {
|
|
|
|
+ TopUserId = int.Parse(UserNavList[1]);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ 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 ProfitCreditTradeProfit2 = 0;
|
|
|
|
+ decimal ProfitCreditProfitRate2 = 0;
|
|
|
|
+ decimal ProfitCreditTradeAmt2 = 0;
|
|
|
|
+ decimal ProfitDebitNonCapTradeAmt = 0;
|
|
|
|
+ decimal ProfitDebitNonTradeCapProfit = 0;
|
|
|
|
+ decimal ProfitDebitProfitRate = 0;
|
|
|
|
+ if (j == 1)
|
|
|
|
+ {
|
|
|
|
+ CreditTradeAmt = TradeAmt; //贷记卡交易总金额
|
|
|
|
+ CreditTradeProfit = ProfitAmt; //贷记卡分润总金额
|
|
|
|
+ if (sub.QrPayFlag == 1)
|
|
|
|
+ {
|
|
|
|
+ QrCreditTradeAmt = TradeAmt; //(云闪付)贷记卡交易总金额
|
|
|
|
+ QrCreditProfitRate = ProfitRate; //(云闪付)贷记卡交易分润比例
|
|
|
|
+ QrCreditTradeProfit = ProfitAmt; //(云闪付)贷记卡交易分润
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ 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 if(sub.HelpFlag == 3)
|
|
|
|
+ {
|
|
|
|
+ ProfitCreditTradeProfit2 = ProfitAmt; //(盈利期)(非云闪付)贷记卡分润总金额
|
|
|
|
+ ProfitCreditProfitRate2 = ProfitRate; //(盈利期)(非云闪付)贷记卡商户交易对应分润比例
|
|
|
|
+ ProfitCreditTradeAmt2 = 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 (sub.Money < 1)
|
|
|
|
+ {
|
|
|
|
+ QrDebitNotCapTradeAmt = TradeAmt; //(云闪付)商户非封顶借记卡交易总额
|
|
|
|
+ QrDebitProfitRate = ProfitRate; //(云闪付)借记卡非封顶交易分润比例
|
|
|
|
+ QrDebitNonTradeCapProfit = ProfitAmt; //(云闪付)借记卡非封顶交易分润总金额
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (sub.Money < 1)
|
|
|
|
+ {
|
|
|
|
+ NonQrDebitNonTradeCapProfit = ProfitAmt; //(非云闪付)借记卡非封顶交易分润总金额
|
|
|
|
+ NonQrDebitNotCapTradeAmt = TradeAmt; //(非云闪付)商户非封顶借记卡交易总额
|
|
|
|
+ }
|
|
|
|
+ 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
|
|
|
|
+ {
|
|
|
|
+ if (sub.Money < 1)
|
|
|
|
+ {
|
|
|
|
+ NotHelpDebitNonCapTradeAmt = TradeAmt; //(非扶持期)(非云闪付)借记卡非封顶交易总金额
|
|
|
|
+ NotHelpDebitNonTradeCapProfit = ProfitAmt; //(非扶持期)(非云闪付)借记卡非封顶交易分润总金额
|
|
|
|
+ }
|
|
|
|
+ NotHelpDebitProfitRate = ProfitRate; //(非扶持期)(非云闪付)借记卡商户交易对应分润比例
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ db.ProfitRewardRecord.Add(new ProfitRewardRecord()
|
|
|
|
+ {
|
|
|
|
+ Version = 1,
|
|
|
|
+ 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, //(盈利期)(非云闪付)贷记卡交易总金额
|
|
|
|
+ ProfitCreditTradeProfit2 = ProfitCreditTradeProfit2, //(盈利期)(非云闪付)贷记卡分润总金额
|
|
|
|
+ ProfitCreditProfitRate2 = ProfitCreditProfitRate2, //(盈利期)(非云闪付)贷记卡商户交易对应分润比例
|
|
|
|
+ ProfitCreditTradeAmt2 = ProfitCreditTradeAmt2, //(盈利期)(非云闪付)贷记卡交易总金额
|
|
|
|
+ ProfitDebitNonCapTradeAmt = ProfitDebitNonCapTradeAmt, //(盈利期)(非云闪付)借记卡非封顶交易总金额
|
|
|
|
+ ProfitDebitNonTradeCapProfit = ProfitDebitNonTradeCapProfit, //(盈利期)(非云闪付)借记卡非封顶交易分润总金额
|
|
|
|
+ ProfitDebitProfitRate = ProfitDebitProfitRate, //(盈利期)(非云闪付)借记卡商户交易对应分润比例
|
|
|
|
+ });
|
|
|
|
+ // db.SaveChanges();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ db.SaveChanges();
|
|
|
|
+ PageNum += 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ op = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ db.Dispose();
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex)
|
|
|
|
+ {
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "WIFI分润监控异常");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ public List<ProfitResult> StartProftForPosByDate(int BrandId, string Month, int PageNum = 1)
|
|
|
|
+ {
|
|
|
|
+ int PageSize = 200;
|
|
|
|
+ int SkipNum = (PageNum - 1) * PageSize;
|
|
|
|
+ string LimitString = " limit " + PageSize;
|
|
|
|
+ if(PageNum > 1)
|
|
|
|
+ {
|
|
|
|
+ LimitString = " limit " + SkipNum + "," + PageSize;
|
|
|
|
+ }
|
|
|
|
+ List<ProfitResult> result = new List<ProfitResult>();
|
|
|
|
+ ProfitObjects obj = RedisDbconn.Instance.Get<ProfitObjects>("pobj1");
|
|
|
|
+ if (obj.Status == 1) //判断分润是否开启
|
|
|
|
+ {
|
|
|
|
+ string sqlstr = "select UserId,HelpDirectTradeAmt from TradeDaySummary where TradeMonth=" + Month + " and BrandId=" + BrandId + LimitString;
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + sqlstr, "WIFI分润监控日志");
|
|
|
|
+ DataTable dt = GetDataTable(sqlstr);
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + dt.Rows.Count.ToString(), "WIFI分润监控日志");
|
|
|
|
+ if(dt.Rows.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
|
+ {
|
|
|
|
+ WebCMSEntities dbnew = new WebCMSEntities();
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ int UserId = int.Parse(dr["UserId"].ToString());
|
|
|
|
+ int QrPayFlag = int.Parse(dr["QrPayFlag"].ToString());
|
|
|
|
+ List<UserLevelSet> levels = dbnew.UserLevelSet.ToList();
|
|
|
|
+ SubUser selfUser = GetUser(UserId, Month) ?? new SubUser();
|
|
|
|
+ int Days = int.Parse(RedisDbconn.Instance.Get<string>("pobjrule:1:HelpPolicy:Days")); //天数
|
|
|
|
+ if (BankCardType == 0)
|
|
|
|
+ {
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":借记卡", "WIFI分润监控日志");
|
|
|
|
+ decimal HelpDirectDebitTradeAmt = decimal.Parse(dr[2].ToString()); //借记卡扶持期交易额
|
|
|
|
+ decimal NotHelpDirectDebitTradeAmt = decimal.Parse(dr[3].ToString()); //借记卡稳定期交易额
|
|
|
|
+ decimal ProfitDirectDebitTradeAmt = decimal.Parse(dr[8].ToString()); //借记卡扶持期交易额
|
|
|
|
+ decimal HelpDirectDebitCapTradeAmt = decimal.Parse(dr[4].ToString()); //借记卡扶持期封顶交易额
|
|
|
|
+ decimal NotHelpDirectDebitCapTradeAmt = decimal.Parse(dr[5].ToString()); //借记卡稳定期封顶交易额
|
|
|
|
+ decimal ProfitDirectDebitCapTradeAmt = decimal.Parse(dr[9].ToString()); //借记卡扶持期封顶交易额
|
|
|
|
+ int HelpDirectDebitCapNum = int.Parse(dr[6].ToString().Split('.')[0]); //借记卡扶持期封顶交易笔数
|
|
|
|
+ int NotHelpDirectDebitCapNum = int.Parse(dr[7].ToString().Split('.')[0]); //借记卡稳定期封顶交易笔数
|
|
|
|
+ int ProfitDirectDebitCapNum = int.Parse(dr[10].ToString().Split('.')[0]); //借记卡扶持期封顶交易笔数
|
|
|
|
+ int UserLevel = selfUser.UserLevel; //当前会员等级
|
|
|
|
+ decimal getLevelProfit = (HelpDirectDebitTradeAmt + NotHelpDirectDebitTradeAmt + ProfitDirectDebitTradeAmt - HelpDirectDebitCapTradeAmt - NotHelpDirectDebitCapTradeAmt - ProfitDirectDebitCapTradeAmt) * 0.0006M + HelpDirectDebitCapNum + NotHelpDirectDebitCapNum + ProfitDirectDebitCapNum;
|
|
|
|
+ result.Add(new ProfitResult()
|
|
|
|
+ {
|
|
|
|
+ UserId = selfUser.Id,
|
|
|
|
+ UserNav = selfUser.ParentNav,
|
|
|
|
+ Money = PublicFunction.NumberFormat(getLevelProfit),
|
|
|
|
+ ProfitRate = 0.0006M,
|
|
|
|
+ Message = "储蓄卡分润",
|
|
|
|
+ BankCardType = BankCardType,
|
|
|
|
+ QrPayFlag = QrPayFlag,
|
|
|
|
+ BrandId = BrandId,
|
|
|
|
+ DirectFlag = 1,
|
|
|
|
+ IsSubsidy = 0,
|
|
|
|
+ TradeAmount = HelpDirectDebitTradeAmt + NotHelpDirectDebitTradeAmt + ProfitDirectDebitTradeAmt,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":贷记卡", "WIFI分润监控日志");
|
|
|
|
+ decimal HelpDirectTradeAmt = decimal.Parse(dr[2].ToString()); //贷记卡扶持期交易额
|
|
|
|
+ decimal NotHelpDirectTradeAmt = decimal.Parse(dr[3].ToString()); //贷记卡稳定期交易额
|
|
|
|
+ decimal ProfitDirectTradeAmt = decimal.Parse(dr[4].ToString()); //贷记卡盈利期期交易额
|
|
|
|
+ int maxLevel = obj.MaxLevel; //最大等级
|
|
|
|
+ decimal diffLevelProfit = 0; //等级级差
|
|
|
|
+ int curLevel = 0; //当前层级的会员等级
|
|
|
|
+ string ParentNav = selfUser.ParentNav;
|
|
|
|
+ if (string.IsNullOrEmpty(ParentNav))
|
|
|
|
+ {
|
|
|
|
+ ParentNav = ",0,";
|
|
|
|
+ }
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + ParentNav, "WIFI分润监控日志");
|
|
|
|
+ if (!string.IsNullOrEmpty(ParentNav))
|
|
|
|
+ {
|
|
|
|
+ ParentNav += "," + UserId + ",";
|
|
|
|
+ string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
|
+ Array.Reverse(ParentNavList); //反转顺序
|
|
|
|
+ int level = 0;
|
|
|
|
+ DateTime now = DateTime.Now;
|
|
|
|
+ DateTime ThisMonth = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00");
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":扶持期:" + HelpDirectTradeAmt, "WIFI分润监控日志");
|
|
|
|
+ if (HelpDirectTradeAmt > 0)
|
|
|
|
+ {
|
|
|
|
+ level = 0;
|
|
|
|
+ curLevel = 0;
|
|
|
|
+ diffLevelProfit = 0; //等级级差
|
|
|
|
+ decimal checkProfit = HelpDirectTradeAmt * 0.0012M;
|
|
|
|
+ decimal curProfit = 0;
|
|
|
|
+ foreach (string UserIdString in ParentNavList)
|
|
|
|
+ {
|
|
|
|
+ level += 1;
|
|
|
|
+ int uid = int.Parse(UserIdString);
|
|
|
|
+ SubUser user = GetUser(uid, Month) ?? new SubUser();
|
|
|
|
+ int UserLevel = GetUserLevel(user); //当前会员等级
|
|
|
|
+ if (curLevel == maxLevel) //判断当前创客是否有直推的激活机具,并且在活动时间内
|
|
|
|
+ {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (UserLevel <= maxLevel && UserLevel >= curLevel)
|
|
|
|
+ {
|
|
|
|
+ int LevelKindId = GetLevelKindId(1, 1, 1);
|
|
|
|
+ ProfitObjectLevels objlevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + UserLevel); //获取当前等级参数
|
|
|
|
+ if (objlevel != null)
|
|
|
|
+ {
|
|
|
|
+ decimal getLevelProfit = 0; //等级分润
|
|
|
|
+ if (objlevel.Percents > 0)
|
|
|
|
+ {
|
|
|
|
+ //获取创客分润规则,注册日开始算起,3个自然月内算扶持期
|
|
|
|
+ getLevelProfit += HelpDirectTradeAmt * objlevel.Percents;
|
|
|
|
+ }
|
|
|
|
+ if (objlevel.AddProfitVal > 0)
|
|
|
|
+ {
|
|
|
|
+ getLevelProfit += objlevel.AddProfitVal;
|
|
|
|
+ }
|
|
|
|
+ decimal money = getLevelProfit;
|
|
|
|
+ getLevelProfit -= diffLevelProfit;
|
|
|
|
+ if (objlevel.LevelDiff == 1) //判断是否有级差
|
|
|
|
+ {
|
|
|
|
+ diffLevelProfit = money;
|
|
|
|
+ }
|
|
|
|
+ if (getLevelProfit >= obj.MinProfitVal)
|
|
|
|
+ {
|
|
|
|
+ int DirectFlag = selfUser.Id == user.Id ? 1 : 0;
|
|
|
|
+ result.Add(new ProfitResult()
|
|
|
|
+ {
|
|
|
|
+ UserId = user.Id,
|
|
|
|
+ UserNav = user.ParentNav,
|
|
|
|
+ Money = PublicFunction.NumberFormat(getLevelProfit),
|
|
|
|
+ ProfitRate = objlevel.Percents,
|
|
|
|
+ Message = "交易分润",
|
|
|
|
+ BankCardType = BankCardType,
|
|
|
|
+ QrPayFlag = QrPayFlag,
|
|
|
|
+ DirectFlag = DirectFlag,
|
|
|
|
+ BrandId = BrandId,
|
|
|
|
+ IsSubsidy = 0,
|
|
|
|
+ TradeAmount = HelpDirectTradeAmt,
|
|
|
|
+ HelpFlag = 1,
|
|
|
|
+ });
|
|
|
|
+ curProfit += getLevelProfit;
|
|
|
|
+ function.WriteLog(user.Id + "-" + UserLevel + "-" + HelpDirectTradeAmt + "-" + DirectFlag + "-扶持期分润:" + getLevelProfit, "WIFI分润监控日志");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(curLevel < UserLevel)
|
|
|
|
+ {
|
|
|
|
+ curLevel = UserLevel;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(curProfit > checkProfit)
|
|
|
|
+ {
|
|
|
|
+ decimal more = curProfit - checkProfit;
|
|
|
|
+ function.WriteLog("超标了:" + more, "WIFI分润监控日志");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ function.WriteLog("------------------------", "WIFI分润监控日志");
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":稳定期:" + NotHelpDirectTradeAmt, "WIFI分润监控日志");
|
|
|
|
+ if (NotHelpDirectTradeAmt > 0)
|
|
|
|
+ {
|
|
|
|
+ level = 0;
|
|
|
|
+ curLevel = 0;
|
|
|
|
+ diffLevelProfit = 0; //等级级差
|
|
|
|
+ foreach (string UserIdString in ParentNavList)
|
|
|
|
+ {
|
|
|
|
+ level += 1;
|
|
|
|
+ int uid = int.Parse(UserIdString);
|
|
|
|
+ SubUser user = GetUser(uid, Month) ?? new SubUser();
|
|
|
|
+ int UserLevel = GetUserLevel(user); //当前会员等级
|
|
|
|
+ if (curLevel == maxLevel) //判断当前创客是否有直推的激活机具,并且在活动时间内
|
|
|
|
+ {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (UserLevel <= maxLevel && UserLevel >= curLevel)
|
|
|
|
+ {
|
|
|
|
+ int LevelKindId = GetLevelKindId(1, 0, 1);
|
|
|
|
+ ProfitObjectLevels objlevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + UserLevel); //获取当前等级参数
|
|
|
|
+ if (objlevel != null)
|
|
|
|
+ {
|
|
|
|
+ decimal getLevelProfit = 0; //等级分润
|
|
|
|
+ if (objlevel.Percents > 0)
|
|
|
|
+ {
|
|
|
|
+ //获取创客分润规则,注册日开始算起,3个自然月内算扶持期
|
|
|
|
+ getLevelProfit += NotHelpDirectTradeAmt * objlevel.Percents;
|
|
|
|
+ }
|
|
|
|
+ if (objlevel.AddProfitVal > 0)
|
|
|
|
+ {
|
|
|
|
+ getLevelProfit += objlevel.AddProfitVal;
|
|
|
|
+ }
|
|
|
|
+ decimal money = getLevelProfit;
|
|
|
|
+ getLevelProfit -= diffLevelProfit;
|
|
|
|
+ if (objlevel.LevelDiff == 1) //判断是否有级差
|
|
|
|
+ {
|
|
|
|
+ diffLevelProfit = money;
|
|
|
|
+ }
|
|
|
|
+ if (getLevelProfit >= obj.MinProfitVal)
|
|
|
|
+ {
|
|
|
|
+ result.Add(new ProfitResult()
|
|
|
|
+ {
|
|
|
|
+ UserId = user.Id,
|
|
|
|
+ UserNav = user.ParentNav,
|
|
|
|
+ Money = PublicFunction.NumberFormat(getLevelProfit),
|
|
|
|
+ ProfitRate = objlevel.Percents,
|
|
|
|
+ Message = "交易分润",
|
|
|
|
+ BankCardType = BankCardType,
|
|
|
|
+ QrPayFlag = QrPayFlag,
|
|
|
|
+ BrandId = BrandId,
|
|
|
|
+ DirectFlag = selfUser.Id == user.Id ? 1 : 0,
|
|
|
|
+ IsSubsidy = 0,
|
|
|
|
+ TradeAmount = NotHelpDirectTradeAmt,
|
|
|
|
+ HelpFlag = 0,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(curLevel < UserLevel)
|
|
|
|
+ {
|
|
|
|
+ curLevel = UserLevel;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ function.WriteLog("------------------------", "WIFI分润监控日志");
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":盈利期:" + ProfitDirectTradeAmt, "WIFI分润监控日志");
|
|
|
|
+ if (ProfitDirectTradeAmt > 0)
|
|
|
|
+ {
|
|
|
|
+ level = 0;
|
|
|
|
+ curLevel = 0;
|
|
|
|
+ diffLevelProfit = 0; //等级级差
|
|
|
|
+ foreach (string UserIdString in ParentNavList)
|
|
|
|
+ {
|
|
|
|
+ level += 1;
|
|
|
|
+ int uid = int.Parse(UserIdString);
|
|
|
|
+ SubUser user = GetUser(uid, Month) ?? new SubUser();
|
|
|
|
+ int UserLevel = GetUserLevel(user); //当前会员等级
|
|
|
|
+ if (curLevel == maxLevel) //判断当前创客是否有直推的激活机具,并且在活动时间内
|
|
|
|
+ {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (UserLevel <= maxLevel && UserLevel >= curLevel)
|
|
|
|
+ {
|
|
|
|
+ int LevelKindId = GetLevelKindId(1, 2, 1);
|
|
|
|
+ ProfitObjectLevels objlevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + UserLevel); //获取当前等级参数
|
|
|
|
+ if (objlevel != null)
|
|
|
|
+ {
|
|
|
|
+ decimal getLevelProfit = 0; //等级分润
|
|
|
|
+ if (objlevel.Percents > 0)
|
|
|
|
+ {
|
|
|
|
+ getLevelProfit += ProfitDirectTradeAmt * objlevel.Percents;
|
|
|
|
+ }
|
|
|
|
+ if (objlevel.AddProfitVal > 0)
|
|
|
|
+ {
|
|
|
|
+ getLevelProfit += objlevel.AddProfitVal;
|
|
|
|
+ }
|
|
|
|
+ decimal money = getLevelProfit;
|
|
|
|
+ getLevelProfit -= diffLevelProfit;
|
|
|
|
+ if (objlevel.LevelDiff == 1) //判断是否有级差
|
|
|
|
+ {
|
|
|
|
+ diffLevelProfit = money;
|
|
|
|
+ }
|
|
|
|
+ if (getLevelProfit >= obj.MinProfitVal)
|
|
|
|
+ {
|
|
|
|
+ result.Add(new ProfitResult()
|
|
|
|
+ {
|
|
|
|
+ UserId = user.Id,
|
|
|
|
+ UserNav = user.ParentNav,
|
|
|
|
+ Money = PublicFunction.NumberFormat(getLevelProfit),
|
|
|
|
+ ProfitRate = objlevel.Percents,
|
|
|
|
+ Message = "交易分润",
|
|
|
|
+ BankCardType = BankCardType,
|
|
|
|
+ QrPayFlag = QrPayFlag,
|
|
|
|
+ BrandId = BrandId,
|
|
|
|
+ DirectFlag = selfUser.Id == user.Id ? 1 : 0,
|
|
|
|
+ IsSubsidy = 0,
|
|
|
|
+ TradeAmount = ProfitDirectTradeAmt,
|
|
|
|
+ HelpFlag = 2,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(curLevel < UserLevel)
|
|
|
|
+ {
|
|
|
|
+ curLevel = UserLevel;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":over", "WIFI分润监控日志");
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "每月统计分润异常");
|
|
|
|
+ }
|
|
|
|
+ dbnew.Dispose();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ sqlstr = "";
|
|
|
|
+ if (BankCardType == 1)
|
|
|
|
+ {
|
|
|
|
+ sqlstr = "select UserId,QrPayFlag,ProfitDirectTradeAmt from CreditTradeDaySummary2Before" + Month + " where BrandId=" + BrandId + LimitString;
|
|
|
|
+ }
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + sqlstr, "WIFI分润监控日志");
|
|
|
|
+ dt = GetDataTable(sqlstr);
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + dt.Rows.Count.ToString(), "WIFI分润监控日志");
|
|
|
|
+ if(dt.Rows.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
|
+ {
|
|
|
|
+ WebCMSEntities dbnew = new WebCMSEntities();
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ int UserId = int.Parse(dr["UserId"].ToString());
|
|
|
|
+ int QrPayFlag = int.Parse(dr["QrPayFlag"].ToString());
|
|
|
|
+ List<UserLevelSet> levels = dbnew.UserLevelSet.ToList();
|
|
|
|
+ SubUser selfUser = GetUser(UserId, Month) ?? new SubUser();
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":贷记卡", "WIFI分润监控日志");
|
|
|
|
+ decimal ProfitDirectTradeAmt = decimal.Parse(dr[2].ToString()); //贷记卡盈利期期交易额
|
|
|
|
+ int maxLevel = obj.MaxLevel; //最大等级
|
|
|
|
+ decimal diffLevelProfit = 0; //等级级差
|
|
|
|
+ int curLevel = 0; //当前层级的会员等级
|
|
|
|
+ string ParentNav = selfUser.ParentNav;
|
|
|
|
+ if (string.IsNullOrEmpty(ParentNav))
|
|
|
|
+ {
|
|
|
|
+ ParentNav = ",0,";
|
|
|
|
+ }
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":" + ParentNav, "WIFI分润监控日志");
|
|
|
|
+ if (!string.IsNullOrEmpty(ParentNav))
|
|
|
|
+ {
|
|
|
|
+ ParentNav += "," + UserId + ",";
|
|
|
|
+ string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
|
+ Array.Reverse(ParentNavList); //反转顺序
|
|
|
|
+ int level = 0;
|
|
|
|
+ DateTime now = DateTime.Now;
|
|
|
|
+ DateTime ThisMonth = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00");
|
|
|
|
+ function.WriteLog("------------------------", "WIFI分润监控日志");
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":盈利期2:" + ProfitDirectTradeAmt, "WIFI分润监控日志");
|
|
|
|
+ if (ProfitDirectTradeAmt > 0)
|
|
|
|
+ {
|
|
|
|
+ level = 0;
|
|
|
|
+ curLevel = 0;
|
|
|
|
+ diffLevelProfit = 0; //等级级差
|
|
|
|
+ foreach (string UserIdString in ParentNavList)
|
|
|
|
+ {
|
|
|
|
+ level += 1;
|
|
|
|
+ int uid = int.Parse(UserIdString);
|
|
|
|
+ SubUser user = GetUser(uid, Month) ?? new SubUser();
|
|
|
|
+ int UserLevel = GetUserLevel(user); //当前会员等级
|
|
|
|
+ if (curLevel == maxLevel) //判断当前创客是否有直推的激活机具,并且在活动时间内
|
|
|
|
+ {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (UserLevel <= maxLevel && UserLevel >= curLevel)
|
|
|
|
+ {
|
|
|
|
+ int LevelKindId = GetLevelKindId(1, 3, 1);
|
|
|
|
+ ProfitObjectLevels objlevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + UserLevel); //获取当前等级参数
|
|
|
|
+ if (objlevel != null)
|
|
|
|
+ {
|
|
|
|
+ decimal getLevelProfit = 0; //等级分润
|
|
|
|
+ if (objlevel.Percents > 0)
|
|
|
|
+ {
|
|
|
|
+ getLevelProfit += ProfitDirectTradeAmt * objlevel.Percents;
|
|
|
|
+ }
|
|
|
|
+ if (objlevel.AddProfitVal > 0)
|
|
|
|
+ {
|
|
|
|
+ getLevelProfit += objlevel.AddProfitVal;
|
|
|
|
+ }
|
|
|
|
+ decimal money = getLevelProfit;
|
|
|
|
+ getLevelProfit -= diffLevelProfit;
|
|
|
|
+ if (objlevel.LevelDiff == 1) //判断是否有级差
|
|
|
|
+ {
|
|
|
|
+ diffLevelProfit = money;
|
|
|
|
+ }
|
|
|
|
+ if (getLevelProfit >= obj.MinProfitVal)
|
|
|
|
+ {
|
|
|
|
+ result.Add(new ProfitResult()
|
|
|
|
+ {
|
|
|
|
+ UserId = user.Id,
|
|
|
|
+ UserNav = user.ParentNav,
|
|
|
|
+ Money = PublicFunction.NumberFormat(getLevelProfit),
|
|
|
|
+ ProfitRate = objlevel.Percents,
|
|
|
|
+ Message = "交易分润",
|
|
|
|
+ BankCardType = BankCardType,
|
|
|
|
+ QrPayFlag = QrPayFlag,
|
|
|
|
+ BrandId = BrandId,
|
|
|
|
+ DirectFlag = selfUser.Id == user.Id ? 1 : 0,
|
|
|
|
+ IsSubsidy = 0,
|
|
|
|
+ TradeAmount = ProfitDirectTradeAmt,
|
|
|
|
+ HelpFlag = 3,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(curLevel < UserLevel)
|
|
|
|
+ {
|
|
|
|
+ curLevel = UserLevel;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":over", "WIFI分润监控日志");
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "每月统计分润异常");
|
|
|
|
+ }
|
|
|
|
+ dbnew.Dispose();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ public SubUser GetUser(int UserId, string Month)
|
|
|
|
+ {
|
|
|
|
+ SubUser user = new SubUser();
|
|
|
|
+ DataTable dt = GetDataTable("select * from Users" + Month + " where Id=" + UserId);
|
|
|
|
+ if(dt.Rows.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ user.Id = int.Parse(dt.Rows[0]["Id"].ToString());
|
|
|
|
+ user.ParentUserId = int.Parse(dt.Rows[0]["ParentUserId"].ToString());
|
|
|
|
+ user.ParentNav = dt.Rows[0]["ParentNav"].ToString();
|
|
|
|
+ user.UserLevel = int.Parse(dt.Rows[0]["UserLevel"].ToString());
|
|
|
|
+ user.PreUserLevel = int.Parse(dt.Rows[0]["PreUserLevel"].ToString());
|
|
|
|
+ user.PreUserLevelBefore = int.Parse(dt.Rows[0]["PreUserLevelBefore"].ToString());
|
|
|
|
+ user.PreLeaderLevel = int.Parse(dt.Rows[0]["PreLeaderLevel"].ToString());
|
|
|
|
+ user.PreOpLevel = int.Parse(dt.Rows[0]["PreOpLevel"].ToString());
|
|
|
|
+ }
|
|
|
|
+ return user;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int GetUserLevel(SubUser user)
|
|
|
|
+ {
|
|
|
|
+ int level = user.UserLevel;
|
|
|
|
+ if(user.PreUserLevelBefore > level) level = user.PreUserLevelBefore;
|
|
|
|
+ return level;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public DataTable GetDataTable(string sqlstr)
|
|
|
|
+ {
|
|
|
|
+ DataTable dt = CustomerSqlConn.dtable(sqlstr, Library.ConfigurationManager.AppSettings["MainSqlConnStr"].ToString());
|
|
|
|
+ return dt;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|