wrj před 8 měsíci
rodič
revize
834b051100

+ 13 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/TTxRecordServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ylx.massage.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -22,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
+import java.util.List;
 import java.util.Objects;
 
 
@@ -49,6 +51,13 @@ public class TTxRecordServiceImpl extends ServiceImpl<TTxRecordMapper, TTxRecord
         if (StringUtils.isBlank(record.getcOpenId())) {
             throw new ServiceException("OpenID不能为空");
         }
+        LambdaQueryWrapper<TTxRecord> tTxRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        tTxRecordLambdaQueryWrapper.eq(TTxRecord::getcOpenId, record.getcOpenId())
+                .eq(TTxRecord::getnStatus, TTxRecordEnum.PASS_ING.getCode());
+        List<TTxRecord> list = this.list(tTxRecordLambdaQueryWrapper);
+        if (CollectionUtil.isNotEmpty(list)) {
+            throw new ServiceException("提现申请正在审核中,请勿重复申请");
+        }
         if (StringUtils.isBlank(record.getOpeningBank())) {
             throw new ServiceException("开户行不能为空");
         }
@@ -64,6 +73,9 @@ public class TTxRecordServiceImpl extends ServiceImpl<TTxRecordMapper, TTxRecord
         if (record.getdPrice().compareTo(user.getdBalance()) > 0) {
             throw new ServiceException("提现金额不能大于钱包余额");
         }
+        if (record.getdPrice().compareTo(user.getGetAmount()) > 0) {
+            throw new ServiceException("提现金额不能大于可提现金额");
+        }
         LambdaQueryWrapper<TJs> mhCompanyLambdaQueryWrapper = new LambdaQueryWrapper<>();
         mhCompanyLambdaQueryWrapper.eq(TJs::getcOpenId, record.getcOpenId());
         TJs js = jsService.getOne(mhCompanyLambdaQueryWrapper);
@@ -93,6 +105,7 @@ public class TTxRecordServiceImpl extends ServiceImpl<TTxRecordMapper, TTxRecord
         UpdateWrapper<TWxUser> businessUpdateWrapper = new UpdateWrapper<>();
         businessUpdateWrapper.lambda().eq(TWxUser::getcOpenid, record.getcOpenId());
         businessUpdateWrapper.lambda().setSql(" d_balance = d_balance - " + record.getdPrice());
+        businessUpdateWrapper.lambda().setSql(" get_amount = get_amount - " + record.getdPrice());
         wxUserService.update(businessUpdateWrapper);
 
         //余额记录