Consult.php 2.6 KB

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