Inform.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 Inform extends BaseModel {
  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. return Db::name('inform')->where($condition)->count();
  26. }
  27. /**
  28. * 增加
  29. * @access public
  30. * @author csdeshang
  31. * @param array $data 参数内容
  32. * @return bool
  33. */
  34. public function addInform($data) {
  35. return Db::name('inform')->insertGetId($data);
  36. }
  37. /**
  38. * 更新
  39. * @access public
  40. * @author csdeshang
  41. * @param array $update_array 更新数据
  42. * @param array $where_array 更新条件
  43. * @return bool
  44. */
  45. public function editInform($update_array, $where_array) {
  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. return Db::name('inform')->where($condition)->delete();
  57. }
  58. /**
  59. * 获得列表
  60. * @access public
  61. * @author csdeshang
  62. * @param array $condition 查询条件
  63. * @param int $pagesize 分页
  64. * @param string $order 排序
  65. * @return array
  66. */
  67. public function getInformList($condition = '', $pagesize = '',$order = 'inform_id desc') {
  68. if($pagesize){
  69. $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);
  70. $this->page_info = $res;
  71. return $res->items();
  72. }else{
  73. return Db::name('inform')->alias('inform')->join('informsubject inform_subject', 'inform.informsubject_id = inform_subject.informsubject_id', 'LEFT')->where($condition)->order($order)->select()->toArray();
  74. }
  75. }
  76. /**
  77. * 根据id获取举报详细信息
  78. * @access public
  79. * @author csdeshang
  80. * @param array $condition 查询条件
  81. * @return array
  82. */
  83. public function getOneInform($condition) {
  84. return Db::name('inform')->where($condition)->find();
  85. }
  86. /**
  87. * 判断该商品是否正在被举报
  88. * @access public
  89. * @author csdeshang
  90. * @param int $goods_id 商品id
  91. * @return bool
  92. */
  93. public function isProcessOfInform($goods_id) {
  94. $condition = array();
  95. $condition[] = array('inform_goods_id','=',$goods_id);
  96. $condition[] = array('inform_state','=',1);
  97. $inform = $this->getOneInform($condition);
  98. if (!empty($inform)) {
  99. return true;
  100. } else {
  101. return false;
  102. }
  103. }
  104. }