PHPackages                             olaf/clock - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. olaf/clock

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

olaf/clock
==========

Clock every day and Carve up cash

v1.0.12(5y ago)2233PHPPHP &gt;=7.0

Since Feb 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/JasonWoWo/clock)[ Packagist](https://packagist.org/packages/olaf/clock)[ RSS](/packages/olaf-clock/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

### 1.参与活动流程图

[](#1参与活动流程图)

### 2.包安装

[](#2包安装)

#### 2.1 项目composer更新

[](#21-项目composer更新)

2.1.1 execute composer

```
composer require "olaf/clock": "dev-master"
```

#### 2.2 Provider配置文件

[](#22-provider配置文件)

 2.2.1 Open your `config/app.php` and add the following to the `providers` array:

```
Happy\Clock\ClockServiceProvider::class
```

2.1.2 Run the command below to publish the package config file `config/clock.php`

```
php artisan vendor:publish --provider="Happy\Clock\ClockServiceProvider"
```

#### 2.3 Clock配置更新

[](#23-clock配置更新)

2.3.1 检测项目Migrate状态

```
➜ php artisan migrate:status
Migration table not found.
```

2.3.2 若未初始话，需要先初始化Migrate服务，否则，跳过该步骤

```
➜ php artisan migrate:install
Migration table created successfully.
```

2.3.3 再次检测Migrate状态

```
➜ php artisan migrate:status
+------+------------------------------------------------+-------+
| Ran? | Migration                                      | Batch |
+------+------------------------------------------------+-------+
| No   | 2014_10_12_000000_create_users_table           |       |
| No   | 2014_10_12_100000_create_password_resets_table |       |
| No   | 2019_08_19_000000_create_failed_jobs_table     |       |
+------+------------------------------------------------+-------+
```

2.3.4 生成Clock的数据库迁移信息

```
➜ php artisan clock:migration
/Users/wangxionghao/Server/package/clock/src/views
Table: pay_clock, pay_clock_day, pay_clock_order, pay_clock_setting,
            pay_clock_user, pay_clock_user_error_log, pay_clock_user_log
A migration that creates 'pay_clock', 'pay_clock_day', 'pay_clock_order',
         'pay_clock_setting', 'pay_clock_user', 'pay_clock_user_error_log', 'pay_clock_user_log' tables will be created in database/migrations directory

 Proceed with the migration creation? [Yes|no] (yes/no) [yes]:
 > yes

Creating migration...
Migration successfully created!
```

该命令执行后，生成 `_clock_setup_tables.php` 文件 2.3.5 数据库迁移

```
➜  php artisan migrate
Migrating: 2021_02_07_074236_clock_setup_tables
Migrated:  2021_02_07_074236_clock_setup_tables (274.25ms)

OR

➜  php artisan migrate --path=./database/migrations/_clock_setup_tables.php
```

2.3.6 日志文件配置 `config/logging.php`中在 `channels` 数组中添加如下内容

```
'clock-server' => [
            'driver' => 'daily',
            'path' => storage_path('logs/clock/info.log'),
            'level' => env('LOG_LEVEL', 'debug'),
            'days' => 14,
 ],
```

### 3.接口服务

[](#3接口服务)

#### 3.1 获取参与打卡首页信息

[](#31-获取参与打卡首页信息)

**请求参数：**

字段字段名称类型备注uid平台用户IDintextra额外参数arrayextra.mobile用户的手机号stringextra.nickname用户的昵称stringextra.openId用户在渠道的IDstring**响应参数模版：**

字段字段名称类型备注status业务状态码int0:表示业务失败，1:表示成功message业务响应内容stringdata业务数据块array**响应参数：**

字段字段名称类型备注status业务状态码int0:表示业务失败，1:表示成功message业务响应内容stringdata业务数据块arraydata.summary数据概览arraydata.summary.is\_remind打卡提醒boolean0:表示关闭，1:表示开启data.summary.clock\_status参与状态int0:未参加, 1:已参加, 2:已打卡data.summary.user\_num参与人数intdata.summary.clock\_user\_num打卡成功人数intdata.summary.clock\_money奖池奖金int按天参与报名的总金额data.summary.clock\_time打卡倒计时int距离05:00的倒计时时间戳data.summary.red\_time开奖倒计时int距离08:05的倒计时时间戳data.summary.zero\_time零点开关intdata.summary.is\_start活动是否开启booleandata.summary.is\_alert是否需要弹窗booleandata.summary.yest\_money昨日奖金池int#### 3.2 参与打卡活动支付

[](#32-参与打卡活动支付)

活动支付的流程为clock服务提供生成订单号，订单号及相关的业务参数初始化后，在向渠道发起支付请求 **请求地址：**

```
use Happy\Clock\CashClock;
use Happy\Clock\Service\ClockService;

public function prepay(Request $request, ClockService $service)
{
    $extra = [
        'nickname' => 'JasonABCDE',
        'mobile' => '18986299292',
        'openId' => 'oq_pO5XHsq87Z3LLBc7p0',
    ];
    $uid = 6;

    $cashClockSer = new CashClock($service);

    $result = $cashClockSer->generateClockOrder($uid, $extra);

    return Response::json($result);
}
```

**请求参数：**

字段字段名称类型备注uid平台用户IDintextra额外参数arrayextra.mobile用户的手机号stringextra.nickname用户的昵称stringextra.openId用户在渠道的IDstring**响应参数：**

字段字段名称类型备注status业务状态码int0:表示业务失败，1:表示成功message业务响应内容stringdata业务数据块arraydata.order\_id订单IDintdata.order\_no外部订单号string#### 3.3 异步回调通知

[](#33-异步回调通知)

接受渠道的回调通知，按业务需求处理打卡订单逻辑及用户参与信息 **请求地址：**

```
use Happy\Clock\CashClock;
use Happy\Clock\Service\ClockService;

public function notify(Request $request, ClockService $service)
    {
        $cashClockSer = new CashClock($service);

        $orderNo = "TTC202102155324302";
        $extra = [
            'amount' => 100 / 100,
            'buyerId' => 'oq_pO5XHsq87Z3LLBc7p0',
            'notify_time' => date('Y-m-d H:i:s'),
            'transactionId' => "Wx2394446280110126",
            'content' => "

                          10010404
                          100001256

													",
            "nickname" => "JasonABCDE",
            "mobile" => "18986299292"
        ];

        $result = $cashClockSer->notifyClockOrder($orderNo, $extra);

        return Response::json($result);
    }
```

**请求参数：**

字段字段名称类型备注order\_no外部订单号stringextra额外回调信息arrayextra.amount回调通知订单金额intextra.buyerId用户在渠道的ID信息stringextra.notify\_time回调通知时间stringextra.content回调的内容块stringextra.nickname用户的昵称信息stringextra.mobile用户的手机信息stringextra.transactionId渠道订单号信息string**响应参数：**

字段字段名称类型备注status业务状态码int0:表示业务失败，1:表示成功message业务响应内容stringdata业务数据块array#### 3.4 检测用户的打卡状态

[](#34-检测用户的打卡状态)

该接口服务用于用户在打卡前的检测，防止已打卡的用户再次发起打卡操作； **请求地址：**

```
ClockCenter/checkUserClock
```

**请求参数：**

字段字段名称类型备注uid平台用户IDint**响应参数：**

字段字段名称类型备注status业务状态码int0:表示业务失败，1:表示成功message业务响应内容stringdata业务数据块arraydata.is\_check\_in是否已打卡boolean1:表示已打卡；0:表示未打卡#### 3.5 用户参与打卡

[](#35-用户参与打卡)

**请求地址：**

```
use Happy\Clock\ClockCenter;
use Happy\Clock\Service\ClockService;

public function clock(Request $request, ClockService $service)
{
    $clockCenterSer = new ClockCenter($service);

    $uid = 4;

    $result = $clockCenterSer->clock($uid);

    return Response::json($result);
}
```

**请求参数：**

字段字段名称类型备注uid平台用户IDint**响应参数：**

字段字段名称类型备注status业务状态码int0:表示业务失败，1:表示成功message业务响应内容stringdata业务数据块arraydata.money参与活动报名日的总奖金池int#### 3.6 系统定时任务红包瓜分

[](#36-系统定时任务红包瓜分)

打卡活动在早上8点结束，系统开始定时任务，将总奖池的红包进行拆分业务，红包总额 = 参与活动报名的总奖金池 - 已成功打卡的总额；在把瓜分的红包放入缓存中； **请求地址：**

```
Commands/ClockRedInit/fire

php artisan clock:init-red
```

#### 3.7 用户领取红包

[](#37-用户领取红包)

定时任务将参与活动未打卡的金额转为奖金，瓜分到每个用户奖金，用户获得的金额为参与打卡费用+红包； **请求地址：**

```
use Happy\Clock\CashClock;
use Happy\Clock\Service\ClockService;

public function openRed(Request $request, ClockService $service)
{
    $cashClockSer = new CashClock($service);

    $uid = 4;
	  // $handler闭包用于处理 各渠道(微信/支付宝)的转账/打款到用户的逻辑逻辑
    $handler = function ($orderNo, $uid) {
        return [
            'return_code' => 'SUCCESS',
            'result_code' => "SUCCESS",
            'order_no' => $orderNo,
            'uid' => $uid
        ];
    };
    $result = $cashClockSer->userOpenRed($uid, $handler);

    return Response::json($result);
}
```

**请求参数：**

字段字段名称类型备注uid平台用户IDint**响应参数：**

字段字段名称类型备注status业务状态码int0:表示业务失败，1:表示成功message业务响应内容stringdata业务数据块arraydata.assign分配的红包信息arraydata.assign.money分配的红包金额int### 4.系统定时任务

[](#4系统定时任务)

#### 4.1 瓜分红包定时任务

[](#41-瓜分红包定时任务)

每天早上8:05分执行，用于将未打卡的参与用户的活动金额瓜分；

```
php artisan clock:init-red

php artisan clock:push-red

php artisan clock:push-red
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

12

Last Release

1867d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11309883?v=4)[JasonWoWo](/maintainers/JasonWowo)[@JasonWoWo](https://github.com/JasonWoWo)

---

Top Contributors

[![Wong-Chai](https://avatars.githubusercontent.com/u/204587074?v=4)](https://github.com/Wong-Chai "Wong-Chai (17 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/olaf-clock/health.svg)

```
[![Health](https://phpackages.com/badges/olaf-clock/health.svg)](https://phpackages.com/packages/olaf-clock)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[pulkitjalan/ip-geolocation

IP Geolocation Wrapper with Laravel Support

89164.9k1](/packages/pulkitjalan-ip-geolocation)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
