'ID', 'mall_id' => '商城ID', 'user_id' => '用户ID', 'user_team_total' => '团队会员总数(不包括本人)', 'user_direct_total' => '直推会员总数(jxmall_user_children.level=1)', 'user_indirect_total' => '间推会员总数(jxmall_user_children.level=2)', 'active_user_team_total' => '团队活跃会员总数(不包括本人)', 'active_user_direct_total' => '直推活跃会员总数(jxmall_user_children.level=1)', 'active_user_indirect_total' => '间推活跃会员总数(jxmall_user_children.level=2)', 'loss_user_team_total' => '团队流失会员总数(不包括本人)', 'loss_user_direct_total' => '直推流失会员总数(jxmall_user_children.level=1)', 'loss_user_indirect_total' => '间推流失会员总数(jxmall_user_children.level=2)', 'user_team_order_total' => '团队会员订单总数(不包括本人)', 'user_direct_order_total' => '直推会员订单总数(jxmall_user_children.level=1)', 'user_indirect_order_total' => '间推会员订单总数(jxmall_user_children.level=2)', 'user_team_order_price_total' => '团队会员订单总额(不包括本人)', 'user_direct_order_price_total' => '直推会员订单总额(jxmall_user_children.level=1)', 'user_indirect_order_price_total' => '间推会员订单总额(jxmall_user_children.level=2)', 'new_user_direct_total' => '近七天新增会员总数(jxmall_user_children.level=1)', 'created_at' => '创建时间', 'updated_at' => '上次更新数据时间', ]; } /** * 保存数据 * @param array $params * @return bool|UserTeamStatistics */ public static function setData(array $params){ try{ $model = new self(); $model->loadDefaultValues(); if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage()); return $model; }catch(\Exception $e){ self::$static_error = $e->getMessage(); return false; } } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id'])->select('id, nickname, avatar_url, mobile'); } /** * 团队会员订单总额 * * @param integer $user_id * @return float */ public static function getTeamFinishOrderPriceTotal(int $user_id) { return static::find() ->select('team_finish_order_price_total') ->where(['user_id' => $user_id]) ->scalar(); } }