MedicalCareOrderServer.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\admin\server\medical;
  3. use app\admin\model\MedicalCareOrder;
  4. use app\admin\model\MedicalCareOrderProduct;
  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 MedicalCareOrderServer
  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 getProductOrderList(int $page, int $limit, string $keywords)
  21. {
  22. [$list, $count] = MedicalCareOrder::getOrderList($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/17
  31. */
  32. public static function productOrderInfo($order_id)
  33. {
  34. SystemRole::affairBegin();
  35. try {
  36. $where = [];
  37. $where['order_id'] = $order_id;
  38. $result = MedicalCareOrder::with(['user','Shop'])->where($where)->first();
  39. //订单详情的列表
  40. $result['detail_list'] = MedicalCareOrderProduct::with(['product','user'])
  41. ->where(['order_product_order_id'=>$order_id])->get();
  42. if (!empty($result)){
  43. SystemRole::affairCommit();
  44. return $result;
  45. }else{
  46. return false;
  47. }
  48. }catch (\Exception $exception){
  49. SystemRole::affairRollback();
  50. throw new \Exception($exception->getMessage(), 500);
  51. }
  52. }
  53. /**
  54. * Notes:修改订单支付状态
  55. * @param string $order_id
  56. * @param int $order_finish
  57. * @return int
  58. * User: YCP
  59. * Date: 2022/11/28
  60. */
  61. public static function updatePayStatus($order_id, $order_pay_status)
  62. {
  63. MedicalCareOrder::affairBegin();
  64. try {
  65. $where = [];
  66. $where['order_id'] = $order_id;
  67. $data = [];
  68. $data['order_pay_status'] = $order_pay_status;
  69. if($order_pay_status == 1){
  70. $data['order_pay_time'] = date("Y-m-d H:i:s",time());
  71. }else{
  72. $data['order_pay_time'] = "";
  73. }
  74. $result = MedicalCareOrder::where($where)->update($data);
  75. if ($result !== false){
  76. $user_id = MedicalCareOrder::where($where)->value('order_user_id');
  77. events('createUserNews', ['log_type' => 0, 'log_uid' => $user_id, 'log_content' => '您的订单支付成功了!']);
  78. MedicalCareOrder::affairCommit();
  79. return true;
  80. }
  81. throw new \Exception('操作失败!');
  82. }catch (\Exception $exception){
  83. MedicalCareOrder::affairRollback();
  84. throw new \Exception($exception->getMessage(), 500);
  85. }
  86. }
  87. }