|
@@ -292,6 +292,155 @@ class UserController extends BaseController
|
|
|
$data = ['sign_count'=>$sign_count,'fee'=>$fee,'fee_pool'=>$fee_pool,'day'=>$day,'book1'=>$book1,'book2'=>$book2,'tomorrow_fee'=>$tomorrow_pool[$tomorrow]];
|
|
|
return view($page,$data);
|
|
|
}
|
|
|
+ public function signV3(){
|
|
|
+ //修改签到页面,version=v2
|
|
|
+ $fee_pool = [0,30,50,120,50,50,50,150];
|
|
|
+ list($sign,$sign_count) = ReadRecordService::getByMultiField($this->uid,'sign_day','sign_counts');
|
|
|
+ $read_record = $this->getSignPageReadRecord($all_bid);
|
|
|
+ if(!$all_bid)$all_bid = [];
|
|
|
+ $user = $this->_user_info;
|
|
|
+ $recommend_book = $this->getSignRecomandBook($user->sex,$all_bid);
|
|
|
+ if ($sign && $sign == date('Y-m-d')) {
|
|
|
+ if ($sign_count % 7 == 1 && $sign_count<=7) {
|
|
|
+ $fee = 30;
|
|
|
+ } elseif ($sign_count % 7 == 3) {
|
|
|
+ $fee = 120;
|
|
|
+ } elseif ($sign_count % 7 == 0) {
|
|
|
+ $fee = 150;
|
|
|
+ } else {
|
|
|
+ $fee = 50;
|
|
|
+ }
|
|
|
+ if($sign_count >=8){
|
|
|
+ $fee_pool[1] = 50;
|
|
|
+ }
|
|
|
+ $day = $sign_count%7;
|
|
|
+ if($day == 0){
|
|
|
+ $day = 7;
|
|
|
+ }
|
|
|
+
|
|
|
+ //签过到了
|
|
|
+ $name = $user->nickname;
|
|
|
+ $head_img = $user->head_img;
|
|
|
+ $balance = $user->balance;
|
|
|
+ $data = ['sign_count'=>$sign_count,'fee'=>$fee,'fee_pool'=>$fee_pool,
|
|
|
+ 'day'=>$day,'is_alert'=>0,'read_record'=>$read_record,'name'=>$name,
|
|
|
+ 'head_img'=>$head_img,
|
|
|
+ 'balance'=>$balance,
|
|
|
+ 'recommend_book'=>$recommend_book
|
|
|
+ ];
|
|
|
+ return view('wap.signV3',$data);
|
|
|
+ }
|
|
|
+ $fee = UserSignService::signToday($this->uid,'v2');
|
|
|
+ if(!$fee){
|
|
|
+ return response()->error('WAP_SYS_ERROR');
|
|
|
+ }
|
|
|
+ $sign_count = ReadRecordService::getSignCount($this->uid);
|
|
|
+ //$sign_count++;
|
|
|
+ if($sign_count >=8){
|
|
|
+ $fee_pool[1] = 50;
|
|
|
+ }
|
|
|
+ $day = $sign_count%7;
|
|
|
+ if($day == 0){
|
|
|
+ $day = 7;
|
|
|
+ }
|
|
|
+ //签过到了
|
|
|
+ $name = $user->nickname;
|
|
|
+ $head_img = $user->head_img;
|
|
|
+ $balance = $user->balance;
|
|
|
+ $data = ['sign_count'=>$sign_count,'fee'=>$fee,'fee_pool'=>$fee_pool,
|
|
|
+ 'day'=>$day,'is_alert'=>1,'read_record'=>$read_record,
|
|
|
+ 'name'=>$name,
|
|
|
+ 'head_img'=>$head_img,
|
|
|
+ 'balance'=>$balance,
|
|
|
+ 'recommend_book'=>$recommend_book
|
|
|
+ ];
|
|
|
+ return view('wap.signV3',$data);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getSignPageReadRecord(&$all_id){
|
|
|
+ $res = ReadRecordService::getReadRecord($this->uid);
|
|
|
+ if($res){
|
|
|
+ $id_arr = [];
|
|
|
+ foreach ($res as $key => $value) {
|
|
|
+ if($key < 2){
|
|
|
+ $id_arr[] = $value['bid'];
|
|
|
+ }
|
|
|
+ $all_id[] = $value['bid'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $book = BookConfigService::getBooksByIds($id_arr);
|
|
|
+ foreach ($res as $key => &$value) {
|
|
|
+ $value['cover'] = '';
|
|
|
+ $value['url'] = sprintf('/reader?bid=%s&cid=%s',Hashids::encode($value['bid']),$value['cid']);
|
|
|
+ $value['last_chapter'] = 0;
|
|
|
+ $value['update_count'] = 0;
|
|
|
+ foreach ($book as $val) {
|
|
|
+ if($value['bid'] == $val->bid){
|
|
|
+ $value['cover'] = $val->cover;
|
|
|
+ $value['last_chapter'] = $val->last_chapter;
|
|
|
+ if($val->status == 0){
|
|
|
+ $value['update_count'] = DB::table('book_updates')
|
|
|
+ ->where('bid',$val->bid)->where('update_type','add_chapter')
|
|
|
+ ->where('created_at','>=',date('Y-m-d H:i:s',$value['time']))
|
|
|
+ ->sum('update_chapter_count');
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+ private function getSignRecomandBook(int $sex,array $all_bid):array
|
|
|
+ {
|
|
|
+ if($sex == 1){
|
|
|
+ $set_key = 'male_high_reco_bids';
|
|
|
+ }else{
|
|
|
+ $set_key = 'female_high_reco_bids';
|
|
|
+ }
|
|
|
+ $bids = Cookie::get('sign_recomand_bids');
|
|
|
+ if(!$bids){
|
|
|
+ $bid_array = Redis::Srandmember($set_key,16);
|
|
|
+ //Log::info($bid_array);
|
|
|
+ $time = strtotime(date('Y-m-d',time()+86400))-time();
|
|
|
+ $new_bid_array = [];
|
|
|
+ foreach ($bid_array as $item){
|
|
|
+ if(in_array($item,$all_bid)){
|
|
|
+ array_unshift($new_bid_array,$item);
|
|
|
+ }else{
|
|
|
+ array_push($new_bid_array,$item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $bids = implode(',',$new_bid_array);
|
|
|
+ Cookie::queue('sign_recomand_bids',$bids,$time);
|
|
|
+ }
|
|
|
+ //Log::info($bids);
|
|
|
+ $result = DB::select(sprintf('select book_configs.book_name,intro,bid,books.category_name,book_configs.cover,first_cid,
|
|
|
+(select GROUP_CONCAT(tags) from book_tags where bid = book_configs.bid and `status` = 1) as tag from book_configs
|
|
|
+left join books on books.id = book_configs.bid left join book_categories on book_categories.id = books.category_id
|
|
|
+where bid in (%s) and is_on_shelf =2 ORDER by field(book_configs.bid,%s)',$bids,$bids));
|
|
|
+ $data = [];
|
|
|
+ foreach ($result as $item){
|
|
|
+ $tag_list = [];
|
|
|
+ if($item->tag){
|
|
|
+ $tag_list = explode(',',$item->tag);
|
|
|
+ }
|
|
|
+ $data[] = [
|
|
|
+ 'book_name'=>$item->book_name,
|
|
|
+ 'intro'=>$item->intro,
|
|
|
+ 'bid'=>$item->bid,
|
|
|
+ 'category_name'=>$item->category_name,
|
|
|
+ 'cover'=>$item->cover,
|
|
|
+ 'tag'=>$item->tag,
|
|
|
+ 'tag_list'=>$tag_list,
|
|
|
+ 'url'=>sprintf('/reader?bid=%s&cid=%s&source=wechatmsg&fromtype=sign_recommend',Hashids::encode($item->bid),$item->first_cid),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
public function recordShare(Request $request){
|
|
|
if(!$this->checkUid()){
|