Fleaconsult.php 3.3 KB

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