diff --git a/app/Model/Promote.php b/app/Model/Promote.php index 72ee9ce..b094f93 100644 --- a/app/Model/Promote.php +++ b/app/Model/Promote.php @@ -11,4 +11,6 @@ class Promote extends Model use PromoteScopes; protected $table = 'tab_promote'; + + public static $levelColumns = ['level1_id', 'level2_id', 'level3_id', 'level3_id']; } \ No newline at end of file diff --git a/app/Repository/PromoteRepository.php b/app/Repository/PromoteRepository.php new file mode 100644 index 0000000..9f08ed1 --- /dev/null +++ b/app/Repository/PromoteRepository.php @@ -0,0 +1,21 @@ +where('id', $id)->first(Promote::$levelColumns); + $levelIds = []; + foreach (Promote::$levelColumns as $column) { + if ($promote->{$column} > 0) { + $levelIds[] = $promote->{$column}; + } + } + return Promote::query()->whereIn('id', $levelIds)->get($columns); + } +} \ No newline at end of file diff --git a/app/Service/PromoteService.php b/app/Service/PromoteService.php new file mode 100644 index 0000000..6171563 --- /dev/null +++ b/app/Service/PromoteService.php @@ -0,0 +1,11 @@ +save(); if (in_array($spend->game_id, [335, 336])) { + $levelPromotes = $this->promoteRepository->getLevelPromotesById($spend->promote_id, ['id', 'level', 'account']); + $levelPromotes = $levelPromotes->indexBy('level'); Lanhuo::addOrder([ 'order_code' => $spend->pay_order_number, 'user_id' => $spend->user_id, @@ -50,6 +60,12 @@ class SpendService extends Service 'order_amount' => $spend->pay_amount, 'pay_time' => date('Y-m-d H:i:s', $spend->spend_time), 'status' => $spend->pay_status, //支付状态(待支付 0 已支付 1 支付失败 2) + 'minister_id' => isset($levelPromotes[2]) ? $levelPromotes[2]->id : 0, + 'minister_name' => isset($levelPromotes[2]) ? $levelPromotes[2]->account : '', + 'headman_id' => isset($levelPromotes[3]) ? $levelPromotes[3]->id : 0, + 'headman_name' => isset($levelPromotes[3]) ? $levelPromotes[3]->account : '', + 'promoter_id' => isset($levelPromotes[4]) ? $levelPromotes[4]->id : 0, + 'promoter_name' => isset($levelPromotes[4]) ? $levelPromotes[4]->account : '', ]); } } diff --git a/app/Service/UserService.php b/app/Service/UserService.php index 6bee2c7..387b427 100644 --- a/app/Service/UserService.php +++ b/app/Service/UserService.php @@ -10,9 +10,18 @@ use App\Model\Player; use App\Model\PlayerRetention; use App\Model\User; use App\Helper\Log; +use Hyperf\Di\Annotation\Inject; +use App\Repository\PromoteRepository; class UserService extends Service { + + /** + * @Inject + * @var PromoteRepository + */ + private $promoteRepository; + public function afterLogin($params) { $gameId = $params['game_id']; @@ -88,6 +97,7 @@ class UserService extends Service 'real_name', 'idcard', 'age_status', + 'promote_id' ]); if (!$user) { throw new BusinessException('用户不存在'); @@ -104,6 +114,8 @@ class UserService extends Service } if (in_array($user->fgame_id, [335, 336])) { + $levelPromotes = $this->promoteRepository->getLevelPromotesById($user->promote_id, ['id', 'level', 'account']); + $levelPromotes = $levelPromotes->indexBy('level'); Lanhuo::addUser([ 'user_id' => $user->id, 'account' => $user->account, @@ -113,6 +125,12 @@ class UserService extends Service 'name' => $user->real_name, 'id_card' => $user->idcard, 'is_real' => $user->age_status == 2 ? 1 : 0, // 是否实名(1-实名 0-未实名) + 'minister_id' => isset($levelPromotes[2]) ? $levelPromotes[2]->id : 0, + 'minister_name' => isset($levelPromotes[2]) ? $levelPromotes[2]->account : '', + 'headman_id' => isset($levelPromotes[3]) ? $levelPromotes[3]->id : 0, + 'headman_name' => isset($levelPromotes[3]) ? $levelPromotes[3]->account : '', + 'promoter_id' => isset($levelPromotes[4]) ? $levelPromotes[4]->id : 0, + 'promoter_name' => isset($levelPromotes[4]) ? $levelPromotes[4]->account : '', ]); } }