CinemaOrderServer.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\admin\server\life;
  3. use app\admin\model\CinemaOrder;
  4. class CinemaOrderServer
  5. {
  6. /**
  7. * Notes:获取订单列表
  8. * @param string $keywords
  9. * @param int $page
  10. * @param int $limit
  11. * @return array
  12. * User: ZQ
  13. * Date: 2022/10/13
  14. */
  15. public static function getOrderList(int $page, int $limit, string $keywords)
  16. {
  17. [$list, $count] = CinemaOrder::getOrderList($page, $limit,$keywords);
  18. if (!empty($list)){
  19. foreach ($list as $k => $v){
  20. $list[$k]['order_create_time'] = date('Y-m-d H:i:s',$v['order_create_time']);
  21. $list[$k]['order_update_time'] = $v['order_update_time'] ? date('Y-m-d H:i:s',$v['order_update_time']) : '';
  22. }
  23. }
  24. return compact('list', 'page', 'limit', 'count');
  25. }
  26. /**
  27. * Notes:获取订单详情
  28. * @param int $order_id
  29. * @return int
  30. * User: ZQ
  31. * Date: 2022/10/13
  32. */
  33. public static function orderInfo($order_id)
  34. {
  35. CinemaOrder::affairBegin();
  36. try {
  37. $where = [];
  38. $where['order_id'] = $order_id;
  39. $result = CinemaOrder::with(['user','detail'])->where($where)->first();
  40. if (!empty($result)){
  41. CinemaOrder::affairCommit();
  42. return $result;
  43. }else{
  44. return false;
  45. }
  46. }catch (\Exception $exception){
  47. CinemaOrder::affairRollback();
  48. throw new \Exception($exception->getMessage(), 500);
  49. }
  50. }
  51. /**
  52. * Notes:修改订单支付状态
  53. * @param string $order_id
  54. * @param int $order_finish
  55. * @return int
  56. * User: YCP
  57. * Date: 2022/11/28
  58. */
  59. public static function updatePayStatus($order_id, $order_pay_status)
  60. {
  61. CinemaOrder::affairBegin();
  62. try {
  63. $where = [];
  64. $where['order_id'] = $order_id;
  65. $data = [];
  66. $data['order_pay_status'] = $order_pay_status;
  67. if($order_pay_status == 1){
  68. $data['order_pay_time'] = time();
  69. }else{
  70. $data['order_pay_time'] = "";
  71. }
  72. $result = CinemaOrder::where($where)->update($data);
  73. if ($result !== false){
  74. CinemaOrder::affairCommit();
  75. return true;
  76. }
  77. throw new \Exception('操作失败!');
  78. }catch (\Exception $exception){
  79. CinemaOrder::affairRollback();
  80. throw new \Exception($exception->getMessage(), 500);
  81. }
  82. }
  83. }