Commit 8f6bcc4f by 杨树贤

添加各种红包类型对应的常量

parent e2a313c2
Showing with 14 additions and 5 deletions
......@@ -18,8 +18,6 @@ class CheckIn extends Model
protected $table = 'check_in';
public $timestamps = false;
const INTEGRAL_TYPE_CHECK_IN = 1;
public function scopePage($query, $page = 1, $pageSize = 10)
{
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
......@@ -49,7 +47,7 @@ class CheckIn extends Model
return false;
}
//使用异步任务去添加流水
$data['integral_id'] = self::INTEGRAL_TYPE_CHECK_IN;
$data['integral_id'] = Integral::INTEGRAL_TYPE_CHECK_IN;
$task = new IntegralBillTask($data);
$result = Task::deliver($task);
if (!$result) {
......@@ -57,7 +55,7 @@ class CheckIn extends Model
}
//添加流水成功后,要把签到记录放到redis
$date = Carbon::now()->toDateString();
$hashKey = 'ic_welfare_integral_limit_' . self::INTEGRAL_TYPE_CHECK_IN;
$hashKey = 'ic_welfare_integral_limit_' . Integral::INTEGRAL_TYPE_CHECK_IN;
$userId = $data['user_id'];
$redis = new RedisModel();
$redis->hincrby($hashKey, $userId, 1);
......
......@@ -18,6 +18,13 @@ class Integral extends Model
protected $hidden = [];
const INTEGRAL_TYPE_INVITE_FRIEND = 1;
const INTEGRAL_TYPE_UPLOAD_GOODS = 2;
const INTEGRAL_TYPE_INTEGRAL_CODE = 3;
const INTEGRAL_TYPE_SHARE = 4;
const INTEGRAL_TYPE_OFFER = 5;
const INTEGRAL_TYPE_CHECK_IN = 6;
public function scopePage($query, $page = 1, $pageSize = 10)
{
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
......@@ -57,11 +64,15 @@ class Integral extends Model
if (!$result) {
ErrorLog(ErrorCode(18, '5'), '写入红包活动列表到Redis失败');
$count = Integral::where('status', 1)->count();
$integrals = $this->addIntegralListToRedis();
}
} else {
$count = $redis->hlen('ic_welfare_integrals');
}
$integrals = arraySequence($integrals, 'id', 'SORT_ASC');
if ($integrals) {
$integrals = arraySequence($integrals, 'id', 'SORT_ASC');
}
return ['data' => array_values($integrals), 'count' => $count];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment