You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.0 KiB
PHP

<?php
namespace Workerman\Lib;
use Workerman\Worker;
$bot_loop = new Worker();
$bot_loop->count = 1;
$bot_loop->name = 'HunJianOrderCheck';
function HunJianOrderReFund($order_id)
{
Tool::log('开始执行HunJianOrderReFund任务', 2);
$url = Tool::ini('AUTO_REFUND');
$res = Tool::post($url, [
'id' => $order_id,
'key' => "dfsd2Ajd256SDI02",
]);
Tool::log(json_encode($res, JSON_UNESCAPED_UNICODE), 2);
}
function HunJianOrderCheck()
{
$db = Db::get();
$hunjian_check= $db->getRow("select * from orders where checkup_type_id = 4 and (title='男性免费婚检(双方)' or title='女性免费婚检(双方)')
and status = 2
and appointment_number is not null
and hunjian_status=0
and created_at < NOW() - INTERVAL 15 MINUTE
", []);
if (!!$hunjian_check) {
$buy_info=json_decode($hunjian_check['buy_info'],true);
if(isset($buy_info['peiou_info']['sfz'])){
$peiou_check= $db->getRow("select * from orders where id_number=?
and checkup_type_id = 4
and status in(2,4)
and appointment_number is not null
", [$buy_info['peiou_info']['sfz']]);
if(!!$peiou_check){
Db2::u($db, 'orders', [
'hunjian_status' => 1,
], 'where id = ?', [
$hunjian_check['id']
]);
}else{
if($hunjian_check['checkup_type_id'] == 4){
HunJianOrderReFund($hunjian_check['id']);
}
}
}else{
if($hunjian_check['checkup_type_id'] == 4){
HunJianOrderReFund($hunjian_check['id']);
}
}
} else {
Tool::log('HunJianOrderCheck未检测到任务');
}
}
$bot_loop->onWorkerStart = function () {
HunJianOrderCheck();
Timer::add(10, function () {
HunJianOrderCheck();
});
};