酒店预订平台
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

106 řádky
3.2 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: nizongfeng
  5. * Date: 2021/11/23
  6. * Time: 17:24
  7. */
  8. namespace app\admin\dao;
  9. use app\admin\command\Util;
  10. use app\admin\model\CfItem;
  11. class CfItemDao
  12. {
  13. /**
  14. * 添加记录
  15. * @param $param
  16. * @return array
  17. */
  18. public function save($param)
  19. {
  20. try {
  21. $data = [
  22. 'item_type' => $param['item_type'],
  23. 'item_name' => $param['item_name'],
  24. 'item_unit' => $param['item_unit'],
  25. 'item_memo' => $param['item_memo'],
  26. 'area' => $param['area'],
  27. 'area_name' => $param['area_name'],
  28. 'province' => $param['province'],
  29. 'province_name' => $param['province_name'],
  30. 'city' => $param['city'],
  31. 'city_name' => $param['city_name'],
  32. 'detail_address' => $param['detail_address'],
  33. 'purchase_user_id'=>$param['purchase_user_id']
  34. ];
  35. $model = new CfItem();
  36. if (empty($param['id'])) {
  37. $data['create_id'] = $param['create_id'];
  38. $data['group_id'] = $param['group_id'];
  39. $id = $model->insertGetId($data);
  40. return Util::returnArrSu("", $id);
  41. } else {
  42. $model->save($data, ['id' => $param['id']]);
  43. return Util::returnArrSu("", $param['id']);
  44. }
  45. } catch (\Exception $e) {
  46. return Util::returnArrEr("更新记录失败:" . $e->getMessage());
  47. }
  48. }
  49. /**
  50. * 获取列表
  51. * @param $param
  52. * @return array
  53. */
  54. public function getList($param)
  55. {
  56. try {
  57. $where = ["del_flag"=>0,"group_id"=>$param['group_id']];
  58. if (!empty($param['item_name'])) {
  59. $where['item_name'] = ["like","%".$param['item_name']."%"];
  60. }
  61. if (!empty($param['item_type'])) {
  62. $where["item_type"] = $param['item_type'];
  63. }
  64. if (!empty($param['area'])) {
  65. $where["area"] = $param['area'];
  66. }
  67. if (!empty($param['province'])) {
  68. $where["province"] = $param['province'];
  69. }
  70. if (!empty($param['city'])) {
  71. $where["city"] = $param['city'];
  72. }
  73. $offset = ($param['pageNum'] - 1) * $param['pageSize'];
  74. $model = new CfItem();
  75. $total = $model->where($where)->count();
  76. $list = $model->where($where)
  77. ->limit($offset, $param['pageSize'])
  78. ->order("id","DESC")->select();
  79. $data = ["total" => $total, "list" => $list->toArray()];
  80. return Util::returnArrSu("", $data);
  81. } catch (\Exception $e) {
  82. return Util::returnArrSu("", ["total" => 0, "list" => []]);
  83. }
  84. }
  85. /**
  86. * 删除
  87. * @param $id
  88. * @return array
  89. */
  90. public function del($id){
  91. try {
  92. //设置收购单状态
  93. $model = new CfItem();
  94. $model->save(['del_flag' => 1], ['id' => $id]);
  95. return Util::returnArrSu();
  96. } catch (\Exception $e) {
  97. return Util::returnArrEr("修改状态失败" . $e->getMessage());
  98. }
  99. }
  100. }