Mallconsult.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 数据层模型
  15. */
  16. class Mallconsult extends BaseModel
  17. {
  18. public $page_info;
  19. /**
  20. * 咨询列表
  21. * @access public
  22. * @author csdeshang
  23. * @param array $condition 条件
  24. * @param string $field 字段
  25. * @param int $pagesize 分页
  26. * @param string $order 排序
  27. * @return array
  28. */
  29. public function getMallconsultList($condition, $field = '*', $pagesize = 0, $order = 'mallconsult_id desc') {
  30. if($pagesize){
  31. $res= Db::name('mallconsult')->where($condition)->field($field)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  32. $this->page_info=$res;
  33. return $res->items();
  34. }else{
  35. return Db::name('mallconsult')->where($condition)->field($field)->order($order)->select()->toArray();
  36. }
  37. }
  38. /**
  39. * 咨询数量
  40. * @access public
  41. * @author csdeshang
  42. * @param type $condition 条件
  43. * @return int
  44. */
  45. public function getMallconsultCount($condition) {
  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. return Db::name('mallconsult')->where($condition)->field($field)->find();
  58. }
  59. /**
  60. * 咨询详细信息
  61. * @access public
  62. * @author csdeshang
  63. * @param int $mallconsult_id ID编号
  64. * @return boolean|multitype:
  65. */
  66. public function getMallconsultDetail($mallconsult_id) {
  67. $consult_info = $this->getMallconsultInfo(array('mallconsult_id' => $mallconsult_id));
  68. if (empty($consult_info)) {
  69. return false;
  70. }
  71. $type_info = model('mallconsulttype')->getMallconsulttypeInfo(array('mallconsulttype_id' => $consult_info['mallconsulttype_id']), 'mallconsulttype_name');
  72. return array_merge($consult_info, $type_info);
  73. }
  74. /**
  75. * 添加咨询
  76. * @access public
  77. * @author csdeshang
  78. * @param array $insert 参数内容
  79. * @return bool
  80. */
  81. public function addMallconsult($insert) {
  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. return Db::name('mallconsult')->where($condition)->update($update);
  95. }
  96. /**
  97. * 删除咨询
  98. * @access public
  99. * @author csdeshang
  100. * @param array $condition 条件
  101. * @return boolean
  102. */
  103. public function delMallconsult($condition) {
  104. return Db::name('mallconsult')->where($condition)->delete();
  105. }
  106. }