ActiveRewardService.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Data;
  5. using System.Threading;
  6. using MySystem.Models.Main;
  7. using Library;
  8. using LitJson;
  9. namespace MySystem
  10. {
  11. public class ActiveRewardService
  12. {
  13. public readonly static ActiveRewardService Instance = new ActiveRewardService();
  14. private ActiveRewardService()
  15. { }
  16. //激活奖
  17. public void StartAct()
  18. {
  19. Thread th = new Thread(StartActListen);
  20. th.IsBackground = true;
  21. th.Start();
  22. }
  23. private void StartActListen()
  24. {
  25. while(true)
  26. {
  27. if(RedisDbconn.Instance.Get<string>("ActiveRewardThreadStatus") == "1")
  28. {
  29. StartActDo();
  30. Thread.Sleep(5000);
  31. }
  32. }
  33. }
  34. public void StartActDo()
  35. {
  36. WebCMSEntities db = new WebCMSEntities();
  37. Models.KxsMain.WebCMSEntities kxsdb = new Models.KxsMain.WebCMSEntities();
  38. DateTime yesterday = DateTime.Now.AddDays(-1);
  39. IQueryable<MerchantDepositOrder> orderList = db.MerchantDepositOrder.Where(m => m.Status == 1 && m.UpdateDate >= yesterday);
  40. foreach (MerchantDepositOrder order in orderList.ToList())
  41. {
  42. doActiveReward(db, kxsdb, order, 300);
  43. RedisDbconn.Instance.AddList("OpenRewardQueue2", order.MerchantId);
  44. RedisDbconn.Instance.AddList("LeaderPrizeQueue2", order.MerchantId);
  45. RedisDbconn.Instance.AddList("OperatePrizeQueue2", order.MerchantId);
  46. MerchantDepositOrder edit = db.MerchantDepositOrder.FirstOrDefault(m => m.Id == order.Id);
  47. if(edit != null)
  48. {
  49. edit.Status = 2;
  50. db.SaveChanges();
  51. Utils.Instance.SendActData(db.MerchantInfo.FirstOrDefault(m => m.Id == edit.MerchantId) ?? new MerchantInfo(), 4);
  52. }
  53. }
  54. db.Dispose();
  55. kxsdb.Dispose();
  56. }
  57. public void doActiveReward(WebCMSEntities db, Models.KxsMain.WebCMSEntities kxsdb, MerchantDepositOrder order, decimal ActPrize)
  58. {
  59. MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
  60. Models.KxsMain.Users user = kxsdb.Users.FirstOrDefault(m => m.Id == merchant.UserId) ?? new Models.KxsMain.Users();
  61. int GetUserId = user.Id;
  62. string ParentNav = user.ParentNav;
  63. int TopUserId = 0;
  64. if (!string.IsNullOrEmpty(ParentNav))
  65. {
  66. TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  67. }
  68. string IdBrand = GetUserId + "_0";
  69. UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
  70. if (userData == null)
  71. {
  72. userData = db.UserMachineData.Add(new UserMachineData()
  73. {
  74. IdBrand = IdBrand,
  75. }).Entity;
  76. db.SaveChanges();
  77. }
  78. userData.ActProfit += ActPrize;
  79. db.SaveChanges();
  80. Models.KxsMain.UserAccount account = kxsdb.UserAccount.FirstOrDefault(m => m.Id == GetUserId);
  81. if (account == null)
  82. {
  83. account = kxsdb.UserAccount.Add(new Models.KxsMain.UserAccount()
  84. {
  85. Id = GetUserId,
  86. UserId = GetUserId,
  87. }).Entity;
  88. kxsdb.SaveChanges();
  89. }
  90. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  91. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  92. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  93. account.BalanceAmount += ActPrize;
  94. account.TotalAmount += ActPrize;
  95. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  96. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  97. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  98. Models.KxsMain.UserAccountRecord userAccountRecord = kxsdb.UserAccountRecord.Add(new Models.KxsMain.UserAccountRecord()
  99. {
  100. CreateDate = DateTime.Now,
  101. UpdateDate = DateTime.Now,
  102. UserId = GetUserId, //创客
  103. ChangeType = 311, //变动类型
  104. ChangeAmount = ActPrize, //变更金额
  105. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  106. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  107. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  108. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  109. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  110. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  111. QueryCount = merchant.Id,
  112. }).Entity;
  113. kxsdb.SaveChanges();
  114. PrizePushHelper.Instance.Do(DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), "来客吧激活奖", "311", ActPrize, GetUserId, "{\"brand_id\":101,\"user_id\":" + GetUserId + "}");
  115. }
  116. //开户奖
  117. public void StartOpenReward()
  118. {
  119. Thread th = new Thread(StartOpenRewardDo);
  120. th.IsBackground = true;
  121. th.Start();
  122. }
  123. public void StartOpenRewardDo()
  124. {
  125. while(true)
  126. {
  127. string content = RedisDbconn.Instance.RPop<string>("OpenRewardQueue2");
  128. if(!string.IsNullOrEmpty(content))
  129. {
  130. try
  131. {
  132. WebCMSEntities db = new WebCMSEntities();
  133. Models.KxsMain.WebCMSEntities kxsdb = new Models.KxsMain.WebCMSEntities();
  134. function.WriteLog("\n\n" + DateTime.Now.ToString() + "\nposid:" + content, "开机奖励发放日志");
  135. int MerchantId = int.Parse(content);
  136. MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId);
  137. if (merchant != null)
  138. {
  139. function.WriteLog("商户:" + merchant.Name, "开机奖励发放日志");
  140. Models.KxsMain.Users user = kxsdb.Users.FirstOrDefault(m => m.Id == merchant.UserId);
  141. if (user != null)
  142. {
  143. function.WriteLog("所属人:" + user.MakerCode, "开机奖励发放日志");
  144. string ParentNav = function.CheckNull(user.ParentNav) + "," + user.Id + ",";
  145. if (!string.IsNullOrEmpty(ParentNav))
  146. {
  147. decimal Prize = 20;
  148. string[] ParentNavs = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  149. for (int i = ParentNavs.Length - 1; i >= 0; i--)
  150. {
  151. int UserId = int.Parse(ParentNavs[i]);
  152. Models.KxsMain.Users puser = kxsdb.Users.FirstOrDefault(m => m.Id == UserId && m.AuthFlag == 1 && m.Status > -1);
  153. if (puser != null && Prize > 0)
  154. {
  155. function.WriteLog("上级:" + puser.MakerCode, "开机奖励发放日志");
  156. function.WriteLog("条件:LeaderLevel:" + puser.LeaderLevel + ",UserType:" + puser.UserType, "开机奖励发放日志");
  157. if(puser.LeaderLevel > 0 || puser.UserType == 1)
  158. {
  159. bool leaderOp = true;
  160. if(puser.LeaderLevel > 0 && puser.UserType == 0)
  161. {
  162. DateTime now = DateTime.Now;
  163. leaderOp = kxsdb.Leaders.Any(m => m.Id == puser.Id && m.ExpiredDate >= now);
  164. function.WriteLog("条件:leaderOp:" + leaderOp, "开机奖励发放日志");
  165. }
  166. if(leaderOp)
  167. {
  168. function.WriteLog("满足条件", "开机奖励发放日志");
  169. int pTopUserId = 0;
  170. if (!string.IsNullOrEmpty(puser.ParentNav))
  171. {
  172. pTopUserId = int.Parse(puser.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  173. }
  174. string IdBrand = puser.Id + "_0";
  175. UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
  176. if (userData == null)
  177. {
  178. userData = db.UserMachineData.Add(new UserMachineData()
  179. {
  180. IdBrand = IdBrand,
  181. }).Entity;
  182. db.SaveChanges();
  183. }
  184. userData.OpenProfit += Prize;
  185. db.SaveChanges();
  186. //账户入库
  187. Models.KxsMain.UserAccount account = kxsdb.UserAccount.FirstOrDefault(m => m.Id == puser.Id);
  188. if (account == null)
  189. {
  190. account = kxsdb.UserAccount.Add(new Models.KxsMain.UserAccount()
  191. {
  192. Id = puser.Id,
  193. UserId = puser.Id,
  194. }).Entity;
  195. kxsdb.SaveChanges();
  196. }
  197. //收支明细入库
  198. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  199. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  200. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  201. account.BalanceAmount += Prize;
  202. account.TotalAmount += Prize;
  203. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  204. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  205. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  206. Models.KxsMain.UserAccountRecord userAccountRecord = kxsdb.UserAccountRecord.Add(new Models.KxsMain.UserAccountRecord()
  207. {
  208. CreateDate = DateTime.Now,
  209. UpdateDate = DateTime.Now,
  210. UserId = puser.Id, //创客
  211. ChangeType = 312, //变动类型
  212. ChangeAmount = Prize, //变更金额
  213. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  214. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  215. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  216. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  217. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  218. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  219. QueryCount = MerchantId,
  220. }).Entity;
  221. kxsdb.SaveChanges();
  222. Prize = 0;
  223. PrizePushHelper.Instance.Do(DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), "来客吧开户奖", "312", Prize, puser.Id, "{\"brand_id\":101,\"user_id\":" + puser.Id + "}");
  224. }
  225. }
  226. }
  227. }
  228. }
  229. }
  230. }
  231. db.Dispose();
  232. kxsdb.Dispose();
  233. }
  234. catch(Exception ex)
  235. {
  236. function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "实时获取开机奖励异常");
  237. }
  238. }
  239. else
  240. {
  241. Thread.Sleep(5000);
  242. }
  243. }
  244. }
  245. //盟主奖
  246. public void StartLeaderReward()
  247. {
  248. Thread th = new Thread(StartLeaderRewardDo);
  249. th.IsBackground = true;
  250. th.Start();
  251. }
  252. public void StartLeaderRewardDo()
  253. {
  254. while (true)
  255. {
  256. string content = RedisDbconn.Instance.RPop<string>("LeaderPrizeQueue2");
  257. if (!string.IsNullOrEmpty(content))
  258. {
  259. try
  260. {
  261. WebCMSEntities db = new WebCMSEntities();
  262. Models.KxsMain.WebCMSEntities kxsdb = new Models.KxsMain.WebCMSEntities();
  263. function.WriteLog("\n\n" + DateTime.Now.ToString() + "\nposid:" + content, "盟主奖励发放日志");
  264. int MerchantId = int.Parse(content);
  265. MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId);
  266. if (merchant != null)
  267. {
  268. function.WriteLog("商户:" + merchant.Name, "盟主奖励发放日志");
  269. Models.KxsMain.Users user = kxsdb.Users.FirstOrDefault(m => m.Id == merchant.UserId);
  270. if (user != null)
  271. {
  272. function.WriteLog("所属人:" + user.MakerCode, "盟主奖励发放日志");
  273. string ParentNav = function.CheckNull(user.ParentNav) + "," + user.Id + ",";
  274. if (!string.IsNullOrEmpty(ParentNav))
  275. {
  276. decimal Prize = 10;
  277. string[] ParentNavs = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  278. for (int i = ParentNavs.Length - 1; i >= 0; i--)
  279. {
  280. int UserId = int.Parse(ParentNavs[i]);
  281. Models.KxsMain.Users puser = kxsdb.Users.FirstOrDefault(m => m.Id == UserId && m.AuthFlag == 1 && m.Status > -1);
  282. if (puser != null && Prize > 0)
  283. {
  284. function.WriteLog("上级:" + puser.MakerCode, "盟主奖励发放日志");
  285. function.WriteLog("条件:LeaderLevel:" + puser.LeaderLevel + ",UserType:" + puser.UserType, "盟主奖励发放日志");
  286. if(puser.LeaderLevel == 2)
  287. {
  288. DateTime now = DateTime.Now;
  289. bool leaderOp = kxsdb.Leaders.Any(m => m.Id == puser.Id && m.ExpiredDate >= now);
  290. function.WriteLog("条件:leaderOp:" + leaderOp, "盟主奖励发放日志");
  291. if(leaderOp)
  292. {
  293. function.WriteLog("满足条件", "盟主奖励发放日志");
  294. int pTopUserId = 0;
  295. if (!string.IsNullOrEmpty(puser.ParentNav))
  296. {
  297. pTopUserId = int.Parse(puser.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  298. }
  299. string IdBrand = puser.Id + "_0";
  300. UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
  301. if (userData == null)
  302. {
  303. userData = db.UserMachineData.Add(new UserMachineData()
  304. {
  305. IdBrand = IdBrand,
  306. }).Entity;
  307. db.SaveChanges();
  308. }
  309. userData.OpenProfit += Prize;
  310. db.SaveChanges();
  311. //账户入库
  312. Models.KxsMain.UserAccount account = kxsdb.UserAccount.FirstOrDefault(m => m.Id == puser.Id);
  313. if (account == null)
  314. {
  315. account = kxsdb.UserAccount.Add(new Models.KxsMain.UserAccount()
  316. {
  317. Id = puser.Id,
  318. UserId = puser.Id,
  319. }).Entity;
  320. kxsdb.SaveChanges();
  321. }
  322. //收支明细入库
  323. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  324. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  325. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  326. account.BalanceAmount += Prize;
  327. account.TotalAmount += Prize;
  328. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  329. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  330. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  331. Models.KxsMain.UserAccountRecord userAccountRecord = kxsdb.UserAccountRecord.Add(new Models.KxsMain.UserAccountRecord()
  332. {
  333. CreateDate = DateTime.Now,
  334. UpdateDate = DateTime.Now,
  335. UserId = puser.Id, //创客
  336. ChangeType = 313, //变动类型
  337. ChangeAmount = Prize, //变更金额
  338. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  339. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  340. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  341. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  342. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  343. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  344. QueryCount = MerchantId,
  345. }).Entity;
  346. kxsdb.SaveChanges();
  347. Prize = 0;
  348. PrizePushHelper.Instance.Do(DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), "来客吧大盟主奖", "313", Prize, puser.Id, "{\"brand_id\":101,\"user_id\":" + puser.Id + "}");
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }
  355. }
  356. db.Dispose();
  357. kxsdb.Dispose();
  358. }
  359. catch (Exception ex)
  360. {
  361. function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "盟主奖发放日志异常");
  362. }
  363. Thread.Sleep(100);
  364. }
  365. else
  366. {
  367. Thread.Sleep(60000);
  368. }
  369. }
  370. }
  371. //运营中心奖
  372. public void StartOperateReward()
  373. {
  374. Thread th = new Thread(StartOperateRewardDo);
  375. th.IsBackground = true;
  376. th.Start();
  377. }
  378. public void StartOperateRewardDo()
  379. {
  380. while (true)
  381. {
  382. string content = RedisDbconn.Instance.RPop<string>("OperatePrizeQueue2");
  383. if (!string.IsNullOrEmpty(content))
  384. {
  385. try
  386. {
  387. WebCMSEntities db = new WebCMSEntities();
  388. Models.KxsMain.WebCMSEntities kxsdb = new Models.KxsMain.WebCMSEntities();
  389. function.WriteLog("\n\n" + DateTime.Now.ToString() + "\nposid:" + content, "运营中心奖励发放日志");
  390. int MerchantId = int.Parse(content);
  391. MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId);
  392. if (merchant != null)
  393. {
  394. function.WriteLog("商户:" + merchant.Name, "运营中心奖励发放日志");
  395. Models.KxsMain.Users user = kxsdb.Users.FirstOrDefault(m => m.Id == merchant.UserId);
  396. if (user != null)
  397. {
  398. function.WriteLog("所属人:" + user.MakerCode, "运营中心奖励发放日志");
  399. string ParentNav = function.CheckNull(user.ParentNav) + "," + user.Id + ",";
  400. if (!string.IsNullOrEmpty(ParentNav))
  401. {
  402. decimal Prize = 5;
  403. string[] ParentNavs = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  404. for (int i = ParentNavs.Length - 1; i >= 0; i--)
  405. {
  406. int UserId = int.Parse(ParentNavs[i]);
  407. Models.KxsMain.Users puser = kxsdb.Users.FirstOrDefault(m => m.Id == UserId && m.AuthFlag == 1 && m.Status > -1);
  408. if (puser != null && Prize > 0)
  409. {
  410. function.WriteLog("上级:" + puser.MakerCode, "运营中心奖励发放日志");
  411. function.WriteLog("条件:LeaderLevel:" + puser.LeaderLevel + ",UserType:" + puser.UserType, "运营中心奖励发放日志");
  412. if(puser.UserType == 1)
  413. {
  414. function.WriteLog("满足条件", "运营中心奖励发放日志");
  415. int pTopUserId = 0;
  416. if (!string.IsNullOrEmpty(puser.ParentNav))
  417. {
  418. pTopUserId = int.Parse(puser.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  419. }
  420. string IdBrand = puser.Id + "_0";
  421. UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
  422. if (userData == null)
  423. {
  424. userData = db.UserMachineData.Add(new UserMachineData()
  425. {
  426. IdBrand = IdBrand,
  427. }).Entity;
  428. db.SaveChanges();
  429. }
  430. userData.OpenProfit += Prize;
  431. db.SaveChanges();
  432. //账户入库
  433. Models.KxsMain.UserAccount account = kxsdb.UserAccount.FirstOrDefault(m => m.Id == puser.Id);
  434. if (account == null)
  435. {
  436. account = kxsdb.UserAccount.Add(new Models.KxsMain.UserAccount()
  437. {
  438. Id = puser.Id,
  439. UserId = puser.Id,
  440. }).Entity;
  441. kxsdb.SaveChanges();
  442. }
  443. //收支明细入库
  444. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  445. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  446. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  447. account.BalanceAmount += Prize;
  448. account.TotalAmount += Prize;
  449. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  450. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  451. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  452. Models.KxsMain.UserAccountRecord userAccountRecord = kxsdb.UserAccountRecord.Add(new Models.KxsMain.UserAccountRecord()
  453. {
  454. CreateDate = DateTime.Now,
  455. UpdateDate = DateTime.Now,
  456. UserId = puser.Id, //创客
  457. ChangeType = 314, //变动类型
  458. ChangeAmount = Prize, //变更金额
  459. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  460. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  461. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  462. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  463. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  464. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  465. QueryCount = MerchantId,
  466. }).Entity;
  467. kxsdb.SaveChanges();
  468. Prize = 0;
  469. PrizePushHelper.Instance.Do(DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), "来客吧运营中心奖", "314", Prize, puser.Id, "{\"brand_id\":101,\"user_id\":" + puser.Id + "}");
  470. }
  471. }
  472. }
  473. }
  474. }
  475. }
  476. db.Dispose();
  477. kxsdb.Dispose();
  478. }
  479. catch (Exception ex)
  480. {
  481. function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "运营中心奖发放日志异常");
  482. }
  483. Thread.Sleep(100);
  484. }
  485. else
  486. {
  487. Thread.Sleep(60000);
  488. }
  489. }
  490. }
  491. }
  492. }