|
|
@@ -4,7 +4,7 @@ namespace app\common\model\user;
|
|
|
|
|
|
use app\common\model\BaseModel;
|
|
|
use app\common\model\store\order\StoreOrder;
|
|
|
-include_once app_path('common.php');
|
|
|
+//include_once app_path('common.php');
|
|
|
class OilLevel extends BaseModel
|
|
|
{
|
|
|
public static function tablePk(): ?string
|
|
|
@@ -21,7 +21,7 @@ class OilLevel extends BaseModel
|
|
|
{
|
|
|
if (in_array($uid, $pass)) return true;
|
|
|
$user = User::find($uid);
|
|
|
- $group_users = get_group_user($user);
|
|
|
+ $group_users = $this->get_group_user($user);
|
|
|
//Todo 获取在$group_users内所有用户的消费情况
|
|
|
$achievement = 0;
|
|
|
//获取该用户购买过的节能油商品的全部订单
|
|
|
@@ -45,5 +45,25 @@ class OilLevel extends BaseModel
|
|
|
if ($spread) return $this->checkLevel($spread['uid'], $pass);
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+ public function get_group_user($id, $init = true, $members = null){
|
|
|
+ if ($init) {
|
|
|
+ $us = \app\common\model\user\User::column('spread_uid', 'uid');
|
|
|
+ $members = [];
|
|
|
+ foreach ($us as $k => $v) {
|
|
|
+ if ($v > 0)
|
|
|
+ $members[$v][] = $k;
|
|
|
+ }
|
|
|
+ $id = [$id];
|
|
|
+ }
|
|
|
+ $arr = array();
|
|
|
+ foreach ($id as $v) {
|
|
|
+ $child = $members[$v] ?? [];
|
|
|
+ $arr = array_merge($arr, $child);
|
|
|
+ }
|
|
|
+ if (count($arr)) {
|
|
|
+ return array_merge($arr, $this->get_group_user($arr, false, $members));
|
|
|
+ } else {
|
|
|
+ return $arr;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|