Storemsg.php 2.7 KB

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