Browse Source

完善老师提现逻辑

weifanli 2 years ago
parent
commit
85cceb6c53

+ 2 - 8
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/UserWithdrawalController.java

@@ -5,22 +5,18 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.excel.UserWithdrawalExport;
-import com.yonge.cooleshow.biz.dal.enums.AuditStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.BizHttpStatus;
 import com.yonge.cooleshow.biz.dal.support.PageUtil;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
-import com.yonge.cooleshow.common.exception.BizException;
 import com.yonge.cooleshow.common.page.PageInfo;
 import com.yonge.toolset.utils.easyexcel.*;
-import com.yonge.toolset.utils.string.StringUtil;
 import io.swagger.annotations.*;
 import org.apache.commons.beanutils.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.util.CollectionUtils;
 import org.springframework.util.DigestUtils;
 import org.springframework.web.bind.annotation.*;
 
@@ -70,12 +66,10 @@ public class UserWithdrawalController extends BaseController {
     @ApiOperation(value = "查询导出", notes = "传入TeacherWithdrawalSearch")
     @PreAuthorize("@pcs.hasPermissions('userWithdrawal/exportExcel')")
     public void exportExcel(@RequestBody TeacherWithdrawalSearch query) {
+        query.setStatus(AuthStatusEnum.DOING);
         List<UserWithdrawalVo> withdrawalVoList = userWithdrawalService.selectList(query);
         List<UserWithdrawalExport> list = new ArrayList<>();
         withdrawalVoList.forEach(o -> {
-            if (AuthStatusEnum.PASS.equals(o.getStatus())) {
-                return;
-            }
             UserWithdrawalExport export = new UserWithdrawalExport();
             try {
                 BeanUtils.copyProperties(export, o);
@@ -116,7 +110,7 @@ public class UserWithdrawalController extends BaseController {
             userWithdrawalService.importExcel(reader.getDataList(), user.getId());
             return HttpResponseResult.succeed();
         } catch (ExcelException e) {
-            return HttpResponseResult.failed(BizHttpStatus.EXPORT.getCode(), e.getErrMsgList(), BizHttpStatus.EXPORT.getMsg());
+            return HttpResponseResult.failed(BizHttpStatus.IMPORT.getCode(), e.getErrMsgList(), BizHttpStatus.IMPORT.getMsg());
         }
     }
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/BizHttpStatus.java

@@ -5,7 +5,7 @@ package com.yonge.cooleshow.biz.dal.enums;
  * @Data: 2022/4/22 18:06
  */
 public enum BizHttpStatus {
-    EXPORT(450, "导出异常"),
+    IMPORT(450, "导入异常"),
     ;
 
     private final int code;

+ 29 - 30
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserWithdrawalServiceImpl.java

@@ -89,8 +89,7 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
         BigDecimal withdrawalServiceFee = getWithdrawalServiceFee();
         withdrawalInfoRes.setWithdrawalServiceFee(withdrawalServiceFee);
         //获取用户可用于提现余额
-        withdrawalInfoRes.setAmountWithdrawal(getAmountUsable(userId).subtract(withdrawalServiceFee)
-                .setScale(2, RoundingMode.HALF_UP));
+        withdrawalInfoRes.setAmountWithdrawal(getAmountUsable(userId));
         return HttpResponseResult.succeed(withdrawalInfoRes);
     }
 
@@ -168,15 +167,14 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
             userWithdrawal.setBankFlowNo(data.getBankFlowNo());
             userWithdrawal.setStatus(data.getStatus());
             userWithdrawal.setVerifyReason(data.getVerifyReason());
-            userWithdrawal.setVerifyUserId(userId);
-            userWithdrawal.setTransferTime(new Date());
+
             userWithdrawal.setUpdateTime(new Date());
             userWithdrawalList.add(userWithdrawal);
         }
         if (!CollectionUtils.isEmpty(errMsgList)) {
             throw new ExcelException("导入异常", errMsgList);
         }
-        authWithdrawalBancth(userWithdrawalList);
+        authWithdrawalBancth(userWithdrawalList, userId);
     }
 
     /***
@@ -185,37 +183,38 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
      * @param: userWithdrawalList
      * @updateTime 2022/4/20 11:18
      */
-    private void authWithdrawalBancth(List<UserWithdrawal> userWithdrawalList) {
+    private void authWithdrawalBancth(List<UserWithdrawal> userWithdrawalList, Long userId) {
         for (UserWithdrawal userWithdrawal : userWithdrawalList) {
             UserWithdrawal old = baseMapper.selectById(userWithdrawal.getId());
-            if (null == old) {
+            if (null == old || !AuthStatusEnum.DOING.equals(old.getStatus()) || AuthStatusEnum.DOING.equals(userWithdrawal.getStatus())) {
                 continue;
             }
-            if (!AuthStatusEnum.PASS.equals(old.getStatus())
-                    && !old.getStatus().equals(userWithdrawal.getStatus())) {
-                baseMapper.updateById(userWithdrawal);
+            userWithdrawal.setUpdateTime(new Date());
 
-                if (AuthStatusEnum.PASS.equals(userWithdrawal.getStatus())) {
-                    //审核通过,账户解冻,入账户明细
-                    UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
-                            old.getUserId(), old.getAmount(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
-                            userWithdrawal.getId(), "老师提现", null
-                    );
-                    accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN_DEDUCT);
-                    accountRecordDto.setSaveRecord(true);
-                    userAccountService.accountChange(accountRecordDto);
-                } else if (AuthStatusEnum.UNPASS.equals(userWithdrawal.getStatus())) {
-                    //审核不通过,账户解冻
-                    UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
-                            old.getUserId(), old.getAmount(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
-                            userWithdrawal.getId(), "老师提现", null
-                    );
-                    accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN_BACK);
-                    accountRecordDto.setSaveRecord(false);
-                    userAccountService.accountChange(accountRecordDto);
-                }
-            }
+            if (AuthStatusEnum.PASS.equals(userWithdrawal.getStatus())) {
+                userWithdrawal.setVerifyUserId(userId);
 
+                //审核通过,账户解冻,入账户明细
+                UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
+                        old.getUserId(), old.getAmount(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
+                        userWithdrawal.getId(), "老师提现", null
+                );
+                accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN_DEDUCT);
+                accountRecordDto.setSaveRecord(true);
+                userAccountService.accountChange(accountRecordDto);
+
+                userWithdrawal.setTransferTime(new Date());
+            } else if (AuthStatusEnum.UNPASS.equals(userWithdrawal.getStatus())) {
+                //审核不通过,账户解冻
+                UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
+                        old.getUserId(), old.getAmount(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
+                        userWithdrawal.getId(), "老师提现", null
+                );
+                accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN_BACK);
+                accountRecordDto.setSaveRecord(false);
+                userAccountService.accountChange(accountRecordDto);
+            }
+            baseMapper.updateById(userWithdrawal);
         }
     }