liuzejian 1 vuosi sitten
vanhempi
commit
27eb07721d

+ 6 - 0
app/Service/Callback/JuliangAccountReportChargeService.php

@@ -33,6 +33,7 @@ class JuliangAccountReportChargeService
             'current_rate' => 0,
             'report_success' => false,
             'info_type' => 'ok',
+            'continue_judge' => true,
         ];
     }
 
@@ -158,6 +159,9 @@ class JuliangAccountReportChargeService
         if(!$this->result['need_report']) {
             return;
         }
+        if(!$this->result['continue_judge']) {
+            return;
+        }
 
         $this->rateConfig = DB::table('juliang_account_rate_config_log')
             ->where(['company_uid' => $this->promotion->uid,
@@ -205,6 +209,7 @@ class JuliangAccountReportChargeService
         }
         if($this->callbackConfig->protect_num <= 0) {
             $this->result['need_report'] = true;
+            $this->result['continue_judge'] = true;
         } else {
             $advPromotionId = $this->trackRecord->adv_promotion_id;
             $protectedRecord = DB::table('juliang_account_promotion_protect_record')
@@ -213,6 +218,7 @@ class JuliangAccountReportChargeService
             if(!$protectedRecord || $protectedRecord->protected_num < $this->callbackConfig->protect_num) {
                 $this->result['need_report'] = true;
                 $this->result['save_record'] = true;
+                $this->result['continue_judge'] = false;
                 $this->result['save_record_type'] = 'protect_promotion';
                 $this->result['info_type'] = 'promotion_protect';
                 $this->result['info_str'] = '计划被保护';

+ 37 - 1
tests/Jobs/Callback/ReportChargeTest.php

@@ -26,6 +26,13 @@ class ReportChargeTest extends \Tests\TestCase
                 'traceInfo' => $traceContext->getTraceInfo()]);
             $reportCharge->handle();
         }
+
+        foreach (range(164, 180) as $i) {
+            $traceContext = new TraceContext();
+            $reportCharge = new ReportCharge(['uid' => 1000 + $i, 'orderId' => 10000 + $i,
+                'traceInfo' => $traceContext->getTraceInfo()]);
+            $reportCharge->handle();
+        }
     }
 
     private function prepareData() {
@@ -37,7 +44,7 @@ class ReportChargeTest extends \Tests\TestCase
                 'uid' => 1000 + $i,
                 'promotion_id' => $promotionId,
                 'user_id' => $optimizerId,
-                'price' => rand(40, 70),
+                'price' => rand(10, 60),
                 'pay_product_id' => 1,
                 'status' => 'PAID',
                 'trade_no' => uniqid(),
@@ -74,6 +81,35 @@ class ReportChargeTest extends \Tests\TestCase
                 'updated_at' => date('Y-m-d H:i:s'),
             ];
         }
+
+        foreach(range(164, 180) as $i) {
+            $orders[] = [
+                'id' => 10000 + $i,
+                'uid' => 1000 + $i,
+                'promotion_id' => $promotionId,
+                'user_id' => $optimizerId,
+                'price' => rand(40, 70),
+                'pay_product_id' => 1,
+                'status' => 'PAID',
+                'trade_no' => uniqid(),
+                'created_at' => '2023-05-19 14:44:01',
+                'updated_at' => date('Y-m-d H:i:s'),
+            ];
+            $ranses[] = [
+                'uid' => 1000 + $i,
+                'ranse_id' => 100,
+                'callback' => uniqid(),
+                'ranse_start_at' => '2023-05-19 14:44:01',
+                'ranse_end_at' => '2023-05-19 15:44:01',
+                'advertiser_id' => '1234568',
+                'adv_promotion_id' => '234',
+                'report_result' => '[]',
+                'created_at' => date('Y-m-d H:i:s'),
+                'updated_at' => date('Y-m-d H:i:s'),
+                'ranse_ip' =>'192.168.1.123',
+                'optimizer_uid' => 5
+            ];
+        }
         DB::table('orders')->where('id', '>=', 10001)->delete();
         DB::table('orders')->insert($orders);
         DB::table('callback_report_ranse_record')->delete();