PackageOrderServer.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\admin\server\package;
  3. use app\admin\model\Package;
  4. use app\admin\model\PackageOrder;
  5. use app\admin\model\PackageOrderDetail;
  6. use app\admin\model\SystemAdmin;
  7. use app\admin\model\SystemMenu;
  8. use app\admin\model\SystemRole;
  9. class PackageOrderServer
  10. {
  11. /**
  12. * Notes:获取角色列表
  13. * @param string $keywords
  14. * @param int $page
  15. * @param int $limit
  16. * @return array
  17. * User: QJF
  18. * Date: 2022/9/17
  19. */
  20. public static function getPackageOrderList(int $page, int $limit, string $keywords)
  21. {
  22. [$list, $count] = PackageOrder::getPackageOrderList($page, $limit,$keywords);
  23. return compact('list', 'page', 'limit', 'count');
  24. }
  25. /**
  26. * Notes:获取订单详情
  27. * @param int $order_id
  28. * @return int
  29. * User: QJF
  30. * Date: 2022/9/19
  31. */
  32. public static function packageOrderInfo($order_id)
  33. {
  34. SystemRole::affairBegin();
  35. try {
  36. $where = [];
  37. $where['order_id'] = $order_id;
  38. $result = PackageOrder::with('Package')->where($where)->first();
  39. //关联权益包
  40. $result['package'] = Package::where(['package_id'=>$result['order_package_id']])->get();
  41. //订单详情的列表
  42. $result['detail_list'] = PackageOrderDetail::where(['detail_order_id'=>$order_id])->get();
  43. if (!empty($result)){
  44. SystemRole::affairCommit();
  45. return $result;
  46. }else{
  47. return false;
  48. }
  49. }catch (\Exception $exception){
  50. SystemRole::affairRollback();
  51. throw new \Exception($exception->getMessage(), 500);
  52. }
  53. }
  54. /**
  55. * Notes:修改订单支付状态
  56. * @param string $order_id
  57. * @param int $order_finish
  58. * @return int
  59. * User: YCP
  60. * Date: 2022/11/28
  61. */
  62. public static function updatePayStatus($order_id, $order_pay_status)
  63. {
  64. PackageOrder::affairBegin();
  65. try {
  66. $where = [];
  67. $where['order_id'] = $order_id;
  68. $data = [];
  69. $data['order_pay_status'] = $order_pay_status;
  70. if($order_pay_status == 2){
  71. $data['order_pay_time'] = time();
  72. }else{
  73. $data['order_pay_time'] = "";
  74. }
  75. $result = PackageOrder::where($where)->update($data);
  76. if ($result !== false){
  77. $user_id = PackageOrder::where($where)->value('order_user_id');
  78. events('createUserNews', ['log_type' => 0, 'log_uid' => $user_id, 'log_content' => '您的权益包订单支付成功了!']);
  79. PackageOrder::affairCommit();
  80. return true;
  81. }
  82. throw new \Exception('操作失败!');
  83. }catch (\Exception $exception){
  84. PackageOrder::affairRollback();
  85. throw new \Exception($exception->getMessage(), 500);
  86. }
  87. }
  88. }