|
|
@@ -6,6 +6,7 @@ use app\common\dao\shared\SharedProsperityGroupUserDao;
|
|
6
|
6
|
use app\common\dao\shared\SharedProsperityRewardRecordDao;
|
|
7
|
7
|
use app\common\dao\shared\SharedProsperityUserDao;
|
|
8
|
8
|
use app\common\dao\shared\SharedProsperityUserLevelLogDao;
|
|
|
9
|
+use app\common\dao\shared\SharedProsperityUserParentLogDao;
|
|
9
|
10
|
use app\common\dao\user\UserDao;
|
|
10
|
11
|
use app\common\dao\user\UserWithdrawalLimitRecordDao;
|
|
11
|
12
|
use app\common\enum\CommonEnum;
|
|
|
@@ -807,6 +808,50 @@ class SharedProsperityUserRepository extends BaseRepository
|
|
807
|
808
|
|
|
808
|
809
|
/**
|
|
809
|
810
|
* @param $userId
|
|
|
811
|
+ * @param $parentId
|
|
|
812
|
+ * @param $remark
|
|
|
813
|
+ * @param $operator
|
|
|
814
|
+ * @return string|void
|
|
|
815
|
+ * @throws DbException
|
|
|
816
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
817
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
818
|
+ * @author 史晨
|
|
|
819
|
+ * @date 2026/3/16 09:35
|
|
|
820
|
+ * 更新用户上级
|
|
|
821
|
+ */
|
|
|
822
|
+ public function updateParent($userId, $parentId, $remark, $operator)
|
|
|
823
|
+ {
|
|
|
824
|
+ if ($userId == $parentId) {
|
|
|
825
|
+ return '不能设置自己为上级';
|
|
|
826
|
+ }
|
|
|
827
|
+ $userInfo = $this->dao->getWhere(['user_id' => $userId]);
|
|
|
828
|
+ if ($parentId == $userInfo->parent_id) {
|
|
|
829
|
+ return '上级未发生变化';
|
|
|
830
|
+ }
|
|
|
831
|
+ Db::startTrans();
|
|
|
832
|
+ try {
|
|
|
833
|
+ // 变更等级
|
|
|
834
|
+ $this->dao->updateByUserId($userId, ['parent_id' => $parentId]);
|
|
|
835
|
+ // 记录日志
|
|
|
836
|
+ /** @var SharedProsperityUserParentLogDao $logDao */
|
|
|
837
|
+ $logDao = app()->make(SharedProsperityUserParentLogDao::class);
|
|
|
838
|
+ $logDao->create([
|
|
|
839
|
+ 'user_id' => $userId,
|
|
|
840
|
+ 'old_parent' => $userInfo->parent_id,
|
|
|
841
|
+ 'new_parent' => $parentId,
|
|
|
842
|
+ 'operator' => $operator,
|
|
|
843
|
+ 'remark' => $remark
|
|
|
844
|
+ ]);
|
|
|
845
|
+ Db::commit();
|
|
|
846
|
+ } catch (\Exception $e) {
|
|
|
847
|
+ Db::rollback();
|
|
|
848
|
+ return $e->getMessage();
|
|
|
849
|
+ }
|
|
|
850
|
+ }
|
|
|
851
|
+
|
|
|
852
|
+
|
|
|
853
|
+ /**
|
|
|
854
|
+ * @param $userId
|
|
810
|
855
|
* @param $type
|
|
811
|
856
|
* @param $number
|
|
812
|
857
|
* @return bool
|