send_order_id = $decode_id[0]; $send_order = SendOrderService::getSendOrderStatic($this->send_order_id); $distribution_channel_id = $send_order->distribution_channel_id; $qappPackage = QappPackageService::getPackage($distribution_channel_id); $this->getCallbackParams($request); $showGzh = 0; $sendOrderId = $this->send_order_id; if ($sendOrderId && in_array($sendOrderId, explode(',', env('SHOW_GZH_SEND_ORDER_IDS')))) { $showGzh = 1; } if ($send_order && $qappPackage) { $this->sendOrderStatistic($send_order);//统计 $cid = $send_order->chapter_id; $hash_bid = Hashids::encode($send_order->book_id); $doShied = QappSendOrderContentShieldConfigService::doShied($this->send_order_id, _getIp()); if($doShied){ if(isset($doShied['bid']) && isset($doShied['cid'])){ $hash_bid = Hashids::encode($doShied['bid']); $cid = $doShied['cid']; } } return view('qapp.start')->with([ 'package' => $qappPackage->package, 'hash_bid' => $hash_bid, 'cid' => $cid, 'send_order_id' => $this->send_order_id, 'show_gzh' => $showGzh ]); } } } /** * 平台附加在推广链接后的参数存储 * @param $request */ private function getCallbackParams($request) { $tid = $request->get('tid',''); $pageId = $request->get('pageId',''); try { if(!empty($tid) && !empty($pageId)){ $qapp_send_order = QappSendOrder::getSendOrderById($this->send_order_id); \Log::info('$qapp_send_order:'.json_encode($qapp_send_order).'$this->send_order_id:'.$this->send_order_id); if($qapp_send_order && !empty($qapp_send_order)){ if(isset($qapp_send_order['platform']) && $qapp_send_order['platform'] == PushConst::PROVIDER_OPPO){ //用户ip $ip = _getIp(); $provider = $qapp_send_order['platform']; $send_order_id = $this->send_order_id; $lbid = $request->get('lbid',''); $params = json_encode(compact('tid','pageId','lbid')); QappCallbackParams::firstOrCreate(compact('ip','send_order_id','provider'),compact('params')); } } } } catch (\Exception $e) { \Log::info('oppo_request_error:'.$e->getMessage()); } } private function sendOrderStatistic($send_order) { $key = date('Y-m-d'); $send_order_flag = Cookie::get('send_order_flag'); $send_orders = explode(',', $send_order_flag); //uv if (!Cookie::get('send_order_flag_' . $this->send_order_id) && !in_array($this->send_order_id, $send_orders)) { Redis::hincrby('send_order_uv_' . $this->send_order_id, $key, 1); Redis::hincrby('send_order_uv_' . $this->send_order_id, 'total', 1); array_push($send_orders, $this->send_order_id); $str = implode(',', $send_orders); Cookie::queue('send_order_flag', $str, env('U_COOKIE_EXPIRE'), null, null, false, false); } if (Cookie::get('send_order_flag_' . $this->send_order_id)) { array_push($send_orders, $this->send_order_id); $str = implode(',', $send_orders); Cookie::queue('send_order_flag', $str, env('U_COOKIE_EXPIRE'), null, null, false, false); Cookie::queue('send_order_flag_' . $this->send_order_id, null, -1); } //pv Redis::hincrby('send_order_pv_' . $this->send_order_id, $key, 1); //每天 Redis::hincrby('send_order_pv_' . $this->send_order_id, 'total', 1); //汇总 Redis::sadd('send_order' . $key, $this->send_order_id); if (isset($send_order->send_time) && $send_order->send_time) { } else { $uv = Redis::hget('send_order_uv_' . $this->send_order_id, $key); if ($uv && $uv > 20) { SendOrderService::updateSendOrderTime($this->send_order_id); } } } /** * @apiVersion 1.0.0 * @apiDescription 获取客服二维码 * @api {GET} customer_img 获取客服二维码 * @apiHeader {String} [Authorization] token * @apiGroup User * @apiName customer_img * @apiSuccess {String} data.name 名称. * @apiSuccess {String} data.url 图片地址. * @apiSuccessExample {json} Success-Response: * * { * "code": 0, * "msg": "", * "data": {} */ public function getCustomerServiceImg(Request $request) { $link = CustomMsgService::customerImgUrlByChannelId($this->distribution_channel_id); $name = 'zhenzhenyd'; if ($link && $link->customer_img_url) { $url = $link->customer_img_url; } else { $url = env('KE_FU_QRCODE', 'https://cdn-novel.iycdm.com/static/img/kefu20190319.jpg'); } // 获取客服信息 $package = $request->header('x-package', ''); $supports = config('option.supports'); $support = getProp($supports, $package, []); if ($support) { $url = getProp($support, 'customerImage', 'https://cdn-novel.iycdm.com/static/img/kefu20190319.jpg'); $name = getProp($support, 'customerAccount', 'zhenzhenyd'); } return response()->success(compact('url', 'name')); } /** * 系统设置 * @return mixed */ public function getOptions(Request $request) { // 获取包名 $package = $request->header('x-package', ''); // 获取客服信息 $supports = config('option.supports'); $support = getProp($supports, $package, (object)[]); // 获取用户信息 $user = User::getUser($this->uid); $sendOrderId = getProp($user, 'send_order_id'); // 获取派单信息 $adPositions = []; if ($sendOrderId) { $sendOrder = QappSendOrder::getSendOrderById($sendOrderId); $channelAccount = QappChannelAccount::getByAccount(getProp($sendOrder, 'account')); $adPositions = AdPositionService::getInstance()->getAdPositions($this->uid, getProp($channelAccount, 'id')); } // 配置 $data = [ 'support' => $support, 'task_center' => [ 'home_show' => 1, 'pay_back_alert_show' => 1, ], 'add_desk_alert' => [ 'sign_out_app_show' => $sendOrderId ? 1 : 0, 'sign_out_reader_show' => $sendOrderId ? 1 : 0, ], 'position' => [ 'home_alert' => getProp($adPositions, 'home_alert', []), 'reader_banner' => getProp($adPositions, 'reader_banner', []), 'open_alert' => getProp($adPositions, 'open_alert', []), ] ]; return response()->success($data); } }