Fleaconsult.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 Fleaconsult extends BaseModel {
  17. public $page_info;
  18. /**
  19. * 添加咨询
  20. * @access public
  21. * @author csdeshang
  22. * @param array $data 参数内容
  23. * @return bool
  24. */
  25. public function addFleaconsult($data) {
  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. switch ($type) {
  57. case 'seller':
  58. $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');
  59. break;
  60. default:
  61. $consult_list = Db::name('fleaconsult')->where($condition)->order($order);
  62. break;
  63. }
  64. if($pagesize){
  65. $consult_list = $consult_list->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  66. $this->page_info = $consult_list;
  67. return $consult_list->items();
  68. }else{
  69. return $consult_list->select()->toArray();
  70. }
  71. }
  72. /**
  73. * 删除咨询
  74. * @access public
  75. * @author csdeshang
  76. * @param int $id ID编号
  77. * @return bool
  78. */
  79. public function delFleaconsult($id) {
  80. return Db::name('fleaconsult')->where("fleaconsult_id in ({$id})")->delete();
  81. }
  82. /**
  83. * 回复咨询
  84. * @access public
  85. * @author csdeshang
  86. * @param array $data 参数内容
  87. * @return type
  88. */
  89. public function replyFleaconsult($data) {
  90. $data['fleaconsult_reply_time'] = TIMESTAMP;
  91. return Db::name('fleaconsult')->where('fleaconsult_id',$data['consult_id'])->update($data);
  92. }
  93. }