200 , 'msg'=>'ok','extend'=>'']; // 会员活跃度 public static function vitality($user_id,$type) { if($type === false) return false; $type++; $redis = new Redis(); $check_key = date('Y-m-d').'_'.$user_id; // 当天是否登录 if(!$redis->get($check_key)) { $redis->set($check_key,86400); $year = date('Y'); $month = date('m'); $day = date('d'); $vitality_info= [ 'user_id'=>$user_id, 'year'=>$year, 'month'=>$month, 'day'=>$day, 'day_time'=>date('Y-m-d'), 'create_at'=>date('Y-m-d H:i:s'), 'type'=>$type ]; UserVitality::create($vitality_info); } } /** * 创建申请发票申请记录【申请开票】 * @param $user_id * @param $order_id * @param $order_type 订单类型 * @param $bill_info 发票抬头id||发票详情 * @param $add_id 售货地址id * @param $send_type 物流类型1点子发票2纸质发票 * @param $remark 备注 * @param $order_pay 订单是否完成支付 * @return array */ public static function buildBillApply($user_id, $order_id, $order_type,$bill_info,$add_id,$send_type,$remark,$order_pay = 1) { $order_table = [ 1=>'level_order',// 会员订单 2=>'store_order',// 商品订单 3=>'activity_apply',// 活动订单 ]; Db::startTrans(); try { $apply_info = [ 'order_id' => $order_id, 'table_name' => $order_table[$order_type], 'user_id' => $user_id, 'remark' => $remark, 'send_type' => $send_type, 'order_type' => $order_type, 'create_at' => date("Y-m-d H:i:s"), 'order_pay' => $order_pay, ]; if($add_id) { $add_info = DeliveryAddress::field('id,pro_name,city_name,county_name,mer_name,detail,phone,name')->where('user_id',$user_id)->where('id',$add_id)->find(); $apply_info['address_info'] = json_encode($add_info->toArray()); } if(is_array($bill_info)){ $apply_info['header'] = $bill_info['header']; $apply_info['type'] = $bill_info['type']; $apply_info['email'] =$bill_info['email']; // $apply_info['bank'] = $bill_info['bank']; // $apply_info['card_no'] = $bill_info['card_no']; // $apply_info['phone'] = $bill_info['phone']; $apply_info['identify_number'] = $bill_info['identify_number']; // $apply_info['address'] = $bill_info['address']; }else if($bill_info){ $bill_header = BillHeader::where('id',$bill_info) ->where('user_id',$user_id)->find(); if(empty($bill_header)) self::exception('发票抬头有误'); $apply_info['header'] = $bill_header->header; $apply_info['email'] = $bill_header->email; $apply_info['type'] = $bill_header->type; $apply_info['identify_number'] = $bill_header->identify_number; } $order_info = Db::name($order_table[$order_type]) ->where('user_id',$user_id) ->where('pay_state',1) ->where('id',$order_id) ->find(); if(empty($order_info) && !in_array($order_type ,[2,3]))self::exception('订单有误'); $check_info = BillApply::where('user_id',$user_id) ->where('order_id',$order_id) ->where('is_deleted',0) ->where('table_name',$order_table[$order_type]) ->find(); if(!empty($check_info) && $check_info->status == 1) self::exception('已开票'); $apply_info = BillApply::create($apply_info); static::$ret_val['extend'] = $apply_info->id ; Db::commit(); }catch (\Exception $e) { Db::rollback(); static::$ret_val['code'] = 201 ; static::$ret_val['msg'] = $e->getMessage(); } return static::$ret_val; } // 获取所有模块设置 public static function getAllModuleTitle() { // 视频 $video = VideoIntro::field('id,title,IF(id,\'video\',0) module')->with(['videoArr'=>function($query){ return $query->where('status',1)->field('id,title,video_id'); }])->where(['is_deleted'=>0])->where('status',1)->order('id desc')->select()->toArray(); array_walk($video,function (&$v){ $v['children'] = $v['video_arr']; unset($v['video_arr']); }); // 资料 $datum = DatumIntro::with(['urlArr'=>function($query){ return $query->field('id,title,datum_id'); }])->where(['is_deleted'=>0])->field('id,title,IF(id,\'datum\',0) module')->order('id desc')->select()->toArray(); array_walk($datum,function (&$v){ $v['children'] = $v['url_arr']; unset($v['url_arr']); }); // 图文 $article = ArticleIntro::with(['itemChildren'=>function($query){ return $query->field('id,title,article_id'); }])->field('id,title,IF(id,\'article\',0) module')->where(['is_deleted'=>0])->order('id asc')->select()->toArray(); array_walk($article,function (&$v){ $v['children'] = $v['item_children']; unset($v['item_children']); }); // $supplier_goods = SupplierGoods::alias('g')->field('g.id,g.supplier_id,g.name title,IF(g.id,\'supplier\',0) module')->where(['g.is_deleted'=>0]) // ->leftJoin('Supplier s', 's.id = g.supplier_id')->select()->toArray(); $supplier_goods = Db::name('supplier')->alias('g')->field('g.id,g.title,IF(g.id,\'supplier\',0) module')->where(['g.is_deleted'=>0]) ->where('status',1)->select(); foreach ($supplier_goods as $k => $v){ $supplier_goods[$k]['children'] = SupplierGoods::alias('g')->field('g.id,g.supplier_id,g.name title,IF(g.id,\'supplier\',0) module')->where(['g.is_deleted'=>0])->where('supplier_id',$v['id'])->where('g.status',1)->select()->toArray(); } // 新闻 $press = Press::field('id,title,IF(id,\'press\',0) module')->where('status',1)->where('is_deleted',0)->select()->toArray(); // 活动 $activity = \app\common\model\Activity::field('id,title,IF(id,\'activity\',0) module')->where('status',1)->where('is_deleted',0)->select()->toArray(); // 问答 $forum = UserForum::field('id,title,IF(id,\'forum\',0) module')->where('status',1)->where('is_deleted',0)->select()->toArray(); //需求 $demand = PlatformDemand::field('id,title,IF(id,\'demand\',0) module')->where('status',1)->where('is_deleted',0)->where('is_over','<>',1)->select()->toArray(); //招聘 $recruit = RecruitCate::field('id,title,IF(id,\'recruit\',0) module')->where('status',1)->where('is_deleted',0)->where('lev',3)->select()->toArray(); foreach ($recruit as $k => $v){ $recruit[$k]['children'] = Recruit::field('id,title,IF(id,\'recruit\',0) module')->where('status',1)->where('is_deleted',0)->where('third_classify',$v['id'])->select()->toArray(); } //商品 $mall = GoodsCate::field('id,title,IF(id,\'mall\',0) module')->where('status',1)->where('is_deleted',0)->where('lev',3)->select()->toArray(); foreach ($mall as $k => $v){ $mall[$k]['children'] = StoreGoods::field('id,name as title,IF(id,\'mall\',0) module')->where('status',1)->where('is_deleted',0)->where('third_classify',$v['id'])->select()->toArray(); } //热搜 // $top_search = TopSearch::field('id,title,IF(id,\'top_search\',0) module')->where('status',1)->where('is_deleted',0)->select()->toArray(); // var_dump($top_search);die; $top_search = [ ['id'=>1 , 'title' => '全部' ,'module'=>'top_search'], ['id'=>2 , 'title' => '问答','module'=>'top_search'], ['id'=>3 , 'title' => '视频','module'=>'top_search'], ['id'=>4 , 'title' => '图文','module'=>'top_search'], ['id'=>5 , 'title' => '资料','module'=>'top_search'], ['id'=>6 , 'title' => '新闻','module'=>'top_search'], ['id'=>7 , 'title' => '供应商','module'=>'top_search'], ['id'=>8 , 'title' => '需求','module'=>'top_search'], ['id'=>9 , 'title' => '招聘','module'=>'top_search'], ['id'=>10 , 'title' => '活动','module'=>'top_search'], ['id'=>11 , 'title' => '商品','module'=>'top_search'], ]; return array_merge($video,$datum,$article,$supplier_goods,$press,$forum,$activity,$demand,$recruit,$mall,$top_search); // return compact(['video','datum','article','supplier_goods']); } // 推荐 public static function getRecommendList($user_id,$module,$page,$page_num,$where_param =[],$sort_type= 0) { if(!$user_id) return['code'=>201,'msg'=>'会员id不能为空']; $redis = new Redis(); $redis_time= 86400; $redis_set = [ '0' => $module.'_'.$user_id.'_recommend_ids',// 全部推荐的id '1' => $module.'_'.$user_id.'_selected_recommend_ids',// 已查询过的推挤id '2' => $module.'_'.$user_id.'_un_recommend',// 非推荐的id '3' => $module.'_'.$user_id.'_selected_un_recommend',// 已查询过的非推荐的id '4' => $module.'_'.$user_id.'_total_num',// 总数量 '5' => $module.'_'.$user_id.'_switch',// 时间段内是否是已经查询 【1已查询过】 ]; $switch = $redis->get($redis_set[5]); if(!$switch) $redis->set($redis_set[5],1,$redis_time);// 设置已查询状态 // 第一页且没查询过数据 if(!$switch) { $redis->set($redis_set[0],'',$redis_time); $redis->set($redis_set[1],'',$redis_time); $redis->set($redis_set[2],'',$redis_time); $redis->set($redis_set[3],'',$redis_time); $redis->set($redis_set[4],0,$redis_time); } $module_set = [ 'video'=>[ 'type'=> 1, 'table'=>'dd_video_url', 'index_field'=>'title', 'select_field'=>' a.id,a.title,a.cover,a.user_id,a.is_vip,a.create_at,a.ali_vid,a.video_id,a.duration ,a.release_time,a.read_num', ], 'Intro'=>[ 'type'=> 1, 'table'=>'dd_datum_intro', 'index_field'=>'title', 'select_field'=>' *', ], 'article'=>[ 'type'=> 2, 'table'=>'dd_article_item', 'index_field'=>'title', 'select_field'=>' a.id,a.title,a.cover,a.content_type,a.pdf,a.images,a.create_at,a.user_id,a.is_vip,a.read_num,a.article_id ,a.author,a.release_time,a.desc ', ], 'datum'=>[ 'type'=> 3, 'table'=>'dd_datum_url', 'index_field'=>'title', 'select_field'=>' a.id,a.title,a.user_id,a.create_at,a.down_num,a.read_num,a.is_vip,a.datum_id,a.url ,a.is_encrypt,a.pdf_clear ,a.release_time ', ], 'forum'=>[ 'type'=> 6, 'table'=>'dd_user_forum', 'index_field'=>'title', 'select_field'=>' a.id,a.title,a.content,a.label,a.level,a.browse_num,a.sort,a.create_at,u.name,u.headimg ,a.release_time', ], 'activity'=>[ 'type'=> 11, 'table'=>'dd_activity', 'index_field'=>'title', 'select_field'=>' a.id,cover,a.user_id,a.province,a.city,a.county,a.address,title,a.status,address,a.read_num,a.label,a.start_time,a.end_time,a.release_time,u.name,u.headimg', ], 'demand'=>[ 'type'=> 5, 'table'=>'dd_platform_demand', 'index_field'=>'title', 'select_field'=>' a.id,a.cover,a.money,a.user_id,a.label,a.title,a.read_num,a.is_over,a.content ,a.release_time,a.desc', ], 'press'=>[ 'type'=> 4, 'table'=>'dd_press', 'index_field'=>'title', 'select_field'=>'a.id,a.title,a.label,a.images,a.read_num,a.transmit_num,a.user_id,a.create_at,a.release_time', ], 'recruit'=>[ 'type'=> 8, 'table'=>'dd_recruit', 'index_field'=>'title', 'select_field'=>'a.id,title,a.work_hours,a.user_id,label,salary,principal,hr_headimg,address,price_min,price_max,company,education,experience_min,experience_max,welfare,province,city,county ,a.release_time,a.company_intro,a.is_ss,a.scale', ], "supplier"=>[ 'type'=> 11, 'table'=>'dd_supplier_goods', 'index_field'=>'name', 'select_field'=>'a.id,a.supplier_id,a.name,a.label,a.cover,a.read_num,k.title supplier_name,k.logo supplier_logo,a.release_time', ], 'goods'=>[ 'type'=> 7, 'table'=>'dd_store_goods', 'index_field'=>'name', 'select_field'=>'a.id,name,cover,low_price,a.label,a.release_time,sale_num,a.user_id,specs', ] ]; $search_log = UserSearch::getSearchTitle($user_id,$module_set[$module]['type']); $search_arr = []; $where_str = 'b.id > 0'; foreach ($search_log as $t){ $search_arr[] = " b.".$module_set[$module]["index_field"]." like '".'%'.$t."%'" .' '; $search_arr[] = " b.label like '".'%'.$t."%'" .' '; } if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr); $time_str = date("Y-m-d H:i:s"); switch ($module) { case 'video': // 第一页查询 安排redis if(!$switch) { // 查询推荐id sql $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id Left JOIN dd_video_intro as k ON a.video_id = k.id WHERE a.is_deleted = 0 AND a.release_time < '".$time_str."' AND a.status =1 AND k.is_deleted = 0 AND k.status = 1 "; $all_recommend = Db::query($recommend_query); //return $recommend_query; $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = VideoUrl::where([['a.status','=',1],['a.is_deleted','=',0],['a.id','not in',$recommend_ids],['a.release_time','< time',$time_str]]) ->where(['k.status'=>1,'k.is_deleted'=>0]) ->alias('a') ->leftJoin('video_intro k','k.id = a.video_id') ->column('a.id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } $list1 = VideoUrl::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$recommend_ids)->orderRand('rand()')->limit($page_num)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : VideoUrl::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$un_recommend)->orderRand('rand()')->limit($num2)->select()->toArray(); $list = array_merge($list1,$list2); array_walk($list,function (&$v,$k){ $v['cover_type'] = $k%7 ? 0 : 1; $v['create_at'] = substr($v['create_at'],0,10); $info_auth = VideoUrl::getVideoAuth($v['user_id'],APPNAME,APPLOGO); $v['app_name'] = $info_auth['app_name']; $v['app_logo'] = $info_auth['app_logo']; $v['read_num'] = numTransform($v['read_num']); }); break; case 'Intro': // 第一页查询 安排redis $where_str = 'id > 0'; foreach ($search_log as $t){ $search_arr[] = $module_set[$module]["index_field"]." like '".'%'.$t."%'" .' '; $search_arr[] = "label like '".'%'.$t."%'" .' '; } // return $search_log; if($page == 1) { // 查询推荐id sql switch ($sort_type) { case 1: $order = ['sort'=>'desc','read_num'=>'desc']; break; case 2: $order = ['id'=>'asc','sort'=>'desc']; break; case 3: $order = ['id'=>'desc','sort'=>'desc']; break; } if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr); $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id WHERE a.is_deleted = 0 AND a.status =1"; $all_recommend = Db::query($recommend_query); // $all_recommend = DatumIntro::where($where_param) // ->alias('b') // ->where($where_str) // ->order($order) // ->column('id'); // return $all_recommend; $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = DatumIntro::where($where_param)->with('urlArr') // ->alias('b') ->where([['status','=',1],['is_deleted','=',0],['id','not in',$recommend_ids]]) // ->where(['status'=>1,'is_deleted'=>0]) // ->where($where_str) ->order($order) ->column('id'); // $un_recommend = VideoUrl::where([['a.status','=',1],['a.is_deleted','=',0],['a.id','not in',$recommend_ids],['a.release_time','< time',$time_str]]) // ->where(['k.status'=>1,'k.is_deleted'=>0]) // ->alias('a') // ->leftJoin('video_intro k','k.id = a.video_id') // ->column('a.id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } $list1 = DatumIntro::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$recommend_ids)->orderRand('rand()')->limit($page_num)->where('a.is_deleted',0)->where('a.status',1)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : DatumIntro::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$un_recommend)->orderRand('rand()')->limit($num2)->where('a.is_deleted',0)->where('a.status',1)->select()->toArray(); $list = array_merge($list1,$list2); // array_walk($list,function (&$v,$k){ // $v['cover_type'] = $k%7 ? 0 : 1; // $v['create_at'] = substr($v['create_at'],0,10); // $info_auth = VideoUrl::getVideoAuth($v['user_id'],APPNAME,APPLOGO); // $v['app_name'] = $info_auth['app_name']; // $v['app_logo'] = $info_auth['app_logo']; // $v['read_num'] = numTransform($v['read_num']); // }); break; case "article": if($page == 1) { // 查询推荐id sql $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id Left JOIN dd_article_intro as k ON k.id = a.article_id WHERE a.is_deleted = 0 AND a.release_time < '".$time_str."' AND a.status =1 AND k.status = 1 AND k.is_deleted = 0 "; $all_recommend = Db::query($recommend_query); $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = ArticleItem::where([['a.status','=',1],['a.is_deleted','=',0],['a.id','not in',$recommend_ids],['a.release_time','< time',$time_str]]) ->where(['k.status'=>1,'k.is_deleted'=>0]) ->alias('a') ->leftJoin('article_intro k','k.id = a.article_id')->column('a.id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } $list1 = ArticleItem::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$recommend_ids)->orderRand('rand()')->limit($page_num)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : ArticleItem::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$un_recommend)->orderRand('rand()')->limit($num2)->select()->toArray(); $list = array_merge($list1,$list2); array_walk($list,function (&$v,$k)use ($user_id){ $v['read_num'] = numTransform($v['read_num']); $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO); $v['app_name'] = $article_auth['app_name']; $v['app_logo'] = $article_auth['app_logo']; $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null; $v['create_at'] = substr($v['create_at'],0,10); $v['is_release'] = UserLearn::checkRelease($user_id,3,$v['id']); $v['is_collect']= UserCollect::checkCollectByType($user_id,3,$v['article_id'],$v['id']); $v['is_like'] = ArticleLike::where(['user_id'=>$user_id,'article_id'=>$v['article_id'],'item_id'=>$v['id']])->count(); $v['like_num'] = ArticleLike::where(['article_id'=>$v['article_id'],'item_id'=>$v['id']])->count(); $v['collect_num'] = UserCollect::getCollectNum(3,$v['article_id'],$v['id']); }); break; case "datum": if($page == 1) { // 查询推荐id sql $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id Left JOIN dd_datum_intro as k ON k.id = a.datum_id WHERE a.is_deleted = 0 AND a.release_time < '".$time_str."' AND a.status =1 AND k.status = 1 AND k.is_deleted = 0 "; $all_recommend = Db::query($recommend_query); $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = DatumUrl::where([['a.status','=',1],['a.is_deleted','=',0],['a.id','not in',$recommend_ids],['a.release_time','< time',$time_str]]) ->where(['k.status'=>1,'k.is_deleted'=>0]) ->alias('a') ->leftJoin('datum_intro k','k.id = a.datum_id')->column('a.id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } $list1 = DatumUrl::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$recommend_ids)->orderRand('rand()')->limit($page_num)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : DatumUrl::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$un_recommend)->orderRand('rand()')->limit($num2)->select()->toArray(); $list = array_merge($list1,$list2); array_walk($list,function (&$v,$k)use ($user_id){ $v['down_num'] = numTransform($v['down_num']); $v['read_num'] = numTransform($v['read_num']); $datum_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO); $v['app_name'] = $datum_auth['app_name']; $v['app_logo'] = $datum_auth['app_logo']; $v['create_at'] = substr($v['create_at'],0,10); $v['is_release'] = UserLearn::checkRelease($user_id,2,$v['id']); }); break; case "forum": if($page == 1) { // 查询推荐id sql // $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id WHERE a.is_deleted = 0 AND a.status = 1 AND is_recommend = 1 AND a.release_time < '".$time_str."'"; $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b) AS c ON c.id = a.id WHERE a.is_deleted = 0 AND a.status = 1 AND is_recommend = 1 AND a.release_time < '".$time_str."'"; // return $recommend_query; $all_recommend = Db::query($recommend_query); $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = UserForum::where([['status','=',1],['is_deleted','=',0],['id','not in',$recommend_ids],['release_time','< time',$time_str]])->column('id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } $list1 = UserForum::field($module_set[$module]['select_field'])->alias('a')->where('a.id','in',$recommend_ids)->leftJoin('store_member u','u.id = a.user_id')->orderRand('rand()')->limit($page_num)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : UserForum::field($module_set[$module]['select_field'])->alias('a')->where('a.id','in',$un_recommend)->leftJoin('store_member u','u.id = a.user_id')->orderRand('rand()')->limit($num2)->select()->toArray(); $list = array_merge($list1,$list2); $user_level = UserLevelRank::getUserVip($user_id); array_walk($list, function (&$v, $k) use ($user_level) { $v['label_name'] = $v['label'] ? explode(',', trim($v['label'], ',')) : null; $reply_num = ForumReply::where(['forum_id' => $v['id']])->where('is_deleted', 0)->count(); $v['reply_num'] = numTransform($reply_num); $v['browse_num'] = numTransform($v['browse_num']); if (!$v['name']) $v['name'] = APPNAME; if (!$v['headimg']) $v['headimg'] = APPLOGO; $v['open_vip'] = !$user_level && $v['level'] ? 1 : 0; }); break; case "activity": if($page == 1) { // 查询推荐id sql $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id WHERE a.is_deleted = 0 AND a.status = 1 AND is_recommend = 1 AND a.release_time < '".$time_str."'"; $all_recommend = Db::query($recommend_query); $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = \app\common\model\Activity::where([['status','=',1],['is_deleted','=',0],['id','not in',$recommend_ids],['release_time','< time',$time_str]])->column('id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } $list1 = \app\common\model\Activity::field($module_set[$module]['select_field'])->alias('a')->where('a.id','in',$recommend_ids)->leftJoin('store_member u','u.id = a.user_id')->orderRand('rand()')->limit($page_num)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : \app\common\model\Activity::field($module_set[$module]['select_field'])->alias('a')->where('a.id','in',$un_recommend)->leftJoin('store_member u','u.id = a.user_id')->orderRand('rand()')->limit($num2)->select()->toArray(); $list = array_merge($list1,$list2); array_walk($list,function (&$v,$k)use ($user_id){ $v['read_num'] = numTransform( $v['read_num']); $v['cover_arr'] = $v['cover'] ? explode('|',$v['cover']) : null; $v['cover'] = $v['cover_arr'] ? $v['cover_arr'][0]:null; $v['is_apply'] = ActivityApply::checkApply($user_id,$v['id']); $v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')): null; }); break; case "demand": if($page == 1) { // 查询推荐id sql $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id WHERE a.is_deleted = 0 AND a.status = 1 AND is_recommend = 1 AND a.release_time < '".$time_str."'" . " AND is_over =" . $where_param['is_over']; $all_recommend = Db::query($recommend_query); $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = PlatformDemand::where([['status','=',1],['is_deleted','=',0],['id','not in',$recommend_ids],['release_time','< time',$time_str],['is_over','=',$where_param['is_over']]])->column('id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } $list1 = PlatformDemand::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$recommend_ids)->where('a.is_over',$where_param['is_over'])->orderRand('rand()')->limit($page_num)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : PlatformDemand::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$un_recommend)->where('a.is_over',$where_param['is_over'])->orderRand('rand()')->limit($num2)->select()->toArray(); $list = array_merge($list1,$list2); array_walk($list,function (&$v,$k){ $info_auth = PlatformDemand::getAuth($v['user_id'],APPNAME,APPLOGO); $v['app_name'] = $info_auth['app_name']; $v['app_logo'] = $info_auth['app_logo']; $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null; $v['cover_arr'] = explode('|',trim($v['cover'],'|')); $v['read_num'] = numTransform($v['read_num']); }); break; case "press": // 第一页查询 安排redis if($page == 1) { // 查询推荐id sql $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id WHERE a.is_deleted = 0 AND a.status = 1 AND is_recommend = 1 AND a.release_time < '".$time_str."'"; $all_recommend = Db::query($recommend_query); $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = Press::where([['status','=',1],['is_deleted','=',0],['id','not in',$recommend_ids],['release_time','< time',$time_str]])->column('id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } $list1 = Press::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$recommend_ids)->orderRand('rand()')->limit($page_num)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : Press::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$un_recommend)->orderRand('rand()')->limit($num2)->select()->toArray(); $list = array_merge($list1,$list2); array_walk($list,function (&$v,$k)use ($user_id){ $v['read_num'] = numTransform($v['read_num']); $v['transmit_num'] = numTransform($v['transmit_num']); $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null; $v['images_arr'] = $v['images']? explode('|',trim($v['images'],'|')):null; $info_auth = \app\common\model\Press::getInfoAuth($v['user_id'],APPNAME,APPLOGO); $v['app_name'] = $info_auth['app_name']; $v['app_logo'] = $info_auth['app_logo']; $v['comment_num'] = PressComment::getCommentNum($v['id']); $v['is_collect'] = UserCollect::checkCollectByType($user_id,4,$v['id']); $v['collect_num'] = UserCollect::getCollectNum(4,$v['id']); $v['is_praise'] = PlatformLike::checkTags($user_id,$v['id'],1); $v['praise_num'] = PlatformLike::getPraiseNum($v['id'],1); $v['switch_open'] = PlatformSwitch::checkSwitch($user_id,$v['id'],10); }); shuffle($list); break; case "recruit": if(!$switch) { // 查询推荐id sql $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id WHERE a.is_deleted = 0 AND a.status = 1 AND is_recommend = 1 AND a.release_time < '".$time_str."'"; if(isset($where_param['city']) && $where_param['city']) $recommend_query .=" AND a.city LIKE '".'%'.$where_param['city']."%'" ; // if(isset($where_param['education']) && $where_param['education']) $recommend_query .=" AND a.education = ".$where_param['education'] ; $all_recommend = Db::query($recommend_query); $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = Recruit::where([['status','=',1],['is_deleted','=',0],['id','not in',$recommend_ids],['release_time','< time',$time_str]]) ->when($where_param,function ($query)use ($where_param){ if(isset($where_param['city']) && $where_param['city']) $query->where('city','like','%'.$where_param['city'].'%'); if(isset($where_param['education']) && $where_param['education']) $query->where('education','=',$where_param['education']); }) ->column('id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } $list1 = Recruit::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$recommend_ids) ->when($where_param,function ($query)use ($where_param){ if(isset($where_param['city']) && $where_param['city']) $query->where('a.city','like','%'.$where_param['city'].'%'); }) ->orderRand('rand()')->limit($page_num)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : Recruit::field($module_set[$module]['select_field'])->alias('a') ->when($where_param,function ($query)use ($where_param){ if(isset($where_param['city']) && $where_param['city']) $query->where('a.city','like','%'.$where_param['city'].'%'); }) ->where('id','in',$un_recommend)->orderRand('rand()')->limit($num2)->select()->toArray(); $list = array_merge($list1,$list2); array_walk($list,function (&$v,$k){ $auth_info = \app\common\model\Recruit::getAuth($v['user_id'],APPNAME,APPLOGO); $v['app_name'] = $auth_info['app_name']; $v['app_logo'] = $auth_info['app_logo']; $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null; $v['welfare_arr'] = explode(',',trim($v['welfare'],',')); }); break; case "supplier": if($page == 1) { // 查询推荐id sql $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id LEFT JOIN dd_supplier as k ON a.supplier_id = k.id WHERE a.is_deleted = 0 AND a.status = 1 AND k.status =1 AND k.is_deleted = 0 AND a.release_time < '".$time_str."'"; $all_recommend = Db::query($recommend_query); $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = SupplierGoods::where([['a.status','=',1],['a.is_deleted','=',0],['a.id','not in',$recommend_ids],['a.release_time','< time',$time_str],['k.status','=',1],['k.is_deleted','=',0]])->leftJoin('Supplier k','k.id = a.supplier_id')->alias('a')->column('a.id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } switch ($sort_type) { case 1: $order = ['c.is_top'=>'desc','c.id'=>'desc','c.like_times'=>'desc']; break; case 2: $order = ['c.is_top'=>'desc','c.like_times'=>'desc','c.id'=>'asc']; break; } $list1 = SupplierGoods::field($module_set[$module]['select_field'])->alias('a')->where('a.id','in',$recommend_ids)->leftJoin('Supplier k','k.id = a.supplier_id')->orderRand('rand()')->limit($page_num)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : SupplierGoods::field($module_set[$module]['select_field'])->alias('a')->where('a.id','in',$un_recommend)->leftJoin('Supplier k','k.id = a.supplier_id')->orderRand('rand()')->limit($num2)->select()->toArray(); $list = array_merge($list1,$list2); array_walk($list,function (&$v,$k){ $v['read_num'] = numTransform($v['read_num']); $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null; $v['cover_arr'] = $v['cover']? explode('|',trim($v['cover'],'|')):null; }); break; case "goods": if($page == 1) { // 查询推荐id sql $recommend_query = "SELECT a.id FROM " .$module_set[$module]['table'] . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM ".$module_set[$module]['table']." b WHERE ( $where_str )) AS c ON c.id = a.id WHERE a.is_deleted = 0 AND a.status = 1 AND is_recommend = 1 AND a.release_time < '".$time_str."'"; $all_recommend = Db::query($recommend_query); $recommend_ids = array_column($all_recommend,'id');// 推荐的 $un_recommend = \app\common\model\StoreGoods::where([['status','=',1],['is_deleted','=',0],['id','not in',$recommend_ids],['release_time','< time',$time_str]])->column('id'); $redis->set($redis_set[0],implode(',',$recommend_ids),$redis_time); $redis->set($redis_set[2],implode(',',$un_recommend),$redis_time); $redis->set($redis_set[4],count($recommend_ids) + count($un_recommend),$redis_time); }else{ $recommend_ids = $redis->get($redis_set[0]);// 所有推荐的id $recommend_ids = $recommend_ids ? explode(',',$recommend_ids) : []; $un_recommend = $redis->get($redis_set[2]);// 所有非推荐的id $un_recommend = $un_recommend ? explode(',',$un_recommend) : []; } $list1 = \app\common\model\StoreGoods::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$recommend_ids)->orderRand('rand()')->limit($page_num)->select()->toArray(); $num2 = $page_num - count($list1); $list2 = $num2 <=0 ? [] : \app\common\model\StoreGoods::field($module_set[$module]['select_field'])->alias('a')->where('id','in',$un_recommend)->orderRand('rand()')->limit($num2)->select()->toArray(); $list = array_merge($list1,$list2); array_walk($list,function (&$v,$k)use ($user_id){ $v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')): null; $v['specs'] = json_decode($v['specs'],true); $v['item_list'] = StoreGoodsItem::getGoodsSpec($v['id']); $v['min_price'] = empty($v['item_list']) ? 0 : min(array_column($v['item_list'],'sell_price')); $v['max_price'] = empty($v['item_list']) ? 0 : max(array_column($v['item_list'],'sell_price')); $v['virtual'] = StoreGoods::getVirtualNum($v['id']); }); break; } if(!empty($list1)) { $select1 = array_column($list1,'id');// 本次查询出推荐的id $diff = array_diff($recommend_ids,$select1); $redis->set($redis_set[0],implode(',',$diff),$redis_time);// 更新推荐的redis缓存 $has_sel_re = $redis->get($redis_set[1]);// 已查询过推荐的id $new_sel_re = array_merge($select1,explode(',',$has_sel_re)); $redis->set($redis_set[1],implode(',',$new_sel_re),$redis_time);// 更新已经查询的推荐的id } if(!empty($list2)) { $select2 = array_column($list2,'id');// 本次查询出推荐的id $diff = array_diff($un_recommend,$select2); $redis->set($redis_set[2],implode(',',$diff),$redis_time);// 更新非推荐的redis缓存 $has_sel_un = $redis->get($redis_set[3]);// 已查询过非推荐的id $new_sel_un = array_merge($select2,explode(',',$has_sel_un)); $redis->set($redis_set[3],implode(',',$new_sel_un),$redis_time);// 更新已经查询的非推荐的id } // 查询数据不足 if(count($list) < $page_num) { $redis->set($redis_set[5],0,$redis_time);// 设置已查询状态 }else{ $residue_recommend_ids = $redis->get($redis_set[0]);// 所有剩余推荐的id // return $residue_recommend_ids; $residue_recommend_ids = $residue_recommend_ids ? explode(',',$residue_recommend_ids) : []; $residue_un_recommend = $redis->get($redis_set[2]);// 所有剩余非推荐的id $residue_un_recommend = $residue_un_recommend ? explode(',',$residue_un_recommend) : []; // 没有剩余数据 if(count($residue_recommend_ids) + count($residue_un_recommend) == 0) { $redis->set($redis_set[5],0,$redis_time);// 设置已查询状态 } } return ['code'=>200,'list'=>$list,'total_count'=>$redis->get($redis_set[4],0),'page_num'=>$page_num,'user_id'=>$user_id]; } // 短信发送 public static function phoneMessageSend($phone,$key,$data) { $mud_arr = []; $mud_arr[0] = [ 'name'=> '会前1天',//模板名称 'tem_code'=> 'SMS_460985703',// 模板code 'param' => [ 'ActivityName'=>isset($data['ActivityName']) ? $data['ActivityName'] : '' , 'time'=>isset($data['time']) ? $data['time'] : '' , 'adress'=>isset($data['adress']) ? $data['adress'] : '' , 'url'=> isset($data['url']) ? $data['url'] : '' , ] ]; $mud_arr[1] = [ 'name'=> '免费票有审核,审核成功',//模板名称 'tem_code'=> 'SMS_460970747',// 模板code 'param' => [ 'ActivityName'=>isset($data['ActivityName']) ? $data['ActivityName'] : '' , 'url'=> isset($data['url']) ? $data['url'] : '' , ] ]; $mud_arr[2] = [ 'name'=> ' 后台主动修改时间地点短信短信通知',//模板名称 'tem_code'=> 'SMS_461030378',// 模板code 'param' => [ 'ActivityName'=>isset($data['ActivityName']) ? $data['ActivityName'] : '' , 'time'=>isset($data['time']) ? $data['time'] : '' , 'adress'=>isset($data['adress']) ? $data['adress'] : '' , ] ]; AlibabaCloud::accessKeyClient('LTAI5tJ5p12drZegeWVG33xZ', '82UWAiY5e5wH8tSkRvMtqVoGO0h8SB')->regionId('cn-hangzhou')->asDefaultClient(); try { $result = AlibabaCloud::rpc() ->product('Dysmsapi') ->version('2017-05-25') ->action('SendSms') ->method('POST') ->host('dysmsapi.aliyuncs.com') ->options([ 'query' => [ 'RegionId' => "cn-hangzhou", 'PhoneNumbers' => $phone, 'SignName' => "搞一下汽车电子", 'TemplateCode' => $mud_arr[$key]['tem_code'], 'TemplateParam' => json_encode($mud_arr[$key]['param']), ], ])->request(); $result = $result->toArray(); if($result['Code'] != "OK") return ['code'=>201,'msg'=>'发送失败']; } catch (ClientException $e) { return ['code'=>201,'msg'=>$e->getErrorMessage().PHP_EOL]; } catch (ServerException $e) { return ['code'=>201,'msg'=>$e->getErrorMessage().PHP_EOL]; }catch (\Exception $e){ return ['code'=>201,'msg'=>$e->getMessage()]; } return ['code'=>200,'msg'=>'发送成功']; } // 邮件推送 public static function emailSend($email,$title) { if(!strpos($email,'@'))return ['code'=>201,'msg'=>'邮箱格式有误']; require_once env('root_path').'vendor/aliyunmail/aliyun-php-sdk-core/Config.php'; $iClientProfile = \DefaultProfile::getProfile("cn-hangzhou", "LTAI5tJ5p12drZegeWVG33xZ", "82UWAiY5e5wH8tSkRvMtqVoGO0h8SB"); $client = new \DefaultAcsClient($iClientProfile); $request = new Dm\SingleSendMailRequest(); $request->setAccountName("gyx@yzm.gyxqcdz.com"); $request->setFromAlias("活动提示"); $request->setAddressType(1); $request->setTagName("activity"); $request->setReplyToAddress("true"); $request->setToAddress($email); $request->setSubject("活动提示"); $html_body = '您报名的活动'.$title.'已发生变更。'; $request->setHtmlBody($html_body); $send_res = $client->getAcsResponse($request); return ['code'=>200,'msg'=>'发送成功']; } //门票邮件推送 public static function ticketSend($ticket_id) { $ticket_info = ActivityApplyItem::where('id',$ticket_id)->find()->toArray(); if(!$ticket_info['email']) return ['code'=>201,'msg'=>'邮件为空']; if(!strpos($ticket_info['email'],'@'))return ['code'=>201,'msg'=>'邮箱格式有误']; $email = $ticket_info['email']; $act_info = \app\common\model\Activity::where('id',$ticket_info['act_id'])->find()->toArray(); $sponsor_info = ActivitySponsor::where('id',$act_info['sponsor_id'])->find(); require_once env('root_path').'vendor/aliyunmail/aliyun-php-sdk-core/Config.php'; $iClientProfile = \DefaultProfile::getProfile("cn-hangzhou", "LTAI5tJ5p12drZegeWVG33xZ", "82UWAiY5e5wH8tSkRvMtqVoGO0h8SB"); $client = new \DefaultAcsClient($iClientProfile); $request = new Dm\SingleSendMailRequest(); $request->setAccountName("gyx@yzm.gyxqcdz.com"); $request->setFromAlias("活动提示"); $request->setAddressType(1); $request->setTagName("activity"); $request->setReplyToAddress("true"); $request->setToAddress($email); $request->setSubject("活动提示"); $act_title = $act_info['title']; $user_name =$ticket_info['name']; $qr_code = $ticket_info['qr_code']; $qr_content= $ticket_info['qr_content']; $server_url1= 'https://'.$_SERVER['SERVER_NAME'].'/static/t1.png'; $server_url2= 'https://'.$_SERVER['SERVER_NAME'].'/static/t2.png'; $server_url3= 'https://'.$_SERVER['SERVER_NAME'].'/static/t3.png'; $sponsor_name = $sponsor_info ? $sponsor_info->title : '官方主办'; $time = $act_info['start_time'].'-'.$act_info['end_time']; $address = $act_info['province'].$act_info['city'].$act_info['county'].$act_info['address']; $html_body = "