PHP code example of olaf / clock
1. Go to this page and download the library: Download olaf/clock library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
olaf / clock example snippets bash
php artisan vendor:publish --provider="Happy\Clock\ClockServiceProvider"
bash
➜ php artisan migrate:install
Migration table created successfully.
bash
➜ 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/<timestamp>_clock_setup_tables.php
bash
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' => "<xml>
<return_code><![CDATA[SUCCESS]]></return_code>
<result_code><![CDATA[SUCCESS]]></result_code>
<sign><![CDATA[C380BEC2BFD727A4B6845133519F3AD6]]></sign>
<mch_id>10010404</mch_id>
<contract_code>100001256</contract_code>
<openid><![CDATA[oAubD08j8Y4GU6YNyq_aGWC8h2OA]]></openid>
<plan_id><![CDATA[1000888]]></plan_id>
<change_type><![CDATA[DELETE]]></change_type>
<operate_time><![CDATA[2015-07-01 10:00:00]]></operate_time>
<contract_id><![CDATA[Wx15463511252015071056489715]]></contract_id>
</xml>",
"nickname" => "JasonABCDE",
"mobile" => "18986299292"
];
$result = $cashClockSer->notifyClockOrder($orderNo, $extra);
return Response::json($result);
}
bash
Commands/ClockRedInit/fire
php artisan clock:init-red
bash
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);
}
bash
php artisan clock:init-red
php artisan clock:push-red
php artisan clock:push-red