|
@@ -27,7 +27,6 @@ class UserSignService
|
|
|
*/
|
|
|
public static function isSign($uid)
|
|
|
{
|
|
|
- //return UserSign::isSign($uid, $day);
|
|
|
$sign_day = ReadRecordService::getSignDay($uid);
|
|
|
//异常
|
|
|
if ($sign_day == -1) {
|
|
@@ -47,7 +46,7 @@ class UserSignService
|
|
|
{
|
|
|
$UserSignModel = new UserSign();
|
|
|
$UserSignModel->setCurrentTable(date('Ym'));
|
|
|
- return $UserSignModel->where('uid',$uid)->where('day','<',date('Y-m-d'))->select('price','sign_time')->orderBy('sign_time','desc')->paginate();
|
|
|
+ return $UserSignModel->where('uid', $uid)->where('day', '<', date('Y-m-d'))->select('price', 'sign_time')->orderBy('sign_time', 'desc')->paginate();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -74,12 +73,12 @@ class UserSignService
|
|
|
if ($sign_day && $sign_day == date('Y-m-d', time() - 86400)) {
|
|
|
$continue = true;
|
|
|
//昨天有签过到
|
|
|
- ReadRecordService::sign((int)$uid, true);
|
|
|
+ ReadRecordService::sign((int) $uid, true);
|
|
|
$count += 1;
|
|
|
} else {
|
|
|
$continue = false;
|
|
|
//昨天没有签过到
|
|
|
- ReadRecordService::sign((int)$uid, false);
|
|
|
+ ReadRecordService::sign((int) $uid, false);
|
|
|
$count = 1;
|
|
|
}
|
|
|
|
|
@@ -105,7 +104,7 @@ class UserSignService
|
|
|
} else {
|
|
|
$user_sign_model = new UserSign();
|
|
|
$user_sign_model->setCurrentTable(date('Ym'));
|
|
|
- $data = ['uid'=>$uid,'price'=>$fee,'day'=>$day,'sign_time'=>time()];
|
|
|
+ $data = ['uid' => $uid, 'price' => $fee, 'day' => $day, 'sign_time' => time()];
|
|
|
$user_sign_model->create($data);
|
|
|
}
|
|
|
return $return_fee;
|
|
@@ -113,33 +112,28 @@ class UserSignService
|
|
|
|
|
|
public static function signV2($uid, $day)
|
|
|
{
|
|
|
- \Log::info('signv2:uid:' . $uid . ' day:' . $day);
|
|
|
//查看签到日期
|
|
|
$sign_day = ReadRecordService::getSignDay($uid);
|
|
|
if ($sign_day == -1) {
|
|
|
return false;
|
|
|
}
|
|
|
- //已经签过到
|
|
|
- if ($sign_day == $day) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
$count = ReadRecordService::getSignCountSimple($uid);
|
|
|
- //记录签到日期
|
|
|
- if ($sign_day && $sign_day == date('Y-m-d', time() - 86400)) {
|
|
|
- $continue = true;
|
|
|
- //昨天有签过到
|
|
|
- ReadRecordService::sign((int)$uid, true);
|
|
|
- $count += 1;
|
|
|
- } else {
|
|
|
- $continue = false;
|
|
|
- //昨天没有签过到
|
|
|
- ReadRecordService::sign((int)$uid, false);
|
|
|
- $count = 1;
|
|
|
+
|
|
|
+ if ($sign_day != $day) {
|
|
|
+ //记录签到日期
|
|
|
+ if ($sign_day && $sign_day == date('Y-m-d', time() - 86400)) {
|
|
|
+ //昨天有签过到
|
|
|
+ ReadRecordService::sign((int) $uid, true);
|
|
|
+ $count += 1;
|
|
|
+ } else {
|
|
|
+ //昨天没有签过到
|
|
|
+ ReadRecordService::sign((int) $uid, false);
|
|
|
+ $count = 1;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$fee = 30;
|
|
|
- if ($count % 7 == 1 && $count<=7) {
|
|
|
+ if ($count % 7 == 1 && $count <= 7) {
|
|
|
$fee = 30;
|
|
|
} elseif ($count % 7 == 3) {
|
|
|
$fee = 120;
|
|
@@ -148,6 +142,10 @@ class UserSignService
|
|
|
} else {
|
|
|
$fee = 50;
|
|
|
}
|
|
|
+ //已经签过到
|
|
|
+ if ($sign_day == $day) {
|
|
|
+ return ['fee' => $fee, 'days' => $count];
|
|
|
+ }
|
|
|
UserService::addBalance($uid, $fee, 0, $fee);
|
|
|
// 先扔到redis里面,异步更新user_sign表
|
|
|
$use_redis_user_sign = true;
|
|
@@ -159,10 +157,10 @@ class UserSignService
|
|
|
} else {
|
|
|
$user_sign_model = new UserSign();
|
|
|
$user_sign_model->setCurrentTable(date('Ym'));
|
|
|
- $data = ['uid'=>$uid,'price'=>$fee,'day'=>$day,'sign_time'=>time()];
|
|
|
+ $data = ['uid' => $uid, 'price' => $fee, 'day' => $day, 'sign_time' => time()];
|
|
|
$user_sign_model->create($data);
|
|
|
}
|
|
|
- return $fee;
|
|
|
+ return ['fee' => $fee, 'days' => $count];
|
|
|
}
|
|
|
|
|
|
public static function getUserSignVersion($uid)
|
|
@@ -216,7 +214,7 @@ class UserSignService
|
|
|
ReadRecordService::setByField($uid, 'sign_version', $version);
|
|
|
}
|
|
|
|
|
|
- public static function signToday($uid,$version='')
|
|
|
+ public static function signToday($uid, $version = '')
|
|
|
{
|
|
|
return self::signV2($uid, date('Y-m-d'));
|
|
|
/*if(!$version){
|
|
@@ -266,11 +264,11 @@ class UserSignService
|
|
|
}
|
|
|
|
|
|
$res = ReadRecordService::getReadRecord($user->uid);
|
|
|
-// foreach ($res as $key => $record) {
|
|
|
-// if ($key == 1) break;
|
|
|
-// $url = env('PROTOCOL') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/reader?bid=' . Hashids::encode($record['bid']) . '&cid=' . $record['cid'];
|
|
|
-// $content .= "\n\n" . '<a href="' . $url . '"> ☞ 《' . $record['book_name'] . '》</a>';
|
|
|
-// }
|
|
|
+ // foreach ($res as $key => $record) {
|
|
|
+ // if ($key == 1) break;
|
|
|
+ // $url = env('PROTOCOL') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/reader?bid=' . Hashids::encode($record['bid']) . '&cid=' . $record['cid'];
|
|
|
+ // $content .= "\n\n" . '<a href="' . $url . '"> ☞ 《' . $record['book_name'] . '》</a>';
|
|
|
+ // }
|
|
|
|
|
|
$read_bid_arr = [];
|
|
|
$read_bid_arr[] = -1;
|
|
@@ -319,7 +317,8 @@ class UserSignService
|
|
|
$status = self::newUserActivityStatus($user->uid);
|
|
|
$record = [];
|
|
|
//新关未付费用户42小时后充推送活动 68元的活动 文案:全年免费看书
|
|
|
- if (strtotime($user->created_at) + 42 * 3600 < time() &&
|
|
|
+ if (
|
|
|
+ strtotime($user->created_at) + 42 * 3600 < time() &&
|
|
|
$user->distribution_channel_id == 123 &&
|
|
|
!in_array(1, $status)
|
|
|
) {
|
|
@@ -363,9 +362,7 @@ class UserSignService
|
|
|
if ($data) {
|
|
|
try {
|
|
|
DB::table('user_sign_push_activity')->insert($data);
|
|
|
- } catch (\Exception $e) {
|
|
|
-
|
|
|
- }
|
|
|
+ } catch (\Exception $e) { }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -469,7 +466,6 @@ class UserSignService
|
|
|
|
|
|
if (time() < strtotime($activity_info->start_time) || time() > strtotime($activity_info->end_time)) {
|
|
|
return false;
|
|
|
-
|
|
|
}
|
|
|
$user = UserService::getById($uid);
|
|
|
if (empty($user))
|