xiongzhu 4 年之前
父节点
当前提交
aa0ffc2383

+ 4 - 0
src/main/java/com/izouma/nineth/repo/UserBankCardRepo.java

@@ -3,11 +3,15 @@ package com.izouma.nineth.repo;
 import com.izouma.nineth.dto.UserBankCard;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
 
+import javax.transaction.Transactional;
 import java.util.List;
 
 public interface UserBankCardRepo extends JpaRepository<UserBankCard, Long>, JpaSpecificationExecutor<UserBankCard> {
     List<UserBankCard> findByUserId(Long userId);
 
+    @Transactional
+    @Modifying
     int deleteByUserId(Long userId);
 }

+ 9 - 0
src/main/java/com/izouma/nineth/service/UserService.java

@@ -476,6 +476,15 @@ public class UserService {
         }
     }
 
+    public void removeAuth(Long userId) {
+        User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
+        if (user.getAuthStatus() == AuthStatus.SUCCESS) {
+            user.setAuthStatus(AuthStatus.NOT_AUTH);
+            userRepo.save(user);
+            identityAuthRepo.deleteAll(identityAuthRepo.findByUserIdAndDelFalse(userId));
+        }
+    }
+
     public Map<String, Object> batchRegister(String phones, String defaultPassword) {
         List<String> exist = new ArrayList<>();
         List<String> err = new ArrayList<>();

+ 12 - 0
src/main/java/com/izouma/nineth/web/UserController.java

@@ -226,6 +226,18 @@ public class UserController extends BaseController {
         userService.removeBankCard(SecurityUtils.getAuthenticatedUser().getId());
     }
 
+    @PostMapping("/removeBankCardAdmin")
+    @PreAuthorize("hasAnyRole('ADMIN')")
+    public void removeBankCardAdmin(@RequestParam Long userId) throws BaseAdaPayException {
+        userService.removeBankCard(userId);
+    }
+
+    @PostMapping("/removeAuthAdmin")
+    @PreAuthorize("hasAnyRole('ADMIN')")
+    public void removeAuthAdmin(@RequestParam Long userId) {
+        userService.removeAuth(userId);
+    }
+
     @PreAuthorize("hasAnyRole('ADMIN')")
     @PostMapping("/batchRegister")
     public Map<String, Object> batchRegister(@RequestParam String phones, @RequestParam String defaultPassword) {

+ 90 - 4
src/main/vue/src/views/UserList.vue

@@ -8,7 +8,7 @@
                 导出
             </el-button>
         </page-title>
-        <div class="filters-container">
+        <div class="filters-container" @keyup.enter="getData">
             <el-input placeholder="搜索..." v-model="search" clearable class="filter-item search">
                 <el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
             </el-input>
@@ -43,9 +43,15 @@
             </el-table-column>
             <el-table-column label="手机" prop="phone"></el-table-column>
             <el-table-column label="创建时间" prop="createdAt" width="150"></el-table-column>
-            <el-table-column label="操作" align="center" fixed="right">
+            <el-table-column label="操作" align="center" fixed="right" width="200">
                 <template slot-scope="{ row }">
-                    <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
+                    <el-button @click="editRow(row)" type="text">编辑</el-button>
+                    <el-button @click="removeCard(row)" size="mini" type="text" :disabled="!row.settleAccountId"
+                        >解绑卡</el-button
+                    >
+                    <el-button @click="removeAuth(row)" size="mini" type="text" :disabled="row.authStatus !== 'SUCCESS'"
+                        >取消认证</el-button
+                    >
                 </template>
             </el-table-column>
         </el-table>
@@ -165,7 +171,7 @@ export default {
                     .then(res => {
                         let el = document.createElement('div');
                         new ClipboardJS(el, {
-                            text: function (trigger) {
+                            text: function(trigger) {
                                 return res;
                             }
                         });
@@ -177,6 +183,86 @@ export default {
                         this.$message.error(e.error);
                     });
             }
+        },
+        removeCard(row) {
+            this.$msgbox({
+                title: '确认解绑吗?',
+                message: '该操作无法撤回,请谨慎操作',
+                showCancelButton: true,
+                confirmButtonText: '确认',
+                cancelButtonText: '取消',
+                type: 'warning',
+                beforeClose: (action, instance, done) => {
+                    if (action === 'confirm') {
+                        instance.confirmButtonLoading = true;
+                        instance.showCancelButton = false;
+                        instance.closeOnClickModal = false;
+                        instance.showClose = false;
+                        this.$http
+                            .post('/user/removeBankCardAdmin', { userId: row.id })
+                            .then(res => {
+                                done();
+                                this.getData();
+                                this.$message.success('解绑成功');
+                                instance.confirmButtonLoading = false;
+                                instance.showCancelButton = true;
+                                instance.closeOnClickModal = true;
+                                instance.showClose = true;
+                            })
+                            .catch(e => {
+                                done();
+                                this.getData();
+                                this.$message.error(e.error || '解绑失败');
+                                instance.confirmButtonLoading = false;
+                                instance.showCancelButton = true;
+                                instance.closeOnClickModal = true;
+                                instance.showClose = true;
+                            });
+                    } else {
+                        done();
+                    }
+                }
+            }).then(_ => {});
+        },
+        removeAuth(row) {
+            this.$msgbox({
+                title: '确认取消认证吗?',
+                message: '该操作无法撤回,请谨慎操作',
+                showCancelButton: true,
+                confirmButtonText: '确认',
+                cancelButtonText: '取消',
+                type: 'warning',
+                beforeClose: (action, instance, done) => {
+                    if (action === 'confirm') {
+                        instance.confirmButtonLoading = true;
+                        instance.showCancelButton = false;
+                        instance.closeOnClickModal = false;
+                        instance.showClose = false;
+                        this.$http
+                            .post('/user/removeAuthAdmin', { userId: row.id })
+                            .then(res => {
+                                done();
+                                this.getData();
+                                this.$message.success('取消认证成功');
+                                instance.confirmButtonLoading = false;
+                                instance.showCancelButton = true;
+                                instance.closeOnClickModal = true;
+                                instance.showClose = true;
+                            })
+                            .catch(e => {
+                                done();
+                                this.getData();
+                                this.$message.error(e.error || '取消认证失败');
+                                instance.confirmButtonLoading = false;
+                                instance.showCancelButton = true;
+                                instance.closeOnClickModal = true;
+                                instance.showClose = true;
+                            });
+                    } else {
+                        done();
+                    }
+                }
+            }).then(_ => {});
         }
     }
 };