Commit 8f6bcc4f by 杨树贤

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

parent e2a313c2
Showing with 14 additions and 5 deletions
...@@ -18,8 +18,6 @@ class CheckIn extends Model ...@@ -18,8 +18,6 @@ class CheckIn extends Model
protected $table = 'check_in'; protected $table = 'check_in';
public $timestamps = false; public $timestamps = false;
const INTEGRAL_TYPE_CHECK_IN = 1;
public function scopePage($query, $page = 1, $pageSize = 10) public function scopePage($query, $page = 1, $pageSize = 10)
{ {
return $query->offset(($page - 1) * $pageSize)->limit($pageSize); return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
...@@ -49,7 +47,7 @@ class CheckIn extends Model ...@@ -49,7 +47,7 @@ class CheckIn extends Model
return false; return false;
} }
//使用异步任务去添加流水 //使用异步任务去添加流水
$data['integral_id'] = self::INTEGRAL_TYPE_CHECK_IN; $data['integral_id'] = Integral::INTEGRAL_TYPE_CHECK_IN;
$task = new IntegralBillTask($data); $task = new IntegralBillTask($data);
$result = Task::deliver($task); $result = Task::deliver($task);
if (!$result) { if (!$result) {
...@@ -57,7 +55,7 @@ class CheckIn extends Model ...@@ -57,7 +55,7 @@ class CheckIn extends Model
} }
//添加流水成功后,要把签到记录放到redis //添加流水成功后,要把签到记录放到redis
$date = Carbon::now()->toDateString(); $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']; $userId = $data['user_id'];
$redis = new RedisModel(); $redis = new RedisModel();
$redis->hincrby($hashKey, $userId, 1); $redis->hincrby($hashKey, $userId, 1);
......
...@@ -18,6 +18,13 @@ class Integral extends Model ...@@ -18,6 +18,13 @@ class Integral extends Model
protected $hidden = []; 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) public function scopePage($query, $page = 1, $pageSize = 10)
{ {
return $query->offset(($page - 1) * $pageSize)->limit($pageSize); return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
...@@ -57,11 +64,15 @@ class Integral extends Model ...@@ -57,11 +64,15 @@ class Integral extends Model
if (!$result) { if (!$result) {
ErrorLog(ErrorCode(18, '5'), '写入红包活动列表到Redis失败'); ErrorLog(ErrorCode(18, '5'), '写入红包活动列表到Redis失败');
$count = Integral::where('status', 1)->count(); $count = Integral::where('status', 1)->count();
$integrals = $this->addIntegralListToRedis();
} }
} else { } else {
$count = $redis->hlen('ic_welfare_integrals'); $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]; 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