瀏覽代碼

Merge branch 'dev' into 2D展厅

# Conflicts:
#	src/main/vue/src/router.js
licailing 4 年之前
父節點
當前提交
b37d6c6e9c

+ 12 - 0
src/main/java/com/izouma/nineth/repo/IdentityAuthRepo.java

@@ -2,6 +2,8 @@ package com.izouma.nineth.repo;
 
 import com.izouma.nineth.domain.IdentityAuth;
 import com.izouma.nineth.enums.AuthStatus;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
@@ -24,6 +26,8 @@ public interface IdentityAuthRepo extends JpaRepository<IdentityAuth, Long>, Jpa
 
     List<IdentityAuth> findByUserIdAndDelFalse(Long userId);
 
+    List<IdentityAuth> findByUserId(Long userId);
+
     Optional<IdentityAuth> findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(Long userId, AuthStatus status);
 
     Optional<IdentityAuth> findByIdAndDelFalse(Long id);
@@ -33,4 +37,12 @@ public interface IdentityAuthRepo extends JpaRepository<IdentityAuth, Long>, Jpa
     List<IdentityAuth> findByStatusAndAutoValidated(AuthStatus status, boolean validated);
 
     int countByIdNoAndStatus(String idNo, AuthStatus status);
+
+    @Query("select distinct i.userId from IdentityAuth i")
+    Page<Long> listUserId(Pageable pageable);
+
+    @Query("delete from IdentityAuth i where i.userId = ?1 and i.id <> ?2")
+    @Modifying
+    @Transactional
+    int deleteDuplicated(Long userId, Long id);
 }

+ 6 - 1
src/main/java/com/izouma/nineth/repo/UserRepo.java

@@ -1,6 +1,7 @@
 package com.izouma.nineth.repo;
 
 import com.izouma.nineth.domain.User;
+import com.izouma.nineth.enums.AuthStatus;
 import com.izouma.nineth.security.Authority;
 import org.springframework.cache.annotation.CachePut;
 import org.springframework.cache.annotation.Cacheable;
@@ -14,7 +15,6 @@ import javax.transaction.Transactional;
 import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Optional;
-import java.util.Set;
 
 public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExecutor<User> {
     @Transactional
@@ -190,4 +190,9 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
     @Modifying
     @Query("update User set vipPoint = ?2 where id = ?1")
     void updateVipPoint(Long id, int num);
+
+    @Query("update User u set u.authStatus = ?2, u.authId = ?3 where u.id = ?1")
+    @Transactional
+    @Modifying
+    void setAuthStatus(Long id, AuthStatus status, Long authId);
 }

+ 15 - 0
src/main/java/com/izouma/nineth/service/AdapayMerchantService.java

@@ -17,6 +17,7 @@ import com.izouma.nineth.dto.adapay.PaymentList;
 import com.izouma.nineth.dto.adapay.SettleAccountsItem;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.AdapayMerchantRepo;
+import com.izouma.nineth.utils.DateTimeUtils;
 import com.izouma.nineth.utils.JpaUtils;
 import com.izouma.nineth.utils.ObjUtils;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
@@ -28,6 +29,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
+import java.time.LocalDate;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -288,4 +290,17 @@ public class AdapayMerchantService {
         }
     }
 
+
+    public Object querySettle(Long merchantId, LocalDate start, LocalDate end, Long userId) throws BaseAdaPayException {
+        AdapayMerchant merchant = adapayMerchantRepo.findById(merchantId).orElseThrow(new BusinessException("商户不存在"));
+
+        Map<String, Object> queryParams = new HashMap<>(5);
+        queryParams.put("member_id", userId.toString());
+        queryParams.put("app_id", merchant.getAppId());
+        queryParams.put("begin_date", DateTimeUtils.format(start, "yyyyMMdd"));
+        queryParams.put("end_date", DateTimeUtils.format(end, "yyyyMMdd"));
+        Map<String, Object> settleCount = SettleAccount.detail(queryParams, merchant.getName());
+        log.info(JSON.toJSONString(settleCount, SerializerFeature.PrettyFormat));
+        return settleCount;
+    }
 }

+ 87 - 11
src/main/java/com/izouma/nineth/service/IdentityAuthService.java

@@ -16,6 +16,7 @@ import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.core.env.Environment;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
@@ -24,7 +25,9 @@ import java.time.LocalDate;
 import java.time.temporal.ChronoUnit;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
@@ -91,30 +94,103 @@ public class IdentityAuthService {
         return userRepo.findByIdInAndDelFalse(userIds);
     }
 
+    //    public void validate(String name, String phone, String idno) {
+//        String body = HttpRequest.post("https://jubrige.market.alicloudapi.com/mobile/3-validate-transfer")
+//                .header("Authorization", "APPCODE b48bc8f6759345a79ae20a951f03dabe")
+//                .contentType(HttpRequest.CONTENT_TYPE_FORM)
+//                .form("idCardNo", idno)
+//                .form("mobile", phone)
+//                .form("name", name)
+//                .body();
+//        JSONObject jsonObject = JSONObject.parseObject(body);
+//        if (jsonObject.getInteger("code") != 200) {
+//            String msg = jsonObject.getString("msg");
+//            throw new BusinessException(msg);
+//        } else {
+//            JSONObject data = jsonObject.getJSONObject("data");
+//            int result = data.getIntValue("result");
+//            String desc = data.getString("desc");
+//            if (result != 0) {
+//                throw new BusinessException(desc);
+//            } else {
+//                log.info("{} {} {} 实名认证通过", name, phone, idno);
+//            }
+//        }
+//    }
     public void validate(String name, String phone, String idno) {
-        String body = HttpRequest.post("https://jubrige.market.alicloudapi.com/mobile/3-validate-transfer")
+        String body = HttpRequest.post("https://zid.market.alicloudapi.com/idcheck/Post")
                 .header("Authorization", "APPCODE b48bc8f6759345a79ae20a951f03dabe")
                 .contentType(HttpRequest.CONTENT_TYPE_FORM)
-                .form("idCardNo", idno)
-                .form("mobile", phone)
-                .form("name", name)
+                .form("cardNo", idno)
+                .form("realName", name)
                 .body();
         JSONObject jsonObject = JSONObject.parseObject(body);
-        if (jsonObject.getInteger("code") != 200) {
-            String msg = jsonObject.getString("msg");
+        if (jsonObject.getInteger("error_code") != 0) {
+            String msg = jsonObject.getString("reason");
             throw new BusinessException(msg);
         } else {
-            JSONObject data = jsonObject.getJSONObject("data");
-            int result = data.getIntValue("result");
-            String desc = data.getString("desc");
-            if (result != 0) {
-                throw new BusinessException(desc);
+            JSONObject data = jsonObject.getJSONObject("result");
+            boolean isOK = Optional.ofNullable(data.getBoolean("isok")).orElse(Boolean.FALSE);
+            if (!isOK) {
+                throw new BusinessException("不匹配");
             } else {
                 log.info("{} {} {} 实名认证通过", name, phone, idno);
             }
         }
     }
 
+    public void removeDuplicated() {
+        boolean hasMore = true;
+        int pageNum = 1;
+        AtomicInteger count = new AtomicInteger();
+        while (hasMore) {
+            Page<Long> page = identityAuthRepo.listUserId(PageRequest.of(pageNum, 100));
+            List<Long> userIds = page.getContent();
+            userIds.parallelStream().forEach(userId -> {
+                userRepo.findById(userId).ifPresent(user -> {
+                    log.info("removeDuplicated {}/{} ", count.incrementAndGet(), page.getTotalElements());
+                    List<IdentityAuth> list = identityAuthRepo.findByUserId(userId);
+                    if (list.size() > 1) {
+                        IdentityAuth auth = list.stream()
+                                .filter(i -> i.getStatus() == AuthStatus.SUCCESS)
+                                .findAny().orElse(null);
+                        if (auth != null) {
+                            userRepo.setAuthStatus(user.getId(), auth.getStatus(), auth.getId());
+                            int num = identityAuthRepo.deleteDuplicated(user.getId(), auth.getId());
+                            log.info("deleted {}", num);
+                            return;
+                        }
+
+                        auth = list.stream()
+                                .filter(i -> i.getStatus() == AuthStatus.PENDING)
+                                .findAny().orElse(null);
+                        if (auth != null) {
+                            userRepo.setAuthStatus(user.getId(), auth.getStatus(), auth.getId());
+                            int num = identityAuthRepo.deleteDuplicated(user.getId(), auth.getId());
+                            log.info("deleted {}", num);
+                            return;
+                        }
+
+                        auth = list.stream()
+                                .filter(i -> i.getStatus() == AuthStatus.FAIL)
+                                .findAny().orElse(null);
+                        if (auth != null) {
+                            userRepo.setAuthStatus(user.getId(), auth.getStatus(), auth.getId());
+                            int num = identityAuthRepo.deleteDuplicated(user.getId(), auth.getId());
+                            log.info("deleted {}", num);
+                            return;
+                        }
+
+                    } else if (list.size() == 1) {
+                        userRepo.setAuthStatus(user.getId(), list.get(0).getStatus(), list.get(0).getId());
+                    }
+                });
+            });
+            hasMore = page.hasNext();
+            pageNum++;
+        }
+    }
+
     @Scheduled(fixedRate = 60000)
     @RedisLock(value = "autoValidate", expire = 30, unit = TimeUnit.MINUTES)
     public void autoValidate() {

+ 7 - 0
src/main/java/com/izouma/nineth/web/AdapayMerchantController.java

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.time.LocalDate;
 import java.util.List;
 
 @RestController
@@ -68,5 +69,11 @@ public class AdapayMerchantController extends BaseController {
     public Object refund(@RequestParam Long id, @RequestParam String orderId) throws BaseAdaPayException {
         return adapayMerchantService.refund(id, orderId);
     }
+
+    @PostMapping("/querySettle")
+    public Object querySettle(@RequestParam Long id, @RequestParam LocalDate start,
+                              @RequestParam LocalDate end, @RequestParam Long userId) throws BaseAdaPayException {
+        return adapayMerchantService.querySettle(id, start, end, userId);
+    }
 }
 

+ 5 - 0
src/main/java/com/izouma/nineth/web/IdentityAuthController.java

@@ -75,5 +75,10 @@ public class IdentityAuthController extends BaseController {
     public List<User> repeat(@RequestParam String idNo, @RequestParam Long userId) {
         return identityAuthService.repeat(idNo, userId);
     }
+
+    @GetMapping("/removeDuplicated")
+    public void removeDuplicated() {
+        identityAuthService.removeDuplicated();
+    }
 }
 

+ 35 - 30
src/main/vue/src/router.js

@@ -444,75 +444,72 @@ const router = new Router({
                     name: 'MintActivityEdit',
                     component: () => import(/* webpackChunkName: "mintActivityEdit" */ '@/views/MintActivityEdit.vue'),
                     meta: {
-                        title: '铸造活动编辑'
-                    }
+                       title: '铸造活动编辑',
+                    },
                 },
                 {
                     path: '/mintActivityList',
                     name: 'MintActivityList',
                     component: () => import(/* webpackChunkName: "mintActivityList" */ '@/views/MintActivityList.vue'),
                     meta: {
-                        title: '铸造活动'
-                    }
-                },
+                       title: '铸造活动',
+                    },
+               },
                 {
                     path: '/mintOrderEdit',
                     name: 'MintOrderEdit',
                     component: () => import(/* webpackChunkName: "mintOrderEdit" */ '@/views/MintOrderEdit.vue'),
                     meta: {
-                        title: '铸造订单编辑'
-                    }
+                       title: '铸造订单编辑',
+                    },
                 },
                 {
                     path: '/mintOrderList',
                     name: 'MintOrderList',
                     component: () => import(/* webpackChunkName: "mintOrderList" */ '@/views/MintOrderList.vue'),
                     meta: {
-                        title: '铸造订单'
-                    }
-                },
+                       title: '铸造订单',
+                    },
+               },
                 {
                     path: '/purchaseLevelEdit',
                     name: 'PurchaseLevelEdit',
-                    component: () =>
-                        import(/* webpackChunkName: "purchaseLevelEdit" */ '@/views/PurchaseLevelEdit.vue'),
+                    component: () => import(/* webpackChunkName: "purchaseLevelEdit" */ '@/views/PurchaseLevelEdit.vue'),
                     meta: {
-                        title: '会员等级编辑'
-                    }
+                       title: '会员等级编辑',
+                    },
                 },
                 {
                     path: '/purchaseLevelList',
                     name: 'PurchaseLevelList',
-                    component: () =>
-                        import(/* webpackChunkName: "purchaseLevelList" */ '@/views/PurchaseLevelList.vue'),
+                    component: () => import(/* webpackChunkName: "purchaseLevelList" */ '@/views/PurchaseLevelList.vue'),
                     meta: {
-                        title: '会员等级'
-                    }
-                },
+                       title: '会员等级',
+                    },
+               },
                 {
                     path: '/newsEdit',
                     name: 'NewsEdit',
                     component: () => import(/* webpackChunkName: "newsEdit" */ '@/views/NewsEdit.vue'),
                     meta: {
-                        title: '新闻管理编辑'
-                    }
+                       title: '新闻管理编辑',
+                    },
                 },
                 {
                     path: '/newsList',
                     name: 'NewsList',
                     component: () => import(/* webpackChunkName: "newsList" */ '@/views/NewsList.vue'),
                     meta: {
-                        title: '新闻管理'
-                    }
-                },
+                       title: '新闻管理',
+                    },
+               },
                 {
                     path: '/adapayMerchantEdit',
                     name: 'AdapayMerchantEdit',
-                    component: () =>
-                        import(/* webpackChunkName: "adapayMerchantEdit" */ '@/views/AdapayMerchantEdit.vue'),
+                    component: () => import(/* webpackChunkName: "adapayMerchantEdit" */ '@/views/AdapayMerchantEdit.vue'),
                     meta: {
-                        title: 'ada编辑'
-                    }
+                        title: 'ada编辑',
+                    },
                 },
                 {
                     path: '/adapayMerchantList',
@@ -537,7 +534,15 @@ const router = new Router({
                     component: () => import(/* webpackChunkName: "showroomList" */ '@/views/ShowroomList.vue'),
                     meta: {
                         title: '展厅'
-                    }
+                    },
+                },
+                {
+                    path: '/querySettle',
+                    name: 'QuerySettle',
+                    component: () => import(/* webpackChunkName: "querySettle" */ '@/views/QuerySettle.vue'),
+                    meta: {
+                        title: '结算查询',
+                    },
                 }
                 /**INSERT_LOCATION**/
             ]
@@ -579,7 +584,7 @@ router.beforeEach((to, from, next) => {
         window.open(url);
         return;
     }
-    if (!store.state.userInfo && to.path !== '/login' && to.path !== '/photoProcessing') {
+    if (!store.state.userInfo && to.path !== '/login' && to.path!=='/photoProcessing') {
         http.axios
             .get('/user/my')
             .then(res => {

+ 150 - 0
src/main/vue/src/views/QuerySettle.vue

@@ -0,0 +1,150 @@
+<template>
+    <div class="list-view" v-loading="loading">
+        <page-title> </page-title>
+        <div class="filters-container">
+            <el-date-picker
+                start-placeholder="开始日期"
+                end-placeholder="结束日期"
+                :picker-options="pickerOptions"
+                type="daterange"
+                class="filter-item"
+                value-format="yyyy-MM-dd"
+                v-model="range"
+            ></el-date-picker>
+            <el-select v-model="merchantId" class="filter-item" placeholder="请选支付通道">
+                <el-option v-for="item in merchantList" :value="item.id" :key="item.id" :label="item.name"></el-option>
+            </el-select>
+            <el-input v-model="userId" placeholder="用户ID" class="filter-item"></el-input>
+            <el-button @click="getData" class="filter-item" type="primary">查询</el-button>
+        </div>
+        <el-table
+            :height="tableHeight"
+            :data="tableData"
+            row-key="id"
+            ref="table"
+            header-row-class-name="table-header-row"
+            header-cell-class-name="table-header-cell"
+            row-class-name="table-row"
+            cell-class-name="table-cell"
+        >
+            <el-table-column type="index" label="#" width="60"></el-table-column>
+            <el-table-column prop="settle_date" label="日期" width="100"> </el-table-column>
+            <el-table-column prop="card_name" label="姓名" width="100"> </el-table-column>
+            <el-table-column prop="card_no" label="卡号"> </el-table-column>
+            <el-table-column prop="settle_amt" label="金额" width="120"> </el-table-column>
+            <el-table-column prop="settle_stat" label="状态" width="100" align="center">
+                <template v-slot="{ row }">
+                    <el-tag :type="row.settle_stat === 'succeeded' ? 'success' : 'danger'">{{
+                        row.settle_stat === 'succeeded' ? '成功' : '失败'
+                    }}</el-tag>
+                </template>
+            </el-table-column>
+            <el-table-column prop="settle_message" label="描述" show-overflow-tooltip></el-table-column>
+        </el-table>
+        <div class="pagination-wrapper">
+            <!-- <div class="multiple-mode-wrapper">
+                <el-button v-if="!multipleMode" @click="toggleMultipleMode(true)">批量编辑</el-button>
+                <el-button-group v-else>
+                    <el-button @click="operation1">批量操作1</el-button>
+                    <el-button @click="operation2">批量操作2</el-button>
+                    <el-button @click="toggleMultipleMode(false)">取消</el-button>
+                </el-button-group>
+            </div> -->
+        </div>
+    </div>
+</template>
+<script>
+import { mapState } from 'vuex';
+import { parse, format, addDays, addMonths } from 'date-fns';
+export default {
+    data() {
+        return {
+            tableHeight: 200,
+            loading: false,
+            tableData: [],
+            range: null,
+            userId: null,
+            merchantList: [],
+            merchantId: null,
+            userId: null,
+            pickerOptions: {
+                shortcuts: [
+                    {
+                        text: '今天',
+                        onClick(picker) {
+                            picker.$emit('pick', [new Date(), new Date()]);
+                        }
+                    },
+                    {
+                        text: '昨天',
+                        onClick(picker) {
+                            picker.$emit('pick', [addDays(new Date(), -1), new Date()]);
+                        }
+                    },
+                    {
+                        text: '最近一周',
+                        onClick(picker) {
+                            picker.$emit('pick', [addDays(new Date(), -7), new Date()]);
+                        }
+                    },
+                    {
+                        text: '最近一月',
+                        onClick(picker) {
+                            picker.$emit('pick', [addMonths(new Date(), -1), new Date()]);
+                        }
+                    }
+                ]
+            }
+        };
+    },
+    computed: {},
+    created() {
+        this.$http.post('/adapayMerchant/all', { size: 1000 }, { body: 'json' }).then(res => {
+            this.merchantList = res.content;
+        });
+        this.range = [format(addDays(new Date(), -7), 'yyyy-MM-dd'), format(new Date(), 'yyyy-MM-dd')];
+    },
+    mounted() {
+        this.tableHeight = document.querySelector('.el-table').getBoundingClientRect().height;
+    },
+    methods: {
+        getData() {
+            if (!(this.range && this.range.length == 2)) {
+                this.$message.error('请选择日期');
+                return;
+            }
+            if (!this.merchantId) {
+                this.$message.error('请选支付通道');
+                return;
+            }
+            if (!this.userId) {
+                this.$message.error('请输入用户ID');
+                return;
+            }
+            this.loading = true;
+            this.$http
+                .post('/adapayMerchant/querySettle', {
+                    start: this.range[0],
+                    end: this.range[1],
+                    id: this.merchantId,
+                    userId: this.userId
+                })
+                .then(res => {
+                    this.loading = false;
+                    console.log(res);
+                    if (res.status === 'succeeded') {
+                        this.tableData = (res.settle_details || []).filter(i => i.settle_type !== 'B');
+                    } else {
+                        this.$message.error(res.error_msg);
+                    }
+                })
+                .catch(e => {
+                    this.loading = false;
+                    this.$message.error(e.error || '查询失败');
+                });
+        }
+    }
+};
+</script>
+<style lang="less" scoped>
+</style>

+ 3 - 4
src/test/java/com/izouma/nineth/CommonTest.java

@@ -455,12 +455,11 @@ public class CommonTest {
 
     @Test
     public void aasdf() {
-        String body = HttpRequest.post("https://jubrige.market.alicloudapi.com/mobile/3-validate-transfer")
+        String body = HttpRequest.post("https://zid.market.alicloudapi.com/idcheck/Post")
                 .header("Authorization", "APPCODE b48bc8f6759345a79ae20a951f03dabe")
                 .contentType(HttpRequest.CONTENT_TYPE_FORM)
-                .form("idCardNo", "430223198503027240")
-                .form("mobile", "13342533959")
-                .form("name", "陈赛")
+                .form("cardNo", "1")
+                .form("realName", "2")
                 .body();
         System.out.println(JSON.toJSONString(JSON.parseObject(body), SerializerFeature.PrettyFormat));
     }

+ 12 - 4
src/test/java/com/izouma/nineth/service/AdapayTest.java

@@ -7,10 +7,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.huifu.adapay.Adapay;
 import com.huifu.adapay.core.exception.BaseAdaPayException;
-import com.huifu.adapay.model.AdapayCommon;
-import com.huifu.adapay.model.MerConfig;
-import com.huifu.adapay.model.Payment;
-import com.huifu.adapay.model.Refund;
+import com.huifu.adapay.model.*;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
 import com.izouma.nineth.utils.excel.BigIntegerConverter;
 import com.izouma.nineth.utils.excel.LocalDateConverter;
@@ -220,4 +217,15 @@ public class AdapayTest {
         Map<String, Object> map = Payment.query("002112022021816391410340666733272313856");
         System.out.println(JSON.toJSONString(map, SerializerFeature.PrettyFormat));
     }
+
+    @Test
+    public void querySettle() throws BaseAdaPayException {
+        Map<String, Object> queryParams = new HashMap<>(5);
+        queryParams.put("member_id", "736136");
+        queryParams.put("app_id", appId);
+        queryParams.put("begin_date", "20220201");
+        queryParams.put("end_date", "20220302");
+        Map<String, Object> settleCount = SettleAccount.detail(queryParams);
+        System.out.println(JSON.toJSONString(settleCount, SerializerFeature.PrettyFormat));
+    }
 }

+ 47 - 0
src/test/java/com/izouma/nineth/service/IdentityAuthServiceTest.java

@@ -1,12 +1,23 @@
 package com.izouma.nineth.service;
 
 import com.izouma.nineth.ApplicationTests;
+import com.izouma.nineth.domain.IdentityAuth;
+import com.izouma.nineth.domain.User;
+import com.izouma.nineth.enums.AuthStatus;
+import com.izouma.nineth.repo.IdentityAuthRepo;
+import com.izouma.nineth.repo.UserRepo;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.List;
+
 public class IdentityAuthServiceTest extends ApplicationTests {
     @Autowired
     private IdentityAuthService identityAuthService;
+    @Autowired
+    private IdentityAuthRepo    identityAuthRepo;
+    @Autowired
+    private UserRepo            userRepo;
 
     @Test
     public void validate() {
@@ -14,4 +25,40 @@ public class IdentityAuthServiceTest extends ApplicationTests {
         identityAuthService.validate("熊竹", "15077886171", "321002199408304614");
     }
 
+    @Test
+    public void asdfa() {
+        User user = userRepo.findById(8157L).get();
+        List<IdentityAuth> list = identityAuthRepo.findByUserId(8157L);
+        if (list.size() > 1) {
+            IdentityAuth auth = list.stream()
+                    .filter(i -> i.getStatus() == AuthStatus.SUCCESS)
+                    .findAny().orElse(null);
+            if (auth != null) {
+                userRepo.setAuthStatus(user.getId(), auth.getStatus(), auth.getId());
+                identityAuthRepo.deleteDuplicated(user.getId(), auth.getId());
+                return;
+            }
+
+            auth = list.stream()
+                    .filter(i -> i.getStatus() == AuthStatus.PENDING)
+                    .findAny().orElse(null);
+            if (auth != null) {
+                userRepo.setAuthStatus(user.getId(), auth.getStatus(), auth.getId());
+                identityAuthRepo.deleteDuplicated(user.getId(), auth.getId());
+                return;
+            }
+
+            auth = list.stream()
+                    .filter(i -> i.getStatus() == AuthStatus.FAIL)
+                    .findAny().orElse(null);
+            if (auth != null) {
+                userRepo.setAuthStatus(user.getId(), auth.getStatus(), auth.getId());
+                identityAuthRepo.deleteDuplicated(user.getId(), auth.getId());
+                return;
+            }
+
+        } else if (list.size() == 1) {
+            userRepo.setAuthStatus(user.getId(), list.get(0).getStatus(), list.get(0).getId());
+        }
+    }
 }