RaiseOldGoodsOrderServer.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. namespace app\admin\server\raise;
  3. use app\admin\model\RaiseGoodsOrder;
  4. class RaiseOldGoodsOrderServer
  5. {
  6. /**
  7. * Notes:获取订单列表
  8. * @param string $keywords
  9. * @param int $page
  10. * @param int $limit
  11. * @return array
  12. * User: ZQ
  13. * Date: 2022/10/13
  14. */
  15. public static function getOrderList(int $page, int $limit, string $keywords)
  16. {
  17. [$list, $count] = RaiseGoodsOrder::getOrderList($page, $limit,$keywords);
  18. if (!empty($list)){
  19. foreach ($list as $k => $v){
  20. $list[$k]['order_subscribe_time'] = date('Y-m-d H:i:s',$v['order_subscribe_time']);
  21. $list[$k]['order_create_time'] = date('Y-m-d H:i:s',$v['order_create_time']);
  22. if (!empty($v['order_update_time'])){
  23. $list[$k]['order_update_time'] = date('Y-m-d H:i:s',$v['order_update_time']);
  24. }
  25. }
  26. }
  27. return compact('list', 'page', 'limit', 'count');
  28. }
  29. /**
  30. * Notes:获取订单详情
  31. * @param int $order_id
  32. * @return int
  33. * User: ZQ
  34. * Date: 2022/10/13
  35. */
  36. public static function getOrderInfo($order_id)
  37. {
  38. $where = [];
  39. $where['order_id'] = $order_id;
  40. $result = RaiseGoodsOrder::where($where)->with(['user'])->first();
  41. if (!empty($result)){
  42. $result['order_subscribe_time'] = date('Y-m-d H:i:s',$result['order_subscribe_time']);
  43. $result['order_create_time'] = date('Y-m-d H:i:s',$result['order_create_time']);
  44. if (!empty($result['order_update_time'])){
  45. $result['order_update_time'] = date('Y-m-d H:i:s',$result['order_update_time']);
  46. }
  47. }
  48. if (!empty($result)){
  49. return $result;
  50. }else{
  51. return false;
  52. }
  53. }
  54. /**
  55. * Notes:订单发货
  56. * @param int $order_id
  57. * @return int
  58. * User: ZQ
  59. * Date: 2022/10/13
  60. */
  61. public static function orderUpdate($order_id,$order_address,$order_address_mobile,$order_address_nickname,$order_remke,$order_express,$order_express_name)
  62. {
  63. RaiseGoodsOrder::affairBegin();
  64. try {
  65. $where = [];
  66. $where['order_id'] = $order_id;
  67. $data = [];
  68. $data['order_address'] = $order_address;
  69. $data['order_address_mobile'] = $order_address_mobile;
  70. $data['order_address_nickname'] = $order_address_nickname;
  71. $data['order_remke'] = $order_remke;
  72. $data['order_express'] = $order_express;
  73. $data['order_express_name'] = $order_express_name;
  74. $data['order_status'] = 1;
  75. $data['order_deliver_id'] = 1;
  76. $result = RaiseGoodsOrder::where($where)->update($data);
  77. if (!empty($result)){
  78. RaiseGoodsOrder::affairCommit();
  79. return $result;
  80. }else{
  81. return false;
  82. }
  83. }catch (\Exception $exception){
  84. RaiseGoodsOrder::affairRollback();
  85. throw new \Exception($exception->getMessage(), 500);
  86. }
  87. }
  88. /**
  89. * Notes:修改订单支付状态
  90. * @param string $order_id
  91. * @param int $order_finish
  92. * @return int
  93. * User: YCP
  94. * Date: 2022/11/28
  95. */
  96. public static function updatePayStatus($order_id, $order_pay_status)
  97. {
  98. RaiseGoodsOrder::affairBegin();
  99. try {
  100. $where = [];
  101. $where['order_id'] = $order_id;
  102. $data = [];
  103. $data['order_pay_status'] = $order_pay_status;
  104. if($order_pay_status == 1){
  105. $data['order_pay_time'] = time();
  106. }else{
  107. $data['order_pay_time'] = "";
  108. }
  109. $result = RaiseGoodsOrder::where($where)->update($data);
  110. if ($result !== false){
  111. RaiseGoodsOrder::affairCommit();
  112. return true;
  113. }
  114. throw new \Exception('操作失败!');
  115. }catch (\Exception $exception){
  116. RaiseGoodsOrder::affairRollback();
  117. throw new \Exception($exception->getMessage(), 500);
  118. }
  119. }
  120. }