Complain.php 3.8 KB

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