OrderComment.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\command;
  3. use app\api\model\order\Order;
  4. use app\api\service\OrderService;
  5. use think\console\Command;
  6. use think\console\Input;
  7. use think\console\Output;
  8. // 评论超时
  9. class OrderComment extends Command
  10. {
  11. // 配置定时器的信息
  12. protected function configure()
  13. {
  14. $this->setName('OrderComment')
  15. ->setDescription('OrderComment start');
  16. }
  17. protected function execute(Input $input, Output $output)
  18. {
  19. \think\Log::custom_log("评论超时定时任务", "-------------- start --------------", "order_comment");
  20. $now_time = time();
  21. // 订单评论超时时间(天)
  22. $max_timeout_limit = (config("site.order_comment_of_timeout") ?? 7) * 24 * 60 * 60;
  23. $orderModel = new Order();
  24. $orderService = new OrderService();
  25. $orders = $orderModel->byOrderCommentExpired($now_time - $max_timeout_limit);
  26. $rand_str = ["服务态度好,超赞!!!", "手法专业,点赞!!!", "性价比高,点赞!!!", "价格合理服务态度好点赞!!!"];
  27. $logs = [];
  28. foreach ($orders as $order) {
  29. $sRes = $orderService->comment($order["id"], [
  30. "star" => 5,
  31. "is_anonymity" => 1,
  32. "tags" => "价格合理,着装规范,手法专业,性价比高",
  33. "content" => array_rand($rand_str),
  34. "negative" => 0,
  35. ]);
  36. array_push($logs, [
  37. "order_id" => $order["id"],
  38. "s_res" => $sRes->code()
  39. ]);
  40. }
  41. \think\Log::custom_log("评论超时定时任务", $logs, "order_comment");
  42. \think\Log::custom_log("评论超时定时任务", "--------------- over --------------", "order_comment");
  43. }
  44. }