FarmOrderServer.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. namespace app\admin\server\life;
  3. use app\admin\model\LifeFarmGoods;
  4. use app\admin\model\LifeFarmOrder;
  5. use app\admin\model\LifeFarmOrderDetail;
  6. use app\admin\model\LifeFoodOrderDetail;
  7. use app\admin\model\MedicalCareOrder;
  8. use app\admin\model\MedicalCareOrderProduct;
  9. use app\admin\model\SystemRole;
  10. class FarmOrderServer
  11. {
  12. /**
  13. * Notes:获取订单列表
  14. * @param string $keywords
  15. * @param int $page
  16. * @param int $limit
  17. * @return array
  18. * User: QJF
  19. * Date: 2022/11/04
  20. */
  21. public static function getOrderList(int $page, int $limit, string $keywords)
  22. {
  23. [$list, $count] = LifeFarmOrder::getOrderList($page, $limit,$keywords);
  24. return compact('list', 'page', 'limit', 'count');
  25. }
  26. /**
  27. * Notes:订单详情
  28. * @return \support\Response
  29. * @param string $keywords
  30. * @param int $page
  31. * @param int $limit
  32. * User: QJF
  33. * Date: 2022/9/27
  34. */
  35. public static function orderInfo($order_id)
  36. {
  37. LifeFarmOrder::affairBegin();
  38. try {
  39. $where = [];
  40. $where['order_id'] = $order_id;
  41. $result = LifeFarmOrder::with(['User','Shop'])->where($where)->first();
  42. //订单详情的列表1
  43. $result['detail_list'] = LifeFarmOrderDetail::where(['detail_order_id'=>$order_id])->get();
  44. if (!empty($result)){
  45. LifeFarmOrder::affairCommit();
  46. return $result;
  47. }else{
  48. return false;
  49. }
  50. }catch (\Exception $exception){
  51. LifeFarmOrder::affairRollback();
  52. throw new \Exception($exception->getMessage(), 500);
  53. }
  54. }
  55. /**
  56. * Notes:订单发货
  57. * User: QJF
  58. * Date: 2022/11/4
  59. */
  60. public static function orderDelivery($param,$admin_id)
  61. {
  62. LifeFarmOrder::affairBegin();
  63. try {
  64. $where = [];
  65. $where['order_id'] = $param['order_id'];
  66. $data['order_deliver_id'] = 1;
  67. $data['order_number'] = $param['order_number'];//物流单号
  68. $data['order_company'] = $param['courier_company'];//物流公司
  69. $data['order_address_nickname'] = $param['order_address_nickname'];//收货人姓名
  70. $data['order_address_mobile'] = $param['order_address_mobile'];//收货人手机号
  71. $data['order_address'] = $param['order_address'];//收货人地址
  72. $data['order_remke'] = $param['order_remke'];//收货人备注
  73. $data['order_deliver_time'] = time();
  74. $data['order_update_time'] = time();
  75. $result = LifeFarmOrder::where($where)->update($data);
  76. if (!empty($result)){
  77. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '订单发货-编号: ' . $param['order_id'];
  78. plog('life-farmorder-delivery', '农场-绿色蔬菜订单发货', $msg);
  79. LifeFarmOrder::affairCommit();
  80. return true;
  81. }else{
  82. return false;
  83. }
  84. }catch (\Exception $exception){
  85. LifeFarmOrder::affairRollback();
  86. throw new \Exception($exception->getMessage(), 500);
  87. }
  88. }
  89. /**
  90. * Notes:修改订单支付状态
  91. * @param string $order_id
  92. * @param int $order_finish
  93. * @return int
  94. * User: YCP
  95. * Date: 2022/11/28
  96. */
  97. public static function updatePayStatus($order_id, $order_pay_status)
  98. {
  99. LifeFarmOrder::affairBegin();
  100. try {
  101. $where = [];
  102. $where['order_id'] = $order_id;
  103. $data = [];
  104. $data['order_pay_status'] = $order_pay_status;
  105. if($order_pay_status == 1){
  106. $data['order_pay_time'] = time();
  107. }else{
  108. $data['order_pay_time'] = "";
  109. }
  110. $result = LifeFarmOrder::where($where)->update($data);
  111. if ($result !== false){
  112. LifeFarmOrder::affairCommit();
  113. return true;
  114. }
  115. throw new \Exception('操作失败!');
  116. }catch (\Exception $exception){
  117. LifeFarmOrder::affairRollback();
  118. throw new \Exception($exception->getMessage(), 500);
  119. }
  120. }
  121. }