|
|
@@ -5,7 +5,9 @@ namespace App\Http\Controllers\admin;
|
|
|
use App\Constants\HttpStatus;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Services\RoomService;
|
|
|
+use App\Services\SecretService;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
use App\Services\UserService;
|
|
|
use Exception;
|
|
|
@@ -13,6 +15,7 @@ use Illuminate\Http\Request;
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
use App\Services\AddressService;
|
|
|
|
|
|
+use Illuminate\Http\JsonResponse;
|
|
|
|
|
|
class User extends Controller
|
|
|
{
|
|
|
@@ -95,6 +98,42 @@ class User extends Controller
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @api {post} /admin/user/merge 账户合并
|
|
|
+ * @apiGroup 会员管理
|
|
|
+ * @apiDescription 合并后,余额,银行卡,USDT地址 将合并到新用户,请谨慎操作
|
|
|
+ *
|
|
|
+ * @apiUse result
|
|
|
+ * @apiUse header
|
|
|
+ * @apiVersion 1.0.0
|
|
|
+ *
|
|
|
+ * @apiParam {string} member_id 接收者的member_id
|
|
|
+ * @apiParam {string} secret_key 被合并的用户的秘钥
|
|
|
+ */
|
|
|
+ public function merge(): JsonResponse
|
|
|
+ {
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ $params = request()->validate([
|
|
|
+ 'member_id' => ['required', 'string', 'min:1'],
|
|
|
+ 'secret_key' => ['required', 'string', 'min:1'],
|
|
|
+ ]);
|
|
|
+ $res = SecretService::migration($params['member_id'], $params['secret_key']);
|
|
|
+ if (!$res) {
|
|
|
+ throw new Exception("迁移失败", HttpStatus::CUSTOM_ERROR);
|
|
|
+ }
|
|
|
+ DB::commit();
|
|
|
+ } catch (ValidationException $e) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->error(intval($e->getCode()));
|
|
|
+ }
|
|
|
+ return $this->success(msg: '已完成迁移');
|
|
|
+ }
|
|
|
+
|
|
|
// 提现地址
|
|
|
public function address()
|
|
|
{
|