Storemsg.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Storemsg extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 新增店铺消息
  16. * @access public
  17. * @author csdeshang
  18. * @param array $data 参数内容
  19. * @return type
  20. */
  21. public function addStoremsg($data)
  22. {
  23. $data['storemsg_addtime'] = TIMESTAMP;
  24. $storemsg_id = Db::name('storemsg')->insertGetId($data);
  25. return $storemsg_id;
  26. }
  27. /**
  28. * 更新店铺消息表
  29. * @access public
  30. * @author csdeshang
  31. * @param array $condition 条件
  32. * @param array $update 更新数据
  33. * @return bool
  34. */
  35. public function editStoremsg($condition, $update)
  36. {
  37. return Db::name('storemsg')->where($condition)->update($update);
  38. }
  39. /**
  40. * 查看店铺消息详细
  41. * @access public
  42. * @author csdeshang
  43. * @param unknown $condition 条件
  44. * @param string $field 字段
  45. * @return bool
  46. */
  47. public function getStoremsgInfo($condition, $field = '*')
  48. {
  49. return Db::name('storemsg')->field($field)->where($condition)->find();
  50. }
  51. /**
  52. * 店铺消息列表
  53. * @access public
  54. * @author csdeshang
  55. * @param type $condition 条件
  56. * @param type $field 字段
  57. * @param type $pagesize 分页
  58. * @param type $order 排序
  59. * @return type
  60. */
  61. public function getStoremsgList($condition, $field = '*', $pagesize = '0', $order = 'storemsg_id desc')
  62. {
  63. $return = Db::name('storemsg')->field($field)->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  64. $this->page_info = $return;
  65. return $return->items();
  66. }
  67. /**
  68. * 计算消息数量
  69. * @access public
  70. * @author csdeshang
  71. * @param array $condition 条件
  72. * @return int
  73. */
  74. public function getStoremsgCount($condition)
  75. {
  76. return Db::name('storemsg')->where($condition)->count();
  77. }
  78. /**
  79. * 删除店铺消息
  80. * @access public
  81. * @author csdeshang
  82. * @param type $condition 条件
  83. * @return bool
  84. */
  85. public function delStoremsg($condition)
  86. {
  87. Db::name('storemsg')->where($condition)->delete();
  88. }
  89. }