where('id', $userID)->find(); } public function getByAddress($address) { return $this->where("address", $address)->find(); } public static function getByParentId(int $uid): int { return self::where('id', $uid)->value("parent_id"); } public function getAllAddress() { $all_list = $this->field('id,address')->select(); $arr = []; foreach ($all_list as $item){ $arr[$item['address']] = $item['id']; } return $arr; } //获取用户余额 冻结金额 和 折合金额 public static function getUserAmount(int $uid): float { return self::where('id', $uid)->sum("balance-frozen_amount"); } //获取用户RWA public static function getUserRwaNum(int $uid): int { return self::where('id', $uid)->value("rwa_num"); } /** * RWA更新数据 * @param int $uid * @param string $power * @return void */ public static function updateForRwaNum(int $uid, int $pid, string $score, string $action) { if($action == '+'){ //更新自己Rwa self::where('id', $uid)->setInc('rwa_num', $score); //更新直推Rwa return self::where('id', $pid)->setInc('direct_rwa', $score); }else{ //更新自己Rwa self::where('id', $uid)->setDec('rwa_num', $score); //更新直推Rwa return self::where('id', $pid)->setDec('direct_rwa', $score); } } /** * 余额更新数据 * @param int $uid * @param string $power * @return void */ public static function updateForRBalance(int $uid, string $score, string $action) { if($action == '+'){ return self::where('id', $uid)->setInc('balance', $score); }else{ return self::where('id', $uid)->setDec('balance', $score); } } //社区向上发放奖励津贴 public static function setCommunityRewards($uid, $pv, $token) { $paths = UserPathModel::where('user_id', $uid)->where('distance', '<', 11)->order('distance', 'asc')->column('distance,parent_id'); if (!empty($paths)) { $model = new LedgerWalletModel(); foreach ($paths as $kk=>$item) { if($kk== 1){ $model->changeWalletAccount($item, $token, $pv, $model::Community, $uid); }else{ //间接推荐有效会员大于层级 if(self::where('parent_id', $item)->where('rwa_num','>', 0)->count() >= $kk){ $model->changeWalletAccount($item, $token, $pv, $model::Community, $uid); } } } } } }