助购获得的那些数据

This commit is contained in:
Jerry Yan 2020-11-15 01:09:37 +08:00
parent fadce0e804
commit 312790a635

View File

@ -35,6 +35,23 @@ class UserLevel extends Base
return $User; return $User;
} }
public function stats()
{
$userId = get_my_id();
$goodsType = 3;
return [
'zgTimes'=>Db::name('orders')->where(compact('userId','goodsType'))->count(),
'zgAmounts'=>Db::name('orders')->where(compact('userId','goodsType'))->sum('helpGetCount'),
'zgYhYhq'=>Db::name('log_moneys')->where([
'targetId'=>$userId,
'remark'=>'预获产品券转换所得',
'moneyType'=>'1',
])->where('dataId', 'in', Db::name('orders')
->where(compact('userId','goodsType'))->column('orderId')
)->where('dataId', '>', 0)->sum('money'),
];
}
/** /**
* TreeList * TreeList
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
@ -64,7 +81,6 @@ class UserLevel extends Base
$treeArr[$newLevel]['userId'] = $userId; $treeArr[$newLevel]['userId'] = $userId;
$treeArr[$newLevel]['userName'] = ''; $treeArr[$newLevel]['userName'] = '';
}else{$newLevel--;} }else{$newLevel--;}
if ($userId <= 1)break;
} while (($newLevel <= $max) && ($newLevel <= (int)dataConf("helpSaleMaxLevel"))); } while (($newLevel <= $max) && ($newLevel <= (int)dataConf("helpSaleMaxLevel")));
// pd($treeArr); // pd($treeArr);
return $treeArr; return $treeArr;