OrderServer.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace app\admin\server\travel;
  3. use app\admin\model\TravelOrder;
  4. use app\admin\model\TravelLine;
  5. class OrderServer
  6. {
  7. /**
  8. * Notes:获取订单列表
  9. * @param string $keywords
  10. * @param int $page
  11. * @param int $limit
  12. * @return array
  13. * User: YCP
  14. * Date: 2022/10/21
  15. */
  16. public static function getOrderList(int $page, int $limit, string $keywords)
  17. {
  18. [$list, $count] = TravelOrder::getOrderList($page, $limit,$keywords);
  19. return compact('list', 'page', 'limit', 'count');
  20. }
  21. /**
  22. * Notes:获取订单详情
  23. * @param int $order_id
  24. * @return int
  25. * User: YCP
  26. * Date: 2022/10/21
  27. */
  28. public static function orderInfo(int $order_id)
  29. {
  30. TravelOrder::affairBegin();
  31. try {
  32. $where = [];
  33. $where['order_id'] = $order_id;
  34. $result = TravelOrder::with(['Line'])->where($where)->first();
  35. if (!empty($result)){
  36. TravelOrder::affairCommit();
  37. return $result;
  38. }else{
  39. return false;
  40. }
  41. }catch (\Exception $exception){
  42. TravelOrder::affairRollback();
  43. throw new \Exception($exception->getMessage(), 500);
  44. }
  45. }
  46. /**
  47. * Notes:修改订单支付状态
  48. * @param string $order_id
  49. * @param int $order_finish
  50. * @return int
  51. * User: YCP
  52. * Date: 2022/11/28
  53. */
  54. public static function updatePayStatus($order_id, $order_pay_status)
  55. {
  56. TravelOrder::affairBegin();
  57. try {
  58. $where = [];
  59. $where['order_id'] = $order_id;
  60. $data = [];
  61. $data['order_pay_status'] = $order_pay_status;
  62. if($order_pay_status == 1){
  63. $data['order_pay_time'] = time();
  64. }else{
  65. $data['order_pay_time'] = "";
  66. }
  67. $result = TravelOrder::where($where)->update($data);
  68. if ($result !== false){
  69. TravelOrder::affairCommit();
  70. return true;
  71. }
  72. throw new \Exception('操作失败!');
  73. }catch (\Exception $exception){
  74. TravelOrder::affairRollback();
  75. throw new \Exception($exception->getMessage(), 500);
  76. }
  77. }
  78. /**
  79. * Notes:修改订单状态
  80. * @param string $order_id
  81. * @param int $order_finish
  82. * @return int
  83. * User: YCP
  84. * Date: 2022/11/28
  85. */
  86. public static function updateOrderStatus($order_id, $order_status, $order_reject_reason)
  87. {
  88. TravelOrder::affairBegin();
  89. try {
  90. $where = [];
  91. $where['order_id'] = $order_id;
  92. $data = [];
  93. $data['order_status'] = $order_status;
  94. if($data['order_status'] == 10){
  95. $data['order_reject_reason'] = $order_reject_reason;
  96. }
  97. $result = TravelOrder::where($where)->update($data);
  98. if ($result !== false){
  99. TravelOrder::affairCommit();
  100. return true;
  101. }
  102. throw new \Exception('操作失败!');
  103. }catch (\Exception $exception){
  104. TravelOrder::affairRollback();
  105. throw new \Exception($exception->getMessage(), 500);
  106. }
  107. }
  108. }