From 1d03a9e224dc0ce11d47bede74da9db2189d663c Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 21 Jul 2021 11:21:09 +0800
Subject: [PATCH] 202107021
---
gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java | 109 +++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 99 insertions(+), 10 deletions(-)
diff --git a/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java b/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java
index 3055b23..2637795 100644
--- a/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java
+++ b/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java
@@ -3,25 +3,27 @@
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.ScoreGoodsSearch;
-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.common.utils.StringUtils;
+import com.xzx.gc.entity.*;
+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.mapper.UserLoginInfoMapper;
+import com.xzx.gc.user.mapper.UserMapper;
+import com.xzx.gc.user.vo.GetScoreNumVo;
import com.xzx.gc.user.vo.JhyInfoListVo;
+import com.xzx.gc.user.vo.ViewJhyInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
+import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -34,6 +36,12 @@
@Autowired
private JhyInfoMapper jhyInfoMapper;
+
+ @Autowired
+ private UserMapper userMapper;
+
+ @Autowired
+ private UserLoginInfoMapper userLoginInfoMapper;
@Autowired
private AccountMapper accountMapper;
@@ -88,6 +96,25 @@
public Map<String, Object> queryList(JhyInfoListDto jhyInfoListDto) {
PageHelper.startPage(jhyInfoListDto.getPage(), jhyInfoListDto.getLimit());
List<JhyInfoListVo> jhyInfoListVos = jhyInfoMapper.selectJhyInfoList(jhyInfoListDto);
+ if(CollUtil.isNotEmpty(jhyInfoListVos)){
+ for(JhyInfoListVo jhyInfoListVo : jhyInfoListVos){
+ String userId = jhyInfoListVo.getUserId();
+ if(StrUtil.isNotEmpty(userId)){
+ AccountInfo accountInfo = accountMapper.selectOneByUserId(userId);
+ String collectScore = StrUtil.isEmpty(accountInfo.getCollectScore()) ? "0" : accountInfo.getCollectScore();
+ jhyInfoListVo.setScore(new BigDecimal(collectScore).setScale( 2, BigDecimal.ROUND_DOWN ));
+
+ Example example = new Example(UserLoginInfo.class);
+ Example.Criteria criteria = example.createCriteria();
+ criteria.andEqualTo("userId", userId);
+ example.setOrderByClause("login_time desc");
+ List<UserLoginInfo> userLoginInfos = userLoginInfoMapper.selectByExample(example);
+ if (CollUtil.isNotEmpty(userLoginInfos)) {
+ jhyInfoListVo.setLastLogintime(CollUtil.getFirst(userLoginInfos).getLoginTime());
+ }
+ }
+ }
+ }
PageInfo<JhyInfoListVo> pageInfo = new PageInfo<>(jhyInfoListVos);
Map<String, Object> data = new HashMap<>();
@@ -119,10 +146,72 @@
List<AccountInfo> accountInfos = accountMapper.selectByExample(exampleAccount);
if(CollUtil.isNotEmpty(accountInfos)){
AccountInfo accountInfo = accountInfos.get(0);
- Integer collectScore = Integer.parseInt(accountInfo.getCollectScore());
- collectScore = collectScore + model.getScore();
- accountInfo.setCollectScore(collectScore.toString());
+ String collectScore = StrUtil.isEmpty(accountInfo.getCollectScore())?"0":accountInfo.getCollectScore();
+// collectScore = collectScore + model.getScore();
+ accountInfo.setCollectScore(model.getScore().toString());
accountMapper.updateByPrimaryKey(accountInfo);
+
+ ScoreDetails scoreDetailsRet = new ScoreDetails();
+ scoreDetailsRet.setUserId(model.getUserId());
+ scoreDetailsRet.setType(ScoreDetails.SCORE_TYPE_ADMIN_RECHARGE);
+ 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;
+ }
+
+ public ViewJhyInfoVo viewJhyInfo(Long id) {
+ JhyInfo jhyInfo = jhyInfoMapper.selectByPrimaryKey(id);
+ ViewJhyInfoVo viewJhyInfoVo = new ViewJhyInfoVo();
+ viewJhyInfoVo.setIsJhy(jhyInfo.getIsJhy());
+ viewJhyInfoVo.setUsername(jhyInfo.getUsername());
+ viewJhyInfoVo.setMobile(jhyInfo.getMobile());
+ viewJhyInfoVo.setIdCard(jhyInfo.getIdentity());
+ viewJhyInfoVo.setIdCardImg(jhyInfo.getCardPos());
+ viewJhyInfoVo.setAddress(jhyInfo.getAddress());
+ String userId = jhyInfo.getUserId();
+ AccountInfo accountInfo = accountMapper.selectOneByUserId(userId);
+ String collectScore = accountInfo.getCollectScore();
+ BigDecimal bigDecimal = new BigDecimal(StrUtil.isEmpty(collectScore) ? "0" : collectScore).setScale( 2, BigDecimal.ROUND_DOWN );
+ viewJhyInfoVo.setScore(bigDecimal);
+ viewJhyInfoVo.setCreateTime(jhyInfo.getCreatedTime().toString());
+
+ UserInfo userInfo = userMapper.selectByPrimaryKey(userId);
+ String nickName = userInfo.getNickName();
+ if(StrUtil.isNotEmpty(nickName)){
+ String decode = StringUtils.decode(nickName);
+ viewJhyInfoVo.setNickname(decode);
+ }
+
+ List<UserLoginInfo> userLoginInfos = userLoginInfoMapper.selectOneByUserId(userId);
+ if(CollUtil.isNotEmpty(userLoginInfos)){
+ String loginTime = userLoginInfos.get(0).getLoginTime();
+ viewJhyInfoVo.setLoginTime(loginTime);
+ }
+ return viewJhyInfoVo;
+ }
+
+ public void updateJhyInfo(UpdateJhyInfoDto model) {
+ JhyInfo jhyInfo = jhyInfoMapper.selectByPrimaryKey(model.getId());
+ String mobile = model.getMobile();
+ String isJhy = model.getIsJhy();
+ jhyInfo.setIsJhy(isJhy);
+ jhyInfo.setMobile(mobile);
+ jhyInfoMapper.updateByPrimaryKey(jhyInfo);
+ }
}
--
Gitblit v1.9.1