AlipayPayBack2Service.cs 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Data;
  5. using MySystem.PxcModels;
  6. using Library;
  7. using LitJson;
  8. namespace MySystem
  9. {
  10. public class AlipayPayBack2Service
  11. {
  12. public readonly static AlipayPayBack2Service Instance = new AlipayPayBack2Service();
  13. private AlipayPayBack2Service()
  14. { }
  15. public void Start(JobMqMsg jobInfo)
  16. {
  17. string content = "";
  18. try
  19. {
  20. dosomething();
  21. // string Msg = "success";
  22. // jobInfo.Status = Msg == "success" ? 1 : 0;
  23. // jobInfo.Msg = Msg == "success" ? "执行完成" : Msg;
  24. // RabbitMQClient.Instance.SendMsg(Newtonsoft.Json.JsonConvert.SerializeObject(jobInfo), "PublicBack");
  25. }
  26. catch (Exception ex)
  27. {
  28. if (!string.IsNullOrEmpty(content))
  29. {
  30. Dictionary<string, string> data = new Dictionary<string, string>();
  31. data.Add("ErrTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  32. data.Add("ErrMsg", ex.ToString());
  33. function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(data), "public_err");
  34. }
  35. else
  36. {
  37. function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "商城订单支付回调异常");
  38. }
  39. }
  40. }
  41. private void dosomething()
  42. {
  43. bool op = true;
  44. while (op)
  45. {
  46. string content = RedisDbconn.Instance.RPop<string>("PayCallBack2");
  47. if (!string.IsNullOrEmpty(content))
  48. {
  49. sloveAlipayCallBack(content);
  50. }
  51. else
  52. {
  53. op = false;
  54. }
  55. }
  56. }
  57. public void sloveAlipayCallBack(string content)
  58. {
  59. JsonData jsonObj = JsonMapper.ToObject(content);
  60. string OrderNo = jsonObj["out_trade_no"].ToString();
  61. string TradeNo = jsonObj["transaction_id"].ToString();
  62. decimal TotalFee = decimal.Parse(function.CheckNum(jsonObj["total_fee"].ToString()));
  63. WebCMSEntities db = new WebCMSEntities();
  64. OrderForNo forNo = db.OrderForNo.FirstOrDefault(m => m.OrderNo == OrderNo);
  65. if (forNo != null)
  66. {
  67. string[] ids = forNo.OrderIds.Split(',');
  68. foreach (string idString in ids)
  69. {
  70. int OrderId = int.Parse(idString);
  71. DoOrderV2(db, OrderId);
  72. }
  73. }
  74. db.Dispose();
  75. }
  76. #region 新订单流程
  77. public void DoOrderV2(WebCMSEntities db, int OrderId)
  78. {
  79. Orders order = db.Orders.FirstOrDefault(m => m.Id == OrderId && m.Status <= 0);
  80. if (order != null)
  81. {
  82. order.Status = 1;
  83. order.PayDate = DateTime.Now;
  84. order.PayStatus = 1;
  85. db.SaveChanges();
  86. if(order.ParentOrderId > 0)
  87. {
  88. int total = db.Orders.Count(m => m.ParentOrderId == order.ParentOrderId);
  89. int paycount = db.Orders.Count(m => m.ParentOrderId == order.ParentOrderId && m.Status > 0);
  90. if(paycount >= total)
  91. {
  92. // order = db.Orders.FirstOrDefault(m => m.Id == order.ParentOrderId && m.Status == 0);
  93. // if (order != null)
  94. // {
  95. // order.Status = 2;
  96. // order.PayDate = DateTime.Now;
  97. // order.PayStatus = 1;
  98. // OrderId = order.Id;
  99. // }
  100. DoOrderV2(db, order.ParentOrderId);
  101. }
  102. return;
  103. }
  104. OrderProduct pro = db.OrderProduct.FirstOrDefault(m => m.OrderId == OrderId);
  105. if (pro != null)
  106. {
  107. order.ProductId = pro.ProductId;
  108. //扣减对应商品的库存
  109. Products product = db.Products.FirstOrDefault(m => m.Id == pro.ProductId);
  110. if(product != null)
  111. {
  112. product.Stock -= pro.ProductCount;
  113. product.BuyCount += pro.ProductCount;
  114. }
  115. db.SaveChanges();
  116. if(order.ErpMode > 0)
  117. {
  118. pro.ProductId = order.ProductId;
  119. }
  120. List<int> couponIds = new List<int>();
  121. if (pro.ProductId == 10 || pro.ProductId == 11 || pro.ProductId == 27 || pro.ProductId == 28 || pro.ProductId == 34 || pro.ProductId == -2)
  122. {
  123. order.Status = 2;
  124. int BuyCount = pro.ProductCount;
  125. int Kind = 0;
  126. int BeforeLeaderLevel = 0;
  127. if (pro.ProductId == 10 || pro.ProductId == 34)
  128. {
  129. Kind = 1;
  130. }
  131. else if (pro.ProductId == 11 || pro.ProductId == -2)
  132. {
  133. Kind = 2;
  134. }
  135. else if (pro.ProductId == 28)
  136. {
  137. Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId && m.LeaderLevel == 0);
  138. if(user != null)
  139. {
  140. BeforeLeaderLevel = user.LeaderLevel;
  141. user.LeaderLevel = 1;
  142. }
  143. }
  144. else if (pro.ProductId == 27)
  145. {
  146. Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId && m.LeaderLevel < 2);
  147. if(user != null)
  148. {
  149. BeforeLeaderLevel = user.LeaderLevel;
  150. user.LeaderLevel = 2;
  151. }
  152. }
  153. if(Kind <= 2 && (pro.ProductId == 10 || pro.ProductId == 11 || pro.ProductId == 34 || pro.ProductId == -2))
  154. {
  155. // 购买600一组机具券,返券
  156. int CouponCount = 0;
  157. if(Kind == 1)
  158. {
  159. CouponCount = 3 * pro.ProductCount;
  160. }
  161. else if(Kind == 2)
  162. {
  163. CouponCount = 2 * pro.ProductCount;
  164. }
  165. string Codes = "";
  166. var coupons = db.PosCoupons.Where(m => m.IsLock == 0 && m.IsUse == 0 && m.UserId == 0 && m.QueryCount == Kind).OrderBy(m => m.Id).Take(CouponCount).ToList();
  167. int RecordId = 0;
  168. if(coupons.Count > 0 && (pro.ProductId == 34 || pro.ProductId == -2))
  169. {
  170. var adds = db.HelpProfitExchange.Add(new HelpProfitExchange()
  171. {
  172. CreateDate = DateTime.Now, //创建时间
  173. UserId = order.UserId,
  174. ExchangeCount = coupons.Count,
  175. }).Entity;
  176. db.SaveChanges();
  177. RecordId = adds.Id;
  178. }
  179. foreach (var coupon in coupons) // TODO: 数量多的话,会慢
  180. {
  181. PosCoupons item = db.PosCoupons.FirstOrDefault(m => m.Id == coupon.Id);
  182. if (item != null)
  183. {
  184. item.CreateDate = DateTime.Now;
  185. item.UserId = order.UserId;
  186. item.UpdateDate = DateTime.Now.AddDays(180);
  187. if(pro.ProductId == 34 || pro.ProductId == -2)
  188. {
  189. item.HelpProfitFlag = 1;
  190. db.HelpProfitExchangeDetail.Add(new HelpProfitExchangeDetail()
  191. {
  192. CreateDate = DateTime.Now, //创建时间
  193. UserId = order.UserId,
  194. PosCouponId = item.Id,
  195. ExchangeCode = item.ExchangeCode,
  196. RecordId = RecordId,
  197. });
  198. }
  199. Codes += item.ExchangeCode + ",";
  200. couponIds.Add(coupon.Id);
  201. }
  202. }
  203. order.SnNos = Codes.TrimEnd(',');
  204. }
  205. db.SaveChanges();
  206. if (pro.ProductId == 27 || pro.ProductId == 28)
  207. {
  208. //充值盟主储备金
  209. decimal TotalPrice = 10000;
  210. if(pro.ProductId == 27)
  211. {
  212. TotalPrice = 40000;
  213. }
  214. OpReserve(db, order, order.UserId, TotalPrice, 1);
  215. Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId) ?? new Users();
  216. if(pro.ProductId == 27)
  217. {
  218. OperateReserveBackFor(db, user.Id, 40000);
  219. //预设大盟主职级
  220. LeaderPreUserLevel(db, order.UserId, 2);
  221. decimal Prize = decimal.Parse(function.CheckNum(PublicFunction.GetPublicParam(db, "BigLeaderPrize")));
  222. if(Prize > 0 && BeforeLeaderLevel < 2 && user.UserType == 0)
  223. {
  224. LeaderRecommendPrize(db, order, user.Id, Prize, 122);
  225. }
  226. }
  227. }
  228. if (pro.ProductId == 28) //购买小盟主,给上级大盟主返储备金
  229. {
  230. bool check = LeaderBack(db, order);
  231. Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId) ?? new Users();
  232. if (check) OperateReserveBackFor(db, user.Id, 10000);
  233. //预设小盟主职级
  234. LeaderPreUserLevel(db, order.UserId, 1);
  235. decimal Prize = decimal.Parse(function.CheckNum(PublicFunction.GetPublicParam(db, "SmallLeaderPrize")));
  236. if(Prize > 0 && BeforeLeaderLevel < 1 && user.UserType == 0)
  237. {
  238. LeaderRecommendPrize(db, order, user.Id, Prize, 123);
  239. }
  240. }
  241. }
  242. // 购买盟主储蓄金
  243. if (pro.ProductId == 39 || pro.ProductId == 40)
  244. {
  245. order.Status = 2;
  246. //充值盟主储备金
  247. decimal TotalPrice = 10000;
  248. if(pro.ProductId == 39)
  249. {
  250. TotalPrice = 40000;
  251. }
  252. OpReserve(db, order, order.UserId, TotalPrice, 1);
  253. if(pro.ProductId == 40) //购买小盟主储蓄金,给上级大盟主返储备金
  254. {
  255. LeaderBack(db, order);
  256. }
  257. }
  258. //推荐下单奖励
  259. if (pro.ProductId == 10 || pro.ProductId == 11)
  260. {
  261. bool checkPrize = db.UserAccountRecord.Any(m => m.QueryCount == OrderId && m.ChangeType == 112);
  262. function.WriteLog("OrderId:" + OrderId, "推荐下单奖励监控日志");
  263. function.WriteLog("checkPrize:" + checkPrize, "推荐下单奖励监控日志");
  264. if (checkPrize)
  265. {
  266. Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
  267. if (user != null)
  268. {
  269. if(user.LeaderLevel > 0 || user.UserType == 1) //盟主或运营中心
  270. {
  271. //获得100元奖励
  272. OpAccount(db, order, order.UserId, 100, pro.ProductCount);
  273. }
  274. }
  275. }
  276. else
  277. {
  278. Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
  279. if (user != null)
  280. {
  281. bool directPrize = false; //直推奖标记
  282. bool bigLeaderPrize = false; //大盟主券标记
  283. bool operateFlag = false; //运营中心标记
  284. bool buyPrize = false; //返100购机奖励标记或返100购机奖励标记-运营中心
  285. int leaderFlag = 0; //返600备用金标记
  286. if(user.LeaderLevel > 0 || user.UserType == 1) //盟主或运营中心
  287. {
  288. if(user.LeaderLevel > 0)
  289. {
  290. UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == order.UserId) ?? new UserAccount();
  291. if(acccount.LeaderReserve >= order.TotalPrice)
  292. {
  293. if(order.PayMode == 4)
  294. {
  295. //扣减备用金
  296. OpReserve(db, order, order.UserId, order.TotalPrice, 0, 0, "商城购机(储备金支付)");
  297. }
  298. }
  299. }
  300. //获得100元奖励
  301. OpAccount(db, order, order.UserId, 100, pro.ProductCount);
  302. //推荐奖励
  303. DirectPrize(db, order.Id, order.UserId, pro.ProductCount);
  304. //推荐下单上级获得30天的机具循环天数(盟主自己得)
  305. var posList = db.PosMachinesTwo.Select(m => new { m.Id, m.UserId, m.BindingState, m.RecycEndDate }).Where(m => m.UserId == order.UserId && m.BindingState == 0 && m.RecycEndDate != null).ToList();
  306. foreach (var subPos in posList)
  307. {
  308. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == subPos.Id);
  309. if (pos != null)
  310. {
  311. pos.RecycEndDate = pos.RecycEndDate.Value.AddDays(30);
  312. }
  313. }
  314. db.SaveChanges();
  315. if(order.PayMode == 4 && user.LeaderLevel > 0) //使用盟主储蓄金,并且是盟主
  316. {
  317. if(user.UserType == 1)
  318. {
  319. if(couponIds.Count > 0)
  320. {
  321. UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == user.Id) ?? new UserAccount();
  322. foreach(int couponId in couponIds)
  323. {
  324. PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
  325. if(coupon != null)
  326. {
  327. if(acccount.LeaderReserve >= 400 * pro.ProductCount)
  328. {
  329. coupon.LeaderUserId = user.Id;
  330. }
  331. coupon.OpId = user.Id;
  332. }
  333. }
  334. }
  335. db.SaveChanges();
  336. }
  337. else
  338. {
  339. //寻找最近运营中心额度大于0的运营中心
  340. int PUserId = user.Id;
  341. bool OperateFlag = true;
  342. bool OncePrizeFlag1 = true;
  343. while(PUserId > 0)
  344. {
  345. Users puser = db.Users.FirstOrDefault(m => m.Id == PUserId);
  346. if(puser != null)
  347. {
  348. if(puser.UserType == 1 && OperateFlag == true) //运营中心
  349. {
  350. if(couponIds.Count > 0)
  351. {
  352. UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == order.UserId) ?? new UserAccount();
  353. foreach(int couponId in couponIds)
  354. {
  355. PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
  356. if(coupon != null)
  357. {
  358. if(acccount.LeaderReserve >= 400 * pro.ProductCount)
  359. {
  360. coupon.LeaderUserId = user.Id;
  361. }
  362. coupon.OpId = puser.Id;
  363. }
  364. }
  365. db.SaveChanges();
  366. if(acccount.LeaderReserve >= 400 * pro.ProductCount && OncePrizeFlag1)
  367. {
  368. //扣减备用金
  369. OpReserve(db, order, order.UserId, 400 * pro.ProductCount, 2, 0, "商城购机");
  370. //返回到余额
  371. OpLeaderAccount(db, order, order.UserId, 400, pro.ProductCount);
  372. OncePrizeFlag1 = false;
  373. }
  374. OperateFlag = false;
  375. }
  376. }
  377. PUserId = puser.ParentUserId;
  378. }
  379. else
  380. {
  381. PUserId = 0;
  382. }
  383. }
  384. }
  385. }
  386. else if(order.PayMode == 4 && user.UserType == 1) //使用盟主储蓄金,并且是运营中心
  387. {
  388. if(couponIds.Count > 0)
  389. {
  390. foreach(int couponId in couponIds)
  391. {
  392. PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
  393. if(coupon != null)
  394. {
  395. coupon.OpId = user.Id;
  396. }
  397. }
  398. }
  399. db.SaveChanges();
  400. //寻找最近储蓄金充足的大盟主
  401. int PUserId = user.Id;
  402. bool LeaderFlag = true;
  403. bool OncePrizeFlag2 = true;
  404. while(PUserId > 0)
  405. {
  406. Users puser = db.Users.FirstOrDefault(m => m.Id == PUserId);
  407. if(puser != null)
  408. {
  409. if(puser.LeaderLevel == 2 && LeaderFlag == true) //大盟主
  410. {
  411. if(couponIds.Count > 0)
  412. {
  413. UserAccount pacccount = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
  414. foreach(int couponId in couponIds)
  415. {
  416. PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
  417. if(coupon != null && pacccount.LeaderReserve >= 400 * pro.ProductCount)
  418. {
  419. coupon.LeaderUserId = puser.Id;
  420. }
  421. }
  422. db.SaveChanges();
  423. UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == order.UserId) ?? new UserAccount();
  424. if(acccount.LeaderReserve >= 400 * pro.ProductCount && OncePrizeFlag2)
  425. {
  426. //扣减备用金
  427. OpReserve(db, order, order.UserId, 400 * pro.ProductCount, 2, 0, "商城购机");
  428. //返回到余额
  429. OpLeaderAccount(db, order, order.UserId, 400, pro.ProductCount);
  430. OncePrizeFlag2 = false;
  431. }
  432. LeaderFlag = false;
  433. }
  434. }
  435. PUserId = puser.ParentUserId;
  436. }
  437. else
  438. {
  439. PUserId = 0;
  440. }
  441. }
  442. }
  443. else
  444. {
  445. //寻找最近储蓄金充足的大盟主及最近运营中心额度大于0的运营中心(含自身)
  446. int PUserId = user.Id;
  447. int LeaderFlag = 0;
  448. bool OperateFlag = true;
  449. bool OncePrizeFlag3 = true;
  450. while(PUserId > 0)
  451. {
  452. Users puser = db.Users.FirstOrDefault(m => m.Id == PUserId);
  453. if(puser != null)
  454. {
  455. if(puser.LeaderLevel > 0 && puser.LeaderLevel > LeaderFlag && LeaderFlag < 2) //大盟主
  456. {
  457. if(couponIds.Count > 0)
  458. {
  459. if(puser.LeaderLevel == 2)
  460. {
  461. UserAccount pacccount = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
  462. foreach(int couponId in couponIds)
  463. {
  464. PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
  465. if(coupon != null && pacccount.LeaderReserve >= 400 * pro.ProductCount)
  466. {
  467. coupon.LeaderUserId = puser.Id;
  468. }
  469. }
  470. db.SaveChanges();
  471. }
  472. UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
  473. if(acccount.LeaderReserve >= 400 * pro.ProductCount && OncePrizeFlag3)
  474. {
  475. //扣减备用金
  476. OpReserve(db, order, puser.Id, 400 * pro.ProductCount, 2, 0, "商城购机");
  477. //返回到余额
  478. OpLeaderAccount(db, order, puser.Id, 400, pro.ProductCount);
  479. LeaderFlag = puser.LeaderLevel;
  480. OncePrizeFlag3 = false;
  481. }
  482. }
  483. }
  484. if(puser.UserType == 1 && OperateFlag == true) //运营中心
  485. {
  486. if(couponIds.Count > 0)
  487. {
  488. foreach(int couponId in couponIds)
  489. {
  490. PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
  491. if(coupon != null)
  492. {
  493. coupon.OpId = puser.Id;
  494. }
  495. }
  496. db.SaveChanges();
  497. OperateFlag = false;
  498. }
  499. }
  500. PUserId = puser.ParentUserId;
  501. }
  502. else
  503. {
  504. PUserId = 0;
  505. }
  506. }
  507. //运营中心返额度(下单人自己是运营中心)
  508. // OperateReserveBackFor(db, order.UserId, order.TotalPrice);
  509. }
  510. return;
  511. }
  512. int ParentUserId = user.ParentUserId;
  513. // List<int> proids = new List<int>();
  514. // proids.Add(10);
  515. // proids.Add(11);
  516. // 普通创客购买600一组的机具券
  517. bool OncePrizeFlag4 = true;
  518. while(ParentUserId > 0)
  519. {
  520. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  521. int machineCount = db.PosMachinesTwo.Count(m => m.BuyUserId == ParentUserId && m.PosSnType == 0 && m.ActivationState == 0); //判断是否拥有3台兑换机
  522. int ActiveCount = db.PosMachinesTwo.Count(m => m.BuyUserId == ParentUserId && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
  523. int couponCount = db.PosCoupons.Count(m => m.UserId == ParentUserId && m.IsUse == 0); //判断是否拥有3张券
  524. function.WriteLog("MakerCode:" + puser.MakerCode, "推荐下单奖励监控日志");
  525. function.WriteLog("machineCount:" + machineCount, "推荐下单奖励监控日志");
  526. function.WriteLog("ActiveCount:" + ActiveCount, "推荐下单奖励监控日志");
  527. if ((machineCount + ActiveCount + couponCount >= 3 || puser.LeaderLevel > 0) && !directPrize)
  528. {
  529. // function.WriteLog("满足条件", "推荐下单奖励监控日志");
  530. // if(puser.LeaderLevel == 0) // 非盟主直推奖励,每个创客第一次下单,上级可得
  531. // {
  532. // List<int> oids = new List<int>();
  533. // var orderpros = db.OrderProduct.Select(m => new { m.OrderId,m.UserId,m.ProductId }).Where(m => m.UserId == order.UserId && proids.Contains(m.ProductId)).ToList();
  534. // foreach(var orderpro in orderpros)
  535. // {
  536. // oids.Add(orderpro.OrderId);
  537. // }
  538. // bool check = db.Orders.Any(m => oids.Contains(m.Id) && m.Status > 0);
  539. // if(!check)
  540. // {
  541. // DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
  542. // directPrize = true;
  543. // }
  544. // }
  545. // else
  546. // {
  547. // 盟主直推奖励,可以每次下单获得
  548. DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
  549. directPrize = true;
  550. // }
  551. //推荐下单上级获得30天的机具循环天数
  552. var posList = db.PosMachinesTwo.Select(m => new { m.Id, m.UserId, m.BindingState, m.RecycEndDate }).Where(m => m.UserId == ParentUserId && m.BindingState == 0 && m.RecycEndDate != null).ToList();
  553. foreach (var subPos in posList)
  554. {
  555. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == subPos.Id);
  556. if (pos != null)
  557. {
  558. pos.RecycEndDate = pos.RecycEndDate.Value.AddDays(30);
  559. }
  560. }
  561. db.SaveChanges();
  562. }
  563. if(puser.LeaderLevel > 0)
  564. {
  565. UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
  566. if(acccount.LeaderReserve >= 400 * pro.ProductCount && !buyPrize)
  567. {
  568. //购机奖励
  569. OpAccount(db, order, puser.Id, 100, pro.ProductCount);
  570. buyPrize = true;
  571. }
  572. if(acccount.LeaderReserve >= 400 * pro.ProductCount && puser.LeaderLevel > leaderFlag && leaderFlag < 2 && OncePrizeFlag4)
  573. {
  574. //扣减备用金
  575. OpReserve(db, order, puser.Id, 400 * pro.ProductCount, 2, order.UserId, "购机奖励");
  576. //返回到余额
  577. OpLeaderAccount(db, order, puser.Id, 400, pro.ProductCount);
  578. leaderFlag = puser.LeaderLevel;
  579. OncePrizeFlag4 = false;
  580. }
  581. //如果是大盟主,则标记大盟主标签
  582. if(couponIds.Count > 0 && puser.LeaderLevel == 2 && acccount.LeaderReserve >= 400 * pro.ProductCount && !bigLeaderPrize)
  583. {
  584. foreach(int couponId in couponIds)
  585. {
  586. PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
  587. if(coupon != null)
  588. {
  589. coupon.LeaderUserId = puser.Id;
  590. }
  591. }
  592. db.SaveChanges();
  593. bigLeaderPrize = true;
  594. }
  595. }
  596. if(puser.UserType == 1)
  597. {
  598. UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
  599. if(!buyPrize)
  600. {
  601. //购机奖励
  602. ChangeAccount(db, order, puser.Id, 100 * pro.ProductCount, 120);
  603. buyPrize = true;
  604. }
  605. //标记标签
  606. if(couponIds.Count > 0 && !operateFlag)
  607. {
  608. foreach(int couponId in couponIds)
  609. {
  610. PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
  611. if(coupon != null)
  612. {
  613. coupon.OpId= puser.Id;
  614. }
  615. }
  616. db.SaveChanges();
  617. operateFlag = true;
  618. }
  619. }
  620. ParentUserId = puser.ParentUserId;
  621. }
  622. //运营中心返额度
  623. // OperateReserveBackFor(db, order.UserId, order.TotalPrice);
  624. }
  625. }
  626. function.WriteLog("\r\n\r\n", "推荐下单奖励监控日志");
  627. }
  628. //推荐王
  629. if(pro.ProductId == 29)
  630. {
  631. RecommendMethod(order.UserId, order.CreateDate.Value.ToString("yyyyMM"));
  632. }
  633. //购买分仓临时额度
  634. if(pro.ProductId == 30 || pro.ProductId == 31 || pro.ProductId == 32)
  635. {
  636. string SendData = "{\"Kind\":\"1\",\"Data\":{\"OrderId\":\"" + order.Id + "\"}}";
  637. RedisDbconn.Instance.AddList("StoreApplyQueue", SendData);
  638. }
  639. }
  640. else
  641. {
  642. if(order.ProductId > 0 && order.ErpMode > 0)
  643. {
  644. //盟主储备金-升级/购买 ErpMode:1-升级,2-购买
  645. if(order.ErpMode > 0)
  646. {
  647. Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
  648. if(user != null)
  649. {
  650. if(order.ErpMode == 1)
  651. {
  652. user.LeaderLevel = 2;
  653. db.SaveChanges();
  654. }
  655. OpReserve(db, order, order.UserId, order.TotalPrice, 1);
  656. }
  657. }
  658. }
  659. }
  660. }
  661. }
  662. //小盟主购买逻辑
  663. public bool LeaderBack(WebCMSEntities db, Orders order)
  664. {
  665. int LeaderUserId = order.UserId;
  666. int level = 0;
  667. bool result = true;
  668. while(LeaderUserId > 0)
  669. {
  670. level += 1;
  671. Users user = db.Users.FirstOrDefault(m => m.Id == LeaderUserId);
  672. if(user != null)
  673. {
  674. if(user.LeaderLevel == 2 && level > 1)
  675. {
  676. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == LeaderUserId);
  677. if(account != null)
  678. {
  679. decimal TotalPrice = 10000;
  680. if(account.LeaderReserve >= TotalPrice)
  681. {
  682. OpReserve(db, order, LeaderUserId, TotalPrice, 2, 0, "推荐小盟主");
  683. OpLeaderAccount(db, order, LeaderUserId, TotalPrice);
  684. LeaderUserId = 0;
  685. result = false;
  686. }
  687. else
  688. {
  689. LeaderUserId = user.ParentUserId;
  690. // decimal LeaderReserve = account.LeaderReserve;
  691. // OpReserve(db, order, LeaderUserId, LeaderReserve, 2, 0, "推荐小盟主");
  692. // OpLeaderAccount(db, order, LeaderUserId, LeaderReserve);
  693. }
  694. }
  695. }
  696. else
  697. {
  698. LeaderUserId = user.ParentUserId;
  699. }
  700. }
  701. else
  702. {
  703. LeaderUserId = 0;
  704. }
  705. }
  706. return result;
  707. }
  708. //操作储备金
  709. public void OpReserve(WebCMSEntities db, Orders order, int UserId, decimal Money, int ChangeType, int SourceUserId = 0, string Remark = "储备金购买")
  710. {
  711. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
  712. if (account == null)
  713. {
  714. account = db.UserAccount.Add(new UserAccount()
  715. {
  716. Id = UserId,
  717. UserId = UserId,
  718. }).Entity;
  719. db.SaveChanges();
  720. }
  721. decimal BeforeAmount = account.LeaderReserve; //变更前总金额
  722. if(ChangeType == 1)
  723. {
  724. account.LeaderReserve += Money;
  725. }
  726. else
  727. {
  728. account.LeaderReserve -= Money;
  729. }
  730. decimal AfterAmount = account.LeaderReserve; //变更后总金额
  731. LeaderReserveRecord add = db.LeaderReserveRecord.Add(new LeaderReserveRecord()
  732. {
  733. CreateDate = DateTime.Now,
  734. ChangeType = ChangeType,
  735. OrderId = order.Id,
  736. Remark = Remark,
  737. AfterAmt = AfterAmount,
  738. BeforeAmt = BeforeAmount,
  739. ChangeAmt = Money,
  740. TradeDate = DateTime.Now.ToString("yyyyMMdd"),
  741. TradeMonth = DateTime.Now.ToString("yyyyMM"),
  742. UserId = UserId,
  743. SourceUserId = SourceUserId,
  744. }).Entity;
  745. db.SaveChanges();
  746. }
  747. //操作余额
  748. public void OpAccount(WebCMSEntities db, Orders order, int UserId, decimal Money, int Count = 1)
  749. {
  750. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
  751. if (account == null)
  752. {
  753. account = db.UserAccount.Add(new UserAccount()
  754. {
  755. Id = UserId,
  756. UserId = UserId,
  757. }).Entity;
  758. db.SaveChanges();
  759. }
  760. int ChangeType = 0;
  761. if(Money == 600)
  762. {
  763. ChangeType = 117;
  764. }
  765. else if(Money == 100)
  766. {
  767. ChangeType = 118;
  768. }
  769. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  770. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  771. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  772. account.BalanceAmount += Money * Count;
  773. account.TotalAmount += Money * Count;
  774. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  775. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  776. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  777. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  778. {
  779. CreateDate = DateTime.Now,
  780. UpdateDate = DateTime.Now,
  781. UserId = UserId, //创客
  782. ChangeType = ChangeType, //变动类型
  783. ChangeAmount = Money * Count, //变更金额
  784. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  785. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  786. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  787. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  788. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  789. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  790. QueryCount = order.Id,
  791. }).Entity;
  792. db.SaveChanges();
  793. }
  794. public void ChangeAccount(WebCMSEntities db, Orders order, int UserId, decimal Money, int ChangeType = 0, string Remark = "")
  795. {
  796. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
  797. if (account == null)
  798. {
  799. account = db.UserAccount.Add(new UserAccount()
  800. {
  801. Id = UserId,
  802. UserId = UserId,
  803. }).Entity;
  804. db.SaveChanges();
  805. }
  806. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  807. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  808. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  809. account.BalanceAmount += Money;
  810. if(Money > 0)
  811. {
  812. account.TotalAmount += Money;
  813. }
  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 = UserId, //创客
  822. ChangeType = ChangeType, //变动类型
  823. ChangeAmount = Math.Abs(Money), //变更金额
  824. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  825. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  826. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  827. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  828. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  829. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  830. QueryCount = order.Id,
  831. Remark = Remark,
  832. }).Entity;
  833. db.SaveChanges();
  834. }
  835. //操作盟主可提现余额
  836. public void OpLeaderAccount(WebCMSEntities db, Orders order, int UserId, decimal Money, int Count = 1)
  837. {
  838. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
  839. if (account == null)
  840. {
  841. account = db.UserAccount.Add(new UserAccount()
  842. {
  843. Id = UserId,
  844. UserId = UserId,
  845. }).Entity;
  846. db.SaveChanges();
  847. }
  848. int ChangeType = 0;
  849. if(Money == 400)
  850. {
  851. ChangeType = 117;
  852. }
  853. decimal BeforeLeaderBalanceAmount = account.LeaderBalanceAmount; //变更前余额
  854. account.LeaderBalanceAmount += Money * Count;
  855. decimal AfterLeaderBalanceAmount = account.LeaderBalanceAmount; //变更后余额
  856. LeaderAccountRecord leaderAccountRecord = db.LeaderAccountRecord.Add(new LeaderAccountRecord()
  857. {
  858. CreateDate = DateTime.Now,
  859. UpdateDate = DateTime.Now,
  860. UserId = UserId, //创客
  861. ChangeType = ChangeType, //变动类型
  862. ChangeAmount = Money * Count, //变更金额
  863. BeforeBalanceAmount = BeforeLeaderBalanceAmount, //变更前余额
  864. AfterBalanceAmount = AfterLeaderBalanceAmount, //变更后余额
  865. QueryCount = order.Id,
  866. }).Entity;
  867. db.SaveChanges();
  868. }
  869. public void DirectPrize(WebCMSEntities db, int OrderId, int UserId, int Count = 1)
  870. {
  871. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
  872. if (account == null)
  873. {
  874. account = db.UserAccount.Add(new UserAccount()
  875. {
  876. Id = UserId,
  877. UserId = UserId,
  878. }).Entity;
  879. db.SaveChanges();
  880. }
  881. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  882. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  883. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  884. account.BalanceAmount += 100 * Count;
  885. account.TotalAmount += 100 * Count;
  886. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  887. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  888. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  889. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  890. {
  891. CreateDate = DateTime.Now,
  892. UpdateDate = DateTime.Now,
  893. UserId = UserId, //创客
  894. ChangeType = 112, //变动类型
  895. ChangeAmount = 100 * Count, //变更金额
  896. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  897. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  898. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  899. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  900. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  901. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  902. QueryCount = OrderId,
  903. }).Entity;
  904. db.SaveChanges();
  905. }
  906. // 推荐王逻辑(下单)
  907. public void RecommendMethod(int UserId, string TradeMonth)
  908. {
  909. string SendData = "{\"Kind\":\"1\",\"Data\":{\"UserId\":\"" + UserId + "\",\"TradeMonth\":\"" + TradeMonth + "\"}}";
  910. RedisDbconn.Instance.AddList("RecommendActStatQueue", SendData);
  911. }
  912. //操作运营中心额度
  913. public void OperateReserveBackFor(WebCMSEntities maindb, int UserId, decimal Money)
  914. {
  915. OpModels.WebCMSEntities db = new OpModels.WebCMSEntities();
  916. while(UserId > 0)
  917. {
  918. Users user = maindb.Users.FirstOrDefault(m => m.Id == UserId);
  919. if(user != null)
  920. {
  921. bool sys = db.SysAdmin.Any(m => m.UserId == UserId);
  922. if(sys)
  923. {
  924. OpModels.UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId) ?? new OpModels.UserAccount();
  925. if(account.TotalAmt <= 0)
  926. {
  927. return;
  928. }
  929. if(account.TotalAmt < Money)
  930. {
  931. Money = account.TotalAmt;
  932. }
  933. if(Money > 0)
  934. {
  935. OperateAmountChange(db, UserId, Money, 2, 1, "商城购机");
  936. OperateAmountChange(db, UserId, Money, 1, 2, "商城购机");
  937. }
  938. UserId = 0;
  939. }
  940. else
  941. {
  942. UserId = user.ParentUserId;
  943. }
  944. }
  945. else
  946. {
  947. UserId = 0;
  948. }
  949. }
  950. db.Dispose();
  951. }
  952. public void OperateReserveBack(int UserId, decimal Money)
  953. {
  954. OpModels.WebCMSEntities db = new OpModels.WebCMSEntities();
  955. OpModels.UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId) ?? new OpModels.UserAccount();
  956. if(account.TotalAmt <= 0)
  957. {
  958. return;
  959. }
  960. if(account.TotalAmt < Money)
  961. {
  962. Money = account.TotalAmt;
  963. }
  964. if(Money > 0)
  965. {
  966. OperateAmountChange(db, UserId, Money, 2, 1, "商城购机");
  967. OperateAmountChange(db, UserId, Money, 1, 2, "商城购机");
  968. }
  969. db.Dispose();
  970. }
  971. public void ActReserveBack(int UserId, decimal OpReserve1, decimal OpReserve2, decimal OpReserve3)
  972. {
  973. OpModels.WebCMSEntities db = new OpModels.WebCMSEntities();
  974. if(OpReserve1 > 0) OperateAmountChange(db, UserId, OpReserve1, 1, 1, "机具激活", true);
  975. if(OpReserve2 > 0) OperateAmountChange(db, UserId, OpReserve2, 1, 2, "机具激活", true);
  976. if(OpReserve3 > 0) OperateAmountChange(db, UserId, OpReserve3, 1, 3, "机具激活", true);
  977. db.Dispose();
  978. }
  979. public void OperateAmountChange(OpModels.WebCMSEntities db, int UserId, decimal Money, int OperateType, int AmountType, string Remark = "", bool record = false)
  980. {
  981. OpModels.UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
  982. if (account == null)
  983. {
  984. account = db.UserAccount.Add(new OpModels.UserAccount()
  985. {
  986. Id = UserId,
  987. UserId = UserId,
  988. }).Entity;
  989. db.SaveChanges();
  990. }
  991. decimal BeforeAmount = account.ValidAmount + account.TotalAmt + account.ValidForGetAmount; //变更前总金额
  992. if(OperateType == 1)
  993. {
  994. if(AmountType == 1)
  995. {
  996. // BeforeAmount = account.TotalAmt;
  997. account.TotalAmt += Money;
  998. // AfterAmount = account.TotalAmt;
  999. }
  1000. else if(AmountType == 2)
  1001. {
  1002. // BeforeAmount = account.ValidForGetAmount;
  1003. account.ValidForGetAmount += Money;
  1004. // AfterAmount = account.ValidForGetAmount;
  1005. }
  1006. else
  1007. {
  1008. // BeforeAmount = account.ValidAmount;
  1009. account.ValidAmount += Money;
  1010. // AfterAmount = account.ValidAmount;
  1011. }
  1012. }
  1013. else
  1014. {
  1015. if(AmountType == 1)
  1016. {
  1017. // BeforeAmount = account.TotalAmt;
  1018. account.TotalAmt -= Money;
  1019. // AfterAmount = account.TotalAmt;
  1020. }
  1021. else if(AmountType == 2)
  1022. {
  1023. // BeforeAmount = account.ValidForGetAmount;
  1024. account.ValidForGetAmount -= Money;
  1025. // AfterAmount = account.ValidForGetAmount;
  1026. }
  1027. else
  1028. {
  1029. // BeforeAmount = account.ValidAmount;
  1030. account.ValidAmount -= Money;
  1031. // AfterAmount = account.ValidAmount;
  1032. }
  1033. }
  1034. decimal AfterAmount = account.ValidAmount + account.TotalAmt + account.ValidForGetAmount; //变更后总金额
  1035. if(record)
  1036. {
  1037. OpModels.AmountRecord add = db.AmountRecord.Add(new OpModels.AmountRecord()
  1038. {
  1039. CreateDate = DateTime.Now,
  1040. UpdateDate = DateTime.Now,
  1041. OperateType = OperateType,
  1042. AfterAmount = AfterAmount,
  1043. BeforeAmount = BeforeAmount,
  1044. UseAmount = Money,
  1045. UserId = UserId,
  1046. SeoDescription = Remark,
  1047. Version = AmountType,
  1048. }).Entity;
  1049. }
  1050. db.SaveChanges();
  1051. }
  1052. #endregion
  1053. #region 盟主推荐奖励
  1054. public void LeaderRecommendPrize(WebCMSEntities db, Orders order, int UserId, decimal Money, int ChangeType)
  1055. {
  1056. int level = 0;
  1057. while(UserId > 0)
  1058. {
  1059. level += 1;
  1060. Users user = db.Users.FirstOrDefault(m => m.Id == UserId);
  1061. if(user != null)
  1062. {
  1063. if((user.UserType == 1 || user.LeaderLevel > 0) && level > 1)
  1064. {
  1065. ChangeAccount(db, order, UserId, Money, ChangeType);
  1066. UserId = 0;
  1067. }
  1068. else
  1069. {
  1070. UserId = user.ParentUserId;
  1071. }
  1072. }
  1073. else
  1074. {
  1075. UserId = 0;
  1076. }
  1077. }
  1078. db.Dispose();
  1079. }
  1080. #endregion
  1081. #region 购买盟主预设职级
  1082. public void LeaderPreUserLevel(WebCMSEntities db, int UserId, int LeaderKind)
  1083. {
  1084. int Month = LeaderKind == 1 ? 6 : 12;
  1085. int Rank = LeaderKind == 1 ? 5 : 7;
  1086. UserRankWhite check = db.UserRankWhite.FirstOrDefault(m => m.Id == UserId);
  1087. if(check == null)
  1088. {
  1089. db.UserRankWhite.Add(new UserRankWhite()
  1090. {
  1091. CreateDate = DateTime.Now, //设置时间
  1092. UpdateDate = DateTime.Now.AddMonths(Month), //过期时间
  1093. Rank = Rank,
  1094. UserId = UserId, //用户
  1095. Id = UserId,
  1096. });
  1097. }
  1098. else
  1099. {
  1100. if(check.Rank < Rank)
  1101. {
  1102. check.Rank = Rank;
  1103. check.UpdateDate = DateTime.Now.AddMonths(Month);
  1104. }
  1105. else if(check.Rank == Rank && check.UpdateDate < DateTime.Now.AddMonths(Month))
  1106. {
  1107. check.UpdateDate = DateTime.Now.AddMonths(Month);
  1108. }
  1109. }
  1110. db.SaveChanges();
  1111. }
  1112. #endregion
  1113. }
  1114. }