Browse Source

回传日志

liuzejian 1 năm trước cách đây
mục cha
commit
2906574914

+ 49 - 8
modules/Callback/Http/Controllers/CallbackLogController.php

@@ -6,6 +6,7 @@ use Catch\Base\CatchController;
 use Illuminate\Foundation\Validation\ValidatesRequests;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
+use Modules\Callback\Services\CallbackConst;
 use Modules\Callback\Services\TiktokEventReportService;
 use Modules\Common\Errors\Errors;
 use Modules\Common\Exceptions\CommonBusinessException;
@@ -30,10 +31,26 @@ class CallbackLogController extends CatchController
         $miniprogramId = $request->input('miniprogram_id');
         $isExport = $request->input('is_export', false);
 
+        $orderNo =  $request->input('order_no');
+        $orderPriceStart = $request->input('order_price_start');
+        $orderPriceEnd = $request->input('order_price_end');
+        $callbackType = $request->input('callback_type', 1);
+        $callbackConfigId = $request->input('callback_config_id');
+
         $sql = DB::table('callback_report_charge_record')
             ->where([
-                'optimizer_uid' => $this->getLoginUserId()
-            ])->when($advertiserId, function ($query, $advertiserId) {
+                'optimizer_uid' => $this->getLoginUserId(),
+                'callback_type' => $callbackType,
+            ])->when($orderNo, function ($query, $orderNo){
+                return $query->where('order_no', $orderNo);
+            })->when($callbackConfigId, function ($query, $callbackConfigId){
+                return $query->where('callback_config_id', $callbackConfigId);
+            })->when($orderPriceStart, function ($query, $orderPriceStart){
+                return $query->where('order_price', '>=', $orderPriceStart);
+            })->when($orderPriceEnd, function ($query, $orderPriceEnd){
+                return $query->where('order_price', '<', $orderPriceEnd);
+            })
+            ->when($advertiserId, function ($query, $advertiserId) {
                 return $query->where('advertiser_id', $advertiserId);
             })->when($uid, function ($query, $uid) {
                 return $query->where('uid', $uid);
@@ -51,23 +68,47 @@ class CallbackLogController extends CatchController
             ->when($orderCreatedAtEndTime, function ($query, $orderCreatedAtEndTime) {
                 return $query->where('order_created_at', '<=', $orderCreatedAtEndTime. ' 23:59:59');
             })->orderBy('created_at', 'desc');
-   
+
         if($isExport) {
             $result = $sql->get();
         } else {
             $result = $sql->paginate($request->integer('limit', 15));
         }
-        $advertisers = DB::table('juliang_account_callback_config')
-            ->where('company_uid', $this->getLoginUserId())
-            ->select('adv_account_id', 'adv_account_name')
-            ->get()->keyBy('adv_account_id');
         $reportSuccessStr = [
             0 => '回传失败',
             1 => '回传成功',
             2 => '补传成功',
         ];
+        $advertisers = $callbackNames = collect();
+        $currentUid = $this->getLoginUserId();
+        if(CallbackConst::TYPE_JL_ACCOUNT == $callbackType) {
+            $advertisers = DB::table('juliang_account_callback_config')
+                ->where('company_uid', $currentUid)
+                ->select('adv_account_id', 'adv_account_name')
+                ->get()->keyBy('adv_account_id');
+        } elseif (CallbackConst::TYPE_JL_EVENT_20 == $callbackType){
+            $callbackNames = DB::table('jl_event_callback_config')
+                ->where('user_id', $currentUid)
+                ->whereIn('id', $result->pluck('callback_config_id'))
+                ->select('id', 'name')->get()->keyBy('id');
+            $promotionNames = DB::table('promotions')
+                ->where('uid', $currentUid)
+                ->whereIn('id', $result->pluck('user_ranse_id'))
+                ->select('id', 'name')->get()->keyBy('id');
+        }
+
+
+
+
+
         foreach ($result as $item) {
-            $item->advertiser_name = $advertisers->get($item->advertiser_id ?? -1)->adv_account_name ?? '';
+            if(CallbackConst::TYPE_JL_ACCOUNT == $callbackType) {
+                $item->advertiser_name = $advertisers->get($item->advertiser_id ?? -1)->adv_account_name ?? '';
+            } elseif(CallbackConst::TYPE_JL_EVENT_20 == $callbackType) {
+                $item->callback_config_name = $callbackNames->get($item->callback_config_id ?? -1)->name ?? '';
+                $item->ranse_name = $promotionNames->get($item->user_ranse_id ?? -1)->name ?? '';
+            }
+
             if('ok' == $item->filter_type ) {
                 $item->filter_reason .= '-'. $reportSuccessStr[$item->report_success] ?? '';
             }

+ 1 - 1
modules/Callback/Http/Controllers/JLEvent/JLEventController.php

@@ -43,7 +43,7 @@ class JLEventController extends CatchController
             })
             ->select('config.id', 'config.name', 'config.charge_type', 'config.updated_at',
                 'promotions.name as promotion_name', 'promotions.id as promotion_id',
-            'config.charge_money_map')
+            'config.charge_money_map', 'config.is_roi')
             ->orderBy('id', 'desc')
             ->paginate($request->input('limit', 15));
         foreach ($result as $item){