123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599 |
- <?php
- namespace App\Http\Controllers\Wechat\OfficialAccount;
- use App\Modules\Channel\Services\ChannelService;
- use App\Modules\Book\Services\BookSearchStatService;
- use App\Http\Controllers\Channel\BaseController as ChannelBaseController;
- use App\Modules\Channel\Models\Channel;
- use App\Modules\Channel\Models\YqMoveChannel;
- use App\Modules\OfficialAccount\Models\MediaCustomer;
- use App\Modules\OfficialAccount\Models\OfficialAccount;
- use App\Modules\OfficialAccount\Models\OfficialInteractiveEvent;
- use App\Modules\OfficialAccount\Models\WechatKeywordMsgs;
- use App\Modules\OfficialAccount\Models\DistributionReply;
- use App\Modules\OfficialAccount\Models\DistributionSelfDefineContent;
- use App\Modules\OfficialAccount\Models\DistributionSelfDefineConfig;
- use App\Modules\OfficialAccount\Services\OfficialAccountService;
- use App\Modules\OfficialAccount\Services\CustomMsgService;
- use App\Modules\OfficialAccount\Services\MsgService;
- use App\Modules\User\Services\ReadRecordService;
- use App\Modules\OfficialAccount\Services\ForceSubscribeService;
- use App\Http\Controllers\Wechat\OfficialAccount\Transformers\OfficialInteractiveEventTransformer;
- use App\Http\Controllers\Wechat\OfficialAccount\Transformers\OfficialInteractiveEventTextTransformer;
- use App\Modules\Book\Services\BookConfigService;
- use App\Modules\User\Services\UserSignService;
- use Illuminate\Http\Request;
- use GuzzleHttp\Client;
- use App\Libs\OSS;
- use Hashids;
- use App\Modules\Book\Models\BookConfig;
-
- class OfficialInteractiveEventController extends ChannelBaseController
- {
-
-
- function officialInteractiveEventFeedback(Request $request)
- {
- $appid = $request->has('appid') ? $request->input('appid') : '';
-
-
-
- $event = $request->has('event') ? $request->input('event') : '';
- $uid = $request->has('uid') ? $request->input('uid') : '';
- $openid = $request->has('openid') ? $request->input('openid') : '';
- \Log::info('-------------------------');
- \Log::info($openid);
- if(empty($event)) {
- return response()->error("PARAM_EMPTY");
- }
- $content = $request->has('content') ? $request->input('content') : '';
- $officialAccount = OfficialAccount::officialAccountByAppid($appid);
- $distribution_channel_id = '';
- if (!empty($officialAccount)) {
- $distribution_channel_id = $officialAccount['distribution_channel_id'];
- }else{
- $distribution_channel_id = '';
- }
- if($event == "text"){
- if(empty($content)) {
- return response()->error("PARAM_EMPTY");
- }
- }
- $encode_distribution_channel_id = encodeDistributionChannelId($distribution_channel_id);
-
-
- $channel = Channel::getById($distribution_channel_id);
- $is_outer_site = isset($channel->is_outer_site)?$channel->is_outer_site:'0';
- $is_domain_simple = isset($channel->is_domain_simple)?$channel->is_domain_simple:'0';
- if($is_domain_simple == '1'){
- $encode_distribution_channel_id = $distribution_channel_id;
- }
- $is_yq_move = '0';
-
- if(isset($channel->is_yq_move) && $channel->is_yq_move){
- \Log::info('new_has_move_site:'.$distribution_channel_id);
- $is_yq_move = 1;
- }
-
- $yqMoveChannel = YqMoveChannel::get_yq_move_channel($distribution_channel_id,1);
- if(!empty($yqMoveChannel)){
- \Log::info('old_has_move_site:'.$distribution_channel_id);
- $is_yq_move = 1;
- }
-
- $params['openid'] = $openid;
- $forceSubscribeUser = ForceSubscribeService::forceSubscribeUsersByOpenid($params);
- $uid = isset($forceSubscribeUser->uid)?$forceSubscribeUser->uid:'0';
-
- \Log::info('distribution_channel_id:'.$distribution_channel_id.' is_outer_site:'.$is_outer_site.' is_yq_move:'.$is_yq_move.' uid:'.$uid);
-
- if ($event == "text") {
-
- if($content != 'search_get_recommend_book'){
- if(strlen($content) <= 100){
- BookSearchStatService::create($uid,$openid,'wechat',$content);
- }
- }
-
-
- if($content == 'search_get_recommend_book'){
- \Log::info('get_recommend_book:'.$openid);
- $feedback['text'] = "";
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
-
-
- $distribution_self_define_config = DistributionSelfDefineConfig::getDistributionSelfDefineConfig($distribution_channel_id,'recommend_book_noreply');
- if(!empty($distribution_self_define_config)){
- \Log::info('distribution_self_define_config_no_recommend_book: distribution_channel_id:'.$distribution_channel_id);
- $feedback['text'] = "";
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
-
- $bid = isset($forceSubscribeUser->bid)?$forceSubscribeUser->bid:'0';
- $params['openid'] = $openid;
- $recommend_book = BookConfigService::getSimpleChannelBookLoop($bid,1,$uid);
- $feedback['text'] = '';
- if(!empty($recommend_book)){
- $bookUrl = env('PROTOCOL').'://site'.encodeDistributionChannelId($distribution_channel_id).'.'.env('WECHAT_CUSTOM_HOST').'.com';
- $bookUrl = $bookUrl.$recommend_book[0]->url.'&fromtype='.$content.'&source=wechatmsg&fromsource=smart_push';
-
- $feedback['text'] = '新书推荐: <a href="' . $bookUrl . '"> 《' . $recommend_book[0]->book_name . '》</a>';
- $feedback['text'] = ChannelService::convertChannelReplyUrl($is_outer_site,$appid, $openid, $feedback['text'],'get_one_recommend_book');
- }
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
- if($content == '签到'){
-
- \Log::info('text_sign:'.$openid);
- $feedback['text'] = UserSignService::userSignReturnContent3($openid,$distribution_channel_id);
- $feedback['text'] = ChannelService::convertChannelReplyUrl($is_outer_site,$appid, $openid, $feedback['text'],'text_sign');
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
-
- $booksInfo = array();
-
- $special_keyword = WechatKeywordMsgs::wechatKeywordByDistributionChannelIdAndKeyword($distribution_channel_id,$content,1);
- if(!empty($special_keyword)){
- \Log::info('officialInteractiveEventFeedback_has_special_keyword:'.$distribution_channel_id.' content:'.$content);
- \Log::info($special_keyword);
- $bid = Hashids::decode($special_keyword['bid'])[0];
- \Log::info('bid:'.$bid);
- $book_conf = BookConfig::getBookById($bid);
- \Log::info('$book_conf');\Log::info($book_conf);
- if(!empty($book_conf)){
- $special_keyword_new = array();
- $special_keyword_new['book_name'] = isset($special_keyword['send_title']) && !empty($special_keyword['send_title'])?$special_keyword['send_title']:$book_conf['book_name'];
- $special_keyword_new['cover'] = isset($special_keyword['send_cover']) && !empty($special_keyword['send_cover'])?$special_keyword['send_cover']:$book_conf['cover'];
- \Log::info('keyword_book_name:'.$special_keyword_new['book_name'].' cover:'.$special_keyword_new['cover']);
- $special_keyword_new['intro'] = $book_conf['intro'];
-
-
- if(isset($special_keyword['send_order_id']) && $special_keyword['send_order_id'] > 0){
- $special_keyword_new['book_url'] = '/yun/'.$special_keyword['send_order_id'];
- }else{
- $special_keyword_new['book_url'] = '/reader?bid='.$special_keyword['bid'].'&cid='.$special_keyword['cid'].'&fromtype=keyword_'.$special_keyword['id'];
- }
- $special_keyword_new['bid'] = $special_keyword['bid'];
- $booksInfo[] = $special_keyword_new;
- }else{
- \Log::info('book_conf_null:'.$distribution_channel_id.' content:'.$content);
- }
- }else{
- $booksInfo = BookConfig::getBooksByKey($content,3);
- }
- \Log::info('event_booksInfo');
- \Log::info($booksInfo);
- if(count($booksInfo) == 0){
- $feedback['text'] = '未找到相关小说,'."\n".'您可以试试:'."\n"."\n".'<a href="'.env('PROTOCOL').'://site'.$encode_distribution_channel_id.'.'.env('WECHAT_CUSTOM_HOST').'.com/recent">查看阅读记录 >> </a> '."\n"."\n".'<a href="'.env('PROTOCOL').'://site'.$encode_distribution_channel_id.'.'.env('WECHAT_CUSTOM_HOST').'.com">去书城首页看看 >> </a> '."\n"."\n".'联系客服:'."\n".'点击菜单栏 “用户中心“ > ”联系客服”';
-
- $feedback['text'] = ChannelService::convertChannelReplyUrl($is_outer_site,$appid, $openid, $feedback['text'],'text_search');
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }else{
- $data=[];
- for ($i=0; $i < count($booksInfo); $i++) {
- $bid = $booksInfo[$i]['bid'];
-
- \Log::info('wechat_log_info:book');\Log::info($booksInfo[$i]);
- $base_url = env('PROTOCOL').'://site'.$encode_distribution_channel_id.'.'.env('WECHAT_CUSTOM_HOST').'.com'.$booksInfo[$i]['book_url'];
- $instro_len = strlen($booksInfo[$i]['intro']);
- \Log::info('wechat_log_info:len:'.$instro_len.' getURL-----'.$base_url);
- if( $instro_len > 100){
- $booksInfo[$i]['intro'] = mb_substr($booksInfo[$i]['intro'], 0, 100, 'utf-8');
- $booksInfo[$i]['intro'] .= '......';
- \Log::info('search_instro_too_long:'.$booksInfo[$i]['intro']);
- }
- $data[$i]=['url'=>$base_url,
- 'title'=>$booksInfo[$i]['book_name'],
- 'description'=>$booksInfo[$i]['intro'],
- 'image'=>$booksInfo[$i]['cover']];
-
-
- break;
- }
- $datatext['text'] = $data;
- $datatext['text'] = ChannelService::convertChannelReplyUrl($is_outer_site,$appid, $openid, $datatext['text'],'text_search');
- return response()->success($datatext);
-
- }
- }
-
- elseif($event == "scan"){
-
- $distribution_self_define_config = DistributionSelfDefineConfig::getDistributionSelfDefineConfig($distribution_channel_id,'force_subscribe_noreply');
- if(!empty($distribution_self_define_config)){
- \Log::info('distribution_self_define_config: distribution_channel_id:'.$distribution_channel_id);
- $feedback['text'] = "";
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
-
- $feedback['text'] = "<a href='".env('PROTOCOL')."://site".$encode_distribution_channel_id.".".env('WECHAT_CUSTOM_HOST').".com/continue'>点此继续阅读 </a> ";
- $feedback['text'] = ChannelService::convertChannelReplyUrl($is_outer_site,$appid, $openid, $feedback['text'],'scan');
-
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
- elseif($event == "click"){
-
- if($content == "contact_customer" && !empty($appid)){
-
-
- if (config('common.click_type')) {
-
-
- \Log::info('wechat_log_info:getURL-----进入方法');
- $mediaCustomer = MediaCustomer::mediaCustomerByAppid($appid);
- if (count($mediaCustomer)>0) {
-
-
- for ($i=0; $i < count($mediaCustomer); $i++) {
-
- $send_event_content = array();
- $send_event_content['image'] = array('media_id'=>$mediaCustomer[$i]['media_id']);
-
- return response()->success($send_event_content);
-
- }
-
- }else{
- $timestamp = (time());
- $gzh_app_id = $appid;
- $group_nick = env('GROUP_NICK');
- $officialAccountPrams['appid'] = $appid;
- $officialAccount = (object)OfficialAccountService::officialAccountByAppid($officialAccountPrams);
- \Log::info('++++++++++++=====GET CUSTOM IMG [1] =====+++++++++++++');
- if (!empty($officialAccount)) {
- $distributionChannelSetting = CustomMsgService::customerImgUrlByChannelId($officialAccount->distribution_channel_id);
- \Log::info('++++++++++++=====GET CUSTOM IMG [2] =====+++++++++++++');
- if (!empty($distributionChannelSetting)) {
-
-
- $params = array("gzh_app_id"=>$appid,"group_nick"=>$group_nick,"is_default"=>0,"img_url"=>$distributionChannelSetting['customer_img_url'],"timestamp"=>$timestamp);
- $sign = get_sign($params);
-
- $mediaCustomerJson ='';
- try {
- $mediaCustomerJson = $this->getUserClient()->request("GET","upload_gzh_img/",
- ['query'=>['gzh_app_id'=>$appid,'group_nick'=>env('GROUP_NICK'),"is_default"=>0,"img_url"=>$distributionChannelSetting['customer_img_url'],'timestamp'=>$timestamp,'sign'=>$sign],'connect_timeout' => 3]
- )->getBody()->getContents();
- } catch (\Exception $e) {
- \Log::info('++++++++++++=====GET CUSTOM IMG [0] =====+++++++++++++');
- }
-
-
-
- $mediaCustomerArray = json_decode($mediaCustomerJson,true);
- \Log::info('++++++++++++=====GET CUSTOM IMG [3] =====+++++++++++++');
- \Log::info($mediaCustomerArray);
-
-
- if ($mediaCustomerArray['code'] == 1) {
-
- $mediaCustomerData = $mediaCustomerArray['data'];
- if (empty($mediaCustomerDat)) {
-
- $mediaCustomerCreate['media_id'] = $mediaCustomerData['media_id'];
- $mediaCustomerCreate['url'] = $mediaCustomerData['url'];
- $mediaCustomerCreate['appid'] = $appid;
- $mediaCustomerCreate['distribution_channel_id'] = $officialAccount->distribution_channel_id;
- MediaCustomer::create($mediaCustomerCreate);
- $send_event_content = array();
- $send_event_content['image'] = array('media_id'=>$mediaCustomerData['media_id']);
-
- return response()->success($send_event_content);
- }
-
-
- }else{
-
- $feedback['text'] = "客服QQ:3389644904\n客服电话:0571-56680019\n在线时间:工作日9:00-21:00\n";
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
- }else{
-
- $params = array("gzh_app_id"=>$appid,"group_nick"=>$group_nick,"timestamp"=>$timestamp);
- $sign = get_sign($params);
- \Log::info('wechat_log_info:getURL-----'.env('MEDIA_API_BASE_URI'));
- \Log::info('wechat_log_info:getURL-----'.$gzh_app_id.'___'.$timestamp.'___'.$sign);
- $mediaCustomerJson ='';
- try {
- $mediaCustomerJson = $this->getUserClient()->request("GET","upload_gzh_img/",
- ['query'=>['gzh_app_id'=>$appid,'group_nick'=>env('GROUP_NICK'),'timestamp'=>$timestamp,'sign'=>$sign],'connect_timeout' => 3]
- )->getBody()->getContents();
- } catch (\Exception $e) {
- \Log::info('wechat_log_info:Exception-----'.$e->getMessage());
- }
-
- \Log::info('wechat_log_info:getURL-----'.env('MEDIA_API_BASE_URI'));
-
- $mediaCustomerArray = json_decode($mediaCustomerJson,true);
-
-
- if ($mediaCustomerArray['code'] == 1) {
-
- $mediaCustomerData = $mediaCustomerArray['data'];
- if (empty($mediaCustomerDat)) {
-
- $mediaCustomerCreate['media_id'] = $mediaCustomerData['media_id'];
- $mediaCustomerCreate['url'] = $mediaCustomerData['url'];
- $mediaCustomerCreate['appid'] = $appid;
- $mediaCustomerCreate['distribution_channel_id'] = $officialAccount->distribution_channel_id;
- MediaCustomer::create($mediaCustomerCreate);
- $send_event_content = array();
- $send_event_content['image'] = array('media_id'=>$mediaCustomerData['media_id']);
-
- return response()->success($send_event_content);
- }
-
-
- }else{
-
- $feedback['text'] = "客服QQ:3389644904\n客服电话:0571-56680019\n在线时间:工作日9:00-21:00\n";
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
- }
-
-
- }
-
-
- }
- }else{
- $feedback['text'] = "客服QQ:3389644904\n在线时间:工作日9:00-21:00\n";
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
-
- }elseif ($content == "daily_sign" && !empty($openid)) {
-
-
- \Log::info('========================进入洋哥签到回调');
- $feedback['text'] = UserSignService::userSignReturnContent3($openid,$distribution_channel_id);
- $feedback['text'] = ChannelService::convertChannelReplyUrl($is_outer_site,$appid, $openid, $feedback['text'],'daily_sign');
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }elseif ($content == "recent_read" && !empty($openid)) {
-
- if($is_yq_move){
- $feedback['text'] = ForceSubscribeService::getYqMoveReply($distribution_channel_id,$openid);
- }
- else
- {
- $feedback['text'] = "<a href='".env('PROTOCOL')."://site".$encode_distribution_channel_id.".".env('WECHAT_CUSTOM_HOST').".com/recent'>点击查看最近阅读 </a>\n\n ";
-
- $sex = ForceSubscribeService::getSexByOpenid($distribution_channel_id,$openid);
- $sex_type = $sex_content = '';
- if($sex == 1){
- $sex_type = 'boy';
- $sex_content = '☞ 都市、玄幻、历史、军事、网游、灵异、科幻等海量书库任你看';
- }else{
- $sex_type = 'girl';
- $sex_content = '☞ 豪门、总裁、虐恋、婚宠、女尊、宫斗、经商、灵异等海量书库任你看';
- }
- $feedback['text'] .= "<a href='".env('PROTOCOL')."://site".$encode_distribution_channel_id.".".env('WECHAT_CUSTOM_HOST').".com/stock?sex=".$sex_type."'>".$sex_content."</a>";
- }
-
-
- $feedback['text'] .= BookConfigService::getHotRandomRecommendBookText($distribution_channel_id,$uid, 2);
- $feedback['text'] = ChannelService::convertChannelReplyUrl($is_outer_site,$appid, $openid, $feedback['text'],'recent_read');
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
-
-
- }
- elseif($event == "unsubscribe"){
- $feedback['text'] = "";
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
- elseif($event == "subscribe"){
-
- $distribution_self_define_config = DistributionSelfDefineConfig::getDistributionSelfDefineConfig($distribution_channel_id,'force_subscribe_noreply');
- if(!empty($distribution_self_define_config)){
- \Log::info('distribution_self_define_config: distribution_channel_id:'.$distribution_channel_id);
- $feedback['text'] = "";
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
-
-
- \Log::info('000000000000');
- if (!empty($openid)) {
-
- \Log::info('subscribe:'.$openid.' distribution_channel_id:'.$distribution_channel_id);
- $params['openid'] = $openid;
- $forceSubscribeUser = ForceSubscribeService::forceSubscribeUsersByOpenid($params);
- \Log::info($forceSubscribeUser);
-
-
-
- $distribution_self_define_content = MsgService::getCurrentReply($distribution_channel_id);
-
- \Log::info('distribution_self_define_content:'.json_encode($distribution_self_define_content));
- if(is_null($distribution_self_define_content)){
-
- $distribution_replay = DistributionReply::getDistributionReply($distribution_channel_id);
- \Log::info('distribution_replay:'.json_encode($distribution_replay));
- $recommend_content = '';
- if(!is_null($distribution_replay)){
- $special_bids = explode(',', $distribution_replay->reply_bids);
-
- $recomm_books = BookConfigService::getBidRecommendBooks($special_bids);
- if (!is_null($recomm_books)) {
- $recommend_content = "\n\n" . '热门书籍推荐';
- foreach ($recomm_books as $book) {
- $url = env('PROTOCOL') . '://site' . $encode_distribution_channel_id . '.' . env('WECHAT_CUSTOM_HOST') . '.com/reader?bid=' . Hashids::encode($book->bid) . '&cid=' . $book->first_cid;
- $recommend_content .= "\n\n" . '<a href="' . $url . '"> >>' . $book->book_name . '</a>';
- }
- }
- }
-
- if (!empty($forceSubscribeUser)) {
-
- \Log::info('exist_force_user:'.$openid);
-
- $uid = isset($forceSubscribeUser->uid)?$forceSubscribeUser->uid:'';
- $userBook = ReadRecordService::getFirstReadRecord($uid);
- $bookName = isset($userBook['book_name'])?$userBook['book_name']:'最近阅读';
- \Log::info('bookName:'.$bookName);
-
- if(!empty($recommend_content)){
- $feedback['text'] = '亲,终于等到你了!'."\n"."\n".'<a href="'.env('PROTOCOL').'://site'.$encode_distribution_channel_id.'.'.env('WECHAT_CUSTOM_HOST').'.com/continue">点我继续阅读 </a> '."\n"."\n".'阅读记录:'."\n"."\n".'><a href="'.env('PROTOCOL').'://site'.$encode_distribution_channel_id.'.'.env('WECHAT_CUSTOM_HOST').'.com/continue">'.$bookName.'</a>';
- $feedback['text'] .= $recommend_content;
- $feedback['text'] .= "\n"."\n".'为方便下次阅读,请'.'<a href="https://help.leyuee.com/top.html">'.'置顶公众号'.'</a>';
- }else{
- $feedback['text'] = '亲,终于等到你了!'."\n"."\n".'<a href="'.env('PROTOCOL').'://site'.$encode_distribution_channel_id.'.'.env('WECHAT_CUSTOM_HOST').'.com/continue">点我继续阅读 </a> '."\n"."\n".'阅读记录:'."\n"."\n".'><a href="'.env('PROTOCOL').'://site'.$encode_distribution_channel_id.'.'.env('WECHAT_CUSTOM_HOST').'.com/continue">'.$bookName.'</a>'."\n"."\n".'为方便下次阅读,请'.'<a href="https://help.leyuee.com/top.html">'.'置顶公众号'.'</a>'."\n\n".'今日签到成功,赠送30书币,连续签到2日后,赠送书币增加至50哦~,进入<a href="'.env('PROTOCOL').'://site'.$encode_distribution_channel_id.'.'.env('WECHAT_CUSTOM_HOST').'.com/person">个人中心 </a>查看!'."\n\n".'明日继续签到得书币哦!';
- }
-
- }else{
- $feedback['text'] = "<a href='".env('PROTOCOL')."://site".$encode_distribution_channel_id.".".env('WECHAT_CUSTOM_HOST').".com/continue'>点击继续阅读 </a> ";
- $feedback['text'] .= $recommend_content;
- }
-
-
- if(strpos($content,'outer') > -1){
- $scene_content = str_replace('qrscene_outer:','',$content);
- $bid_cid = explode('_', $scene_content);
- $bid = isset($bid_cid[0])?$bid_cid[0]:'';
- $cid = isset($bid_cid[1])?$bid_cid[1]:'';
- if(!empty($bid) && !empty($cid)){
- $book_conf = BookConfig::getBookById($bid);
- \Log::info('out_book_conf');\Log::info($book_conf);
- if(!empty($book_conf)){
- $data = array();
- $encode_bid = Hashids::encode($bid);
- $data[]=['url'=>env('PROTOCOL').'://site'.$encode_distribution_channel_id.'.'.env('WECHAT_CUSTOM_HOST').'.com'.'/reader?bid='.$encode_bid.'&cid='.$cid.'&fromtype=outer_'.$scene_content,
- 'title'=>$book_conf['book_name'],
- 'description'=>$book_conf['intro'],
- 'image'=>$book_conf['cover']
- ];
-
- \Log::info('outer:'.json_encode($data));
- $feedback['text'] = $data;
- }
- }
- }
-
- }else{
-
- if(isset($distribution_self_define_content->is_pic) && $distribution_self_define_content->is_pic){
- $feedback['text'] = ImageNewsToArray($distribution_self_define_content->content);
- }else{
- $feedback['text'] = isset($distribution_self_define_content->content)?$distribution_self_define_content->content:'';
- }
- }
- $feedback['text'] = ChannelService::convertChannelReplyUrl($is_outer_site,$appid, $openid, $feedback['text'],'subscribe');
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
-
- }else{
- $feedback['text'] = "<a href='".env('PROTOCOL')."://site".$encode_distribution_channel_id.".".env('WECHAT_CUSTOM_HOST').".com/continue'>点击继续阅读 </a> ";
- $feedback['text'] = ChannelService::convertChannelReplyUrl($is_outer_site,$appid, $openid, $feedback['text'],'subscribe');
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }
- }elseif($event == "TEMPLATESENDJOBFINISH"){
- $feedback['text'] = "";
- return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
- }else{
-
-
- return response()->error('EVENT_NOT_FOUND');
- }
- }
- public function getUserClient(){
-
- return new Client(['base_uri' => env('MEDIA_API_BASE_URI')]);
- }
-
- }
|