Mallconsult.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 Mallconsult extends BaseModel
  16. {
  17. public $page_info;
  18. /**
  19. * 咨询列表
  20. * @access public
  21. * @author csdeshang
  22. * @param array $condition 条件
  23. * @param string $field 字段
  24. * @param int $pagesize 分页
  25. * @param string $order 排序
  26. * @return array
  27. */
  28. public function getMallconsultList($condition, $field = '*', $pagesize = 0, $order = 'mallconsult_id desc') {
  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. return Db::name('mallconsult')->where($condition)->count();
  46. }
  47. /**
  48. * 单条咨询
  49. * @access public
  50. * @author csdeshang
  51. * @param type $condition 条件
  52. * @param type $field 字段
  53. * @return type
  54. */
  55. public function getMallconsultInfo($condition, $field = '*') {
  56. return Db::name('mallconsult')->where($condition)->field($field)->find();
  57. }
  58. /**
  59. * 咨询详细信息
  60. * @access public
  61. * @author csdeshang
  62. * @param int $mallconsult_id ID编号
  63. * @return boolean|multitype:
  64. */
  65. public function getMallconsultDetail($mallconsult_id) {
  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. $insert['mallconsult_addtime'] = TIMESTAMP;
  82. return Db::name('mallconsult')->insertGetId($insert);
  83. }
  84. /**
  85. * 编辑咨询
  86. * @access public
  87. * @author csdeshang
  88. * @param array $condition 条件
  89. * @param array $update 数据
  90. * @return boolean
  91. */
  92. public function editMallconsult($condition, $update) {
  93. return Db::name('mallconsult')->where($condition)->update($update);
  94. }
  95. /**
  96. * 删除咨询
  97. * @access public
  98. * @author csdeshang
  99. * @param array $condition 条件
  100. * @return boolean
  101. */
  102. public function delMallconsult($condition) {
  103. return Db::name('mallconsult')->where($condition)->delete();
  104. }
  105. }