- 新增订单列表页面UI,支持状态筛选和搜索功能 - 新增订单删除API接口,支持用户软删除已完成/已取消订单 - 新增订单详情接口返回商品列表和联系信息 - 新增多个图标资源和API接口 - 修改上传配置和订单相关逻辑
69 行
2.2 KiB
PHP
69 行
2.2 KiB
PHP
<?php
|
|
|
|
define('APP_PATH', __DIR__ . '/../server/application/');
|
|
require __DIR__ . '/../server/thinkphp/base.php';
|
|
\think\App::initCommon();
|
|
|
|
use think\Db;
|
|
use app\common\library\OrderStatus;
|
|
|
|
$order = Db::name('order')->where('id', 95)->find();
|
|
echo "Order 95: status={$order['status']}, settle_status={$order['settle_status']}, finish_time={$order['finish_time']}\n";
|
|
|
|
$expiredTime = time() - 172800;
|
|
echo "finish_time={$order['finish_time']} vs expiredTime={$expiredTime}\n";
|
|
|
|
$rows = Db::name('order')
|
|
->where('status', OrderStatus::PENDING_VERIFY)
|
|
->where('settle_status', 0)
|
|
->where('finish_time', '<', $expiredTime)
|
|
->select();
|
|
echo "Matched rows count: " . count($rows) . "\n";
|
|
|
|
foreach ($rows as $r) {
|
|
try {
|
|
Db::startTrans();
|
|
$orderId = (int)$r['id'];
|
|
$masterId = (int)$r['master_id'];
|
|
$payAmount = (float)$r['pay_amount'];
|
|
$rate = 10.00;
|
|
$commission = round($payAmount * $rate / 100, 2);
|
|
$settleAmount = round($payAmount - $commission, 2);
|
|
|
|
Db::name('order')->where('id', $orderId)->update([
|
|
'status' => OrderStatus::COMPLETED,
|
|
'verify_time' => time(),
|
|
'settle_status' => 1,
|
|
'settle_amount' => $settleAmount,
|
|
'updatetime' => time(),
|
|
]);
|
|
|
|
Db::name('order_log')->insert([
|
|
'order_id' => $orderId,
|
|
'status' => OrderStatus::COMPLETED,
|
|
'remark' => '完工超48小时未验收,系统自动确认完成并结算',
|
|
'actor_type' => 'system',
|
|
'actor_id' => 0,
|
|
'createtime' => time(),
|
|
]);
|
|
|
|
Db::name('settle')->insert([
|
|
'order_id' => $orderId,
|
|
'master_id' => $masterId,
|
|
'order_amount' => $payAmount,
|
|
'commission_rate' => $rate,
|
|
'commission' => $commission,
|
|
'settle_amount' => $settleAmount,
|
|
'status' => 'settled',
|
|
'settle_time' => time(),
|
|
'createtime' => time(),
|
|
]);
|
|
|
|
Db::commit();
|
|
echo "Success processed order {$orderId}\n";
|
|
} catch (\Exception $e) {
|
|
Db::rollback();
|
|
echo "Error: " . $e->getMessage() . "\n";
|
|
}
|
|
}
|