| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace app\command;
- use app\api\model\order\Order;
- use app\api\service\OrderService;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- // 评论超时
- class OrderComment extends Command
- {
- // 配置定时器的信息
- protected function configure()
- {
- $this->setName('OrderComment')
- ->setDescription('OrderComment start');
- }
- protected function execute(Input $input, Output $output)
- {
- \think\Log::custom_log("评论超时定时任务", "-------------- start --------------", "order_comment");
- $now_time = time();
- // 订单评论超时时间(天)
- $max_timeout_limit = (config("site.order_comment_of_timeout") ?? 7) * 24 * 60 * 60;
- $orderModel = new Order();
- $orderService = new OrderService();
- $orders = $orderModel->byOrderCommentExpired($now_time - $max_timeout_limit);
- $rand_str = ["服务态度好,超赞!!!", "手法专业,点赞!!!", "性价比高,点赞!!!", "价格合理服务态度好点赞!!!"];
- $logs = [];
- foreach ($orders as $order) {
- $sRes = $orderService->comment($order["id"], [
- "star" => 5,
- "is_anonymity" => 1,
- "tags" => "价格合理,着装规范,手法专业,性价比高",
- "content" => array_rand($rand_str),
- "negative" => 0,
- ]);
- array_push($logs, [
- "order_id" => $order["id"],
- "s_res" => $sRes->code()
- ]);
- }
- \think\Log::custom_log("评论超时定时任务", $logs, "order_comment");
- \think\Log::custom_log("评论超时定时任务", "--------------- over --------------", "order_comment");
- }
- }
|