12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace App\Modules\Activity\Services;
- use App\Modules\Product\Models\Product;
- /**
- * 个人微信号——国庆活动
- *
- * @property int $start_time 活动开始时间
- * @property int $end_time 活动结束时间
- * @property string $title 活动名称
- * @property int $product_id 活动充值选项id
- * @property array $sign_config 活动签到配置
- * @property \App\Modules\Product\Models\Product $product 活动充值选项
- * @property bool $is_begin 活动是否开始
- * @property bool $is_end 活动是否结束
- * @property string $redis_key redis键值
- */
- trait NationalDay
- {
- public $start_time;
- public $end_time;
- public $title;
- public $product_id;
- public $product;
- public $sign_config;
- public $is_begin;
- public $is_end;
- private $redis_key;
- public function __construct()
- {
- $this->start_time = strtotime('2019-10-01');
- $this->end_time = strtotime('2019-10-08');
- $this->title = "十月金秋&国庆666书币福利";
- $this->product_id = 7498;
- $this->product = $this->getProduct();
- $this->sign_config = [
- ['day' => 1, 'bonus' => 50, 'is_strong' => false],
- ['day' => 2, 'bonus' => 50, 'is_strong' => false],
- ['day' => 3, 'bonus' => 100, 'is_strong' => true],
- ['day' => 4, 'bonus' => 50, 'is_strong' => false],
- ['day' => 5, 'bonus' => 50, 'is_strong' => false],
- ['day' => 6, 'bonus' => 50, 'is_strong' => false],
- ['day' => 7, 'bonus' => 266, 'is_strong' => true],
- ];
- $this->redis_key = 'activity_national_day:' . date('Ymd');
- $this->is_begin = time() >= $this->start_time;
- $this->is_end = time() >= $this->end_time;
- }
- /**
- * 获取签到奖励
- * @param int $days 累计签到天数
- * @return int
- */
- protected function getSignBonusMoney(int $days)
- {
- $config = collect($this->sign_config)->where('day', $days)->first();
- return $config ? $config['bonus'] : 0;
- }
- private function getProduct()
- {
- return Product::find($this->product_id);
- }
- }
|