Consult.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Consult 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 getConsultCount($condition)
  22. {
  23. return Db::name('consult')->where($condition)->count();
  24. }
  25. /**
  26. * 添加咨询
  27. * @access public
  28. * @author csdeshang
  29. * @param array $data 参数内容
  30. * @return int
  31. */
  32. public function addConsult($data)
  33. {
  34. return Db::name('consult')->insertGetId($data);
  35. }
  36. /**
  37. * 商品咨询列表
  38. * @access public
  39. * @author csdeshang
  40. * @param array $condition 检索条件
  41. * @param str $field 字段
  42. * @param int $pagesize 分页信息
  43. * @param str $order 排序
  44. * @return array
  45. */
  46. public function getConsultList($condition, $field = '*', $pagesize = 10, $order = 'consult_id desc')
  47. {
  48. $res = Db::name('consult')->where($condition)->field($field)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  49. $this->page_info = $res;
  50. return $res->items();
  51. }
  52. /**
  53. * 获取咨询信息
  54. * @access public
  55. * @author csdeshang
  56. * @param array $condition 咨询条件
  57. * @return array
  58. */
  59. public function getConsultInfo($condition)
  60. {
  61. return Db::name('consult')->where($condition)->find();
  62. }
  63. /**
  64. * 删除咨询
  65. * @access public
  66. * @author csdeshang
  67. * @param array $condition 检索条件
  68. */
  69. public function delConsult($condition)
  70. {
  71. return Db::name('consult')->where($condition)->delete();
  72. }
  73. /**
  74. * 回复咨询
  75. * @access public
  76. * @author csdeshang
  77. * @param array $condition 条件
  78. * @param array $data 参数内容
  79. * @return type
  80. */
  81. public function editConsult($condition, $data)
  82. {
  83. $data['consult_replytime'] = TIMESTAMP;
  84. return Db::name('consult')->where($condition)->update($data);
  85. }
  86. }