Complain.php 3.7 KB

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