心理咨询网
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.

MemberGroupModel.php 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * @copyright (C)2016-2099 Hnaoyun Inc.
  4. * @author XingMeng
  5. * @email hnxsh@foxmail.com
  6. * @date 2020年06月25日
  7. * 会员等级模型类
  8. */
  9. namespace app\admin\model\member;
  10. use core\basic\Model;
  11. class MemberGroupModel extends Model
  12. {
  13. // 获取会员等级列表
  14. public function getList()
  15. {
  16. return parent::table('ay_member_group')->order('gcode,id')
  17. ->page()
  18. ->select();
  19. }
  20. // 查找会员等级
  21. public function findGroup($field, $keyword)
  22. {
  23. return parent::table('ay_member_group')->like($field, $keyword)
  24. ->order('gcode,id')
  25. ->page()
  26. ->select();
  27. }
  28. // 获取最后一个code
  29. public function getLastGid()
  30. {
  31. return parent::table('ay_member_group')->order('id DESC')->value('gcode');
  32. }
  33. // 获取等级选择列表
  34. public function getSelect()
  35. {
  36. return parent::table('ay_member_group')->field('id,gcode,gname')
  37. ->order('gcode,id')
  38. ->select();
  39. }
  40. // 获取会员等级详情
  41. public function getGroup($id)
  42. {
  43. return parent::table('ay_member_group')->where("id=$id")->find();
  44. }
  45. // 获取会员等级名称
  46. public function getGroupName($id)
  47. {
  48. return parent::table('ay_member_group')->where("id=$id")->value('gname');
  49. }
  50. // 添加会员等级
  51. public function addGroup(array $data)
  52. {
  53. return parent::table('ay_member_group')->autoTime()->insert($data);
  54. }
  55. // 删除会员等级
  56. public function delGroup($id)
  57. {
  58. return parent::table('ay_member_group')->where("id=$id")->delete();
  59. }
  60. // 修改会员等级
  61. public function modGroup($id, $data)
  62. {
  63. return parent::table('ay_member_group')->where("id=$id")->update($data);
  64. }
  65. // 查找等级下会员是否存在
  66. public function findGroupUser($id)
  67. {
  68. return parent::table('ay_member')->field('id')
  69. ->where("gid=$id")
  70. ->find();
  71. }
  72. // 查找等级编号
  73. public function findGroupCode($gcode, $id = null)
  74. {
  75. if ($id) {
  76. return parent::table('ay_member_group')->field('id')
  77. ->where("gcode='$gcode' and id<>$id")
  78. ->find();
  79. } else {
  80. return parent::table('ay_member_group')->field('id')
  81. ->where("gcode='$gcode'")
  82. ->find();
  83. }
  84. }
  85. }