Fleaconsult.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 Fleaconsult extends BaseModel {
  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. if (empty($data)) {
  26. return false;
  27. }
  28. $consult = array();
  29. $consult['seller_id'] = $data['seller_id'];
  30. $consult['member_id'] = $data['member_id'];
  31. $consult['goods_id'] = $data['goods_id'];
  32. $consult['fleaconsult_email'] = trim($data['email']);
  33. $consult['fleaconsult_content'] = trim($data['consult_content']);
  34. $consult['fleaconsult_addtime'] = TIMESTAMP;
  35. $consult['fleaconsult_type'] = $data['type'];
  36. $result = Db::name('fleaconsult')->insertGetId($consult);
  37. if ($result) {
  38. return $result;
  39. } else {
  40. return false;
  41. }
  42. }
  43. /**
  44. * 查询咨询
  45. * @access public
  46. * @author csdeshang
  47. * @param type $condition 查询条件
  48. * @param type $pagesize 分页信息
  49. * @param type $type 查询类型
  50. * @param type $ctype 咨询类型
  51. * @param type $order 排序
  52. * @return type
  53. */
  54. public function getFleaconsultList($condition, $pagesize = '', $type = "simple", $ctype = 'goods',$order='fleaconsult.fleaconsult_id desc') {
  55. switch ($type) {
  56. case 'seller':
  57. $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');
  58. break;
  59. default:
  60. $consult_list = Db::name('fleaconsult')->where($condition)->order($order);
  61. break;
  62. }
  63. if($pagesize){
  64. $consult_list = $consult_list->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  65. $this->page_info = $consult_list;
  66. return $consult_list->items();
  67. }else{
  68. return $consult_list->select()->toArray();
  69. }
  70. }
  71. /**
  72. * 删除咨询
  73. * @access public
  74. * @author csdeshang
  75. * @param int $id ID编号
  76. * @return bool
  77. */
  78. public function delFleaconsult($id) {
  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. $data['fleaconsult_reply_time'] = TIMESTAMP;
  90. return Db::name('fleaconsult')->where('fleaconsult_id',$data['consult_id'])->update($data);
  91. }
  92. }