Mallconsult.php 3.4 KB

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