Inform.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Inform extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 查询举报数量
  16. * @access public
  17. * @author csdeshang
  18. * @param array $condition 查询条件
  19. * @return int
  20. */
  21. public function getInformCount($condition)
  22. {
  23. return Db::name('inform')->where($condition)->count();
  24. }
  25. /**
  26. * 增加
  27. * @access public
  28. * @author csdeshang
  29. * @param array $data 参数内容
  30. * @return bool
  31. */
  32. public function addInform($data)
  33. {
  34. return Db::name('inform')->insertGetId($data);
  35. }
  36. /**
  37. * 更新
  38. * @access public
  39. * @author csdeshang
  40. * @param array $update_array 更新数据
  41. * @param array $where_array 更新条件
  42. * @return bool
  43. */
  44. public function editInform($update_array, $where_array)
  45. {
  46. return Db::name('inform')->where($where_array)->update($update_array);
  47. }
  48. /**
  49. * 删除
  50. * @access public
  51. * @author csdeshang
  52. * @param array $condition 条件
  53. * @return bool
  54. */
  55. public function delInform($condition)
  56. {
  57. return Db::name('inform')->where($condition)->delete();
  58. }
  59. /**
  60. * 获得列表
  61. * @access public
  62. * @author csdeshang
  63. * @param array $condition 查询条件
  64. * @param int $pagesize 分页
  65. * @param string $order 排序
  66. * @return array
  67. */
  68. public function getInformList($condition = '', $pagesize = '', $order = 'inform_id desc')
  69. {
  70. if ($pagesize) {
  71. $res = Db::name('inform')->alias('inform')->join('informsubject inform_subject', 'inform.informsubject_id = inform_subject.informsubject_id', 'LEFT')->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  72. $this->page_info = $res;
  73. return $res->items();
  74. } else {
  75. return Db::name('inform')->alias('inform')->join('informsubject inform_subject', 'inform.informsubject_id = inform_subject.informsubject_id', 'LEFT')->where($condition)->order($order)->select()->toArray();
  76. }
  77. }
  78. /**
  79. * 根据id获取举报详细信息
  80. * @access public
  81. * @author csdeshang
  82. * @param array $condition 查询条件
  83. * @return array
  84. */
  85. public function getOneInform($condition)
  86. {
  87. return Db::name('inform')->where($condition)->find();
  88. }
  89. /**
  90. * 判断该商品是否正在被举报
  91. * @access public
  92. * @author csdeshang
  93. * @param int $goods_id 商品id
  94. * @return bool
  95. */
  96. public function isProcessOfInform($goods_id)
  97. {
  98. $condition = array();
  99. $condition[] = array('inform_goods_id', '=', $goods_id);
  100. $condition[] = array('inform_state', '=', 1);
  101. $inform = $this->getOneInform($condition);
  102. if (!empty($inform)) {
  103. return true;
  104. } else {
  105. return false;
  106. }
  107. }
  108. }