PackageOrderServer.php 3.4 KB

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