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) { request()->offsetSet('qapp_account', $this->qapp_account); $result = $this->service->findUserReportInfos($this->channel_id, $request->all()); return response()->pagination(new ReportOrderTramsformer, $result); } public function reportLogExport(QueryReportRequest $request) { request()->offsetSet('qapp_account', $this->qapp_account); $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(); } }