Storecost.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 数据层模型
  14. */
  15. class Storecost extends BaseModel {
  16. public $page_info;
  17. /**
  18. * 读取列表
  19. * @access public
  20. * @author csdeshang
  21. * @param array $condition 条件
  22. * @param int $pagesize 分页
  23. * @param string $order 排序
  24. * @param string $field 字段
  25. * @return array
  26. */
  27. public function getStorecostList($condition, $pagesize = '', $order = '', $field = '*') {
  28. if($pagesize){
  29. $result = Db::name('storecost')->field($field)->where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  30. $this->page_info = $result;
  31. return $result->items();
  32. }else{
  33. $result = Db::name('storecost')->field($field)->where($condition)->order($order)->select()->toArray();
  34. return $result;
  35. }
  36. }
  37. /**
  38. * 读取单条记录
  39. * @access public
  40. * @author csdeshang
  41. * @param array $condition 条件
  42. * @param string $fields 字段
  43. * @return array
  44. */
  45. public function getStorecostInfo($condition, $fields = '*') {
  46. $result = Db::name('storecost')->where($condition)->field($fields)->find();
  47. return $result;
  48. }
  49. /**
  50. * 增加
  51. * @access public
  52. * @author csdeshang
  53. * @param array $data 数据
  54. * @return bool
  55. */
  56. public function addStorecost($data) {
  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. return Db::name('storecost')->where($condition)->delete();
  68. }
  69. /**
  70. * 更新
  71. * @access public
  72. * @author csdeshang
  73. * @param array $data 更新数据
  74. * @param array $condition 条件
  75. * @return bool
  76. */
  77. public function editStorecost($data, $condition) {
  78. return Db::name('storecost')->where($condition)->update($data);
  79. }
  80. }
  81. ?>