- 新增地址选择插件,支持地图位置选择并返回地址和经纬度 - 新增微信订阅消息发送功能,支持审核结果、提现通知等场景 - 新增订单支付状态查询、提现收款人姓名保存等接口 - 新增服务区域管理,支持按省市区划分并同步到信息发布 - 新增资金流水和营收报表导出功能 - 新增可用优惠券查询、订单退款拆分处理等功能 - 优化后台角标显示、首页数据统计、UI配置下发等 - 修复订单支付并发问题、地区管理逻辑等
83 行
2.6 KiB
PHP
83 行
2.6 KiB
PHP
<?php
|
||
|
||
namespace app\admin\command;
|
||
|
||
use app\common\library\CouponService;
|
||
use think\console\Command;
|
||
use think\console\Input;
|
||
use think\console\Output;
|
||
use think\Db;
|
||
|
||
/**
|
||
* 定时维护任务(建议 crontab 每 5 分钟执行一次)
|
||
*
|
||
* php think fc:settle
|
||
*
|
||
* 职责:
|
||
* 1. 佣金到期结算:status=0 且 settle_due<=now → status=1(T+N 结算周期)
|
||
* 2. 关闭超时未支付订单(24 小时)并退回优惠券
|
||
* 3. 同步「转账中」的提现单(回调缺失兜底)
|
||
*/
|
||
class FcSettle extends Command
|
||
{
|
||
protected function configure()
|
||
{
|
||
$this->setName('fc:settle')
|
||
->setDescription('分销佣金到期结算 / 关闭超时订单 / 同步转账状态');
|
||
}
|
||
|
||
protected function execute(Input $input, Output $output)
|
||
{
|
||
$now = time();
|
||
|
||
/* 1. 佣金到期结算 */
|
||
$settled = Db::name('fc_commission')
|
||
->where('status', 0)
|
||
->where('settle_due', '<=', $now)
|
||
->update([
|
||
'status' => 1,
|
||
'settletime' => $now,
|
||
]);
|
||
$output->writeln('==> 佣金结算:' . $settled . ' 笔');
|
||
|
||
/* 2. 关闭超时未支付订单(24 小时) */
|
||
$expired = Db::name('fc_order')
|
||
->where('status', 'pending')
|
||
->where('createtime', '<', $now - 86400)
|
||
->select();
|
||
|
||
$closed = 0;
|
||
foreach ($expired as $order) {
|
||
$affected = Db::name('fc_order')
|
||
->where('id', (int)$order['id'])
|
||
->where('status', 'pending')
|
||
->update([
|
||
'status' => 'closed',
|
||
'updatetime' => $now,
|
||
]);
|
||
if ($affected) {
|
||
CouponService::release((string)$order['order_no']);
|
||
$closed++;
|
||
}
|
||
}
|
||
$output->writeln('==> 关闭超时订单:' . $closed . ' 笔');
|
||
|
||
/* 3. 同步转账中的提现单(最多 20 笔) */
|
||
$synced = 0;
|
||
if (class_exists('\app\common\library\WxTransfer') && \app\common\library\WxTransfer::isReady()) {
|
||
$rows = Db::name('fc_withdraw')->where('status', 'paying')->limit(20)->select();
|
||
foreach ($rows as $row) {
|
||
try {
|
||
\app\common\library\WxTransfer::sync((int)$row['id']);
|
||
$synced++;
|
||
} catch (\Throwable $e) {
|
||
// 单笔失败不影响其它
|
||
}
|
||
}
|
||
}
|
||
$output->writeln('==> 同步转账状态:' . $synced . ' 笔');
|
||
|
||
$output->writeln('==> 完成');
|
||
}
|
||
}
|