Fleaconsult.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Fleaconsult extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 添加咨询
  16. * @access public
  17. * @author csdeshang
  18. * @param array $data 参数内容
  19. * @return bool
  20. */
  21. public function addFleaconsult($data)
  22. {
  23. if (empty($data)) {
  24. return false;
  25. }
  26. $consult = array();
  27. $consult['seller_id'] = $data['seller_id'];
  28. $consult['member_id'] = $data['member_id'];
  29. $consult['goods_id'] = $data['goods_id'];
  30. $consult['fleaconsult_email'] = trim($data['email']);
  31. $consult['fleaconsult_content'] = trim($data['consult_content']);
  32. $consult['fleaconsult_addtime'] = TIMESTAMP;
  33. $consult['fleaconsult_type'] = $data['type'];
  34. $result = Db::name('fleaconsult')->insertGetId($consult);
  35. if ($result) {
  36. return $result;
  37. } else {
  38. return false;
  39. }
  40. }
  41. /**
  42. * 查询咨询
  43. * @access public
  44. * @author csdeshang
  45. * @param type $condition 查询条件
  46. * @param type $pagesize 分页信息
  47. * @param type $type 查询类型
  48. * @param type $ctype 咨询类型
  49. * @param type $order 排序
  50. * @return type
  51. */
  52. public function getFleaconsultList($condition, $pagesize = '', $type = "simple", $ctype = 'goods', $order = 'fleaconsult.fleaconsult_id desc')
  53. {
  54. switch ($type) {
  55. case 'seller':
  56. $consult_list = Db::name('fleaconsult')->where($condition)->alias('fleaconsult')->field('fleaconsult.*,member.member_name,member.member_avatar,flea.goods_name')->order($order)->join('member member', 'fleaconsult.member_id = member.member_id')->join('flea flea', 'fleaconsult.goods_id = flea.goods_id');
  57. break;
  58. default:
  59. $consult_list = Db::name('fleaconsult')->where($condition)->order($order);
  60. break;
  61. }
  62. if ($pagesize) {
  63. $consult_list = $consult_list->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  64. $this->page_info = $consult_list;
  65. return $consult_list->items();
  66. } else {
  67. return $consult_list->select()->toArray();
  68. }
  69. }
  70. /**
  71. * 删除咨询
  72. * @access public
  73. * @author csdeshang
  74. * @param int $id ID编号
  75. * @return bool
  76. */
  77. public function delFleaconsult($id)
  78. {
  79. return Db::name('fleaconsult')->where("fleaconsult_id in ({$id})")->delete();
  80. }
  81. /**
  82. * 回复咨询
  83. * @access public
  84. * @author csdeshang
  85. * @param array $data 参数内容
  86. * @return type
  87. */
  88. public function replyFleaconsult($data)
  89. {
  90. $data['fleaconsult_reply_time'] = TIMESTAMP;
  91. return Db::name('fleaconsult')->where('fleaconsult_id', $data['consult_id'])->update($data);
  92. }
  93. }