RechargeWithDraw.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace App\dao\Estatisticas;
  3. use App\Facade\TableName;
  4. use App\Http\helper\NumConfig;
  5. use Carbon\Carbon;
  6. use Illuminate\Support\Facades\DB;
  7. use Illuminate\Support\Facades\Log;
  8. class RechargeWithDraw
  9. {
  10. public function recharge($UserID, $Recharge, $Fee = 0)
  11. {
  12. $Recharge = $Recharge * NumConfig::NUM_VALUE;
  13. try {
  14. // 数据统计后台 -- 充值记录添加
  15. $UserRegisterDate = DB::table(TableName::QPAccountsDB() . 'AccountsInfo')->where('UserID', $UserID)->select('RegisterDate', 'Channel')->first();
  16. if($UserID == 4293017 ){
  17. // $UserRegisterDate->Channel = 101;
  18. }
  19. DB::connection('mysql')->table('rummy_ltv_statistics')
  20. ->where('channel', $UserRegisterDate->Channel)
  21. ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
  22. ->update([
  23. 'total_recharge' => DB::raw('total_recharge+' . $Recharge),
  24. 'total_recharge_fee' => DB::raw('total_recharge_fee+' . $Fee),
  25. ]);
  26. DB::connection('mysql')->table('rummy_ltv_statistics')
  27. ->where('channel', -1)
  28. ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
  29. ->update([
  30. 'total_recharge' => DB::raw('total_recharge+' . $Recharge),
  31. 'total_recharge_fee' => DB::raw('total_recharge_fee+' . $Fee),
  32. ]);
  33. } catch (\Exception $exception) {
  34. Log::info('【充值】数据统计后台信息添加失败' . $UserID . ' - ' . $Recharge);
  35. }
  36. }
  37. public function withDraw($UserID, $WithDraw, $Fee = 0, $ServiceFee = 0)
  38. {
  39. try {
  40. // 数据统计后台 -- 充值记录添加
  41. $UserRegisterDate = DB::table(TableName::QPAccountsDB() . 'AccountsInfo')->where('UserID', $UserID)->select('RegisterDate', 'Channel')->first();
  42. // if($UserID == 4293017 ){
  43. // $UserRegisterDate->Channel = 101;
  44. // }
  45. DB::connection('mysql')->table('rummy_cash_statistics')
  46. ->where('channel', $UserRegisterDate->Channel)
  47. ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
  48. ->update([
  49. 'total_cash' => DB::raw('total_cash+' . $WithDraw),
  50. 'total_cash_fee' => DB::raw('total_cash_fee+' . $Fee),
  51. 'total_service_fee' => DB::raw('total_service_fee+' . $ServiceFee),
  52. ]);
  53. DB::connection('mysql')->table('rummy_cash_statistics')
  54. ->where('channel', -1)
  55. ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
  56. ->update([
  57. 'total_cash' => DB::raw('total_cash+' . $WithDraw),
  58. 'total_cash_fee' => DB::raw('total_cash_fee+' . $Fee),
  59. 'total_service_fee' => DB::raw('total_service_fee+' . $ServiceFee),
  60. ]);
  61. } catch (\Exception $exception) {
  62. Log::info('【提现】数据统计后台信息添加失败' . $UserID . ' - ' . $WithDraw);
  63. }
  64. }
  65. public function refund($UserID, $Recharge, $Fee)
  66. {
  67. $Recharge = $Recharge * NumConfig::NUM_VALUE;
  68. try {
  69. // 数据统计后台 -- 退款记录添加
  70. $UserRegisterDate = DB::table(TableName::QPAccountsDB() . 'AccountsInfo')->where('UserID', $UserID)->select('RegisterDate', 'Channel')->first();
  71. DB::connection('mysql')->table('rummy_ltv_statistics')
  72. ->where('channel', $UserRegisterDate->Channel)
  73. ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
  74. ->update([
  75. 'total_refund' => DB::raw('total_refund+' . $Recharge),
  76. 'total_refund_fee' => DB::raw('total_refund_fee+' . $Fee),
  77. ]);
  78. DB::connection('mysql')->table('rummy_ltv_statistics')
  79. ->where('channel', -1)
  80. ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
  81. ->update([
  82. 'total_refund' => DB::raw('total_refund+' . $Recharge),
  83. 'total_refund_fee' => DB::raw('total_refund_fee+' . $Fee),
  84. ]);
  85. } catch (\Exception $exception) {
  86. Log::info('【充值】数据统计后台退款信息添加失败' . $UserID . ' - ' . $Fee);
  87. }
  88. }
  89. }