BellsController.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\admin\controller\sys_manage;
  3. use app\model\Order;
  4. use app\model\SysMessage;
  5. use support\Log;
  6. use support\Request;
  7. class BellsController
  8. {
  9. public function orderNum()
  10. {
  11. $messageNum = SysMessage::where('message_status', 'PENDING')->count();
  12. return json_success('success', ['num' => $messageNum]);
  13. }
  14. public function orderList()
  15. {
  16. $messages = SysMessage::where('message_status', 'PENDING')
  17. ->select('message_id', 'message_title', 'join_message_object_json', 'message_addtimes','message_category')
  18. ->orderBy('message_addtimes', 'DESC')
  19. ->get()
  20. ->toArray();
  21. foreach ($messages as &$message) {
  22. if (!empty($message['join_message_object_json'])) {
  23. $messageObjectJson = json_decode($message['join_message_object_json'], true);
  24. $message['order_id'] = $messageObjectJson['order_id'] ?? '';
  25. }
  26. }
  27. return json_success('success', ['messages' => $messages]);
  28. }
  29. /**
  30. * @Desc 关闭订单提醒
  31. * @Author Gorden
  32. * @Date 2024/10/28 15:28
  33. *
  34. * @param Request $request
  35. * @return \support\Response
  36. */
  37. public function closeOrderBell(Request $request)
  38. {
  39. $messageId = $request->post('message_id');
  40. if (!$messageId) {
  41. return json_fail("参数异常");
  42. }
  43. Log::info("订单提醒操作", $request->post());
  44. try {
  45. $message = SysMessage::where('message_id', $messageId)->first();
  46. $message->message_status = 'DONE';
  47. $message->save();
  48. return json_success('success');
  49. } catch (\Exception $e) {
  50. return json_fail('操作失败');
  51. }
  52. }
  53. }