酒店预订平台
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

105 wiersze
2.9 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: nizongfeng
  5. * Date: 2021/10/27
  6. * Time: 19:19
  7. */
  8. namespace app\admin\dao;
  9. use app\admin\command\Util;
  10. use app\admin\model\PurchasePrice;
  11. use think\Exception;
  12. class PurchasePriceDao
  13. {
  14. /**
  15. * 添加采购单每日价格
  16. * @param $param
  17. * @param int $order_id
  18. * @param string $prod_type
  19. * @param int $order_detail_id
  20. * @param int $purchase_id
  21. * @return array
  22. */
  23. public function saveList($param, int $order_id, string $prod_type, int $order_detail_id, int $purchase_id)
  24. {
  25. try {
  26. //删除记录
  27. $this->delete($purchase_id);
  28. //循环添加
  29. foreach ($param as $value) {
  30. $data = [
  31. "order_id" => $order_id,
  32. "prod_type" => $prod_type,
  33. "order_detail_id" => $order_detail_id,
  34. "purchase_id" => $purchase_id,
  35. "run_date" => $value['run_date'],
  36. "count" => $value['count'],
  37. "price" => $value['price'],
  38. "cost" => $value['cost'],
  39. "del_flag" => 0
  40. ];
  41. $model = new PurchasePrice();
  42. if (empty($value['id'])) {
  43. $model->insertGetId($data);
  44. } else {
  45. $model->save($data, ["id" => $value['id']]);
  46. }
  47. }
  48. return Util::returnArrSu();
  49. } catch (Exception $e) {
  50. return Util::returnArrEr("添加/更新采购单每日价格失败:" . $e->getMessage());
  51. }
  52. }
  53. /**
  54. * 删除数据
  55. * @param $purchase_id
  56. */
  57. public function delete($purchase_id)
  58. {
  59. $model = new PurchasePrice();
  60. $model->save(["del_flag" => 1], ["purchase_id" => $purchase_id]);
  61. }
  62. /**
  63. * 删除数据
  64. * @param $purchase_id
  65. */
  66. public function deleteByOrderId($orderId)
  67. {
  68. $model = new PurchasePrice();
  69. $model->save(["del_flag" => 1], ["order_id" => $orderId]);
  70. }
  71. /**
  72. * 删除子订单对于的每日价格
  73. * @param $subOrderId
  74. */
  75. public function deleteBySubOrderId($subOrderId) {
  76. $model = new PurchasePrice();
  77. $model->save(["del_flag" => 1], ["order_detail_id" => $subOrderId]);
  78. }
  79. /**
  80. * 获取采购单金额
  81. * @param $orderId
  82. * @return array
  83. */
  84. public function getPurchasePriceListByOrderId($orderId) {
  85. $model = new PurchasePrice();
  86. try {
  87. $list = $model->where(["order_id" => $orderId, "del_flag" => 0])->select()->toArray();
  88. if (null == $list) {
  89. return Util::returnArrSu("", []);
  90. }
  91. return Util::returnArrSu("", $list);
  92. }catch (Exception $e) {
  93. return Util::returnArrEr("获取采购单金额异常".$e->getMessage());
  94. }
  95. }
  96. }