HealthyOrderServer.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace app\admin\server\healthy;
  3. use app\admin\model\HealthyOrder;
  4. class HealthyOrderServer
  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/11/4
  14. */
  15. public static function getOrderList(int $page, int $limit, string $keywords)
  16. {
  17. [$list, $count] = HealthyOrder::getOrderList($page, $limit,$keywords);
  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/11/2
  26. */
  27. public static function orderInfo(int $order_id)
  28. {
  29. HealthyOrder::affairBegin();
  30. try {
  31. $where = [];
  32. $where['order_id'] = $order_id;
  33. $result = HealthyOrder::with(['User','Shop','HealthyOrderProduct'])->where($where)->first();
  34. if (!empty($result)){
  35. HealthyOrder::affairCommit();
  36. return $result;
  37. }else{
  38. return false;
  39. }
  40. }catch (\Exception $exception){
  41. HealthyOrder::affairRollback();
  42. throw new \Exception($exception->getMessage(), 500);
  43. }
  44. }
  45. /**
  46. * Notes:发货
  47. * User: YCP
  48. * Date: 2022/11/9
  49. */
  50. public static function orderDelivery($params,$admin_id)
  51. {
  52. HealthyOrder::affairBegin();
  53. try {
  54. $where = [];
  55. $where['order_id'] = $params['order_id'];
  56. $data['order_express_no'] = $params['order_express_no'];//快递单号
  57. $data['order_express_company'] = $params['order_express_company'];//物流公司
  58. $data['order_status'] = $params['order_status']; //0待发货 1已发货,待收货 2已收货待评价 3已完成 4部分退款 5全部退款
  59. $data['order_delivery'] = time();
  60. $result = HealthyOrder::where($where)->update($data);
  61. if (!empty($result)){
  62. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '订单发货-编号: ' . $params['order_id'];
  63. plog('healthy-healthyorder-delivery', '健康订单发货', $msg);
  64. HealthyOrder::affairCommit();
  65. return true;
  66. }else{
  67. return false;
  68. }
  69. }catch (\Exception $exception){
  70. HealthyOrder::affairRollback();
  71. throw new \Exception($exception->getMessage(), 500);
  72. }
  73. }
  74. /**
  75. * Notes:修改订单支付状态
  76. * @param string $order_id
  77. * @param int $order_finish
  78. * @return int
  79. * User: YCP
  80. * Date: 2022/11/28
  81. */
  82. public static function updatePayStatus($order_id, $order_pay_status)
  83. {
  84. HealthyOrder::affairBegin();
  85. try {
  86. $where = [];
  87. $where['order_id'] = $order_id;
  88. $data = [];
  89. $data['order_pay_status'] = $order_pay_status;
  90. if($order_pay_status == 1){
  91. $data['order_pay_time'] = date("Y-m-d H:i:s",time());
  92. }else{
  93. $data['order_pay_time'] = "";
  94. }
  95. $result = HealthyOrder::where($where)->update($data);
  96. if ($result !== false){
  97. HealthyOrder::affairCommit();
  98. return true;
  99. }
  100. throw new \Exception('操作失败!');
  101. }catch (\Exception $exception){
  102. HealthyOrder::affairRollback();
  103. throw new \Exception($exception->getMessage(), 500);
  104. }
  105. }
  106. }