瀏覽代碼

充值提现费用统计

laowu 2 周之前
父節點
當前提交
28a9dbebe0

+ 1 - 1
app/Game/Services/AgentSystemService.php

@@ -82,7 +82,7 @@ class AgentSystemService
         //StoredProcedure::addPlatformData($UserID, 4, $TakeMoney);
 
         // 数据统计后台 -- 提现记录添加
-        (new RechargeWithDraw())->withDraw($UserID, $TakeMoney);
+        (new RechargeWithDraw())->withDraw($UserID, $TakeMoney, $orderWithDraw->withdraw_fee);
         $RecordData = [
             'before_state' => $query->State,
             'after_state' => $withdraw_data['State'] ?? 0,

+ 3 - 0
app/Http/Controllers/Admin/RechargeController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers\Admin;
 
 use App\AdminConfig;
+use App\dao\Estatisticas\RechargeWithDraw;
 use App\Facade\TableName;
 use App\Http\Controllers\Controller;
 use App\Http\helper\NumConfig;
@@ -867,6 +868,8 @@ class RechargeController extends Controller
             if ($updated === false) {
                 return apiReturnFail('设置退款状态失败');
             }
+            $fee = ($order->payment_code=='AiNewPay' && $order->title==2)?800:3000;
+            (new RechargeWithDraw())->refund($order->user_id, $order->amount, $fee);
 
             $admin_id = $admin->id;
             (new AccountsRecordLogic())->create_record($id, $order->pay_status, 9, '', $admin_id, 2);

+ 1 - 1
app/Http/logic/admin/WithdrawalLogic.php

@@ -575,7 +575,7 @@ class WithdrawalLogic extends BaseLogicController
         StoredProcedure::addPlatformData($UserID, 4, $TakeMoney);
 
         // 数据统计后台 -- 提现记录添加
-        (new RechargeWithDraw())->withDraw($UserID, $TakeMoney);
+        (new RechargeWithDraw())->withDraw($UserID, $TakeMoney, $withdrawOrder->withdraw_fee);
 
         $redis = Redis::connection();
         $redis->incr('draw_'.date('Ymd').$UserID);

+ 1 - 1
app/Http/logic/api/AiNewPayCashierLogic.php

@@ -204,7 +204,7 @@ class AiNewPayCashierLogic implements CashierInterFace
                     $ServiceFee = $query->ServiceFee;
                     RecordUserDataStatistics::updateOrAdd($UserID, $TakeMoney, 0, $ServiceFee);
 
-                    (new RechargeWithDraw())->withDraw($UserID, $TakeMoney);
+                    (new RechargeWithDraw())->withDraw($UserID, $TakeMoney, $withdraw_data['withdraw_fee'] ?? 0);
 
                     $redis = Redis::connection();
                     $redis->incr('draw_' . date('Ymd') . $UserID);

+ 3 - 1
app/Http/logic/api/AiPayCashierLogic.php

@@ -292,7 +292,9 @@ class AiPayCashierLogic implements CashierInterFace
         }
 
         RecordUserDataStatistics::updateOrAdd($UserID, $TakeMoney, 0, $serviceFee);
-        (new RechargeWithDraw())->withDraw($UserID, $TakeMoney);
+        $fee = DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $OrderId)
+            ->value('withdraw_fee');
+        (new RechargeWithDraw())->withDraw($UserID, $TakeMoney, $fee);
         $redis = Redis::connection();
         $redis->incr('draw_' . date('Ymd') . $UserID);
         PrivateMail::successMail($UserID, $OrderId, $TakeMoney);

+ 3 - 1
app/Http/logic/api/CoinPayCashierLogic.php

@@ -182,7 +182,9 @@ class CoinPayCashierLogic implements CashierInterFace
         }
 
         RecordUserDataStatistics::updateOrAdd($UserID, $TakeMoney, 0, $serviceFee);
-        (new RechargeWithDraw())->withDraw($UserID, $TakeMoney);
+        $fee = DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $OrderId)
+            ->value('withdraw_fee');
+        (new RechargeWithDraw())->withDraw($UserID, $TakeMoney, $fee);
         $redis = Redis::connection();
         $redis->incr('draw_' . date('Ymd') . $UserID);
         PrivateMail::successMail($UserID, $OrderId, $TakeMoney);

+ 1 - 1
app/Http/logic/api/PagYeepPayCashierLogic.php

@@ -262,7 +262,7 @@ class PagYeepPayCashierLogic implements CashierInterFace
                     RecordUserDataStatistics::updateOrAdd($UserID, $TakeMoney, 0, $ServiceFee);
 
                     // 数据统计后台 -- 提现记录添加
-                    (new RechargeWithDraw())->withDraw($UserID, $TakeMoney);
+                    (new RechargeWithDraw())->withDraw($UserID, $TakeMoney, $withdraw_data['withdraw_fee'] ?? 0);
 
                     $redis = Redis::connection();
                     $redis->incr('draw_' . date('Ymd') . $UserID);

+ 1 - 1
app/Http/logic/api/WDPayCashierLogic.php

@@ -240,7 +240,7 @@ class WDPayCashierLogic implements CashierInterFace
                     RecordUserDataStatistics::updateOrAdd($UserID, $TakeMoney, 0, $ServiceFee);
 
                     // 数据统计后台 -- 提现记录添加
-                    (new RechargeWithDraw())->withDraw($UserID, $TakeMoney);
+                    (new RechargeWithDraw())->withDraw($UserID, $TakeMoney, $withdraw_data['withdraw_fee'] ?? 0);
 
                     $redis = Redis::connection();
                     $redis->incr('draw_' . date('Ymd') . $UserID);

+ 1 - 1
app/Http/logic/api/WiwiPayCashierLogic.php

@@ -223,7 +223,7 @@ class WiwiPayCashierLogic implements CashierInterFace
                     RecordUserDataStatistics::updateOrAdd($UserID, $TakeMoney, 0, $ServiceFee);
 
                     // 数据统计后台 -- 提现记录添加
-                    (new RechargeWithDraw())->withDraw($UserID, $TakeMoney);
+                    (new RechargeWithDraw())->withDraw($UserID, $TakeMoney, $withdraw_data['withdraw_fee']);
 
                     $redis = Redis::connection();
                     $redis->incr('draw_' . date('Ymd') . $UserID);

+ 3 - 1
app/Services/OrderServices.php

@@ -474,7 +474,9 @@ class  OrderServices
 //        }
 
         // 数据统计后台 -- 充值记录添加
-        (new RechargeWithDraw())->recharge($user_id, $payAmt);
+        $fee = DB::table('agent.dbo.order')->lock('with(nolock)')->where('order_sn', $order_sn)
+            ->value('payment_fee');
+        (new RechargeWithDraw())->recharge($user_id, $payAmt, $fee);
 //        (new RechargeWithDraw())->recharge($user_id, $Recharge);
 
         // 连续未充值 VIP 新礼包(gift_id=305)—— 充值成功后写入 7 日礼包记录(仅在首次充值时)

+ 46 - 6
app/dao/Estatisticas/RechargeWithDraw.php

@@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Log;
 
 class RechargeWithDraw
 {
-    public function recharge($UserID, $Recharge)
+    public function recharge($UserID, $Recharge, $Fee = 0)
     {
         $Recharge = $Recharge * NumConfig::NUM_VALUE;
 
@@ -28,19 +28,25 @@ class RechargeWithDraw
             DB::connection('mysql')->table('rummy_ltv_statistics')
                 ->where('channel', $UserRegisterDate->Channel)
                 ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
-                ->increment('total_recharge', $Recharge);
+                ->update([
+                    'total_recharge' => DB::raw('total_recharge+' . $Recharge),
+                    'total_recharge_fee' => DB::raw('total_recharge_fee+' . $Fee),
+                ]);
 
             DB::connection('mysql')->table('rummy_ltv_statistics')
                 ->where('channel', -1)
                 ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
-                ->increment('total_recharge', $Recharge);
+                ->update([
+                    'total_recharge' => DB::raw('total_recharge+' . $Recharge),
+                    'total_recharge_fee' => DB::raw('total_recharge_fee+' . $Fee),
+                ]);
         } catch (\Exception $exception) {
             Log::info('【充值】数据统计后台信息添加失败' . $UserID . ' - ' . $Recharge);
         }
 
     }
 
-    public function withDraw($UserID, $WithDraw)
+    public function withDraw($UserID, $WithDraw, $Fee = 0)
     {
         try {
 
@@ -54,14 +60,48 @@ class RechargeWithDraw
             DB::connection('mysql')->table('rummy_cash_statistics')
                 ->where('channel', $UserRegisterDate->Channel)
                 ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
-                ->increment('total_cash', $WithDraw);
+                ->update([
+                    'total_cash' => DB::raw('total_cash+' . $WithDraw),
+                    'total_cash_fee' => DB::raw('total_cash_fee+' . $Fee),
+                ]);
 
             DB::connection('mysql')->table('rummy_cash_statistics')
                 ->where('channel', -1)
                 ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
-                ->increment('total_cash', $WithDraw);
+                ->update([
+                    'total_cash' => DB::raw('total_cash+' . $WithDraw),
+                    'total_cash_fee' => DB::raw('total_cash_fee+' . $Fee),
+                ]);
         } catch (\Exception $exception) {
             Log::info('【提现】数据统计后台信息添加失败' . $UserID . ' - ' . $WithDraw);
         }
     }
+
+    public function refund($UserID, $Recharge, $Fee)
+    {
+        $Recharge = $Recharge * NumConfig::NUM_VALUE;
+        try {
+
+            // 数据统计后台 -- 退款记录添加
+            $UserRegisterDate = DB::table(TableName::QPAccountsDB() . 'AccountsInfo')->where('UserID', $UserID)->select('RegisterDate', 'Channel')->first();
+
+            DB::connection('mysql')->table('rummy_ltv_statistics')
+                ->where('channel', $UserRegisterDate->Channel)
+                ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
+                ->update([
+                    'total_refund' => DB::raw('total_refund+' . $Recharge),
+                    'total_refund_fee' => DB::raw('total_refund_fee+' . $Fee),
+                ]);
+
+            DB::connection('mysql')->table('rummy_ltv_statistics')
+                ->where('channel', -1)
+                ->where('at_date', Carbon::parse($UserRegisterDate->RegisterDate)->format('Ymd'))
+                ->update([
+                    'total_refund' => DB::raw('total_refund+' . $Recharge),
+                    'total_refund_fee' => DB::raw('total_refund_fee+' . $Fee),
+                ]);
+        } catch (\Exception $exception) {
+            Log::info('【充值】数据统计后台退款信息添加失败' . $UserID . ' - ' . $Fee);
+        }
+    }
 }