Mallconsult.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Mallconsult extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 咨询列表
  16. * @access public
  17. * @author csdeshang
  18. * @param array $condition 条件
  19. * @param string $field 字段
  20. * @param int $pagesize 分页
  21. * @param string $order 排序
  22. * @return array
  23. */
  24. public function getMallconsultList($condition, $field = '*', $pagesize = 0, $order = 'mallconsult_id desc')
  25. {
  26. if ($pagesize) {
  27. $res = Db::name('mallconsult')->where($condition)->field($field)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  28. $this->page_info = $res;
  29. return $res->items();
  30. } else {
  31. return Db::name('mallconsult')->where($condition)->field($field)->order($order)->select()->toArray();
  32. }
  33. }
  34. /**
  35. * 咨询数量
  36. * @access public
  37. * @author csdeshang
  38. * @param type $condition 条件
  39. * @return int
  40. */
  41. public function getMallconsultCount($condition)
  42. {
  43. return Db::name('mallconsult')->where($condition)->count();
  44. }
  45. /**
  46. * 单条咨询
  47. * @access public
  48. * @author csdeshang
  49. * @param type $condition 条件
  50. * @param type $field 字段
  51. * @return type
  52. */
  53. public function getMallconsultInfo($condition, $field = '*')
  54. {
  55. return Db::name('mallconsult')->where($condition)->field($field)->find();
  56. }
  57. /**
  58. * 咨询详细信息
  59. * @access public
  60. * @author csdeshang
  61. * @param int $mallconsult_id ID编号
  62. * @return boolean|multitype:
  63. */
  64. public function getMallconsultDetail($mallconsult_id)
  65. {
  66. $consult_info = $this->getMallconsultInfo(array('mallconsult_id' => $mallconsult_id));
  67. if (empty($consult_info)) {
  68. return false;
  69. }
  70. $type_info = model('mallconsulttype')->getMallconsulttypeInfo(array('mallconsulttype_id' => $consult_info['mallconsulttype_id']), 'mallconsulttype_name');
  71. return array_merge($consult_info, $type_info);
  72. }
  73. /**
  74. * 添加咨询
  75. * @access public
  76. * @author csdeshang
  77. * @param array $insert 参数内容
  78. * @return bool
  79. */
  80. public function addMallconsult($insert)
  81. {
  82. $insert['mallconsult_addtime'] = TIMESTAMP;
  83. return Db::name('mallconsult')->insertGetId($insert);
  84. }
  85. /**
  86. * 编辑咨询
  87. * @access public
  88. * @author csdeshang
  89. * @param array $condition 条件
  90. * @param array $update 数据
  91. * @return boolean
  92. */
  93. public function editMallconsult($condition, $update)
  94. {
  95. return Db::name('mallconsult')->where($condition)->update($update);
  96. }
  97. /**
  98. * 删除咨询
  99. * @access public
  100. * @author csdeshang
  101. * @param array $condition 条件
  102. * @return boolean
  103. */
  104. public function delMallconsult($condition)
  105. {
  106. return Db::name('mallconsult')->where($condition)->delete();
  107. }
  108. }