RechargeWithDraw.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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)
  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. ]);
  52. DB::connection('mysql')->table('rummy_cash_statistics')
  53. ->where('channel', -1)
  54. ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
  55. ->update([
  56. 'total_cash' => DB::raw('total_cash+' . $WithDraw),
  57. 'total_cash_fee' => DB::raw('total_cash_fee+' . $Fee),
  58. ]);
  59. } catch (\Exception $exception) {
  60. Log::info('【提现】数据统计后台信息添加失败' . $UserID . ' - ' . $WithDraw);
  61. }
  62. }
  63. public function refund($UserID, $Recharge, $Fee)
  64. {
  65. $Recharge = $Recharge * NumConfig::NUM_VALUE;
  66. try {
  67. // 数据统计后台 -- 退款记录添加
  68. $UserRegisterDate = DB::table(TableName::QPAccountsDB() . 'AccountsInfo')->where('UserID', $UserID)->select('RegisterDate', 'Channel')->first();
  69. DB::connection('mysql')->table('rummy_ltv_statistics')
  70. ->where('channel', $UserRegisterDate->Channel)
  71. ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
  72. ->update([
  73. 'total_refund' => DB::raw('total_refund+' . $Recharge),
  74. 'total_refund_fee' => DB::raw('total_refund_fee+' . $Fee),
  75. ]);
  76. DB::connection('mysql')->table('rummy_ltv_statistics')
  77. ->where('channel', -1)
  78. ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
  79. ->update([
  80. 'total_refund' => DB::raw('total_refund+' . $Recharge),
  81. 'total_refund_fee' => DB::raw('total_refund_fee+' . $Fee),
  82. ]);
  83. } catch (\Exception $exception) {
  84. Log::info('【充值】数据统计后台退款信息添加失败' . $UserID . ' - ' . $Fee);
  85. }
  86. }
  87. }