Inform.php 3.4 KB

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