Complain.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Complain 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 getComplainCount($condition)
  22. {
  23. return Db::name('complain')->where($condition)->count();
  24. }
  25. /**
  26. * 增加
  27. * @access public
  28. * @author csdeshang
  29. * @param array $data 参数内容
  30. * @return bool
  31. */
  32. public function addComplain($data)
  33. {
  34. return Db::name('complain')->insertGetId($data);
  35. }
  36. /**
  37. * 更新
  38. * @access public
  39. * @author csdeshang
  40. * @param array $update_array 更新数据
  41. * @param array $where_array 更新条件
  42. * @return boll
  43. */
  44. public function editComplain($update_array, $where_array)
  45. {
  46. return Db::name('complain')->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 delComplain($condition)
  56. {
  57. return Db::name('complain')->where($condition)->delete();
  58. }
  59. /**
  60. * 获得投诉列表
  61. * @access public
  62. * @author csdeshang
  63. * @param array $condition 检索条件
  64. * @param int $pagesize 分页信息
  65. * @param str $order 排序
  66. * @return array
  67. */
  68. public function getComplainList($condition = '', $pagesize = '', $order = 'complain_id desc')
  69. {
  70. if ($pagesize) {
  71. $res = Db::name('complain')->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('complain')->where($condition)->order($order)->select()->toArray();
  76. }
  77. }
  78. /**
  79. * 获得投诉商品列表
  80. * @access public
  81. * @author csdeshang
  82. * @param array $complain_list 投诉列表
  83. * @return array
  84. */
  85. public function getComplainGoodsList($complain_list)
  86. {
  87. $goods_ids = array();
  88. if (!empty($complain_list) && is_array($complain_list)) {
  89. foreach ($complain_list as $key => $value) {
  90. $goods_ids[] = $value['order_goods_id']; //订单商品表编号
  91. }
  92. }
  93. $res = Db::name('ordergoods')->where('rec_id', 'in', $goods_ids)->select()->toArray();
  94. return ds_change_arraykey($res, 'rec_id');
  95. }
  96. /**
  97. * 检查投诉是否存在
  98. * @access public
  99. * @author csdeshang
  100. * @param array $condition 检索条件
  101. * @return boolean
  102. */
  103. public function isComplainExist($condition = '')
  104. {
  105. $list = Db::name('complain')->where($condition)->select()->toArray();
  106. if (empty($list)) {
  107. return false;
  108. } else {
  109. return true;
  110. }
  111. }
  112. /**
  113. * 根据id获取投诉详细信息
  114. * @access public
  115. * @author csdeshang
  116. * @param int $complain_id 投诉ID
  117. * @return type
  118. */
  119. public function getOneComplain($complain_id)
  120. {
  121. return Db::name('complain')->where('complain_id', intval($complain_id))->find();
  122. }
  123. }