Storecost.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Storecost extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 读取列表
  16. * @access public
  17. * @author csdeshang
  18. * @param array $condition 条件
  19. * @param int $pagesize 分页
  20. * @param string $order 排序
  21. * @param string $field 字段
  22. * @return array
  23. */
  24. public function getStorecostList($condition, $pagesize = '', $order = '', $field = '*')
  25. {
  26. if ($pagesize) {
  27. $result = Db::name('storecost')->field($field)->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  28. $this->page_info = $result;
  29. return $result->items();
  30. } else {
  31. $result = Db::name('storecost')->field($field)->where($condition)->order($order)->select()->toArray();
  32. return $result;
  33. }
  34. }
  35. /**
  36. * 读取单条记录
  37. * @access public
  38. * @author csdeshang
  39. * @param array $condition 条件
  40. * @param string $fields 字段
  41. * @return array
  42. */
  43. public function getStorecostInfo($condition, $fields = '*')
  44. {
  45. $result = Db::name('storecost')->where($condition)->field($fields)->find();
  46. return $result;
  47. }
  48. /**
  49. * 增加
  50. * @access public
  51. * @author csdeshang
  52. * @param array $data 数据
  53. * @return bool
  54. */
  55. public function addStorecost($data)
  56. {
  57. return Db::name('storecost')->insertGetId($data);
  58. }
  59. /**
  60. * 删除
  61. * @access public
  62. * @author csdeshang
  63. * @param array $condition 条件
  64. * @return bool
  65. */
  66. public function delStorecost($condition)
  67. {
  68. return Db::name('storecost')->where($condition)->delete();
  69. }
  70. /**
  71. * 更新
  72. * @access public
  73. * @author csdeshang
  74. * @param array $data 更新数据
  75. * @param array $condition 条件
  76. * @return bool
  77. */
  78. public function editStorecost($data, $condition)
  79. {
  80. return Db::name('storecost')->where($condition)->update($data);
  81. }
  82. }