|
@@ -34,6 +34,7 @@ use Redis;
|
|
use DB;
|
|
use DB;
|
|
use App\Modules\Book\Models\BookConfig;
|
|
use App\Modules\Book\Models\BookConfig;
|
|
use App\Modules\Promotion\Services\PromotionService;
|
|
use App\Modules\Promotion\Services\PromotionService;
|
|
|
|
+use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
|
|
|
|
|
|
class OfficialInteractiveEventController extends Controller
|
|
class OfficialInteractiveEventController extends Controller
|
|
{
|
|
{
|
|
@@ -187,6 +188,98 @@ class OfficialInteractiveEventController extends Controller
|
|
return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
|
|
return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ($content == '最近阅读') {
|
|
|
|
+ // $channel_sex = ChannelService::getChannelCompanySex($distribution_channel_id);
|
|
|
|
+ $channelInfo = ChannelService::getById($distribution_channel_id);
|
|
|
|
+ $property = isset($channelInfo->property) ? $channelInfo->property : '';
|
|
|
|
+ $channel_sex = 3;
|
|
|
|
+ if ($property === ChannelConst::PROPERTY_MALE) {
|
|
|
|
+ $channel_sex = 1;
|
|
|
|
+ }
|
|
|
|
+ if ($property === ChannelConst::PROPERTY_FEMALE) {
|
|
|
|
+ $channel_sex = 2;
|
|
|
|
+ }
|
|
|
|
+ \Log::info('channel_sex:' . $channel_sex . ' distribution_channel_id:' . $distribution_channel_id . ' property:' . $property);
|
|
|
|
+
|
|
|
|
+ $feedback['text'] = "尊敬的会员:\n\n <a href='" . env('PROTOCOL') . "://site" . $encode_distribution_channel_id . "." . $WECHAT_CUSTOM_HOST . ".com/recent'>☞ 点我继续上次阅读 </a>";
|
|
|
|
+
|
|
|
|
+ if ($channel_sex != 1) {
|
|
|
|
+ // 根据用户性别确定男女频
|
|
|
|
+ $sex = ForceSubscribeService::getUserRealSexByUid($uid);
|
|
|
|
+ $channel_name = $sex == 1 ? '男频' : '女频';
|
|
|
|
+
|
|
|
|
+ // 站点属性优先
|
|
|
|
+ if ($channel_sex == 2) {
|
|
|
|
+ $channel_name = '女频';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $recomm_books = BookConfigService::getSignRecommendBooksFromCache([], $channel_name, 2);
|
|
|
|
+
|
|
|
|
+ $recent_read_reco_content = '';
|
|
|
|
+ if ($recomm_books) {
|
|
|
|
+ // 判断是否不展示书名
|
|
|
|
+ $self_config = ChannelService::check_channel_account_priv($distribution_channel_id, 'hide_book_name');
|
|
|
|
+ $hide_type = isset($self_config->type) ? $self_config->type : 'not_hide';
|
|
|
|
+ $recommend_titles = [];
|
|
|
|
+ if ($hide_type == 'hide_book_name') {
|
|
|
|
+ \Log::info('hide_book_name reco:' . $distribution_channel_id . ' uid:' . $uid);
|
|
|
|
+ $recommend_titles = PromotionService::getRandomHeadline($sex, count($recomm_books));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $recent_read_reco_content .= "\n\n" . '热门书籍推荐~';
|
|
|
|
+ foreach ($recomm_books as $key => $book) {
|
|
|
|
+ $book_name = $book->book_name;
|
|
|
|
+ if ($hide_type == 'hide_book_name') {
|
|
|
|
+ $book_name = isset($recommend_titles[$key]->title) ? $recommend_titles[$key]->title : $book->book_name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/reader?bid=' . Hashids::encode($book->bid) . '&cid=' . $book->first_cid;
|
|
|
|
+ $recent_read_reco_content .= "\n\n" . '<a href="' . $url . '"> ☞ 《' . $book_name . '》</a>';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $feedback['text'] .= $recent_read_reco_content;
|
|
|
|
+ } else {
|
|
|
|
+ // 男频站点
|
|
|
|
+ // 1本在测的,1本优质书,共2本,如果没有在测的书,则返回2本优质书
|
|
|
|
+ // 用户按照15天注册后的用户
|
|
|
|
+ $sex = ForceSubscribeService::getUserRealSexByUid($uid);
|
|
|
|
+ [$bids, $test_bid] = BookConfig::getLeftRecomBids($uid, '男频', 2);
|
|
|
|
+ \Log::info('bids and test_bid:' . $uid . ' data:' . json_encode([$bids, $test_bid]));
|
|
|
|
+ if ($bids) {
|
|
|
|
+ $recomm_books = BookService::getSimpleBooksByIds($bids);
|
|
|
|
+ $recent_read_reco_content = '';
|
|
|
|
+ if ($recomm_books) {
|
|
|
|
+ // 判断是否不展示书名
|
|
|
|
+ $self_config = ChannelService::check_channel_account_priv($distribution_channel_id, 'hide_book_name');
|
|
|
|
+ $hide_type = isset($self_config->type) ? $self_config->type : 'not_hide';
|
|
|
|
+ $recommend_titles = [];
|
|
|
|
+ if ($hide_type == 'hide_book_name') {
|
|
|
|
+ \Log::info('hide_book_name reco:' . $distribution_channel_id . ' uid:' . $uid);
|
|
|
|
+ $recommend_titles = PromotionService::getRandomHeadline($sex, count($recomm_books));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $recent_read_reco_content .= "\n\n" . '热门书籍推荐~';
|
|
|
|
+ foreach ($recomm_books as $key => $book) {
|
|
|
|
+ $book_name = $book->name;
|
|
|
|
+ if ($hide_type == 'hide_book_name') {
|
|
|
|
+ $book_name = isset($recommend_titles[$key]->title) ? $recommend_titles[$key]->title : $book_name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/reader?bid=' . Hashids::encode($book->id) . '&cid=' . $book->first_cid;
|
|
|
|
+ if ($book->id == $test_bid) {
|
|
|
|
+ $url .= '&fromsource=smart_push';
|
|
|
|
+ }
|
|
|
|
+ $recent_read_reco_content .= "\n\n" . '<a href="' . $url . '"> ☞ 《' . $book_name . '》</a>';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $feedback['text'] .= $recent_read_reco_content;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $feedback['text'] = ChannelService::convertChannelReplyUrl($is_outer_site, $appid, $openid, $feedback['text'], 'recent_read');
|
|
|
|
+ return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
|
|
|
|
+ }
|
|
|
|
+
|
|
$booksInfo = array();
|
|
$booksInfo = array();
|
|
// 判断是否自定义关键字
|
|
// 判断是否自定义关键字
|
|
$special_keyword = WechatKeywordMsgs::wechatKeywordByDistributionChannelIdAndKeyword($distribution_channel_id, $content, 1);
|
|
$special_keyword = WechatKeywordMsgs::wechatKeywordByDistributionChannelIdAndKeyword($distribution_channel_id, $content, 1);
|
|
@@ -459,6 +552,20 @@ class OfficialInteractiveEventController extends Controller
|
|
|
|
|
|
|
|
|
|
} elseif ($content == "daily_sign" && !empty($openid)) {
|
|
} elseif ($content == "daily_sign" && !empty($openid)) {
|
|
|
|
+ //强关信息
|
|
|
|
+ $user = ForceSubscribeUsers::getOneForceSubscribeUsersByOpenid($openid);
|
|
|
|
+ if (!$user) {
|
|
|
|
+ $feedback['text'] = "亲爱的用户,本次签到最高可领取150书币哦\n\n/:heart".'<a href="weixin://bizmsgmenu?msgmenucontent=签到&msgmenuid=2">点击此处签到领书币</a>';
|
|
|
|
+ }else {
|
|
|
|
+ //用户信息
|
|
|
|
+ $user_info = User::where('id',$user->uid)->first();
|
|
|
|
+ if ($user_info && !empty($user_info->nickname)) {
|
|
|
|
+ $feedback['text'] = '亲爱的'.$user_info->nickname.",本次签到最高可领取150书币哦\n\n/:heart".'<a href="weixin://bizmsgmenu?msgmenucontent=签到&msgmenuid=2">点击此处签到领书币</a>';
|
|
|
|
+ }else {
|
|
|
|
+ $feedback['text'] = "亲爱的用户,本次签到最高可领取150书币哦\n\n/:heart".'<a href="weixin://bizmsgmenu?msgmenucontent=签到&msgmenuid=2">点击此处签到领书币</a>';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
|
|
|
|
|
|
//调洋哥的接口发送签到客服消息
|
|
//调洋哥的接口发送签到客服消息
|
|
\Log::info('========================进入洋哥签到回调');
|
|
\Log::info('========================进入洋哥签到回调');
|
|
@@ -483,6 +590,9 @@ class OfficialInteractiveEventController extends Controller
|
|
return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
|
|
return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
|
|
|
|
|
|
} elseif ($content == "recent_read" && !empty($openid)) {
|
|
} elseif ($content == "recent_read" && !empty($openid)) {
|
|
|
|
+ $feedback['text'] = '欢迎回来,<a href="weixin://bizmsgmenu?msgmenucontent=最近阅读&msgmenuid=1">点此继续阅读~</a>';
|
|
|
|
+ return response()->item(new OfficialInteractiveEventTransformer(), (object)$feedback);
|
|
|
|
+
|
|
// $channel_sex = ChannelService::getChannelCompanySex($distribution_channel_id);
|
|
// $channel_sex = ChannelService::getChannelCompanySex($distribution_channel_id);
|
|
$channelInfo = ChannelService::getById($distribution_channel_id);
|
|
$channelInfo = ChannelService::getById($distribution_channel_id);
|
|
$property = isset($channelInfo->property) ? $channelInfo->property : '';
|
|
$property = isset($channelInfo->property) ? $channelInfo->property : '';
|