博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一個傳統的C2C網站的用戶充值的过程
阅读量:6888 次
发布时间:2019-06-27

本文共 2789 字,大约阅读时间需要 9 分钟。

 

  1. #region 插入用户汇款充值记录
  2. public void UserRemittance(UserAccountRecord userAccountRecord, WebBankAccountRecord webBankAccountRecord)
  3. {
  4. /// 
  5. ///用户账户收支明细
  6. /// 
  7. IUserAccountRecordsRepository IUARRpstry = new UserAccountRecordsRepository();
  8. /// 
  9. ///  用户账户余额
  10. /// 
  11. IUserAccountBalancesRepository IUABRpstry = new UserAccountBalancesRepository();
  12. /// 
  13. /// 网站银行账户收支明细
  14. /// 
  15. IWebBankAccountRecordsRepository IWBARRpstry = new WebBankAccountRecordsRepository();
  16. /// 
  17. /// 网站银行账户余额
  18. /// 
  19. IWebAccountBalancesRepository IWABRpstry = new WebAccountBalancesRepository();
  20. using (TransactionScope ts = new TransactionScope())
  21. {
  22. try
  23. {
  24. using (TransactionScope ts2 = new TransactionScope())
  25. {
  26. //第一步:插入新的记录到用户账户收支明细表(UserAccountRecords)
  27. #region 第一步:插入新的记录到用户账户收支明细表(UserAccountRecords)
  28. try
  29. {
  30. using (TransactionScope ts3 = new TransactionScope())
  31. {
  32. try
  33. {
  34. IUARRpstry.Insert(userAccountRecord);
  35. ts3.Complete();
  36. }
  37. catch (Exception err)
  38. {
  39. throw err;
  40. }
  41. finally
  42. {
  43. ts3.Dispose();
  44. }
  45. }
  46. #endregion
  47. //第二步:更新用户账户余额(UserAccountBalances)
  48. #region 第二步:更新用户账户余额(UserAccountBalances)
  49. Entity.UserAccountBalance userAccountBalanceLinq = (from userAccountBalance in IUABRpstry.GetUserAccountBalances().Where(x => x.UserID.Equals(userAccountRecord.UserID))
  50. select userAccountBalance).SingleOrDefault();
  51. decimal totalBalance = (from useraccountrecord in IUARRpstry.GetUserAccountRecords().Where(x => x.UserID.Equals(userAccountRecord.UserID) && x.Status.Equals(Entity.UserAccountRecordStatus.Normal))
  52. select useraccountrecord.Amount).Sum();
  53. userAccountBalanceLinq.TotalBalance = totalBalance;
  54. IUABRpstry.Update(userAccountBalanceLinq, Entity.UserAccountBalancesColumnEnum.TotalBalance);
  55. #endregion
  56. //第三步:插入新的记录到网站银行账户收支明细(WebBankAccountRecords)
  57. #region 插入新的记录到网站银行账户收支明细(WebBankAccountRecords)
  58. IWBARRpstry.Insert(webBankAccountRecord);
  59. #endregion
  60. ts2.Complete();
  61. }
  62. catch (Exception err)
  63. {
  64. throw err;
  65. }
  66. finally
  67. {
  68. ts2.Dispose();
  69. }
  70. }
  71. //第四步:更新网站银行账户余额(WebAccountBalances)
  72. #region 第四步:更新网站银行账户余额(WebAccountBalances)
  73. decimal BankAccountBalance;
  74. int sum = (from balance in IWBARRpstry.GetWebBankAccountRecords().Where(x => x.Status.Equals(Entity.WebBankAccountRecordStatus.Normal))
  75. select balance).Count();
  76. if (sum == 0)
  77. {
  78. BankAccountBalance = 0;
  79. }
  80. else
  81. {
  82. BankAccountBalance = (from balance in IWBARRpstry.GetWebBankAccountRecords().Where(x => x.Status.Equals(Entity.WebBankAccountRecordStatus.Normal))
  83. select balance.Amount).Sum();
  84. }
  85. Entity.WebAccountBalance webAccountBalance = (from webAB in IWABRpstry.GetWebAccountBalances()
  86. select webAB).SingleOrDefault();
  87. webAccountBalance.BankAcountBalance = BankAccountBalance;
  88. IWABRpstry.Update(webAccountBalance, Entity.WebAccountBalancesColumnEnum.BankAcountBalance);
  89. #endregion
  90. ts.Complete();
  91. }
  92. catch (Exception err)
  93. {
  94. throw err;
  95. }
  96. finally
  97. {
  98. ts.Dispose();
  99. }
  100. }
  101. }
  102. #endregion
本文转自博客园张占岭(仓储大叔)的博客,原文链接: ,如需转载请自行联系原博主。
你可能感兴趣的文章
软件测试书籍推荐
查看>>
[linux]执行pip安装的程序:command not found
查看>>
dcm4che tools 之dicomdir
查看>>
HDU 4849-Wow! Such City!(最短路)
查看>>
关于IM的一些思考与实践
查看>>
SimInfo获取(MCC, MNC, PLMN)
查看>>
[置顶] 我的Android进阶之旅------>介绍一款集录制与剪辑为一体的屏幕GIF 动画制作工具 GifCam...
查看>>
IMP导入数据 出现ORA-01691问题 解决办法
查看>>
dll常规安装方法
查看>>
【转】一个安全测试的CheckList
查看>>
【转】教你Ruby快速入门
查看>>
OSI七层模型具体解释
查看>>
微信小程序教程01:小程序简介
查看>>
Spring 属性配置
查看>>
Vue-loader 的巧妙玩法
查看>>
Vue-vuex
查看>>
【Vue.js 牛刀小试】02:第二章 - 常见的指令的使用
查看>>
KOA2 compose 串联中间件实现(洋葱模型)
查看>>
基于NodeJS的HTTP server Plus 1:Range (范围请求)
查看>>
JS的节流、函数防抖 原理及使用场景
查看>>