心理咨询网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MemberModel.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * @copyright (C)2016-2099 Hnaoyun Inc.
  4. * @author XingMeng
  5. * @email hnxsh@foxmail.com
  6. * @date 2019年10月05日
  7. * 会员模型类
  8. */
  9. namespace app\admin\model\member;
  10. use core\basic\Model;
  11. class MemberModel extends Model
  12. {
  13. // 获取会员列表
  14. public function getList()
  15. {
  16. $field = array(
  17. 'a.*',
  18. 'b.gname'
  19. );
  20. $join = array(
  21. 'ay_member_group b',
  22. 'a.gid=b.id',
  23. 'LEFT'
  24. );
  25. return parent::table('ay_member a')->field($field)
  26. ->join($join)
  27. ->order('a.id desc')
  28. ->page()
  29. ->select();
  30. }
  31. // 查找会员
  32. public function findMember($field, $keyword)
  33. {
  34. $fields = array(
  35. 'a.*',
  36. 'b.gname'
  37. );
  38. $join = array(
  39. 'ay_member_group b',
  40. 'a.gid=b.id',
  41. 'LEFT'
  42. );
  43. return parent::table('ay_member a')->field($fields)
  44. ->join($join)
  45. ->like($field, $keyword)
  46. ->order('a.id desc')
  47. ->page()
  48. ->select();
  49. }
  50. // 检查会员
  51. public function checkMember($where)
  52. {
  53. return parent::table('ay_member')->where($where)->find();
  54. }
  55. // 获取最后一个code
  56. public function getLastCode()
  57. {
  58. return parent::table('ay_member')->order('id DESC')->value('ucode');
  59. }
  60. // 获取会员详情
  61. public function getMember($id)
  62. {
  63. $field = array(
  64. 'a.*',
  65. 'b.gname'
  66. );
  67. $join = array(
  68. 'ay_member_group b',
  69. 'a.gid=b.id',
  70. 'LEFT'
  71. );
  72. return parent::table('ay_member a')->field($field)
  73. ->join($join)
  74. ->where("a.id=$id")
  75. ->find();
  76. }
  77. // 添加会员
  78. public function addMember(array $data)
  79. {
  80. return parent::table('ay_member')->insert($data);
  81. }
  82. // 删除会员
  83. public function delMember($id)
  84. {
  85. return parent::table('ay_member')->where("id=$id")->delete();
  86. }
  87. // 删除会员
  88. public function delMemberList($ids)
  89. {
  90. return parent::table('ay_member')->delete($ids);
  91. }
  92. // 修改会员
  93. public function modMember($id, $data)
  94. {
  95. return parent::table('ay_member')->where("id=$id")->update($data);
  96. }
  97. // 修改会员
  98. public function modMemberList($ids, $data)
  99. {
  100. return parent::table('ay_member')->in('id', $ids)->update($data);
  101. }
  102. // 会员字段
  103. public function getFields()
  104. {
  105. return parent::table('ay_member_field')->where('status=1')
  106. ->order('sorting')
  107. ->select();
  108. }
  109. }