酒店预订平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

123 lines
2.9 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: nizongfeng
  5. * Date: 2021/11/10
  6. * Time: 11:06
  7. */
  8. namespace app\admin\service;
  9. use app\admin\command\Util;
  10. use think\Db;
  11. use think\Exception;
  12. class ReceiptOrderService
  13. {
  14. /**
  15. * 保存详情
  16. * @param $param
  17. * @return array
  18. */
  19. public function save($param){
  20. $dao = new ReceiptOrderDao();
  21. return $dao->save($param);
  22. }
  23. /**
  24. * 获取列表
  25. * @param $param
  26. * @return array
  27. */
  28. public function getList($param){
  29. $dao = new ReceiptOrderDao();
  30. return $dao->getList($param);
  31. }
  32. /**
  33. * 设置状态
  34. * @param $id
  35. * @param $status
  36. * @return array
  37. */
  38. public function setStatus($id,$status) {
  39. Db::startTrans();
  40. //1.设置收购单状态
  41. $dao = new ReceiptOrderDao();
  42. $statusRe = $dao->setStatus($id,$status);
  43. if (!$statusRe['flag']) {
  44. Db::rollback();
  45. return$statusRe;
  46. }
  47. //2.设置所有订单主表的状态
  48. $orderDao = new OrderMainDao();
  49. $orderRe = $orderDao->setReceiptOrderStatus($id,$status);
  50. if (!$orderRe['flag']) {
  51. Db::rollback();
  52. return $orderRe;
  53. }
  54. Db::commit();
  55. return Util::returnArrSu();
  56. }
  57. /**
  58. * 添加主订单到采购单
  59. * @param $id
  60. * @param $order_id
  61. * @return array
  62. */
  63. public function addOrderMain($id,$order_id){
  64. $model = new ReceiptOrderDao();
  65. $infoRe = $model->getInfoById($id);
  66. if (!$infoRe['flag']) {
  67. return $infoRe;
  68. }
  69. $orderIds = explode(",", $order_id);
  70. $orderMainDao = new OrderMainDao();
  71. $addRe = $orderMainDao->addOrderMainInReceipt($infoRe['data'],$orderIds);
  72. if (!$addRe['flag']) {
  73. return $addRe;
  74. }
  75. return Util::returnArrSu();
  76. }
  77. /**
  78. * 移除采购单
  79. * @param $order_id
  80. * @return array
  81. */
  82. public function removeOrderMain($order_id){
  83. $orderIds = explode(",", $order_id);
  84. $orderMainDao = new OrderMainDao();
  85. return $orderMainDao->removeOrderMainFormReceipt($orderIds);
  86. }
  87. /**
  88. * 获取主订单列表
  89. * @param $param
  90. * @return array
  91. */
  92. public function getOrderMainList($param){
  93. $orderMainDao = new OrderMainDao();
  94. $where = ["id"=>["neq",""]];
  95. if (!empty($param['order_id'])) {
  96. $where["order"]=$param['order_id'];
  97. }
  98. switch ($param['inReceipt']) {
  99. case 0:
  100. break;
  101. case 1:
  102. $where["receipt_order_id"] = $param['receipt_order_id'];
  103. break;
  104. case 2:
  105. $where["receipt_order_id"] = ["neq",$param['receipt_order_id']];
  106. break;
  107. case 3:
  108. $where["receipt_order_id"] = "";
  109. }
  110. return $orderMainDao->getOrderListByWhere($where,$param);
  111. }
  112. }