其余文件
This commit is contained in:
55
app/common/command/IntegralOrderFinish.php
Normal file
55
app/common/command/IntegralOrderFinish.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\common\command;
|
||||
|
||||
|
||||
use app\common\enum\IntegralOrderEnum;
|
||||
use app\common\model\integral\IntegralOrder;
|
||||
use app\common\server\ConfigServer;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\facade\Log;
|
||||
|
||||
class IntegralOrderFinish extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('integral_order_finish')
|
||||
->setDescription('积分订单自动确认收货');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
try {
|
||||
$time = time();
|
||||
$config = ConfigServer::get('transaction', 'order_auto_receipt_days', 7);
|
||||
if ($config == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$finish_limit = $config * 24 * 60 * 60;
|
||||
$model = new IntegralOrder();
|
||||
$orders = $model->field(true)->where([
|
||||
['order_status', '=', IntegralOrderEnum::ORDER_STATUS_GOODS],
|
||||
['del', '=', 0]
|
||||
])->whereRaw("shipping_time+$finish_limit < $time")
|
||||
->select()->toArray();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$model->where(['id' => $order['id']])
|
||||
->update([
|
||||
'order_status' => IntegralOrderEnum::ORDER_STATUS_COMPLETE,
|
||||
'update_time' => $time,
|
||||
'confirm_time' => $time,
|
||||
]);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Log::write('积分订单自动确认收货异常:'.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user