Group.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\model\user;
  12. use traits\ModelTrait;
  13. use basic\ModelBasic;
  14. use app\admin\model\user\User;
  15. /**
  16. * 用户管理 model
  17. * Class User
  18. * @package app\admin\model\user
  19. */
  20. class Group extends ModelBasic
  21. {
  22. use ModelTrait;
  23. public static function getUids()
  24. {
  25. return self::where('uid', 'neq', 0)->column('uid');
  26. }
  27. public static function getAll($where)
  28. {
  29. $model = new self();
  30. if ($where['nickname'] != '') $model->where('uid|user_name|phone|share_name', $where['nickname']);
  31. return self::page($model, function ($item) {
  32. $item['share_count'] = self::where(['share_uid' => $item['uid']])->count();
  33. $item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
  34. }, $where);
  35. }
  36. public static function setMember($uid)
  37. {
  38. $share_uid = self::where('uid', $uid)->value('share_uid');
  39. return self::GetDb('group_of_members')->where('uid', $share_uid)->where('is_del', 0)->value('shop_uid');
  40. }
  41. //记录当前用户所在店铺存在则删除
  42. public static function saveGroupAndShop($uid, $shop_uid)
  43. {
  44. if (self::GetDb('group_of_members')->where(['uid' => $uid])->count()) {
  45. self::GetDb('group_of_members')->where(['uid' => $uid])->update(['is_del' => 1]);
  46. }
  47. self::GetDb('group_of_members')->insert(['uid' => $uid, 'shop_uid' => $shop_uid, 'add_time' => time()]);
  48. }
  49. }