|
@@ -228,7 +228,8 @@ class CustomMsgService
|
|
|
$continueReadUrl = env('PROTOCOL').'://site'.encodeDistributionChannelId($distribution_channel_id).'.'.env('CUSTOM_HOST').'.com/continue?fromtype=not_pay';
|
|
|
|
|
|
//拼接文案和用户最近阅读书籍的链接以及书籍名称
|
|
|
- $data['content'] = '亲,你上次看的书还在等着你呐~点击继续阅读'."\n".'<a href="'.$continueReadUrl.'"> >《'.$userBook['book_name'].'》</a>'."\n".'首冲50元即可畅读100万字,年费VIP更可全年无限畅读。'."\n".'为方便下次阅读,请'.'<a href="https://help.leyuee.com/top.html">'.'置顶公众号'.'</a>';
|
|
|
+ //$data['content'] = '亲,你上次看的书还在等着你呐~点击继续阅读'."\n".'<a href="'.$continueReadUrl.'"> >《'.$userBook['book_name'].'》</a>'."\n".'首冲50元即可畅读100万字,年费VIP更可全年无限畅读。'."\n".'为方便下次阅读,请'.'<a href="https://help.leyuee.com/top.html">'.'置顶公众号'.'</a>';
|
|
|
+ $data['content'] = '亲,你上次看的书还在等着你呐~'."\n".'<a href="'.$continueReadUrl.'"> >点击继续阅读</a>'."\n".'首冲50元即可畅读100万字,年费VIP更可全年无限畅读。'."\n".'为方便下次阅读,请'.'<a href="https://help.leyuee.com/top.html">'.'置顶公众号'.'</a>';
|
|
|
$data['type'] = 'one_task';// last_task,one_task
|
|
|
$data['task_id'] = 1;
|
|
|
$data['send_time'] = date("Y-m-d H:i:s");
|
|
@@ -1791,11 +1792,11 @@ class CustomMsgService
|
|
|
$force_users = ForceSubscribeService::forceUserCountByCustomPrams($custom_param['appids'],$custom_param['distribution_channel_id'],$custom_param['subscribe_time'],$custom_param['sex'],$custom_param['balance'],$custom_param['category_id'],$custom_param['order_type'],$custom_param['sign_time'],$custom_param['skip']);
|
|
|
$force_users = self::get_unique_users($force_users,'unpaid_send_activity',3600*48);
|
|
|
}
|
|
|
- // 付费用户推送
|
|
|
- elseif($category_type == 'pay_daily_push'){
|
|
|
- $custom_param['order_type'] = 'd';//6-13小时充值,考虑到0-6点不推送
|
|
|
- $force_users = ForceSubscribeService::forceUserCountByCustomPrams($custom_param['appids'],$custom_param['distribution_channel_id'],$custom_param['subscribe_time'],$custom_param['sex'],$custom_param['balance'],$custom_param['category_id'],$custom_param['order_type'],$custom_param['sign_time'],$custom_param['skip']);
|
|
|
- $force_users = self::get_unique_users($force_users,'pay_daily_push',3600*24);
|
|
|
+ // 付费用户推送
|
|
|
+ elseif($category_type == 'pay_daily_push'){
|
|
|
+ $custom_param['order_type'] = 'd';//6-13小时充值,考虑到0-6点不推送
|
|
|
+ $force_users = ForceSubscribeService::forceUserCountByCustomPrams($custom_param['appids'],$custom_param['distribution_channel_id'],$custom_param['subscribe_time'],$custom_param['sex'],$custom_param['balance'],$custom_param['category_id'],$custom_param['order_type'],$custom_param['sign_time'],$custom_param['skip']);
|
|
|
+ $force_users = self::get_unique_users($force_users,'pay_daily_push',3600*24);
|
|
|
}
|
|
|
else{
|
|
|
|
|
@@ -1865,20 +1866,20 @@ class CustomMsgService
|
|
|
['image'=>'https://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/smart_push/toutiao.jpg']
|
|
|
];
|
|
|
}
|
|
|
- $send_content[] = $first_activity;
|
|
|
-
|
|
|
- }
|
|
|
- // 未付费优惠充值活动推送(多选项)
|
|
|
- elseif($category_type == 'unpaid_send_big_activity'){
|
|
|
- //活动链接
|
|
|
- $continueReadUrl = env('PROTOCOL').'://site'.encodeDistributionChannelId($distribution_channel_id).'.'.env('CUSTOM_HOST').'.com/sale/newUserSale?fromtype=unpaid_send_activity&send_time='.time();
|
|
|
- $send_content = '您的新用户专享礼包已送达'."\n\n".'送25000书币及优惠券,畅读全站小说无压力!'."\n\n".'过期失效,只有1次机会哦!'."\n\n".'<a href="'.$continueReadUrl.'">点击立即领取> ></a>'."\n\n".'为方便下次阅读,请'.'<a href="https://help.leyuee.com/top.html">'.'置顶公众号'.'</a>';
|
|
|
- }
|
|
|
- // 未付费9.9活动推送
|
|
|
- elseif($category_type == 'unpaid_send_activity'){
|
|
|
- //活动链接
|
|
|
- $continueReadUrl = env('PROTOCOL').'://site'.encodeDistributionChannelId($distribution_channel_id).'.'.env('CUSTOM_HOST').'.com/sale/newUserActivity?fromtype=unpaid_send_activity&send_time='.time();
|
|
|
- $send_content = '您的新用户专享礼包已送达'."\n\n".'充9.9元,得2000书币,只有一次机会哦!'."\n\n".'过期失效,不要错过!'."\n\n".'<a href="'.$continueReadUrl.'">点击立即领取> ></a>'."\n\n".'为方便下次阅读,请'.'<a href="https://help.leyuee.com/top.html">'.'置顶公众号'.'</a>';
|
|
|
+ $send_content[] = $first_activity;
|
|
|
+
|
|
|
+ }
|
|
|
+ // 未付费优惠充值活动推送(多选项)
|
|
|
+ elseif($category_type == 'unpaid_send_big_activity'){
|
|
|
+ //活动链接
|
|
|
+ $continueReadUrl = env('PROTOCOL').'://site'.encodeDistributionChannelId($distribution_channel_id).'.'.env('CUSTOM_HOST').'.com/sale/newUserSale?fromtype=unpaid_send_activity&send_time='.time();
|
|
|
+ $send_content = '您的新用户专享礼包已送达'."\n\n".'送25000书币及优惠券,畅读全站小说无压力!'."\n\n".'过期失效,只有1次机会哦!'."\n\n".'<a href="'.$continueReadUrl.'">点击立即领取> ></a>'."\n\n".'为方便下次阅读,请'.'<a href="https://help.leyuee.com/top.html">'.'置顶公众号'.'</a>';
|
|
|
+ }
|
|
|
+ // 未付费9.9活动推送
|
|
|
+ elseif($category_type == 'unpaid_send_activity'){
|
|
|
+ //活动链接
|
|
|
+ $continueReadUrl = env('PROTOCOL').'://site'.encodeDistributionChannelId($distribution_channel_id).'.'.env('CUSTOM_HOST').'.com/sale/newUserActivity?fromtype=unpaid_send_activity&send_time='.time();
|
|
|
+ $send_content = '您的新用户专享礼包已送达'."\n\n".'充9.9元,得2000书币,只有一次机会哦!'."\n\n".'过期失效,不要错过!'."\n\n".'<a href="'.$continueReadUrl.'">点击立即领取> ></a>'."\n\n".'为方便下次阅读,请'.'<a href="https://help.leyuee.com/top.html">'.'置顶公众号'.'</a>';
|
|
|
}
|
|
|
// 付费用户推送
|
|
|
elseif($category_type == 'pay_daily_push'){
|
|
@@ -1886,23 +1887,23 @@ class CustomMsgService
|
|
|
$book_name = isset($userBook['book_name'])?$userBook['book_name']:'';
|
|
|
$user = UserService::getById($uid);
|
|
|
$balance = isset($user->balance)?$user->balance:'0';
|
|
|
- $nickname = isset($user->nickname)?$user->nickname:'';
|
|
|
- //用户最近阅读链接
|
|
|
+ $nickname = isset($user->nickname)?$user->nickname:'';
|
|
|
+ //用户最近阅读链接
|
|
|
$continueReadUrl = env('PROTOCOL').'://site'.encodeDistributionChannelId($distribution_channel_id).'.'.env('CUSTOM_HOST').'.com/continue?fromtype=pay_daily_push';
|
|
|
//拼接文案
|
|
|
if(empty($book_name)){
|
|
|
- $send_content = '尊敬的会员:'.$nickname."\n\n".'您的账户余额:'.$balance."\n\n".'<a href="'.$continueReadUrl.'">点击继续阅读~</a>'."\n";
|
|
|
+ $send_content = '尊敬的会员:'.$nickname."\n\n".'您的账户余额:'.$balance."\n\n".'<a href="'.$continueReadUrl.'">点击继续阅读~</a>'."\n";
|
|
|
}else{
|
|
|
- $send_content = '尊敬的会员:'.$nickname."\n\n".'您的账户余额:'.$balance."\n\n".'最近阅读书籍:《'.$book_name.'》'."\n\n".'<a href="'.$continueReadUrl.'">点击继续阅读~</a>'."\n";
|
|
|
+ $send_content = '尊敬的会员:'.$nickname."\n\n".'您的账户余额:'.$balance."\n\n".'最近阅读书籍:《'.$book_name.'》'."\n\n".'<a href="'.$continueReadUrl.'">点击继续阅读~</a>'."\n";
|
|
|
}
|
|
|
- \Log::info('pay_daily_push_send_content:'.$uid);\Log::info($send_content);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // TODO最近阅读?
|
|
|
- else{}
|
|
|
-
|
|
|
- return $send_content;
|
|
|
+ \Log::info('pay_daily_push_send_content:'.$uid);\Log::info($send_content);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO最近阅读?
|
|
|
+ else{}
|
|
|
+
|
|
|
+ return $send_content;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -2761,17 +2762,17 @@ class CustomMsgService
|
|
|
* @param unknown_type $timestamp
|
|
|
*/
|
|
|
static function upload_material_img($param) {
|
|
|
- $params = array("gzh_app_id"=>$param['gzh_app_id'],"img_url"=>$param['img_url'],"group_nick"=>$param['group_nick'],"timestamp"=>$param['timestamp']);
|
|
|
- $sign = get_sign($params);
|
|
|
-
|
|
|
- //获取封面图片media_id
|
|
|
- $mediaCustomerJson = self::getUserClient()->request("GET","upload_material_img/",
|
|
|
- ['query'=>['gzh_app_id'=>$param['gzh_app_id'],'img_url'=>$param['img_url'],'group_nick'=>$param['group_nick'],'timestamp'=>$param['timestamp'],'sign'=>$sign],'connect_timeout' => 3]
|
|
|
- )->getBody()->getContents();
|
|
|
-
|
|
|
- \Log::info("alter_upload_material_img:".$param['gzh_app_id'].' img_url:'.$param['img_url']);
|
|
|
- \Log::info($mediaCustomerJson);
|
|
|
-
|
|
|
+ $params = array("gzh_app_id"=>$param['gzh_app_id'],"img_url"=>$param['img_url'],"group_nick"=>$param['group_nick'],"timestamp"=>$param['timestamp']);
|
|
|
+ $sign = get_sign($params);
|
|
|
+
|
|
|
+ //获取封面图片media_id
|
|
|
+ $mediaCustomerJson = self::getUserClient()->request("GET","upload_material_img/",
|
|
|
+ ['query'=>['gzh_app_id'=>$param['gzh_app_id'],'img_url'=>$param['img_url'],'group_nick'=>$param['group_nick'],'timestamp'=>$param['timestamp'],'sign'=>$sign],'connect_timeout' => 3]
|
|
|
+ )->getBody()->getContents();
|
|
|
+
|
|
|
+ \Log::info("alter_upload_material_img:".$param['gzh_app_id'].' img_url:'.$param['img_url']);
|
|
|
+ \Log::info($mediaCustomerJson);
|
|
|
+
|
|
|
$mediaCustomerArray = json_decode($mediaCustomerJson,true);
|
|
|
return $mediaCustomerArray;
|
|
|
}
|
|
@@ -2781,30 +2782,30 @@ class CustomMsgService
|
|
|
\Log::info('last_urls');\Log::info($last_urls);
|
|
|
$multy_urls = [];
|
|
|
foreach($last_urls as $last_url){
|
|
|
- if(strpos($last_url,'mmbiz.qpic.cn') > -1){
|
|
|
- \Log::info('wx_url_continue:'.$last_url);
|
|
|
- continue;
|
|
|
+ if(strpos($last_url,'mmbiz.qpic.cn') > -1){
|
|
|
+ \Log::info('wx_url_continue:'.$last_url);
|
|
|
+ continue;
|
|
|
}
|
|
|
- $last_url = str_replace(array("&",""","amp;","quot;"), "", htmlspecialchars($last_url));
|
|
|
- $params = array("gzh_app_id"=>$base_param['gzh_app_id'],"img_url"=>$last_url,"group_nick"=>$base_param['group_nick'],"timestamp"=>$base_param['timestamp']);
|
|
|
+ $last_url = str_replace(array("&",""","amp;","quot;"), "", htmlspecialchars($last_url));
|
|
|
+ $params = array("gzh_app_id"=>$base_param['gzh_app_id'],"img_url"=>$last_url,"group_nick"=>$base_param['group_nick'],"timestamp"=>$base_param['timestamp']);
|
|
|
$sign = get_sign($params);
|
|
|
- $params['sign'] = $sign;
|
|
|
+ $params['sign'] = $sign;
|
|
|
$url = env('MEDIA_API_BASE_URI').'upload_material_img?'.http_build_query($params);
|
|
|
$multy_url = [];
|
|
|
$multy_url['request_url'] = $url;
|
|
|
$multy_url['old_url'] = $last_url;
|
|
|
- $multy_urls[] = $multy_url;
|
|
|
+ $multy_urls[] = $multy_url;
|
|
|
}
|
|
|
|
|
|
// 最多尝试3次
|
|
|
$try_time = 0;
|
|
|
while($try_time < 3){
|
|
|
try{
|
|
|
- $url_mappings = self::multiRequest($multy_urls);
|
|
|
- \Log::info('$url_mappings');\Log::info($url_mappings);
|
|
|
- if(!empty($url_mappings)){
|
|
|
- \Log::info('multiRequest_success');
|
|
|
- break;
|
|
|
+ $url_mappings = self::multiRequest($multy_urls);
|
|
|
+ \Log::info('$url_mappings');\Log::info($url_mappings);
|
|
|
+ if(!empty($url_mappings)){
|
|
|
+ \Log::info('multiRequest_success');
|
|
|
+ break;
|
|
|
}
|
|
|
}catch(\Exception $e){
|
|
|
\Log::info('multiRequest_ept:'.$e->getMessage());
|
|
@@ -2818,28 +2819,28 @@ class CustomMsgService
|
|
|
|
|
|
foreach($url_mappings as $key=>$url_mapping){
|
|
|
\Log::info('replace_old_url:'.$url_mapping['old_url'].' new_url:'.$url_mapping['new_url']);
|
|
|
- $content = str_replace($url_mapping['old_url'], $url_mapping['new_url'], $content);
|
|
|
+ $content = str_replace($url_mapping['old_url'], $url_mapping['new_url'], $content);
|
|
|
}
|
|
|
return $content;
|
|
|
}
|
|
|
|
|
|
- static function multiRequest($data){
|
|
|
- $client = new Client(
|
|
|
- ['allow_redirects'=>true,
|
|
|
- 'timeout'=>120000]);
|
|
|
-
|
|
|
+ static function multiRequest($data){
|
|
|
+ $client = new Client(
|
|
|
+ ['allow_redirects'=>true,
|
|
|
+ 'timeout'=>120000]);
|
|
|
+
|
|
|
$promises = [];
|
|
|
- $mappings = [];
|
|
|
-
|
|
|
+ $mappings = [];
|
|
|
+
|
|
|
for($i=0;$i<count($data);$i++){
|
|
|
\Log::info('async_url:'.$data[$i]['request_url']);
|
|
|
- $promises[$i] = $client->getAsync($data[$i]['request_url']);
|
|
|
- }
|
|
|
+ $promises[$i] = $client->getAsync($data[$i]['request_url']);
|
|
|
+ }
|
|
|
$results = Promise\unwrap($promises);
|
|
|
-// \Log::info('multy_$results');\Log::info($results);
|
|
|
- $j = 0;
|
|
|
- foreach($data as $key=>&$v){
|
|
|
- $res = $results[$key]->getBody()->getContents();
|
|
|
+// \Log::info('multy_$results');\Log::info($results);
|
|
|
+ $j = 0;
|
|
|
+ foreach($data as $key=>&$v){
|
|
|
+ $res = $results[$key]->getBody()->getContents();
|
|
|
$res = json_decode($res,true);
|
|
|
\Log::info('res:'.$key.' res:'.json_encode($res));
|
|
|
$mappings[$key]['old_url'] = $data[$key]['old_url'];
|
|
@@ -2849,45 +2850,45 @@ class CustomMsgService
|
|
|
\Log::info('multiRequest_error_return:'.$data[$key]['old_url'].' res:'.json_encode($res).' request_url:'.$data[$key]['request_url']);
|
|
|
return null;
|
|
|
}
|
|
|
- }
|
|
|
- return $mappings;
|
|
|
+ }
|
|
|
+ return $mappings;
|
|
|
}
|
|
|
|
|
|
// 单个链接上传替换
|
|
|
static function one_upload_material_imgs($content,$last_urls){
|
|
|
\Log::info('one_upload_material_imgs_start');
|
|
|
- foreach($last_urls as $key=>$last_url){
|
|
|
- \Log::info('last_urls_count:'.count($last_urls).' now:'.$key);
|
|
|
- if(strpos($last_url,'mmbiz.qpic.cn') > -1){
|
|
|
- \Log::info('wx_url_continue:'.$last_url);
|
|
|
- continue;
|
|
|
- }
|
|
|
- $last_url = str_replace(array("&",""","amp;","quot;"), "", htmlspecialchars($last_url));
|
|
|
-
|
|
|
- // TODO 加try 3次?
|
|
|
- $i = 0;
|
|
|
- while($i < 3){
|
|
|
- try{
|
|
|
- \Log::info('child_upload_material_img_start:i'.$i.' last_url:'.$last_url);
|
|
|
- $param['img_url'] = $last_url;
|
|
|
- $upload_res = self::upload_material_img($param);
|
|
|
- \Log::info('$upload_res');\Log::info($upload_res);
|
|
|
- if($upload_res['code'] == 1){
|
|
|
- $content = str_replace($last_url, $upload_res['data']['url'], $content);
|
|
|
- break;
|
|
|
- }
|
|
|
- }catch(\Exception $e){
|
|
|
- \Log::info('upload_matrial_img_ept:'.$e->getMessage());
|
|
|
- sleep(1);
|
|
|
- }
|
|
|
- $i++;
|
|
|
- }
|
|
|
-
|
|
|
- if($i == 3){
|
|
|
- \Log::info('upload_matrial_img_return');
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
+ foreach($last_urls as $key=>$last_url){
|
|
|
+ \Log::info('last_urls_count:'.count($last_urls).' now:'.$key);
|
|
|
+ if(strpos($last_url,'mmbiz.qpic.cn') > -1){
|
|
|
+ \Log::info('wx_url_continue:'.$last_url);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $last_url = str_replace(array("&",""","amp;","quot;"), "", htmlspecialchars($last_url));
|
|
|
+
|
|
|
+ // TODO 加try 3次?
|
|
|
+ $i = 0;
|
|
|
+ while($i < 3){
|
|
|
+ try{
|
|
|
+ \Log::info('child_upload_material_img_start:i'.$i.' last_url:'.$last_url);
|
|
|
+ $param['img_url'] = $last_url;
|
|
|
+ $upload_res = self::upload_material_img($param);
|
|
|
+ \Log::info('$upload_res');\Log::info($upload_res);
|
|
|
+ if($upload_res['code'] == 1){
|
|
|
+ $content = str_replace($last_url, $upload_res['data']['url'], $content);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }catch(\Exception $e){
|
|
|
+ \Log::info('upload_matrial_img_ept:'.$e->getMessage());
|
|
|
+ sleep(1);
|
|
|
+ }
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($i == 3){
|
|
|
+ \Log::info('upload_matrial_img_return');
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return $content;
|
|
@@ -2907,14 +2908,14 @@ class CustomMsgService
|
|
|
if(isset($ff_urls[0])){
|
|
|
unset($ff_urls[0]);
|
|
|
}
|
|
|
- \Log::info('ff_matchs:');
|
|
|
+ \Log::info('ff_matchs:');
|
|
|
\Log::info($ff_urls);
|
|
|
|
|
|
// 背景图模式
|
|
|
//background: url("http://yueduyun.oss-cn-hangzhou.aliyuncs.com/book_chapter_image_test/5pNo6A7wqQmB1WgQygDjkOM9VZn2vXeY/1/1_0.jpg")
|
|
|
- preg_match_all('/background: url\((.*)\)/U',$content,$bg_matchs);
|
|
|
+ preg_match_all('/background: url\((.*)\)/U',$content,$bg_matchs);
|
|
|
$bg_urls = isset($bg_matchs[1])?$bg_matchs[1]:array();
|
|
|
- \Log::info('bg_urls:');
|
|
|
+ \Log::info('bg_urls:');
|
|
|
\Log::info($bg_urls);
|
|
|
|
|
|
$last_urls = array_merge($ff_urls,$bg_urls);
|