Consult.php 2.5 KB

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