fly 4 éve
szülő
commit
f59e95bd20

+ 233 - 0
src/Controller/LandingPage/LinkController.php

@@ -0,0 +1,233 @@
+<?php
+
+namespace General\Controller\LandingPage;
+
+use App\Http\Controllers\Channel\BaseController;
+use App\Jobs\AutoCheckLandingPage;
+use App\Libs\AliOSS;
+use General\Controllers\LandingPage\Transformers\BaiDuAdAccountTransformer;
+use General\Controllers\LandingPage\Transformers\LinkTransformer;
+use General\Controllers\LandingPage\Transformers\ReportOrderTramsformer;
+use General\Helpers\ExcelHelper;
+use General\Models\LandingPage\LandingPageLink;
+use General\Requests\BaiDuAdAccountRequest;
+use General\Requests\LandingPageLinkRequest;
+use General\Requests\LinkReportTypeRequest;
+use General\Requests\QueryReportRequest;
+use General\Requests\ReReportRequest;
+use General\Services\Config\ConfigService;
+use Illuminate\Http\Request;
+use General\Services\LandingPage\LandingPageLinkService;
+
+class LinkController extends BaseController
+{
+    private $service;
+
+    public function __construct()
+    {
+        $this->service = new LandingPageLinkService;
+    }
+
+    public function index(Request $request)
+    {
+        $query_params = $request->except('_url');
+        $query_params['channel_id'] = $this->channel_id;
+        $result = $this->service->findLinks($query_params, true);
+        return response()->pagination(new LinkTransformer, $result);
+    }
+
+    public function edit(int $id)
+    {
+        $link_model = LandingPageLink::find($id);
+        if ($link_model) {
+            if ($this->channel_id != $link_model->channel_id) {
+                return response()->error('CHANNEL_ERROR');
+            }
+            $link_model->content = $link_model->content_path ? AliOSS::getLandingPageString($link_model->content_path) : $link_model->content;
+            return response()->success($link_model);
+        }
+        return response()->error('PARAM_ERROR');
+    }
+
+    protected function getLinkDomain(string $domain)
+    {
+        return $domain;
+    }
+
+    public function save(LandingPageLinkRequest $request)
+    {
+        $params = $request->except('_url');
+        if (isset($params['id'])) {
+            $link_model = LandingPageLink::find($params['id']);
+            if ($link_model) {
+                if (in_array($link_model->status, [LandingPageLinkService::APPROVED_STATUS, LandingPageLinkService::WAITTING_APPROVE_STATUS])) {
+                    return response()->error('STATUS_EDIT_ERROR');
+                }
+                if ($this->channel_id != $link_model->channel_id) {
+                    return response()->error('CHANNEL_ERROR');
+                }
+            }
+        } else {
+            if (!isset($params['link_source'])) {
+                $params['link_source'] = LandingPageLinkService::tiktok;
+            }
+        }
+        $params['channel_id'] = $this->channel_id;
+        if (isset($params['gzh_biz']) && isset($params['filing'])) {
+            $params['config'] = json_encode([
+                'gzh_biz' => $params['gzh_biz'],
+                'filing' => $params['filing'],
+            ]);
+        }
+        $file = $request->file('sub_img');
+        if ($file) {
+            $path = 'img/' . time() . '.' . $file->extension();
+            AliOSS::uploadLandingPageImg($path, $file->path());
+            $params['sub_img'] = 'https://' . $this->getLinkDomain($params['domain']) . '/' . $path;
+        }
+        $gzh_img = $request->file('gzh_img');
+        if ($gzh_img) {
+            $path = 'img/' . $params['gzh_code'] . time() . '.' . $gzh_img->extension();
+            AliOSS::uploadLandingPageImg($path, $gzh_img->path());
+            $params['gzh_img'] = 'https://' . $this->getLinkDomain($params['domain']) . '/' . $path;
+        }
+        if ($params['content']) {
+            if (isset($link_model) && $link_model->content_path) {
+                $path = $link_model->content_path;
+            } else {
+                $path = 'content/' . time() . '.html';
+            }
+            AliOSS::uploadLandingPageString($path, $params['content']);
+            $params['content_path'] = $path;
+        }
+        $params['status'] = LandingPageLinkService::NEW_STATUS;
+        $this->service->saveLink($params);
+        return response()->success();
+    }
+
+
+    public function changeStatus(int $id, Request $request)
+    {
+        $status = (int) $request->get('status', 0);
+        $link_model = LandingPageLink::find($id);
+        if ($link_model) {
+            if ($this->channel_id != $link_model->channel_id) {
+                return response()->error('CHANNEL_ERROR');
+            }
+            $remark =  $request->get('remark', '');
+            $this->service->updateLinkStatus($id, $status, $remark);
+            $service = new ConfigService;
+            if (($this->is_inner || $service->hasAuth($this->channel_user_id, ConfigService::landing_page_auto_check)) && $status == LandingPageLinkService::WAITTING_APPROVE_STATUS) {
+                dispatch(new AutoCheckLandingPage($link_model))->onConnection('redis')->onQueue('{auto_check_landing_page_queue}');
+            }
+            return response()->success();
+        } else {
+            return response()->error('PARAM_ERROR');
+        }
+    }
+
+    public function delete(int $id)
+    {
+        $this->service->deleteLink($id);
+        return response()->success();
+    }
+
+    public function domain()
+    {
+        return response()->success($this->service->findDomains());
+    }
+
+    public function officialAccounts()
+    {
+        return response()->success($this->service->findOfficialAccounts($this->channel_id));
+    }
+
+    public function getConfig()
+    {
+        $config = $this->service->getChargeFeedBackConfig($this->channel_id, $this->channel_user_id);
+        return response()->success($config);
+    }
+
+    public function setReportType(LinkReportTypeRequest $request)
+    {
+        $type = $request->get('type');
+        $molecule = (int)$request->get('molecule', 0);
+        $eligible_count = (int) $request->get('eligible_count', 0);
+        $this->service->setReportType($this->channel_id, $type, $molecule, $eligible_count);
+        return response()->success();
+    }
+
+    /**
+     * 查询上报用户日志
+     */
+    public function queryReportLog(QueryReportRequest $request)
+    {
+        $result = $this->service->findUserReportInfos($this->channel_id, $request->all());
+        return response()->pagination(new ReportOrderTramsformer, $result);
+    }
+
+    public function reportLogExport(QueryReportRequest $request)
+    {
+        $result = $this->service->findUserReportInfos($this->channel_id, $request->all(), false);
+        $result = collectionTransform(new ReportOrderTramsformer, $result);
+        $headers = [
+            '订单号',
+            '用户ID',
+            '注册时间',
+            '注册IP',
+            '下单金额',
+            '支付时间',
+            '下单IP',
+            '绑定ID',
+            '广告计划ID',
+            '推广平台',
+            '回传状态',
+            '回传结果类型',
+            '回传结果',
+            '回传百分比',
+            '回传配置百分比'
+        ];
+        ExcelHelper::exportWebFileCsv($headers, $result, "回传日志");
+    }
+
+    public function setSwitch(Request $request)
+    {
+        $is_orange = $request->get('is_orange', 0);
+        $status = $request->get('status');
+        $is_sync = $request->get('is_sync', 0);
+        if (is_numeric($is_orange) && is_numeric($status) && is_numeric($is_sync)) {
+            if ($is_sync) {
+                $this->service->syncSwitchStatus($this->user_channel_ids, $status, $is_orange);
+            } else {
+                $this->service->setSwitchStatus($this->channel_id, $status, $is_orange);
+            }
+        }
+        return response()->success();
+    }
+
+    public function addBaiDuAdAccount(BaiDuAdAccountRequest $request)
+    {
+        $this->service->addBaiduAdAccount($request->all(), $this->channel_user_id);
+        return response()->success();
+    }
+
+    public function delBaiDuAdAccount(int $id)
+    {
+        $this->service->delBaiduAdAccount($id, $this->channel_user_id);
+        return response()->success();
+    }
+
+    public function findBaiDuAdAccounts()
+    {
+        $result = $this->service->findBaiDuAdAccounts($this->channel_user_id);
+        return response()->collection(new BaiDuAdAccountTransformer, $result);
+    }
+
+    public function reReport(int $bind_id, ReReportRequest $request)
+    {
+        $amount = $request->get('amount');
+        $order_no = $request->get('order_no');
+        $this->service->reReport($bind_id, $amount, $order_no);
+        return response()->success();
+    }
+}

+ 22 - 0
src/Controller/LandingPage/Transformers/BaiDuAdAccountTransformer.php

@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * Date: 2017/3/31
+ * Time: 14:02
+ */
+
+namespace General\Controllers\LandingPage\Transformers;
+
+
+class BaiDuAdAccountTransformer
+{
+    public function transform($item)
+    {
+        return [
+            'id' => $item->id,
+            'account_name' => $item->account_name,
+            'token' => $item->token,
+        ];
+    }
+}

+ 51 - 0
src/Controller/LandingPage/Transformers/LinkTransformer.php

@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * Date: 2017/3/31
+ * Time: 14:02
+ */
+
+namespace General\Controllers\LandingPage\Transformers;
+
+use General\Models\LandingPage\LandingPageLink;
+
+class LinkTransformer
+{
+    public function transform($item)
+    {
+        return [
+            'id' => $item->id,
+            'channel_id' => $item->channel_id,
+            'title' => $item->title,
+            'name' => $item->name,
+            'bid' => $item->bid,
+            'appid' => $item->appid,
+            'gzh_code' => $item->gzh_code,
+            'gzh_img' => $item->gzh_img,
+            'gzh_name' => $item->gzh_name,
+            'sub_img' => $item->sub_img,
+            'company_name' => $item->company_name,
+            'domain' => $item->domain,
+            'status' => $item->status,
+            'content' => $item->content,
+            'remark' => $item->remark,
+            'cdn_link' => $item->cdn_link,
+            'link_source' => $item->link_source,
+            'landing_page_link' => ($item->cdn_link ? $this->getLandingPageLink($item) : ''),
+        ];
+    }
+
+    protected function getLandingPageLink(LandingPageLink $model)
+    {
+        switch ($model->link_source) {
+            case 'baidu':
+                $adid = $model->adAccount ? $model->adAccount->id : 0;
+                return "{$model->cdn_link}?dycallback=8&channel_id={$model->channel_id}&adid={$adid}";
+            case 'kuaishou':
+                return "{$model->cdn_link}?dycallback=6&channel_id={$model->channel_id}";
+            default:
+                return "{$model->cdn_link}?dycallback=1&channel_id={$model->channel_id}&link_source={$model->link_source}";
+        }
+    }
+}

+ 78 - 0
src/Controller/LandingPage/Transformers/ReportOrderTramsformer.php

@@ -0,0 +1,78 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * Date: 2017/3/31
+ * Time: 14:02
+ */
+
+namespace General\Controllers\LandingPage\Transformers;
+
+use General\Models\Order\Order;
+
+class ReportOrderTramsformer
+{
+    const REPORT_TYPE = [
+        'amount_filter' => '回传金额过滤',
+        'register_24_charge' => '充值时间和注册时间必须在24小时以内',
+        'current_day_register' => '注册时间和充值时间必须同一天',
+        'no_user_match' => '无匹配用户(ip切换或者非落地页用户)',
+        'feedback_user' => '已回传用户(非首充)',
+        'percent_filter' => '百分比过滤',
+        'protected_eligible' => '计划保护范围(不算在比例基数里面)',
+    ];
+    const platform = [
+        'tiktok' => '抖音',
+        'iqiyi' => '爱奇艺',
+        'uc' => 'UC',
+        'weibo' => '微博粉丝通',
+        'tencent' => '腾讯',
+        'kuaishou' => '快手',
+        'baidu' => '百度',
+    ];
+
+    public function transform($item)
+    {
+
+        $reason = $this->getType($item);
+        $status = $item->reportOrder ? $item->reportOrder->status : 0;
+        if ($status == 1) {
+            $reason = '';
+        }
+
+        return [
+            'order_no' => $item->trade_no,
+            'uid' => $item->uid,
+            'register_time' => $item->user ? (string)$item->user->created_at : '',
+            'register_ip' => $item->user ? $item->user->register_ip : '',
+            'amount' => $item->price,
+            'pay_time' => (string)$item->created_at,
+            'charge_ip' => $item->create_ip,
+            'bind_id' => $item->reportUser ? $item->reportUser->id : 0,
+            'adid' => $item->reportUser ? $item->reportUser->adid : 0,
+            'platform' => $this->getPlatform($item),
+            'status' => $status,
+            'type' => $item->reportOrder ? $item->reportOrder->type : '',
+            'content' => $reason,
+            'report_percent' => ($item->reportOrder ? $item->reportOrder->report_percent * 100 : 0) . '%',
+            'config_percent' => ($item->reportOrder ? $item->reportOrder->config_percent * 100 : 0) . '%',
+        ];
+    }
+
+    private function getPlatform(Order $item)
+    {
+        if ($item->reportUser) {
+            return self::platform[$item->reportUser->platform];
+        }
+        return '';
+    }
+
+    private function getType(Order $item)
+    {
+        if ($item->reportOrder) {
+            return array_key_exists($item->reportOrder->type, self::REPORT_TYPE) ? self::REPORT_TYPE[$item->reportOrder->type] : '';
+        } else {
+            return self::REPORT_TYPE['no_user_match'];
+        }
+    }
+}

+ 34 - 0
src/Helpers/ExcelHelper.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace General\Helpers;
+
+/**
+ * excel 工具类
+ */
+class ExcelHelper
+{
+    /**
+     * web端导出csv文件
+     * @param array $column_names 列名
+     * @param array $data 导出数据内容
+     * @param string $filename 导出文件名
+     */
+    public static function exportWebFileCsv(array $column_names, array $data, string $filename)
+    {
+        header("Content-type:application/vnd.ms-excel");
+        header("Content-Disposition:attachment;filename=" . $filename . ".csv");
+        $column_names = collect($column_names)->map(function ($item) {
+            return "\"" . mb_convert_encoding($item, "GBK", "UTF-8") . "\"";
+        })->all();
+        echo implode(",", $column_names);
+        echo "\r\n";
+        foreach ($data as $item) {
+            $rows = collect($item)->map(function ($row) {
+                return "\"" . mb_convert_encoding(is_numeric($row) && strlen($row) > 10 ? "'" . $row : $row, "GBK", "UTF-8") . "\"";
+            })->all();
+            echo implode(",", $rows);
+            echo "\r\n";
+        }
+        exit();
+    }
+}

+ 36 - 0
src/Jobs/AutoCheckLandingPage.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace General\Jobs;
+
+use General\Models\LandingPage\LandingPageLink;
+use Illuminate\Bus\Queueable;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+
+class AutoCheckLandingPage implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    private $link;
+
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct(LandingPageLink $link)
+    {
+        $this->link = $link;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+    }
+}

+ 0 - 21
src/Models/User/QappUser.php

@@ -1,21 +0,0 @@
-<?php
-
-namespace General\Models\User;
-
-use Illuminate\Database\Eloquent\Model;
-
-class QappUser extends Model
-{
-    protected $table = 'qapp_users';
-    protected $fillable = [
-        'imei',
-        'oaid',
-        'androidid',
-        'device_no',
-        'mac',
-        'uid',
-        'device_info',
-        'phone',
-        'channel_id',
-    ];
-}

+ 54 - 0
src/Services/LandingPage/ChargeFeedBack/ChargeFeedBack.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace General\Services\LandingPage\ChargeFeedBack;
+
+use General\Services\Config\ConfigService;
+use Redis;
+
+/**
+ * 付费回传
+ */
+class ChargeFeedBack
+{
+    protected $service;
+    protected $type;
+
+    public function __construct()
+    {
+        $this->service = new ConfigService;
+    }
+
+    /**
+     * 设置开关状态
+     */
+    public function setSwitchStatus(int $channel_id, int $status)
+    {
+        $this->service->saveConfig($channel_id, $this->type, $status);
+        Redis::hSet('channel:setting:' . $channel_id, $this->type, $status);
+    }
+
+    /**
+     * 获取开关状态
+     */
+    public function getSwitchStatus(int $channel_id)
+    {
+        $status = Redis::hGet('channel:setting:' . $channel_id, $this->type);
+        if (!$status) {
+            $status = $this->service->hasAuth($channel_id, $this->type);
+            if ($status) {
+                $this->setSwitchStatus($channel_id, $status);
+            }
+        }
+        return $status;
+    }
+
+    /**
+     * 同步开关状态
+     */
+    public function syncSwitchStatus(array $channel_ids, int $status)
+    {
+        foreach ($channel_ids as $channel_id) {
+            $this->setSwitchStatus($channel_id, $status);
+        }
+    }
+}

+ 17 - 0
src/Services/LandingPage/ChargeFeedBack/NormalChargeFeedBack.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace General\Services\LandingPage\ChargeFeedBack;
+
+
+/**
+ * 一般回传
+ */
+class NormalChargeFeedBack extends ChargeFeedBack
+{
+    public function __construct()
+    {
+        $this->type = 'tiktok_report';
+        parent::__construct();
+    }
+}
+

+ 16 - 0
src/Services/LandingPage/ChargeFeedBack/OrangeChargeFeedBack.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace General\Services\LandingPage\ChargeFeedBack;
+
+
+/**
+ * 橙子建站回传
+ */
+class OrangeChargeFeedBack extends ChargeFeedBack
+{
+    public function __construct()
+    {
+        $this->type = 'orange_site_report';
+        parent::__construct();
+    }
+}

+ 23 - 121
src/Services/LandingPage/LandingPageLinkService.php

@@ -3,8 +3,6 @@
 namespace General\Services\LandingPage;
 
 use App\Consts\BaseConst;
-use Exception;
-use General\Models\User\QappUser;
 use General\Models\Order\Order;
 use General\Models\LandingPage\LandingPageDomain;
 use General\Models\LandingPage\LandingPageLink;
@@ -15,7 +13,6 @@ use General\Models\Report\ReportUserBindRecord;
 use General\Models\Report\ReportUserChargeRecord;
 use General\Services\Report\BaseReport;
 use General\Services\Config\ConfigService;
-use GuzzleHttp\Client;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\DB;
 use Redis;
@@ -85,7 +82,7 @@ class LandingPageLinkService
         self::baidu,
     ];
 
-    public static function saveLink(array $data)
+    public function saveLink(array $data)
     {
         if (isset($data['id'])) {
             $data['updated_at'] = now();
@@ -95,12 +92,12 @@ class LandingPageLinkService
         }
     }
 
-    public static function deleteLink(int $id)
+    public function deleteLink(int $id)
     {
         LandingPageLink::where('id', $id)->delete();
     }
 
-    public static function updateLinkStatus(int $id, int $status, string $remark)
+    public function updateLinkStatus(int $id, int $status, string $remark)
     {
         if ($status) {
             self::saveLink(['id' => $id, 'status' => $status, 'remark' => $remark]);
@@ -108,7 +105,7 @@ class LandingPageLinkService
         }
     }
 
-    public static function findLinks(array $query_params = [], bool $is_page = false)
+    public function findLinks(array $query_params = [], bool $is_page = false)
     {
         $sql = LandingPageLink::orderBy('id', 'desc');
         if (isset($query_params['name']) && $query_params['name']) {
@@ -133,12 +130,12 @@ class LandingPageLinkService
         }
     }
 
-    public static function findDomains()
+    public function findDomains()
     {
         return LandingPageDomain::where('is_enabled', 1)->get();
     }
 
-    public static function findOfficialAccounts(int $distribution_channel_id)
+    public function findOfficialAccounts(int $distribution_channel_id)
     {
         return OfficialAccount::select('nickname', 'appid', 'alias', 'head_img')
             ->where('distribution_channel_id', $distribution_channel_id)
@@ -150,7 +147,7 @@ class LandingPageLinkService
     /**
      * 获取付费回传配置信息
      */
-    public static function getChargeFeedBackConfig(int $channel_id, int $channel_user_id)
+    public function getChargeFeedBackConfig(int $channel_id, int $channel_user_id)
     {
         $switch_status = (new NormalChargeFeedBack)->getSwitchStatus($channel_id);
         $orange_switch_status = (new OrangeChargeFeedBack)->getSwitchStatus($channel_id);
@@ -182,22 +179,22 @@ class LandingPageLinkService
         return $result;
     }
 
-    private static function getService(bool $is_orange)
+    private function getService(bool $is_orange)
     {
         return $is_orange ? new OrangeChargeFeedBack : new NormalChargeFeedBack;
     }
 
-    public static function setSwitchStatus(int $channel_id, int $status, bool $is_orange = false)
+    public function setSwitchStatus(int $channel_id, int $status, bool $is_orange = false)
     {
-        self::getService($is_orange)->setSwitchStatus($channel_id, $status);
+        $this->getService($is_orange)->setSwitchStatus($channel_id, $status);
     }
 
-    public static function syncSwitchStatus(array $channel_ids, int $status, bool $is_orange = false)
+    public function syncSwitchStatus(array $channel_ids, int $status, bool $is_orange = false)
     {
-        self::getService($is_orange)->syncSwitchStatus($channel_ids, $status);
+        $this->getService($is_orange)->syncSwitchStatus($channel_ids, $status);
     }
 
-    public static function findUserReportInfos(int $channel_id, array $params, bool $is_page = true)
+    public function findUserReportInfos(int $channel_id, array $params, bool $is_page = true)
     {
         $sql = Order::where('distribution_channel_id', $channel_id)
             ->where('status', 'PAID')
@@ -226,7 +223,7 @@ class LandingPageLinkService
         }
     }
 
-    public static function setReportType(int $channel_id, string $type, int $molecule, int $eligible_count)
+    public function setReportType(int $channel_id, string $type, int $molecule, int $eligible_count)
     {
         if (in_array($type, LandingPageLinkService::REPORT_TYPE)) {
             Redis::hset('channel:setting:' . $channel_id, 'tiktok_report_type', $type);
@@ -245,7 +242,7 @@ class LandingPageLinkService
         }
     }
 
-    public static function addBaiduAdAccount(array $data, int $channel_user_id)
+    public function addBaiduAdAccount(array $data, int $channel_user_id)
     {
         $model = BaiDuAdAccount::create(
             [
@@ -255,20 +252,20 @@ class LandingPageLinkService
                 'is_enabled' => 1,
             ]
         );
-        self::baiDuAdAccountReport($model);
+        $this->baiDuAdAccountReport($model);
     }
 
-    public static function delBaiduAdAccount(int $id, int $channel_user_id)
+    public function delBaiduAdAccount(int $id, int $channel_user_id)
     {
         $model = BaiDuAdAccount::where('id', $id)->where('channel_user_id', $channel_user_id)->first();
         if ($model) {
             $model->is_enabled = 0;
             $model->save();
-            self::baiDuAdAccountReport($model);
+            $this->baiDuAdAccountReport($model);
         }
     }
 
-    private static function baiDuAdAccountReport(BaiDuAdAccount $model)
+    private function baiDuAdAccountReport(BaiDuAdAccount $model)
     {
         $service = new Report;
         $service->report('api/report/baidu/token', [
@@ -279,12 +276,12 @@ class LandingPageLinkService
         ]);
     }
 
-    public static function findBaiduAdAccounts(int $channel_user_id): Collection
+    public function findBaiduAdAccounts(int $channel_user_id): Collection
     {
         return BaiDuAdAccount::where('is_enabled', 1)->where('channel_user_id', $channel_user_id)->get();
     }
 
-    public static function reportInstance(bool $is_qapp, string $link_source): BaseReport
+    public function reportInstance(string $link_source, bool $is_qapp): BaseReport
     {
         $name = $is_qapp ? 'Qapp' . ucfirst($link_source) . 'Report' : ucfirst($link_source) . 'Report';
         $namespace = "\\General\\Services\\Report\\{$name}";
@@ -292,12 +289,11 @@ class LandingPageLinkService
         return $instance;
     }
 
-    public static function reReport(int $bind_id, float $amount, string $order_no)
+    public function reReport(int $bind_id, float $amount, string $order_no, bool $is_qapp = false)
     {
         $report_user = ReportUserBindRecord::find($bind_id);
         if ($report_user) {
-            $is_qapp = QappUser::where('uid', $report_user->uid)->exists();
-            $instance = self::reportInstance($is_qapp, $report_user->platform);
+            $instance = $this->reportInstance($report_user->platform, $is_qapp);
             $result =  $instance->reportCharge($report_user, $amount);
             ReportUserChargeRecord::updateOrCreate(
                 [
@@ -312,97 +308,3 @@ class LandingPageLinkService
         }
     }
 }
-
-/**
- * 橙子建站回传
- */
-class OrangeChargeFeedBack extends ChargeFeedBack
-{
-    public function __construct()
-    {
-        $this->type = 'orange_site_report';
-        parent::__construct();
-    }
-}
-
-/**
- * 一般回传
- */
-class NormalChargeFeedBack extends ChargeFeedBack
-{
-    public function __construct()
-    {
-        $this->type = 'tiktok_report';
-        parent::__construct();
-    }
-}
-
-/**
- * 付费回传
- */
-class ChargeFeedBack
-{
-    protected $service;
-    protected $type;
-
-    public function __construct()
-    {
-        $this->service = new ConfigService;
-    }
-
-    /**
-     * 设置开关状态
-     */
-    public function setSwitchStatus(int $channel_id, int $status)
-    {
-        $this->service->saveConfig($channel_id, $this->type, $status);
-        Redis::hSet('channel:setting:' . $channel_id, $this->type, $status);
-    }
-
-    /**
-     * 获取开关状态
-     */
-    public function getSwitchStatus(int $channel_id)
-    {
-        $status = Redis::hGet('channel:setting:' . $channel_id, $this->type);
-        if (!$status) {
-            $status = $this->service->hasAuth($channel_id, $this->type);
-            if ($status) {
-                $this->setSwitchStatus($channel_id, $status);
-            }
-        }
-        return $status;
-    }
-
-    /**
-     * 同步开关状态
-     */
-    public function syncSwitchStatus(array $channel_ids, int $status)
-    {
-        foreach ($channel_ids as $channel_id) {
-            $this->setSwitchStatus($channel_id, $status);
-        }
-    }
-}
-
-
-class Report
-{
-    public function report(string $path, array $query_params)
-    {
-        $client = new Client(['timeout' => 3]);
-        $query_params['sign'] = _sign($query_params,  BaseConst::TIKTOK_KEY);
-        try {
-            $response =  $client->post(env('TRACK_API_DOMAIN') . '/' . $path, ['form_params' => $query_params]);
-            if ($response->getStatusCode() == 200) {
-                $result = $response->getBody()->getContents();
-                myLog('track_api')->info($result);
-                return json_decode($result, true);
-            } else {
-                return [];
-            }
-        } catch (Exception $e) {
-            myLog('track_api')->error($e->getMessage());
-        }
-    }
-}

+ 28 - 0
src/Services/LandingPage/Report.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace General\Services\LandingPage;
+
+use App\Consts\BaseConst;
+use Exception;
+use GuzzleHttp\Client;
+
+class Report
+{
+    public function report(string $path, array $query_params)
+    {
+        $client = new Client(['timeout' => 3]);
+        $query_params['sign'] = _sign($query_params,  BaseConst::TIKTOK_KEY);
+        try {
+            $response =  $client->post(env('TRACK_API_DOMAIN') . '/' . $path, ['form_params' => $query_params]);
+            if ($response->getStatusCode() == 200) {
+                $result = $response->getBody()->getContents();
+                myLog('track_api')->info($result);
+                return json_decode($result, true);
+            } else {
+                return [];
+            }
+        } catch (Exception $e) {
+            myLog('track_api')->error($e->getMessage());
+        }
+    }
+}