SycnSpTradeService.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using MySystem.SpModels;
  5. using Library;
  6. using LitJson;
  7. using System.Threading;
  8. namespace MySystem
  9. {
  10. public class SycnSpTradeService
  11. {
  12. public readonly static SycnSpTradeService Instance = new SycnSpTradeService();
  13. private SycnSpTradeService()
  14. { }
  15. public void Start()
  16. {
  17. Thread th = new Thread(StartDo);
  18. th.IsBackground = true;
  19. th.Start();
  20. }
  21. public void StartDo()
  22. {
  23. while (true)
  24. {
  25. try
  26. {
  27. List<string> BrandIds = new List<string>();
  28. BrandIds.Add("14");
  29. BrandIds.Add("17");
  30. BrandIds.Add("23");
  31. BrandIds.Add("24");
  32. BrandIds.Add("25");
  33. BrandIds.Add("26");
  34. BrandIds.Add("32");
  35. WebCMSEntities spdb = new WebCMSEntities();
  36. PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
  37. JavaProductModels.WebCMSEntities pdb = new JavaProductModels.WebCMSEntities();
  38. DateTime start = DateTime.Now.AddDays(-60);
  39. DateTime end = DateTime.Now.AddMinutes(-3);
  40. int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/TradeRecordId.txt")));
  41. IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id >= StartId && !BrandIds.Contains(m.ProductType) && m.CreateDate >= start && m.Status == 1).OrderBy(m => m.CreateDate).Take(20);
  42. foreach (TradeRecord trade in trades.ToList())
  43. {
  44. DoQueueTrade(db, pdb, trade);
  45. TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
  46. if (edit != null)
  47. {
  48. edit.Status = 2;
  49. }
  50. spdb.SaveChanges();
  51. }
  52. spdb.Dispose();
  53. db.Dispose();
  54. pdb.Dispose();
  55. }
  56. catch (Exception ex)
  57. {
  58. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "同步SP交易数据到MAIN异常");
  59. }
  60. Thread.Sleep(500);
  61. }
  62. }
  63. public void DoQueueTrade(PxcModels.WebCMSEntities db, JavaProductModels.WebCMSEntities pdb, TradeRecord trade)
  64. {
  65. string TradeSnNo = trade.TradeSnNo;
  66. if(trade.ProductType == "30")
  67. {
  68. trade.MerNo = trade.Field2;
  69. }
  70. bool op = true;
  71. //判断盒易付吱码交易
  72. if(trade.ProductType == "12" && trade.TradeType == "2")
  73. {
  74. JavaProductModels.KxsMerchant merchant = pdb.KxsMerchant.FirstOrDefault(m => m.MerchantNo == trade.MerNo);
  75. if(merchant != null)
  76. {
  77. JavaProductModels.KxsMachine pos = pdb.KxsMachine.FirstOrDefault(m => m.Id == merchant.MachineId);
  78. if(pos != null)
  79. {
  80. trade.TradeSnNo = pos.PosSn;
  81. }
  82. }
  83. }
  84. if (trade.SerEntryMode == "N" && trade.ProductType == "1") //金控押金获取
  85. {
  86. if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
  87. {
  88. op = false;
  89. PosPushDataNewHelper.Deposit(trade);
  90. }
  91. }
  92. else if (trade.SerEntryMode == "1" && trade.ProductType == "27") //金控押金获取
  93. {
  94. if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
  95. {
  96. op = false;
  97. PosPushDataNewHelper.Deposit(trade);
  98. }
  99. }
  100. else if ((trade.ProductType == "4" || trade.ProductType == "8" || trade.ProductType == "9") && (trade.ErrorCode == "5200" || trade.ErrorCode == "5800")) //乐刷海科费率0.52,0.58的不入库
  101. {
  102. op = false;
  103. }
  104. else if (trade.SerEntryMode == "1" && trade.ProductType == "10") //联动押金获取
  105. {
  106. if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
  107. {
  108. op = false;
  109. PosPushDataNewHelper.Deposit(trade);
  110. }
  111. }
  112. else if (trade.SerEntryMode == "40" && trade.ProductType == "12") //盒易付押金获取
  113. {
  114. if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
  115. {
  116. op = false;
  117. PosPushDataNewHelper.Deposit(trade);
  118. //创业帮押金数据推送
  119. string conn = ConfigurationManager.AppSettings["PushSqlConnStr"].ToString();
  120. CustomerSqlConn.op("INSERT INTO `u_kxs_trade_info_" + trade.CreateDate.Value.ToString("yyyyMM") + "` (`user_id`, `cash_flag`, `merch_no`, `agent_id`, `pos_sn`, `order_id`, `amount`, `trans_time`, `card_type`, `pay_type`) VALUES (123005, 1, '" + trade.MerNo + "', '01', '" + trade.TradeSnNo + "', '" + trade.TradeSerialNo + "', " + trade.TradeAmount + ", '" + trade.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 1, 0);", conn);
  121. }
  122. }
  123. else if (trade.SettleFee == 0 && trade.ProductType == "15") //联客宝押金获取
  124. {
  125. if (trade.TradeAmount == 99 || trade.TradeAmount == 199 || trade.TradeAmount == 299)
  126. {
  127. op = false;
  128. }
  129. }
  130. else if (trade.Field2 == "1590" && trade.ProductType == "22") //立刷微智能押金获取
  131. {
  132. if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
  133. {
  134. op = false;
  135. }
  136. }
  137. else if (trade.SerEntryMode == "DEPOSIT" && trade.ProductType == "30") //拉卡拉押金获取
  138. {
  139. if (trade.TradeAmount == 9900 || trade.TradeAmount == 19900 || trade.TradeAmount == 29900)
  140. {
  141. op = false;
  142. if(trade.ProductType == "30")
  143. {
  144. PxcModels.LklMerNo mer = db.LklMerNo.FirstOrDefault(m => m.ExtMerNo == trade.MerNo);
  145. if(mer != null)
  146. {
  147. trade.MerNo = mer.MerNo;
  148. }
  149. }
  150. PosPushDataNewHelper.Deposit(trade);
  151. }
  152. }
  153. else if (trade.SerEntryMode == "MACHINE" && trade.ProductType == "34") //联动掌中宝押金获取
  154. {
  155. PosPushDataNewHelper.Deposit(trade);
  156. op = false;
  157. }
  158. if (trade.DiscountRateFlag == "True")
  159. {
  160. op = false;
  161. }
  162. if(trade.ProductType == "7" && trade.TradeStatus != "00")
  163. {
  164. op = false;
  165. }
  166. if (op)
  167. {
  168. bool check = db.SpOrderNos.Any(m => m.OrderNo == trade.TradeSerialNo);
  169. if (!check)
  170. {
  171. PosPushDataNewHelper.Trade(trade);
  172. //创业帮交易数据推送
  173. if(trade.ProductType == "12")
  174. {
  175. int BankCardType = 1;
  176. if (trade.BankCardType == "C")
  177. {
  178. BankCardType = 1;
  179. }
  180. else if (trade.BankCardType == "D")
  181. {
  182. BankCardType = 0;
  183. }
  184. string conn = ConfigurationManager.AppSettings["PushSqlConnStr"].ToString();
  185. CustomerSqlConn.op("INSERT INTO `u_kxs_trade_info_" + trade.CreateDate.Value.ToString("yyyyMM") + "` (`user_id`, `cash_flag`, `merch_no`, `agent_id`, `pos_sn`, `order_id`, `amount`, `trans_time`, `card_type`, `pay_type`) VALUES (123005, 0, '" + trade.MerNo + "', '01', '" + trade.TradeSnNo + "', '" + trade.TradeSerialNo + "', " + trade.TradeAmount + ", '" + trade.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', " + BankCardType + ", 0);", conn);
  186. }
  187. }
  188. }
  189. }
  190. public void StartSim()
  191. {
  192. Thread th = new Thread(StartSimDo);
  193. th.IsBackground = true;
  194. th.Start();
  195. }
  196. public void StartSimDo()
  197. {
  198. while (true)
  199. {
  200. try
  201. {
  202. WebCMSEntities spdb = new WebCMSEntities();
  203. PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
  204. DateTime start = DateTime.Now.AddDays(-40);
  205. int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/TradeRecordId.txt")));
  206. IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id >= StartId && m.ProductType == "14" && m.CreateDate >= start && m.Status == 1).OrderBy(m => m.CreateDate).Take(20);
  207. foreach (TradeRecord trade in trades.ToList())
  208. {
  209. PosPushDataNewHelper.Trade(trade);
  210. TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
  211. if (edit != null)
  212. {
  213. edit.Status = 2;
  214. }
  215. spdb.SaveChanges();
  216. }
  217. spdb.Dispose();
  218. db.Dispose();
  219. }
  220. catch (Exception ex)
  221. {
  222. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "同步SP交易数据到MAIN异常");
  223. }
  224. Thread.Sleep(500);
  225. }
  226. }
  227. public void StartTradeStatus()
  228. {
  229. Thread th = new Thread(StartTradeStatusDo);
  230. th.IsBackground = true;
  231. th.Start();
  232. }
  233. public void StartTradeStatusDo()
  234. {
  235. while (true)
  236. {
  237. try
  238. {
  239. PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
  240. WebCMSEntities spdb = new WebCMSEntities();
  241. DateTime start = DateTime.Now.AddDays(-10);
  242. DateTime end = DateTime.Now.AddMinutes(-10);
  243. int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/TradeRecordId.txt")));
  244. IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id >= StartId && m.CreateDate >= start && m.CreateDate < end && m.Status == 0).OrderBy(m => m.CreateDate).Take(20);
  245. foreach (TradeRecord trade in trades.ToList())
  246. {
  247. int Status = 1;
  248. bool op = db.PosMachinesTwo.Any(m => m.PosSn == trade.TradeSnNo);
  249. if(!op)
  250. {
  251. Status = -1;
  252. }
  253. else
  254. {
  255. op = db.PosMerchantInfo.Any(m => m.KqSnNo == trade.TradeSnNo);
  256. if(!op)
  257. {
  258. Status = -2;
  259. }
  260. }
  261. TradeRecord edit = spdb.TradeRecord.FirstOrDefault(m => m.Id == trade.Id);
  262. if (edit != null)
  263. {
  264. edit.Status = Status;
  265. spdb.SaveChanges();
  266. }
  267. }
  268. db.Dispose();
  269. spdb.Dispose();
  270. }
  271. catch (Exception ex)
  272. {
  273. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "恢复原始交易没有统计上的数据异常");
  274. }
  275. Thread.Sleep(10000);
  276. }
  277. }
  278. //机具激活逻辑
  279. public void ActPos(PxcModels.WebCMSEntities db, PxcModels.PosMachinesTwo pos, decimal CheckMoney, int CheckDays, bool PrizeFlag = true, string ActivationTime = "")
  280. {
  281. DateTime now = DateTime.Now;
  282. if(!string.IsNullOrEmpty(ActivationTime))
  283. {
  284. now = DateTime.Parse(ActivationTime);
  285. }
  286. DateTime TransferTime = pos.TransferTime == null ? DateTime.Parse("2050-01-01") : pos.TransferTime.Value;
  287. int minute = 30;
  288. if(pos.BrandId == 14 && pos.PosSn.StartsWith("CS"))
  289. {
  290. minute = 60 * 24 * 30;
  291. }
  292. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:贷记卡是否刷满" + CheckMoney + ";贷记卡交易:" + pos.CreditTrade + "");
  293. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:是否有机具所属人;机具所属人Id:" + pos.BuyUserId + "");
  294. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:是否未激活;机具激活状态:" + pos.ActivationState + "");
  295. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:划拨时间不能超过绑定时间" + minute + "分钟;划拨时间:" + TransferTime.ToString() + ",绑定时间:" + pos.BindingTime.Value.ToString());
  296. if (pos.CreditTrade >= CheckMoney && pos.BuyUserId > 0 && pos.ActivationState == 0 && TransferTime.AddMinutes(-minute) < pos.BindingTime)
  297. {
  298. Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件");
  299. pos.ActivationState = 1;
  300. pos.ActivationTime = now;
  301. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:是否营训");
  302. if(pos.CardType == 101)
  303. {
  304. Utils.Instance.PrizeRecord(1, pos.PosSn, "是营训");
  305. pos.IsPurchase = 1;
  306. Utils.Instance.PrizeRecord(1, pos.PosSn, "取消循环资格");
  307. }
  308. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:是否关联商户信息");
  309. PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
  310. if (merchant != null)
  311. {
  312. merchant.ActiveStatus = 1;
  313. merchant.MerStandardDate = now;
  314. db.SaveChanges();
  315. if(pos.BrandId != 14)
  316. {
  317. //发放奖励MQ
  318. PrizeSetHelper.Do("1", pos.PosSn);
  319. }
  320. Utils.Instance.PrizeRecord(1, pos.PosSn, "已关联");
  321. //发放开机奖励
  322. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:绑定时间不超过" + CheckDays + "天;当前绑定时间:" + pos.BindingTime.ToString() + "");
  323. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:非营训;当前类型:" + pos.CardType);
  324. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:奖励开关;当前:" + PrizeFlag);
  325. if(pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
  326. {
  327. Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放开机奖励");
  328. RedisDbconn.Instance.AddList("OpenRewardQueue", pos.Id.ToString());
  329. if(pos.BrandId == 14)
  330. {
  331. Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放运营中心奖励");
  332. RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
  333. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:大盟主标记;当前大盟主Id:" + pos.LeaderUserId);
  334. PxcModels.Leaders leader = db.Leaders.FirstOrDefault(m => m.Id == pos.LeaderUserId) ?? new PxcModels.Leaders();
  335. DateTime ExpiredDate = leader.ExpiredDate == null ? DateTime.Parse("1900-01-01") : leader.ExpiredDate.Value;
  336. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:盟主是否过期;过期时间:" + pos.LeaderUserId);
  337. if(pos.LeaderUserId > 0 && ExpiredDate > now)
  338. {
  339. Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放大盟主奖励");
  340. RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
  341. }
  342. }
  343. }
  344. }
  345. //发放大盟主奖励
  346. decimal Deposit = decimal.Parse(function.CheckNum(pos.SeoKeyword));
  347. if(pos.BrandId != 14)
  348. {
  349. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:有押金;当前押金:" + Deposit);
  350. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:大盟主标记;当前大盟主Id:" + pos.LeaderUserId);
  351. PxcModels.Leaders leader = db.Leaders.FirstOrDefault(m => m.Id == pos.LeaderUserId) ?? new PxcModels.Leaders();
  352. DateTime ExpiredDate = leader.ExpiredDate == null ? DateTime.Parse("1900-01-01") : leader.ExpiredDate.Value;
  353. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:盟主是否过期;过期时间:" + pos.LeaderUserId);
  354. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:绑定时间不超过" + CheckDays + "天;绑定时间:" + pos.BindingTime.Value.ToString() + "");
  355. }
  356. if (Deposit > 0 && pos.LeaderUserId > 0 && db.Leaders.Any(m => m.Id == pos.LeaderUserId && m.ExpiredDate > now) && pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
  357. {
  358. Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放大盟主奖励");
  359. RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
  360. }
  361. //发放运营中心奖励
  362. if (Deposit > 0 && pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
  363. {
  364. Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放运营中心奖励");
  365. RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
  366. }
  367. if(pos.CardType < 100)
  368. {
  369. //统计激活数
  370. RedisDbconn.Instance.AddList("StatActQueue", "{\"TradeDate\":\"" + now.ToString("yyyyMMdd") + "\",\"UserId\":\"" + pos.BuyUserId + "\",\"BrandId\":\"" + pos.BrandId + "\"}");
  371. //运营中心额度变更
  372. OpAmountItem item = new OpAmountItem()
  373. {
  374. UserId = pos.OpId,
  375. OperateType = 1,
  376. ChangeType = 9,
  377. Remark = "机具激活",
  378. UseAmount = pos.OpReserve1 + pos.OpReserve2 + pos.OpReserve3,
  379. UseValidForGetAmount = pos.OpReserve2,
  380. UseTotalAmt = pos.OpReserve1,
  381. UseValidAmount = pos.OpReserve3,
  382. DataType = 2,
  383. DataId = pos.Id,
  384. };
  385. RedisDbconn.Instance.AddList("OperateAmountRecordServiceQueue", item);
  386. }
  387. //清理预扣款
  388. RedisDbconn.Instance.AddList("PosWithholdQueue", "{\"UserId\":\"" + pos.BuyUserId + "\",\"SnNo\":\"" + pos.PosSn + "\"}");
  389. //推送激活数据
  390. if(Deposit == 0) Utils.Instance.SendActData(pos);
  391. }
  392. else if (pos.ActivationState == 1 && pos.BrandId == 14)
  393. {
  394. if(pos.BindingTime > now.AddDays(-CheckDays) && pos.CardType < 100 && PrizeFlag)
  395. {
  396. RedisDbconn.Instance.AddList("OpenRewardQueue", pos.Id.ToString());
  397. if(pos.BrandId == 14)
  398. {
  399. RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
  400. PxcModels.Leaders leader = db.Leaders.FirstOrDefault(m => m.Id == pos.LeaderUserId) ?? new PxcModels.Leaders();
  401. DateTime ExpiredDate = leader.ExpiredDate == null ? DateTime.Parse("1900-01-01") : leader.ExpiredDate.Value;
  402. if(pos.LeaderUserId > 0 && ExpiredDate > now)
  403. {
  404. RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
  405. }
  406. }
  407. }
  408. }
  409. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:已激活;当前状态:" + pos.ActivationState);
  410. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:绑定后台30天到60天之间;绑定时间:" + pos.BindingTime.Value.ToString() + "");
  411. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:贷记卡是否刷满10000;贷记卡交易:" + pos.CreditTrade + "");
  412. Utils.Instance.PrizeRecord(1, pos.PosSn, "条件:非营训;当前类型:" + pos.CardType);
  413. if(pos.ActivationState == 1 && pos.BindingTime.Value.AddDays(30) <= DateTime.Now && pos.BindingTime.Value.AddDays(60) > DateTime.Now && pos.CreditTrade >= 10000 && pos.CardType < 100)
  414. {
  415. Utils.Instance.PrizeRecord(1, pos.PosSn, "满足条件,发放盟主开机奖励");
  416. RedisDbconn.Instance.AddList("LeaderRewardQueue", pos.Id.ToString());
  417. //发放奖励MQ
  418. PrizeSetHelper.Do("1", pos.PosSn);
  419. }
  420. }
  421. //立刷格外奖励
  422. public void LiShuaActPrize(PxcModels.WebCMSEntities db, PxcModels.PosMachinesTwo pos, int prize)
  423. {
  424. PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
  425. if(merchant != null)
  426. {
  427. PxcModels.Users getUser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new PxcModels.Users();
  428. int BuyTopUserId = 0;
  429. string ParentNav = getUser.ParentNav;
  430. if (!string.IsNullOrEmpty(ParentNav))
  431. {
  432. string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  433. if (ParentNavList.Length > 1)
  434. {
  435. BuyTopUserId = int.Parse(ParentNavList[1]);
  436. }
  437. else if (ParentNavList.Length == 1)
  438. {
  439. BuyTopUserId = int.Parse(ParentNavList[0]);
  440. }
  441. }
  442. if(prize == 50)
  443. {
  444. StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize);
  445. }
  446. if(prize == 40)
  447. {
  448. StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize, 12);
  449. }
  450. if(prize == 30)
  451. {
  452. StatService.Instance.doActiveReward(db, merchant, pos, getUser.Id, getUser.ParentNav, BuyTopUserId, prize, 133);
  453. }
  454. }
  455. }
  456. private int GetLeShuaHaiKe(int UserId, int BrandId)
  457. {
  458. if(DateTime.Now >= DateTime.Parse("2023-08-01 00:00:00"))
  459. {
  460. return 0;
  461. }
  462. int ActStatus = 1;
  463. try
  464. {
  465. string Date = DateTime.Now.ToString("yyyyMMdd");
  466. int checkNum = 0;
  467. if(Date == "20230720") checkNum = 12;
  468. if(Date == "20230721") checkNum = 11;
  469. if(Date == "20230722") checkNum = 10;
  470. if(Date == "20230723") checkNum = 9;
  471. if(Date == "20230724") checkNum = 8;
  472. if(Date == "20230725") checkNum = 7;
  473. if(Date == "20230726") checkNum = 6;
  474. if(Date == "20230727") checkNum = 5;
  475. if(Date == "20230728") checkNum = 4;
  476. if(Date == "20230729") checkNum = 3;
  477. if(Date == "20230730") checkNum = 2;
  478. if(Date == "20230731") checkNum = 1;
  479. int check = int.Parse(function.CheckInt(RedisDbconn.Instance.Get<string>("lscut:" + UserId + ":" + BrandId + ":" + Date)));
  480. if(check <= checkNum)
  481. {
  482. check += 1;
  483. RedisDbconn.Instance.Set("lscut:" + UserId + ":" + BrandId + ":" + Date, check.ToString());
  484. }
  485. else
  486. {
  487. ActStatus = -1;
  488. RedisDbconn.Instance.Set("lscut:" + UserId + ":" + BrandId + ":" + Date, "0");
  489. }
  490. }
  491. catch(Exception ex)
  492. {
  493. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "乐刷海科计数异常");
  494. }
  495. return ActStatus;
  496. }
  497. }
  498. }