Helius
2021-07-02 1cc585091b57b6824c710fbe8a620559a8f1e286
gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java
@@ -3,18 +3,17 @@
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xzx.gc.common.exception.RestException;
import com.xzx.gc.entity.AccountInfo;
import com.xzx.gc.entity.JhyInfo;
import com.xzx.gc.entity.ScoreDetails;
import com.xzx.gc.user.dto.AddScoreNumDto;
import com.xzx.gc.user.dto.ExamineJwyDto;
import com.xzx.gc.user.dto.JhyApplyDto;
import com.xzx.gc.user.dto.JhyInfoListDto;
import com.xzx.gc.user.dto.*;
import com.xzx.gc.user.mapper.AccountMapper;
import com.xzx.gc.user.mapper.JhyInfoMapper;
import com.xzx.gc.user.vo.GetScoreNumVo;
import com.xzx.gc.user.vo.JhyInfoListVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -120,7 +119,7 @@
        List<AccountInfo> accountInfos = accountMapper.selectByExample(exampleAccount);
        if(CollUtil.isNotEmpty(accountInfos)){
            AccountInfo accountInfo = accountInfos.get(0);
            Integer collectScore = Integer.parseInt(accountInfo.getCollectScore());
            String collectScore = StrUtil.isEmpty(accountInfo.getCollectScore())?"0":accountInfo.getCollectScore();
//            collectScore = collectScore + model.getScore();
            accountInfo.setCollectScore(model.getScore().toString());
            accountMapper.updateByPrimaryKey(accountInfo);
@@ -128,11 +127,24 @@
            ScoreDetails scoreDetailsRet = new ScoreDetails();
            scoreDetailsRet.setUserId(model.getUserId());
            scoreDetailsRet.setType(ScoreDetails.SCORE_TYPE_ADMIN_RECHARGE);
            scoreDetailsRet.setOriginalScore(new BigDecimal(collectScore));
            scoreDetailsRet.setCurrentScore(new BigDecimal(model.getScore()));
            scoreDetailsRet.setChangeScore(new BigDecimal(model.getScore()));
            scoreDetailsRet.setOriginalScore(new BigDecimal(collectScore).setScale( 0, BigDecimal.ROUND_DOWN ));
            scoreDetailsRet.setCurrentScore(new BigDecimal(model.getScore()).setScale( 0, BigDecimal.ROUND_DOWN ));
            scoreDetailsRet.setChangeScore(new BigDecimal(model.getScore()).setScale( 0, BigDecimal.ROUND_DOWN ));
            scoreDetailsRet.setCreatedTime(new Date());
            accountMapper.insertScoreDetailsRet(scoreDetailsRet);
        }
    }
    public GetScoreNumVo getScoreNum(GetScoreNumDto model) {
        GetScoreNumVo getScoreNumVo = new GetScoreNumVo();
        Example exampleAccount = new Example(AccountInfo.class);
        Example.Criteria criteriaAccount = exampleAccount.createCriteria();
        criteriaAccount.andEqualTo("userId",model.getUserId());
        List<AccountInfo> accountInfos = accountMapper.selectByExample(exampleAccount);
        if(CollUtil.isNotEmpty(accountInfos)){
            AccountInfo accountInfo = accountInfos.get(0);
            getScoreNumVo.setScore(new BigDecimal(StrUtil.isEmpty(accountInfo.getCollectScore())?"0":accountInfo.getCollectScore()).setScale( 0, BigDecimal.ROUND_DOWN ));
        }
        return getScoreNumVo;
    }
}