StatService.cs 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  1. using System;
  2. using System.Collections.Generic;
  3. using Library;
  4. using LitJson;
  5. using System.Linq;
  6. using System.Data;
  7. using MySystem.PxcModels;
  8. namespace MySystem
  9. {
  10. public class StatService
  11. {
  12. public readonly static StatService Instance = new StatService();
  13. private StatService()
  14. { }
  15. public void Start(JobMqMsg jobInfo)
  16. {
  17. string content = "";
  18. try
  19. {
  20. string doDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
  21. string flag = function.ReadInstance("/Stat/" + doDate + ".txt");
  22. if (string.IsNullOrEmpty(flag))
  23. {
  24. function.WritePage("/Stat/", doDate + ".txt", DateTime.Now.ToString("HH:mm:ss"));
  25. dosomething1(doDate);
  26. dosomething11(doDate);
  27. dosomething2(doDate);
  28. dosomething4(doDate);
  29. }
  30. string Msg = "success";
  31. jobInfo.Status = Msg == "success" ? 1 : 0;
  32. jobInfo.Msg = Msg == "success" ? "执行完成" : Msg;
  33. RabbitMQClient.Instance.SendMsg(Newtonsoft.Json.JsonConvert.SerializeObject(jobInfo), "PublicBack");
  34. }
  35. catch (Exception ex)
  36. {
  37. if (!string.IsNullOrEmpty(content))
  38. {
  39. Dictionary<string, string> data = new Dictionary<string, string>();
  40. data.Add("ErrTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  41. data.Add("ErrMsg", ex.ToString());
  42. function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(data), "public_err");
  43. }
  44. else
  45. {
  46. function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "public_service");
  47. }
  48. }
  49. }
  50. public void ActiveReward(JobMqMsg jobInfo)
  51. {
  52. string content = "";
  53. try
  54. {
  55. dosomething3();
  56. string Msg = "success";
  57. jobInfo.Status = Msg == "success" ? 1 : 0;
  58. jobInfo.Msg = Msg == "success" ? "执行完成" : Msg;
  59. RabbitMQClient.Instance.SendMsg(Newtonsoft.Json.JsonConvert.SerializeObject(jobInfo), "PublicBack");
  60. }
  61. catch (Exception ex)
  62. {
  63. if (!string.IsNullOrEmpty(content))
  64. {
  65. Dictionary<string, string> data = new Dictionary<string, string>();
  66. data.Add("ErrTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  67. data.Add("ErrMsg", ex.ToString());
  68. function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(data), "public_err");
  69. }
  70. else
  71. {
  72. function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "public_service");
  73. }
  74. }
  75. }
  76. public void clear()
  77. {
  78. RedisDbconn.Instance.Clear("TotalAmount*");
  79. RedisDbconn.Instance.Clear("TotalCloudPayAmount*");
  80. RedisDbconn.Instance.Clear("TotalPosAmount*");
  81. RedisDbconn.Instance.Clear("TeamTotalAmount*");
  82. RedisDbconn.Instance.Clear("TeamTotalCloudPayAmount*");
  83. RedisDbconn.Instance.Clear("TeamTotalPosAmount*");
  84. // RedisDbconn.Instance.Clear("TotalUser*");
  85. // RedisDbconn.Instance.Clear("TeamTotalUser*");
  86. // RedisDbconn.Instance.Clear("AddUser*");
  87. // RedisDbconn.Instance.Clear("TeamAddUser*");
  88. // RedisDbconn.Instance.Clear("TotalPosMerchant*");
  89. // RedisDbconn.Instance.Clear("TeamTotalPosMerchant*");
  90. RedisDbconn.Instance.Clear("MerTotalAmount*");
  91. }
  92. // 1. 前一天的绑定记录和创客信息匹配,设置商户型创客
  93. public void dosomething1(string date)
  94. {
  95. // TODO: 每天扫描非商户型创客的持有机具数量
  96. SpModels.WebCMSEntities spdb = new SpModels.WebCMSEntities();
  97. WebCMSEntities db = new WebCMSEntities();
  98. DateTime yesterday = DateTime.Parse(date + " 00:00:00");
  99. DateTime today = DateTime.Parse(DateTime.Parse(date).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00");
  100. List<SpModels.BindRecord> binds = spdb.BindRecord.Where(m => m.CreateTime >= yesterday && m.CreateTime < today).ToList();
  101. foreach (SpModels.BindRecord bind in binds)
  102. {
  103. string Mobile = bind.MerNewSnNo;
  104. string MerNo = bind.MerNo;
  105. string BeforeNum = "";
  106. string AfterNum = "";
  107. if (Mobile.Contains("****") && Mobile.Length == 11)
  108. {
  109. BeforeNum = Mobile.Substring(0, 3);
  110. AfterNum = Mobile.Substring(7);
  111. }
  112. string Name = bind.MerName;
  113. if (bind.ProductType == "2")
  114. {
  115. if (Name.Contains("-"))
  116. {
  117. Name = Name.Split('-')[1];
  118. }
  119. else if (Name.Contains("_"))
  120. {
  121. Name = Name.Split('_')[1];
  122. }
  123. }
  124. PxcModels.Users user = db.Users.FirstOrDefault(m => m.Mobile.StartsWith(BeforeNum) && m.Mobile.EndsWith(AfterNum) && m.RealName == Name && m.AuthFlag == 1 && m.MerchantType == 0);
  125. if (user != null)
  126. {
  127. user.MerchantType = 1;
  128. PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo) ?? new PxcModels.PosMerchantInfo();
  129. merchant.MerUserType = 1;
  130. PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.BindMerchantId == merchant.Id);
  131. if (pos != null)
  132. {
  133. pos.SeoTitle = user.Id.ToString(); // 记录商户型创客的Id
  134. }
  135. db.SaveChanges();
  136. RedisDbconn.Instance.Set("Users:" + user.Id, user);
  137. RedisDbconn.Instance.Set("PosMerchantInfo:" + merchant.Id, merchant);
  138. RedisDbconn.Instance.Set("PosMachinesTwo:" + pos.Id, pos);
  139. }
  140. }
  141. spdb.Dispose();
  142. db.Dispose();
  143. }
  144. // 1. 前一天的商户型创客,判断名下是否3台激活机器,是则变为非商户型创客
  145. public void dosomething11(string date)
  146. {
  147. WebCMSEntities db = new WebCMSEntities();
  148. DateTime yesterday = DateTime.Parse(date + " 00:00:00");
  149. DateTime today = DateTime.Parse(DateTime.Parse(date).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00");
  150. var users = db.Users.Select(m => new { m.Id, m.MerchantType }).Where(m => m.MerchantType == 1).ToList();
  151. foreach (var user in users)
  152. {
  153. int machineCount = db.PosMachinesTwo.Count(m => m.UserId == user.Id && m.PosSnType == 0);
  154. if (machineCount >= 3)
  155. {
  156. Users edit = db.Users.FirstOrDefault(m => m.Id == user.Id);
  157. if (edit != null)
  158. {
  159. edit.MerchantType = 0;
  160. db.SaveChanges();
  161. RedisDbconn.Instance.Set("Users:" + user.Id, edit);
  162. }
  163. }
  164. }
  165. db.Dispose();
  166. }
  167. // 2. 每天统计前一天的交易额,每笔交易判断商户号的所属人是商户型创客,如果是,则从此人开始累计交易额,若不是,则从此人上级开始累计交易额
  168. public void dosomething2(string date)
  169. {
  170. string yesterday = date + " 00:00:00";
  171. string today = DateTime.Parse(date).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00";
  172. string TradeMonth = DateTime.Parse(date).ToString("yyyyMM");
  173. string TradeDate = DateTime.Parse(date).ToString("yyyyMMdd");
  174. DataTable dt = dbconn.dtable("select UserId,BrandId,MerchantId,BankCardType,QrPayFlag,sum(TradeAmount) from TradeRecord where CreateDate>='" + yesterday + "' and CreateDate<'" + today + "' group by UserId,BrandId,MerchantId,BankCardType,QrPayFlag");
  175. foreach (DataRow dr in dt.Rows)
  176. {
  177. int UserId = int.Parse(dr["UserId"].ToString()); //创客ID
  178. int BrandId = int.Parse(dr["BrandId"].ToString()); //品牌
  179. int MerchantId = int.Parse(dr["MerchantId"].ToString()); //商户Id
  180. int BankCardType = int.Parse(dr["BankCardType"].ToString()); //卡类型
  181. int QrPayFlag = int.Parse(dr["QrPayFlag"].ToString()); //云闪付
  182. decimal TradeAmount = decimal.Parse(dr[5].ToString()); //当日交易额
  183. string content = "{";
  184. content += "\"DateString\":\"" + date + "\",";
  185. content += "\"UserId\":\"" + UserId + "\",";
  186. content += "\"BrandId\":\"" + BrandId + "\",";
  187. content += "\"MerchantId\":\"" + MerchantId + "\",";
  188. content += "\"BankCardType\":\"" + BankCardType + "\",";
  189. content += "\"QrPayFlag\":\"" + QrPayFlag + "\",";
  190. content += "\"TradeAmount\":\"" + TradeAmount + "\"";
  191. content += "}";
  192. RedisDbconn.Instance.AddList("TradeStatQueue", content);
  193. }
  194. }
  195. // 3. 前一天的激活记录,根据创客类型,如果是商户型创客,则激活奖励的起始人从此人上级计算。如果不是,则从此人开始计算
  196. public void dosomething3(int posid = 0)
  197. {
  198. WebCMSEntities db = new WebCMSEntities();
  199. DateTime yesterday = DateTime.Now.AddHours(-3);
  200. DateTime today = DateTime.Now;
  201. IQueryable<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && !string.IsNullOrEmpty(m.SeoKeyword));
  202. if (posid > 0)
  203. {
  204. posList = posList.Where(m => m.Id == posid);
  205. }
  206. else
  207. {
  208. posList = posList.Where(m => m.ActivationTime >= yesterday && m.ActivationTime < today);
  209. }
  210. foreach (PosMachinesTwo pos in posList.ToList())
  211. {
  212. // PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId && !string.IsNullOrEmpty(m.MerIdcardNo));
  213. PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
  214. if (merchant != null)
  215. {
  216. // PosMerchantOtherInfo otherInfo = db.PosMerchantOtherInfo.FirstOrDefault(m => m.CertId == merchant.MerIdcardNo && m.PrizeFlag1 == 0);
  217. // if (otherInfo != null)
  218. // {
  219. // otherInfo.PrizeFlag1 = 1;
  220. // db.SaveChanges();
  221. string ParentNav = "";
  222. Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
  223. if (user != null)
  224. {
  225. int GetUserId = user.Id;
  226. ParentNav = user.ParentNav;
  227. int TopUserId = 0;
  228. if (!string.IsNullOrEmpty(ParentNav))
  229. {
  230. TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  231. }
  232. decimal ActPrize = decimal.Parse(function.CheckNum(pos.SeoKeyword));
  233. if (pos.BrandId == 1 || pos.BrandId == 3)
  234. {
  235. ActPrize = ActPrize / 100;
  236. }
  237. if (ActPrize > 0)
  238. {
  239. bool check = db.ActiveReward.Any(m => m.KqMerNo == merchant.KqMerNo);
  240. if (!check)
  241. {
  242. if (ActPrize == 99)
  243. {
  244. ActPrize = 100;
  245. }
  246. else if (ActPrize == 199)
  247. {
  248. ActPrize = 200;
  249. }
  250. else if (ActPrize == 299)
  251. {
  252. ActPrize = 300;
  253. }
  254. Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new Users();
  255. db.ActiveReward.Add(new ActiveReward()
  256. {
  257. CreateDate = DateTime.Now,
  258. UpdateDate = DateTime.Now,
  259. UserId = GetUserId, //创客
  260. MerchantId = pos.BindMerchantId, //商户
  261. StandardDate = pos.ActivationTime, //达标日期
  262. RewardAmount = ActPrize, //奖励金额
  263. BrandId = pos.BrandId, //品牌
  264. UserNav = ParentNav, //创客父级
  265. DirectBuddyNo = merchant.UserId, //商户直属创客
  266. KqMerNo = merchant.KqMerNo, //渠道商户编号
  267. KqSnNo = pos.PosSn, //渠道SN号
  268. SnType = pos.PosSnType, //机具类型
  269. SnApplyUserId = pos.BuyUserId, //机具申请创客
  270. ActType = 0, //激活类型
  271. SnStoreId = pos.StoreId, //SN仓库
  272. RewardTips = "激活奖励", //奖励描述
  273. Remark = "激活奖励", //备注
  274. ActDate = pos.ActivationTime, //激活时间
  275. TopUserId = TopUserId, //顶级创客
  276. SeoTitle = machineUser.RealName,
  277. });
  278. db.SaveChanges();
  279. string IdBrand = GetUserId + "_" + pos.BrandId;
  280. UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
  281. if (userData == null)
  282. {
  283. userData = db.UserMachineData.Add(new UserMachineData()
  284. {
  285. IdBrand = IdBrand,
  286. }).Entity;
  287. db.SaveChanges();
  288. }
  289. userData.ActProfit += ActPrize;
  290. db.SaveChanges();
  291. RedisDbconn.Instance.Set("UserMachineData:" + IdBrand, userData);
  292. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == GetUserId);
  293. if (account == null)
  294. {
  295. account = db.UserAccount.Add(new UserAccount()
  296. {
  297. Id = GetUserId,
  298. UserId = GetUserId,
  299. }).Entity;
  300. db.SaveChanges();
  301. }
  302. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  303. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  304. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  305. account.BalanceAmount += ActPrize;
  306. account.TotalAmount += ActPrize;
  307. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  308. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  309. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  310. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  311. {
  312. CreateDate = DateTime.Now,
  313. UpdateDate = DateTime.Now,
  314. UserId = GetUserId, //创客
  315. ChangeType = 0, //变动类型
  316. ProductType = pos.BrandId, //产品类型
  317. ChangeAmount = ActPrize, //变更金额
  318. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  319. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  320. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  321. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  322. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  323. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  324. }).Entity;
  325. db.SaveChanges();
  326. RedisDbconn.Instance.Set("UserAccount:" + GetUserId, account);
  327. string dateString = pos.ActivationTime.Value.ToString("yyyyMMdd");
  328. string monthString = pos.ActivationTime.Value.ToString("yyyyMM");
  329. // 激活奖励列表
  330. List<string> dates = RedisDbconn.Instance.GetList<string>("ActiveRewardDay:" + GetUserId + ":" + pos.BrandId);
  331. if (!dates.Contains(dateString))
  332. {
  333. RedisDbconn.Instance.AddList("ActiveRewardDay:" + GetUserId + ":" + pos.BrandId, dateString);
  334. }
  335. RedisDbconn.Instance.AddNumber("ActiveRewardAmt:" + GetUserId + ":" + pos.BrandId + ":" + dateString, ActPrize);
  336. List<string> months = RedisDbconn.Instance.GetList<string>("ActiveRewardMonth:" + GetUserId + ":" + pos.BrandId);
  337. if (!months.Contains(monthString))
  338. {
  339. RedisDbconn.Instance.AddList("ActiveRewardMonth:" + GetUserId + ":" + pos.BrandId, monthString);
  340. }
  341. RedisDbconn.Instance.AddNumber("ActiveRewardAmt:" + GetUserId + ":" + pos.BrandId + ":" + monthString, ActPrize);
  342. // 激活奖励详情
  343. List<int> actPrizeList = RedisDbconn.Instance.GetList<int>("ActiveRewardDetail:" + GetUserId + ":" + pos.BrandId + ":" + dateString);
  344. if (!actPrizeList.Contains(pos.BindMerchantId))
  345. {
  346. RedisDbconn.Instance.AddList("ActiveRewardDetail:" + GetUserId + ":" + pos.BrandId + ":" + dateString, pos.BindMerchantId);
  347. }
  348. RedisDbconn.Instance.AddNumber("ActiveRewardAmt:mer:" + pos.BindMerchantId + ":" + pos.BrandId + ":" + dateString, ActPrize);
  349. //收支明细
  350. RedisDbconn.Instance.AddList("UserAccountRecord:" + GetUserId + ":1:" + monthString, userAccountRecord);
  351. RedisDbconn.Instance.AddNumber("UserAccount:" + GetUserId + ":1:" + monthString, ActPrize);
  352. }
  353. }
  354. }
  355. // }
  356. }
  357. }
  358. db.Dispose();
  359. }
  360. //根据商户信息发放激活奖励
  361. public void dosomething32(int merid = 0)
  362. {
  363. WebCMSEntities db = new WebCMSEntities();
  364. DateTime yesterday = DateTime.Now.AddHours(-3);
  365. DateTime today = DateTime.Now;
  366. IQueryable<PosMerchantInfo> merList = db.PosMerchantInfo.Where(m => m.ActiveStatus == 1 && !string.IsNullOrEmpty(m.SeoKeyword));
  367. if (merid > 0)
  368. {
  369. merList = merList.Where(m => m.Id == merid);
  370. }
  371. else
  372. {
  373. merList = merList.Where(m => m.MerStandardDate >= yesterday && m.MerStandardDate < today);
  374. }
  375. foreach (PosMerchantInfo merchant in merList.ToList())
  376. {
  377. // PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId && !string.IsNullOrEmpty(m.MerIdcardNo));
  378. // PosMerchantOtherInfo otherInfo = db.PosMerchantOtherInfo.FirstOrDefault(m => m.CertId == merchant.MerIdcardNo && m.PrizeFlag1 == 0);
  379. // if (otherInfo != null)
  380. // {
  381. // otherInfo.PrizeFlag1 = 1;
  382. // db.SaveChanges();
  383. MachineForMerNo forMerNo = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == merchant.MerchantNo) ?? new MachineForMerNo();
  384. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == forMerNo.SnId) ?? new PosMachinesTwo();
  385. string ParentNav = "";
  386. Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
  387. if (user != null)
  388. {
  389. int GetUserId = user.Id;
  390. ParentNav = user.ParentNav;
  391. int TopUserId = 0;
  392. if (!string.IsNullOrEmpty(ParentNav))
  393. {
  394. TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  395. }
  396. decimal ActPrize = decimal.Parse(function.CheckNum(merchant.SeoKeyword));
  397. if (pos.BrandId == 1 || pos.BrandId == 3)
  398. {
  399. ActPrize = ActPrize / 100;
  400. }
  401. if (ActPrize > 0)
  402. {
  403. bool check = db.ActiveReward.Any(m => m.KqSnNo == pos.PosSn);
  404. if (!check)
  405. {
  406. if (ActPrize == 99)
  407. {
  408. ActPrize = 100;
  409. }
  410. else if (ActPrize == 199)
  411. {
  412. ActPrize = 200;
  413. }
  414. else if (ActPrize == 299)
  415. {
  416. ActPrize = 300;
  417. }
  418. Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new Users();
  419. db.ActiveReward.Add(new ActiveReward()
  420. {
  421. CreateDate = DateTime.Now,
  422. UpdateDate = DateTime.Now,
  423. UserId = GetUserId, //创客
  424. MerchantId = pos.BindMerchantId, //商户
  425. StandardDate = pos.ActivationTime, //达标日期
  426. RewardAmount = ActPrize, //奖励金额
  427. BrandId = pos.BrandId, //品牌
  428. UserNav = ParentNav, //创客父级
  429. DirectBuddyNo = merchant.UserId, //商户直属创客
  430. KqMerNo = merchant.KqMerNo, //渠道商户编号
  431. KqSnNo = pos.PosSn, //渠道SN号
  432. SnType = pos.PosSnType, //机具类型
  433. SnApplyUserId = pos.BuyUserId, //机具申请创客
  434. ActType = 0, //激活类型
  435. SnStoreId = pos.StoreId, //SN仓库
  436. RewardTips = "激活奖励", //奖励描述
  437. Remark = "激活奖励", //备注
  438. ActDate = pos.ActivationTime, //激活时间
  439. TopUserId = TopUserId, //顶级创客
  440. SeoTitle = machineUser.RealName,
  441. });
  442. db.SaveChanges();
  443. string IdBrand = GetUserId + "_" + pos.BrandId;
  444. UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
  445. if (userData == null)
  446. {
  447. userData = db.UserMachineData.Add(new UserMachineData()
  448. {
  449. IdBrand = IdBrand,
  450. }).Entity;
  451. db.SaveChanges();
  452. }
  453. userData.ActProfit += ActPrize;
  454. db.SaveChanges();
  455. RedisDbconn.Instance.Set("UserMachineData:" + IdBrand, userData);
  456. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == GetUserId);
  457. if (account == null)
  458. {
  459. account = db.UserAccount.Add(new UserAccount()
  460. {
  461. Id = GetUserId,
  462. UserId = GetUserId,
  463. }).Entity;
  464. db.SaveChanges();
  465. }
  466. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  467. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  468. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  469. account.BalanceAmount += ActPrize;
  470. account.TotalAmount += ActPrize;
  471. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  472. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  473. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  474. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  475. {
  476. CreateDate = DateTime.Now,
  477. UpdateDate = DateTime.Now,
  478. UserId = GetUserId, //创客
  479. ChangeType = 0, //变动类型
  480. ProductType = pos.BrandId, //产品类型
  481. ChangeAmount = ActPrize, //变更金额
  482. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  483. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  484. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  485. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  486. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  487. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  488. }).Entity;
  489. db.SaveChanges();
  490. RedisDbconn.Instance.Set("UserAccount:" + GetUserId, account);
  491. string dateString = pos.ActivationTime.Value.ToString("yyyyMMdd");
  492. string monthString = pos.ActivationTime.Value.ToString("yyyyMM");
  493. // 激活奖励列表
  494. List<string> dates = RedisDbconn.Instance.GetList<string>("ActiveRewardDay:" + GetUserId + ":" + pos.BrandId);
  495. if (!dates.Contains(dateString))
  496. {
  497. RedisDbconn.Instance.AddList("ActiveRewardDay:" + GetUserId + ":" + pos.BrandId, dateString);
  498. }
  499. RedisDbconn.Instance.AddNumber("ActiveRewardAmt:" + GetUserId + ":" + pos.BrandId + ":" + dateString, ActPrize);
  500. List<string> months = RedisDbconn.Instance.GetList<string>("ActiveRewardMonth:" + GetUserId + ":" + pos.BrandId);
  501. if (!months.Contains(monthString))
  502. {
  503. RedisDbconn.Instance.AddList("ActiveRewardMonth:" + GetUserId + ":" + pos.BrandId, monthString);
  504. }
  505. RedisDbconn.Instance.AddNumber("ActiveRewardAmt:" + GetUserId + ":" + pos.BrandId + ":" + monthString, ActPrize);
  506. // 激活奖励详情
  507. List<int> actPrizeList = RedisDbconn.Instance.GetList<int>("ActiveRewardDetail:" + GetUserId + ":" + pos.BrandId + ":" + dateString);
  508. if (!actPrizeList.Contains(pos.BindMerchantId))
  509. {
  510. RedisDbconn.Instance.AddList("ActiveRewardDetail:" + GetUserId + ":" + pos.BrandId + ":" + dateString, pos.BindMerchantId);
  511. }
  512. RedisDbconn.Instance.AddNumber("ActiveRewardAmt:mer:" + pos.BindMerchantId + ":" + pos.BrandId + ":" + dateString, ActPrize);
  513. //收支明细
  514. RedisDbconn.Instance.AddList("UserAccountRecord:" + GetUserId + ":1:" + monthString, userAccountRecord);
  515. RedisDbconn.Instance.AddNumber("UserAccount:" + GetUserId + ":1:" + monthString, ActPrize);
  516. }
  517. }
  518. }
  519. // }
  520. }
  521. db.Dispose();
  522. }
  523. //3. 前一天的激活记录,根据创客类型,如果是商户型创客,则开机奖励的起始人从此人上级计算。如果不是,则从此人开始计算
  524. public void dosomething4(string date)
  525. {
  526. WebCMSEntities db = new WebCMSEntities();
  527. DateTime yesterday = DateTime.Parse(date + " 00:00:00");
  528. DateTime today = DateTime.Parse(DateTime.Parse(date).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00");
  529. List<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && m.ActivationTime >= yesterday && m.ActivationTime < today && !string.IsNullOrEmpty(m.SeoKeyword) && m.SeoKeyword != "0" && m.CreditTrade >= 1000).ToList();
  530. foreach (PosMachinesTwo pos in posList)
  531. {
  532. if (pos.ActivationTime > DateTime.Now.AddDays(-20))
  533. {
  534. decimal ActPrize = decimal.Parse(function.CheckNum(pos.SeoKeyword));
  535. if (ActPrize > 0)
  536. {
  537. // PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId && !string.IsNullOrEmpty(m.MerIdcardNo));
  538. PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
  539. if (merchant != null)
  540. {
  541. // PosMerchantOtherInfo otherInfo = db.PosMerchantOtherInfo.FirstOrDefault(m => m.CertId == merchant.MerIdcardNo && m.PrizeFlag2 == 0);
  542. // if (otherInfo != null)
  543. // {
  544. // otherInfo.PrizeFlag2 = 1;
  545. // db.SaveChanges();
  546. // 从机具所属人上级开始分开机奖励
  547. Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
  548. if (user != null)
  549. {
  550. if (!string.IsNullOrEmpty(user.ParentNav))
  551. {
  552. decimal Prize = 20;
  553. string[] ParentNavs = user.ParentNav.Trim(',').Replace(",,", ",").Split(',');
  554. for (int i = ParentNavs.Length - 1; i >= 0; i--)
  555. {
  556. int UserId = int.Parse(ParentNavs[i]);
  557. Users puser = db.Users.FirstOrDefault(m => m.Id == UserId && m.AuthFlag == 1);
  558. if (puser != null && Prize > 0)
  559. {
  560. int machineCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.PosSnType == 0); //判断是否拥有3台购买机
  561. int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
  562. // int BigCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.BrandId == 3); //判断是否拥有2台大机
  563. // int BigActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1 && m.BrandId == 3); //判断是否拥有2台激活大机(不限购买或赠送)
  564. if (machineCount + ActiveCount >= 3)
  565. {
  566. int pTopUserId = 0;
  567. if (!string.IsNullOrEmpty(puser.ParentNav))
  568. {
  569. pTopUserId = int.Parse(puser.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  570. }
  571. Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new Users();
  572. OpenRewardDetail detail = db.OpenRewardDetail.Add(new OpenRewardDetail()
  573. {
  574. CreateDate = DateTime.Now,
  575. UpdateDate = DateTime.Now,
  576. TradeMonth = yesterday.ToString("yyyyMM"), //交易月
  577. TradeDate = yesterday, //达标日期
  578. UserId = puser.Id, //创客
  579. BrandId = pos.BrandId, //品牌
  580. ProductName = RelationClass.GetKqProductsInfo(pos.BrandId), //产品名称
  581. MerchantId = pos.BindMerchantId, //商户
  582. DirectUserId = merchant.UserId, //商户直属人
  583. SnNo = pos.PosSn, //SN号
  584. MerNo = merchant.KqMerNo, //渠道商户号
  585. SnType = pos.PosSnType, //机具类型
  586. StandardDate = pos.ActivationTime, //商户的激活日期
  587. SnStoreId = pos.StoreId, //SN仓库
  588. MerBuddyType = puser.MerchantType, //商户创客类型
  589. RewardType = 1, //奖励类型 1-开机直接奖励,2-开机间接奖励
  590. RewardTips = "开机奖励", //奖励描述
  591. CreditTradeAmt = pos.CreditTrade, //贷记卡交易总金额
  592. DebitTradeAmt = pos.DebitCardTrade, //借记卡交易总金额
  593. CreditRewardAmount = Prize, //贷记卡交易奖励金额
  594. RewardDesc = "开机奖励", //奖励描述
  595. TopUserId = pTopUserId, //顶级创客
  596. SeoTitle = machineUser.RealName,
  597. }).Entity;
  598. db.OpenReward.Add(new OpenReward()
  599. {
  600. CreateDate = DateTime.Now,
  601. UpdateDate = DateTime.Now,
  602. TradeMonth = yesterday.ToString("yyyyMM"), //交易月
  603. TradeDate = DateTime.Now, //达标日期
  604. UserId = puser.Id, //创客
  605. BrandId = pos.BrandId, //品牌
  606. RewardType = 2, //奖励类型
  607. CreditTradeAmt = pos.CreditTrade, //贷记卡交易总金额
  608. DebitTradeAmt = pos.DebitCardTrade, //借记卡交易总金额
  609. CreditRewardAmount = Prize, //贷记卡交易奖励金额
  610. RewardDesc = "开机奖励", //奖励描述
  611. TopUserId = pTopUserId, //顶级创客
  612. });
  613. string IdBrand = puser.Id + "_" + pos.BrandId;
  614. UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
  615. if (userData == null)
  616. {
  617. userData = db.UserMachineData.Add(new UserMachineData()
  618. {
  619. IdBrand = IdBrand,
  620. }).Entity;
  621. db.SaveChanges();
  622. }
  623. userData.OpenProfit += Prize;
  624. db.SaveChanges();
  625. RedisDbconn.Instance.Set("UserMachineData:" + IdBrand, userData);
  626. //账户入库
  627. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id);
  628. if (account == null)
  629. {
  630. account = db.UserAccount.Add(new UserAccount()
  631. {
  632. Id = puser.Id,
  633. UserId = puser.Id,
  634. }).Entity;
  635. db.SaveChanges();
  636. }
  637. //收支明细入库
  638. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  639. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  640. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  641. account.BalanceAmount += Prize;
  642. account.TotalAmount += Prize;
  643. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  644. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  645. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  646. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  647. {
  648. CreateDate = DateTime.Now,
  649. UpdateDate = DateTime.Now,
  650. UserId = puser.Id, //创客
  651. ChangeType = 50, //变动类型
  652. ProductType = pos.BrandId, //产品类型
  653. ChangeAmount = Prize, //变更金额
  654. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  655. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  656. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  657. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  658. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  659. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  660. }).Entity;
  661. db.SaveChanges();
  662. RedisDbconn.Instance.Set("UserAccount:" + puser.Id, account);
  663. string dateString = yesterday.ToString("yyyyMMdd");
  664. string monthString = yesterday.ToString("yyyyMM");
  665. // 开机奖励列表
  666. List<string> dates = RedisDbconn.Instance.GetList<string>("OpenRewardDay:" + puser.Id + ":" + pos.BrandId);
  667. if (!dates.Contains(dateString))
  668. {
  669. RedisDbconn.Instance.AddList("OpenRewardDay:" + puser.Id + ":" + pos.BrandId, dateString);
  670. }
  671. RedisDbconn.Instance.AddNumber("OpenRewardAmt:" + puser.Id + ":" + pos.BrandId + ":" + dateString, Prize);
  672. List<string> months = RedisDbconn.Instance.GetList<string>("OpenRewardMonth:" + puser.Id + ":" + pos.BrandId);
  673. if (!months.Contains(monthString))
  674. {
  675. RedisDbconn.Instance.AddList("OpenRewardMonth:" + puser.Id + ":" + pos.BrandId, monthString);
  676. }
  677. RedisDbconn.Instance.AddNumber("OpenRewardAmt:" + puser.Id + ":" + pos.BrandId + ":" + monthString, Prize);
  678. // 开机奖励详情
  679. RedisDbconn.Instance.AddList("OpenRewardDetail:" + puser.Id + ":" + pos.BrandId + ":" + dateString, detail);
  680. //收支明细
  681. RedisDbconn.Instance.AddList("UserAccountRecord:" + puser.Id + ":1:" + monthString, userAccountRecord);
  682. RedisDbconn.Instance.AddNumber("UserAccount:" + puser.Id + ":1:" + monthString, Prize);
  683. Prize -= 10;
  684. }
  685. }
  686. }
  687. }
  688. }
  689. // }
  690. }
  691. }
  692. }
  693. }
  694. db.Dispose();
  695. }
  696. public void dosomething42(string date)
  697. {
  698. WebCMSEntities db = new WebCMSEntities();
  699. DateTime yesterday = DateTime.Parse(date + " 00:00:00");
  700. DateTime today = DateTime.Parse(DateTime.Parse(date).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00");
  701. List<PosMerchantInfo> merList = db.PosMerchantInfo.Where(m => m.ActiveStatus == 1 && m.MerStandardDate >= yesterday && m.MerStandardDate < today && !string.IsNullOrEmpty(m.SeoKeyword) && m.SeoKeyword != "0").ToList();
  702. foreach (PosMerchantInfo merchant in merList)
  703. {
  704. MachineForMerNo forMerNo = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == merchant.MerchantNo) ?? new MachineForMerNo();
  705. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == forMerNo.SnId) ?? new PosMachinesTwo();
  706. if (pos.ActivationTime > DateTime.Now.AddDays(-20) && pos.CreditTrade >= 1000)
  707. {
  708. decimal ActPrize = decimal.Parse(function.CheckNum(merchant.SeoKeyword));
  709. if (ActPrize > 0)
  710. {
  711. // PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId && !string.IsNullOrEmpty(m.MerIdcardNo));
  712. // PosMerchantOtherInfo otherInfo = db.PosMerchantOtherInfo.FirstOrDefault(m => m.CertId == merchant.MerIdcardNo && m.PrizeFlag2 == 0);
  713. // if (otherInfo != null)
  714. // {
  715. // otherInfo.PrizeFlag2 = 1;
  716. // db.SaveChanges();
  717. // 从机具所属人上级开始分开机奖励
  718. Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
  719. if (user != null)
  720. {
  721. if (!string.IsNullOrEmpty(user.ParentNav))
  722. {
  723. decimal Prize = 20;
  724. string[] ParentNavs = user.ParentNav.Trim(',').Replace(",,", ",").Split(',');
  725. for (int i = ParentNavs.Length - 1; i >= 0; i--)
  726. {
  727. int UserId = int.Parse(ParentNavs[i]);
  728. Users puser = db.Users.FirstOrDefault(m => m.Id == UserId && m.AuthFlag == 1);
  729. if (puser != null && Prize > 0)
  730. {
  731. int machineCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.PosSnType == 0); //判断是否拥有3台购买机
  732. int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
  733. // int BigCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.BrandId == 3); //判断是否拥有2台大机
  734. // int BigActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1 && m.BrandId == 3); //判断是否拥有2台激活大机(不限购买或赠送)
  735. if (machineCount + ActiveCount >= 3)
  736. {
  737. int pTopUserId = 0;
  738. if (!string.IsNullOrEmpty(puser.ParentNav))
  739. {
  740. pTopUserId = int.Parse(puser.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  741. }
  742. Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new Users();
  743. OpenRewardDetail detail = db.OpenRewardDetail.Add(new OpenRewardDetail()
  744. {
  745. CreateDate = DateTime.Now,
  746. UpdateDate = DateTime.Now,
  747. TradeMonth = yesterday.ToString("yyyyMM"), //交易月
  748. TradeDate = yesterday, //达标日期
  749. UserId = puser.Id, //创客
  750. BrandId = pos.BrandId, //品牌
  751. ProductName = RelationClass.GetKqProductsInfo(pos.BrandId), //产品名称
  752. MerchantId = pos.BindMerchantId, //商户
  753. DirectUserId = merchant.UserId, //商户直属人
  754. SnNo = pos.PosSn, //SN号
  755. MerNo = merchant.KqMerNo, //渠道商户号
  756. SnType = pos.PosSnType, //机具类型
  757. StandardDate = pos.ActivationTime, //商户的激活日期
  758. SnStoreId = pos.StoreId, //SN仓库
  759. MerBuddyType = puser.MerchantType, //商户创客类型
  760. RewardType = 1, //奖励类型 1-开机直接奖励,2-开机间接奖励
  761. RewardTips = "开机奖励", //奖励描述
  762. CreditTradeAmt = pos.CreditTrade, //贷记卡交易总金额
  763. DebitTradeAmt = pos.DebitCardTrade, //借记卡交易总金额
  764. CreditRewardAmount = Prize, //贷记卡交易奖励金额
  765. RewardDesc = "开机奖励", //奖励描述
  766. TopUserId = pTopUserId, //顶级创客
  767. SeoTitle = machineUser.RealName,
  768. }).Entity;
  769. db.OpenReward.Add(new OpenReward()
  770. {
  771. CreateDate = DateTime.Now,
  772. UpdateDate = DateTime.Now,
  773. TradeMonth = yesterday.ToString("yyyyMM"), //交易月
  774. TradeDate = DateTime.Now, //达标日期
  775. UserId = puser.Id, //创客
  776. BrandId = pos.BrandId, //品牌
  777. RewardType = 2, //奖励类型
  778. CreditTradeAmt = pos.CreditTrade, //贷记卡交易总金额
  779. DebitTradeAmt = pos.DebitCardTrade, //借记卡交易总金额
  780. CreditRewardAmount = Prize, //贷记卡交易奖励金额
  781. RewardDesc = "开机奖励", //奖励描述
  782. TopUserId = pTopUserId, //顶级创客
  783. });
  784. string IdBrand = puser.Id + "_" + pos.BrandId;
  785. UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
  786. if (userData == null)
  787. {
  788. userData = db.UserMachineData.Add(new UserMachineData()
  789. {
  790. IdBrand = IdBrand,
  791. }).Entity;
  792. db.SaveChanges();
  793. }
  794. userData.OpenProfit += Prize;
  795. db.SaveChanges();
  796. RedisDbconn.Instance.Set("UserMachineData:" + IdBrand, userData);
  797. //账户入库
  798. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id);
  799. if (account == null)
  800. {
  801. account = db.UserAccount.Add(new UserAccount()
  802. {
  803. Id = puser.Id,
  804. UserId = puser.Id,
  805. }).Entity;
  806. db.SaveChanges();
  807. }
  808. //收支明细入库
  809. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  810. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  811. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  812. account.BalanceAmount += Prize;
  813. account.TotalAmount += Prize;
  814. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  815. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  816. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  817. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  818. {
  819. CreateDate = DateTime.Now,
  820. UpdateDate = DateTime.Now,
  821. UserId = puser.Id, //创客
  822. ChangeType = 50, //变动类型
  823. ProductType = pos.BrandId, //产品类型
  824. ChangeAmount = Prize, //变更金额
  825. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  826. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  827. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  828. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  829. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  830. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  831. }).Entity;
  832. db.SaveChanges();
  833. RedisDbconn.Instance.Set("UserAccount:" + puser.Id, account);
  834. string dateString = yesterday.ToString("yyyyMMdd");
  835. string monthString = yesterday.ToString("yyyyMM");
  836. // 开机奖励列表
  837. List<string> dates = RedisDbconn.Instance.GetList<string>("OpenRewardDay:" + puser.Id + ":" + pos.BrandId);
  838. if (!dates.Contains(dateString))
  839. {
  840. RedisDbconn.Instance.AddList("OpenRewardDay:" + puser.Id + ":" + pos.BrandId, dateString);
  841. }
  842. RedisDbconn.Instance.AddNumber("OpenRewardAmt:" + puser.Id + ":" + pos.BrandId + ":" + dateString, Prize);
  843. List<string> months = RedisDbconn.Instance.GetList<string>("OpenRewardMonth:" + puser.Id + ":" + pos.BrandId);
  844. if (!months.Contains(monthString))
  845. {
  846. RedisDbconn.Instance.AddList("OpenRewardMonth:" + puser.Id + ":" + pos.BrandId, monthString);
  847. }
  848. RedisDbconn.Instance.AddNumber("OpenRewardAmt:" + puser.Id + ":" + pos.BrandId + ":" + monthString, Prize);
  849. // 开机奖励详情
  850. RedisDbconn.Instance.AddList("OpenRewardDetail:" + puser.Id + ":" + pos.BrandId + ":" + dateString, detail);
  851. //收支明细
  852. RedisDbconn.Instance.AddList("UserAccountRecord:" + puser.Id + ":1:" + monthString, userAccountRecord);
  853. RedisDbconn.Instance.AddNumber("UserAccount:" + puser.Id + ":1:" + monthString, Prize);
  854. Prize -= 10;
  855. }
  856. }
  857. }
  858. }
  859. }
  860. // }
  861. }
  862. }
  863. }
  864. db.Dispose();
  865. }
  866. }
  867. }