|
@@ -16,9 +16,6 @@ use App\Modules\Activity\Services\ActivityService;
|
|
|
|
|
|
class UserSignService
|
|
|
{
|
|
|
- protected $table = 'user_sign';
|
|
|
- protected $fillable = ['uid', 'price', 'day', 'sign_time'];
|
|
|
-
|
|
|
/**
|
|
|
* 用户是否已签到
|
|
|
* @param $uid
|
|
@@ -46,71 +43,11 @@ 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();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 签到
|
|
|
- * @param $uid
|
|
|
- * @param $day
|
|
|
- * @return mixed
|
|
|
- */
|
|
|
- public static function sign($uid, $day)
|
|
|
- {
|
|
|
- \Log::info('sign: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;
|
|
|
- }
|
|
|
-
|
|
|
- $return_fee = $fee = 30;
|
|
|
- //连续签到两天 50书币
|
|
|
- if ($continue && $count >= 3) {
|
|
|
- $return_fee = $fee = 50;
|
|
|
- }
|
|
|
- if ($count % 15 == 7) {
|
|
|
- $fee += 100;
|
|
|
- }
|
|
|
- if ($count % 15 == 0) {
|
|
|
- $fee += 150;
|
|
|
- }
|
|
|
- UserService::addBalance($uid, $fee, 0, $fee);
|
|
|
- // 先扔到redis里面,异步更新user_sign表
|
|
|
- $use_redis_user_sign = true;
|
|
|
- if ($use_redis_user_sign) {
|
|
|
- $sign_data = ['uid' => $uid, 'price' => $fee, 'day' => $day, 'sign_time' => time(), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')];
|
|
|
- Redis::sadd('user_sign:uid', $uid);
|
|
|
- Redis::hset('user_sign:uid:info', $uid, json_encode($sign_data));
|
|
|
- ReadRecordService::setSignInfo($uid, json_encode($sign_data));
|
|
|
- } else {
|
|
|
- $user_sign_model = new UserSign();
|
|
|
- $user_sign_model->setCurrentTable(date('Ym'));
|
|
|
- $data = ['uid' => $uid, 'price' => $fee, 'day' => $day, 'sign_time' => time()];
|
|
|
- $user_sign_model->create($data);
|
|
|
- }
|
|
|
- return $return_fee;
|
|
|
- }
|
|
|
|
|
|
- public static function signV2($uid, $day)
|
|
|
+ public static function sign($uid, $day)
|
|
|
{
|
|
|
//查看签到日期
|
|
|
$sign_day = ReadRecordService::getSignDay($uid);
|
|
@@ -161,74 +98,11 @@ class UserSignService
|
|
|
return ['fee' => $fee, 'days' => $count];
|
|
|
}
|
|
|
|
|
|
- public static function getUserSignVersion($uid)
|
|
|
- {
|
|
|
- return 'v2';
|
|
|
- /*list($version, $sign_day, $count) = ReadRecordService::getByMultiField($uid, 'sign_version', 'sign_day', 'sign_counts');
|
|
|
- if ($version == 'v2') {
|
|
|
- return 'v2';
|
|
|
- }
|
|
|
- if ($version == 'v1') {
|
|
|
- if ($sign_day == date('Y-m-d')) {
|
|
|
- return $version;
|
|
|
- }
|
|
|
- if ($sign_day == date('Y-m-d', time() - 86400)) {
|
|
|
- if ($count % 15 == 0 ) {
|
|
|
- ReadRecordService::setByMultiField($uid, ['sign_counts' => 0, 'sign_version' => 'v2']);
|
|
|
- return 'v2';
|
|
|
- }
|
|
|
- return $version;
|
|
|
- }
|
|
|
-
|
|
|
- ReadRecordService::setByMultiField($uid, ['sign_version' => 'v2']);
|
|
|
- return 'v2';
|
|
|
- }
|
|
|
-
|
|
|
- if (!$count || !$sign_day) {
|
|
|
- ReadRecordService::setByMultiField($uid, ['sign_version' => 'v2']);
|
|
|
- return 'v2';
|
|
|
- }
|
|
|
-
|
|
|
- if ($sign_day == date('Y-m-d')) {
|
|
|
- self::setUserSignVersion($uid, 'v1');
|
|
|
- return 'v1';
|
|
|
- }
|
|
|
-
|
|
|
- if ($sign_day == date('Y-m-d', time() - 86400)) {
|
|
|
- if ($count % 15 == 0) {
|
|
|
- ReadRecordService::setByMultiField($uid, ['sign_counts' => 0, 'sign_version' => 'v2']);
|
|
|
- return 'v2';
|
|
|
- }
|
|
|
- self::setUserSignVersion($uid, 'v1');
|
|
|
- return 'v1';
|
|
|
- }
|
|
|
-
|
|
|
- self::setUserSignVersion($uid, 'v2');
|
|
|
- return 'v2';*/
|
|
|
- }
|
|
|
-
|
|
|
public static function setUserSignVersion($uid, $version)
|
|
|
{
|
|
|
ReadRecordService::setByField($uid, 'sign_version', $version);
|
|
|
}
|
|
|
|
|
|
- public static function signToday($uid, $version = '')
|
|
|
- {
|
|
|
- return self::signV2($uid, date('Y-m-d'));
|
|
|
- /*if(!$version){
|
|
|
- $version = self::getUserSignVersion($uid);
|
|
|
- }
|
|
|
- if($version == 'v1'){
|
|
|
- return self::sign($uid, date('Y-m-d'));
|
|
|
- }
|
|
|
-
|
|
|
- if($version == 'v2'){
|
|
|
- return self::signV2($uid, date('Y-m-d'));
|
|
|
- }
|
|
|
- return 0;*/
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 新签到回复
|
|
|
* @param $openid
|