From 3a82a5078037deef31caf3694acc36c4f386ffb3 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Wed, 10 Nov 2021 11:14:43 +0800 Subject: [PATCH] Merge branch 'score-shop' of http://120.27.238.55:7000/r/xzx into score-shop --- gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java | 371 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 346 insertions(+), 25 deletions(-) diff --git a/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java b/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java index 766ea84..4cb50d3 100644 --- a/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java +++ b/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java @@ -6,21 +6,16 @@ import cn.hutool.core.date.DateUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.xzx.gc.common.constant.CommonEnum; import com.xzx.gc.common.exception.RestException; +import com.xzx.gc.common.utils.RedisUtil; import com.xzx.gc.common.utils.StringUtils; -import com.xzx.gc.entity.AccountInfo; -import com.xzx.gc.entity.SysMessage; -import com.xzx.gc.entity.UserHeadRelate; -import com.xzx.gc.entity.UserShareInfo; -import com.xzx.gc.user.dto.HeadProfitLitDto; -import com.xzx.gc.user.dto.HeadTeamDto; +import com.xzx.gc.entity.*; +import com.xzx.gc.user.dto.*; import com.xzx.gc.user.mapper.*; import com.xzx.gc.user.vo.HeadInfoVo; import com.xzx.gc.user.vo.HeadProfitListVo; import com.xzx.gc.user.vo.HeadTeamVo; -import com.xzx.gc.user.dto.AdddistribDto; -import com.xzx.gc.user.dto.DistribInfoListDto; -import com.xzx.gc.user.dto.DistribListDto; import com.xzx.gc.user.mapper.AccountMapper; import com.xzx.gc.user.mapper.SysMessageMapper; import com.xzx.gc.user.mapper.UserHeadRelateMapper; @@ -28,16 +23,16 @@ import com.xzx.gc.user.vo.*; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import com.xzx.gc.entity.RedPaperRule; import com.xzx.gc.model.JsonResult; -import com.xzx.gc.user.dto.UpdateSettingDto; import com.xzx.gc.user.mapper.RedPaperRuleMapper; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.HashMap; import java.util.List; @@ -46,6 +41,7 @@ import java.util.List; import java.util.Map; +@Slf4j @Service @Transactional public class DistribService { @@ -62,6 +58,10 @@ private UserShareInfoMapper userShareInfoMapper; @Autowired private SysMessageMapper sysMessageMapper; + @Autowired + private RedisUtil redisUtil; + @Autowired + private ScoreDetailsMapper scoreDetailsMapper; public ViewSettingVo viewSetting(String ruleStr) { ViewSettingVo viewSettingVo = new ViewSettingVo(); @@ -71,7 +71,7 @@ viewSettingVo.setOrderNumFrist(0); viewSettingVo.setRegularPoint(0); viewSettingVo.setRegularMoneyPercent(BigDecimal.ZERO); - viewSettingVo.setFinishOrderNum(0); +// viewSettingVo.setFinishOrderNum(0); viewSettingVo.setPointReward(0); viewSettingVo.setStatus((short) 0); }else{ @@ -84,8 +84,8 @@ viewSettingVo.setOrderNumFrist(StrUtil.isEmpty(shareRatios.get(1))?0:Integer.parseInt(shareRatios.get(1))); viewSettingVo.setRegularPoint(StrUtil.isEmpty(shareRatios.get(2))?0:Integer.parseInt(shareRatios.get(2))); viewSettingVo.setRegularMoneyPercent(StrUtil.isEmpty(shareRatios.get(3))?BigDecimal.ZERO:new BigDecimal(shareRatios.get(3))); - viewSettingVo.setFinishOrderNum(StrUtil.isEmpty(shareRatios.get(4))?0:Integer.parseInt(shareRatios.get(4))); - viewSettingVo.setPointReward(StrUtil.isEmpty(shareRatios.get(5))?0:Integer.parseInt(shareRatios.get(5))); +// viewSettingVo.setFinishOrderNum(StrUtil.isEmpty(shareRatios.get(4))?0:Integer.parseInt(shareRatios.get(4))); + viewSettingVo.setPointReward(StrUtil.isEmpty(shareRatios.get(4))?0:Integer.parseInt(shareRatios.get(4))); viewSettingVo.setStatus(redPaperRule.getStatus()); } }else{ @@ -94,7 +94,7 @@ viewSettingVo.setOrderNumFrist(0); viewSettingVo.setRegularPoint(0); viewSettingVo.setRegularMoneyPercent(BigDecimal.ZERO); - viewSettingVo.setFinishOrderNum(0); +// viewSettingVo.setFinishOrderNum(0); viewSettingVo.setPointReward(0); viewSettingVo.setStatus((short) 0); } @@ -104,6 +104,7 @@ public void join(String headId, String userId) { + log.info("#加入团队:{}, {}#", headId, userId); AccountInfo headInfo = accountMapper.selectOneByUserId(headId); if (AccountInfo.IS_HEAD_N.equals(headInfo.getIsHead())) { throw new RestException(-3, "不是团长"); @@ -119,6 +120,10 @@ } AccountInfo accountInfo = accountMapper.selectOneByUserId(userId); + if (AccountInfo.IS_HEAD_Y.equals(accountInfo.getIsHead())) { + throw new RestException(-3, "团长不能加入团队"); + } + UserShareInfo userShareInfo = userShareInfoMapper.selectByRegistPhone(accountInfo.getAccountName()); if (userShareInfo != null) { throw new RestException(-3, "您已与推广员绑定, 无法加入"); @@ -128,15 +133,18 @@ userHeadRelate.setHeadUserId(headId); userHeadRelate.setUserId(userId); userHeadRelate.setScore(BigDecimal.ZERO); + userHeadRelate.setCreatedTime(new Date()); userHeadRelate.setAmount(BigDecimal.ZERO); userHeadRelateMapper.insert(userHeadRelate); SysMessage sysMessage = new SysMessage(); sysMessage.setCreateTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); - sysMessage.setCreateUserId(userId); + sysMessage.setCreateUserId(headId); + sysMessage.setUserId(headId); sysMessage.setMobilePhone(accountInfo.getAccountName()); sysMessage.setMessageType("4"); - sysMessage.setMessage("手机号:" + accountInfo.getAccountName() + "的用户, 成功加入您的团队"); + sysMessage.setMessageSubTypeName("团队消息"); + sysMessage.setMessage("手机号:" + accountInfo.getAccountName().replaceAll("(\\w{3})\\w*(\\w{4})", "$1****$2") + "的用户, 成功加入您的团队"); sysMessage.setFlag("2"); sysMessageMapper.insert(sysMessage); } @@ -174,13 +182,14 @@ stringBuffer.append(regularPoint+","); BigDecimal regularMoneyPercent = ObjectUtil.isEmpty(model.getRegularMoneyPercent()) ? BigDecimal.ZERO : model.getRegularMoneyPercent(); stringBuffer.append(regularMoneyPercent+","); - int finishOrderNum = ObjectUtil.isEmpty(model.getFinishOrderNum()) ? 0 : model.getFinishOrderNum(); - stringBuffer.append(finishOrderNum+","); +// int finishOrderNum = ObjectUtil.isEmpty(model.getFinishOrderNum()) ? 0 : model.getFinishOrderNum(); +// stringBuffer.append(finishOrderNum+","); int pointReward = ObjectUtil.isEmpty(model.getPointReward()) ? 0 : model.getPointReward(); stringBuffer.append(pointReward); redPaperRule.setStatus((short) 0); redPaperRule.setRuleName("分销规则"); - redPaperRule.setSharingProfitType("frist_reward,order_num_frist,regular_point,regular_money_percent,finish_order_num,point_reward"); + redPaperRule.setRuleType("9"); + redPaperRule.setSharingProfitType("frist_reward,order_num_frist,regular_point,regular_money_percent,point_reward"); redPaperRule.setShareRatio(stringBuffer.toString()); redPaperRuleMapper.insert(redPaperRule); } @@ -197,12 +206,12 @@ stringBuffer.append(regularPoint+","); BigDecimal regularMoneyPercent = ObjectUtil.isEmpty(model.getRegularMoneyPercent()) ? BigDecimal.ZERO : model.getRegularMoneyPercent(); stringBuffer.append(regularMoneyPercent+","); - int finishOrderNum = ObjectUtil.isEmpty(model.getFinishOrderNum()) ? 0 : model.getFinishOrderNum(); - stringBuffer.append(finishOrderNum+","); +// int finishOrderNum = ObjectUtil.isEmpty(model.getFinishOrderNum()) ? 0 : model.getFinishOrderNum(); +// stringBuffer.append(finishOrderNum+","); int pointReward = ObjectUtil.isEmpty(model.getPointReward()) ? 0 : model.getPointReward(); stringBuffer.append(pointReward); redPaperRule.setStatus(model.getStatus()); - redPaperRule.setSharingProfitType("frist_reward,order_num_frist,regular_point,regular_money_percent,finish_order_num,point_reward"); + redPaperRule.setSharingProfitType("first_reward,order_num_first,regular_point,regular_money_percent,point_reward"); redPaperRule.setShareRatio(stringBuffer.toString()); redPaperRuleMapper.updateByPrimaryKey(redPaperRule); } @@ -232,8 +241,7 @@ return data; } - public void adddistrib(AdddistribDto model) { - String id = model.getId(); + public void adddistrib(String id) { AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id); accountInfo.setIsHead(1); accountMapper.updateByPrimaryKey(accountInfo); @@ -262,4 +270,317 @@ return data; } + + public ViewDistribInfoVo viewDistribInfo(String id) { + //获取团长基本信息 + ViewDistribInfoVo viewDistribInfoVo = accountMapper.selectDistribByAccountId(id); + if(StrUtil.isNotEmpty(viewDistribInfoVo.getNickname())){ + String decode = StringUtils.decode(viewDistribInfoVo.getNickname()); + viewDistribInfoVo.setNickname(decode); + } + return accountMapper.selectDistribByAccountId(id); + } + + public Map<String, Object> userHeadInfoList(UserHeadInfoListDto userHeadInfoListDto) { + String id = userHeadInfoListDto.getId(); + AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id); + String userId = accountInfo.getUserId(); + PageHelper.startPage(userHeadInfoListDto.getPage(), userHeadInfoListDto.getLimit()); + List<UserHeadInfoVo> userHeadInfoVos = accountMapper.selectUserHeadInfoByAccountId(userId); + if(CollUtil.isNotEmpty(userHeadInfoVos)){ + for(UserHeadInfoVo userHeadInfoVo : userHeadInfoVos){ + String nickname = userHeadInfoVo.getNickname(); + String decode = StringUtils.decode(nickname); + userHeadInfoVo.setNickname(decode); + } + } + PageInfo<UserHeadInfoVo> pageInfo = new PageInfo<>(userHeadInfoVos); + Map<String, Object> data = new HashMap<>(); + int count = Convert.toInt(pageInfo.getTotal()); + data.put("data", userHeadInfoVos); + data.put("count", count); + data.put("code", 0); + return data; + } + + public Map<String, Object> orderItemsList(UserHeadInfoListDto userHeadInfoListDto) { + String id = userHeadInfoListDto.getId(); + AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id); + String userId = accountInfo.getUserId(); + PageHelper.startPage(userHeadInfoListDto.getPage(), userHeadInfoListDto.getLimit()); + List<OrderItemsVo> orderItemsVos = accountMapper.selectOrderItemsByUserId(userId); + if(CollUtil.isNotEmpty(orderItemsVos)){ + for(OrderItemsVo orderItemsVo : orderItemsVos){ + if(ObjectUtil.isNotEmpty(orderItemsVo)){ + String nickname = orderItemsVo.getNickname(); + String decode = StringUtils.decode(nickname); + orderItemsVo.setNickname(decode); + Long orderId = orderItemsVo.getOrderId(); + List<JhyOrderItems> jhyOrderItems = accountMapper.selectOrderById(orderId); + if(CollUtil.isNotEmpty(jhyOrderItems)){ + orderItemsVo.setOrderItems(jhyOrderItems); + } + } + } + } + PageInfo<OrderItemsVo> pageInfo = new PageInfo<>(orderItemsVos); + Map<String, Object> data = new HashMap<>(); + int count = Convert.toInt(pageInfo.getTotal()); + data.put("data", orderItemsVos); + data.put("count", count); + data.put("code", 0); + return data; + } + + public void prohibitDistrib(ProhibitDistribDto model) { + Integer status = model.getStatus(); + String id = model.getId(); + AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id); + accountInfo.setIsProhibit(status.toString()); + accountMapper.updateByPrimaryKey(accountInfo); + } + + + public Map<String, Object> distribDataList(DistribDataListDto distribDataListDto) { + if(StrUtil.isNotEmpty(distribDataListDto.getQueryCol())){ + String decode = StringUtils.encode(distribDataListDto.getQueryCol()); + distribDataListDto.setName(decode); + distribDataListDto.setPhone(distribDataListDto.getQueryCol()); + } + PageHelper.startPage(distribDataListDto.getPage(), distribDataListDto.getLimit()); + List<DistribDataListVo> distribDataListVos = accountMapper.distribDataList(distribDataListDto); + if(CollUtil.isNotEmpty(distribDataListVos)){ + for(DistribDataListVo distribDataListVo : distribDataListVos){ + if(ObjectUtil.isNotEmpty(distribDataListVo)){ + String nickname = distribDataListVo.getNickname(); + String decode = StringUtils.decode(nickname); + distribDataListVo.setNickname(decode); + String id = distribDataListVo.getId(); + String kg = accountMapper.selectOrderByHeadUserId(id,distribDataListDto); + distribDataListVo.setKg(kg); + String jdsl = accountMapper.selectJDSLByHeadUserId(id,distribDataListDto); + distribDataListVo.setJdsl(jdsl); + } + } + } + PageInfo<DistribDataListVo> pageInfo = new PageInfo<>(distribDataListVos); + Map<String, Object> data = new HashMap<>(); + int count = Convert.toInt(pageInfo.getTotal()); + data.put("data", distribDataListVos); + data.put("count", count); + data.put("code", 0); + return data; + } + + public DistribDataInfoVo distribDataInfo(DistribDataInfoDto distribDataInfoDto) { + return accountMapper.selectDistribDataInfoVo(); + } + + public Map<String, Object> distribDataExport(ExportDistribDataListDto distribDataListDto) { + if(StrUtil.isNotEmpty(distribDataListDto.getQueryCol())){ + String decode = StringUtils.encode(distribDataListDto.getQueryCol()); + distribDataListDto.setName(decode); + distribDataListDto.setPhone(distribDataListDto.getQueryCol()); + } + List<DistribDataListVo> distribDataListVos = accountMapper.distribDataExport(distribDataListDto); + if(CollUtil.isNotEmpty(distribDataListVos)){ + for(DistribDataListVo distribDataListVo : distribDataListVos){ + if(ObjectUtil.isNotEmpty(distribDataListVo)){ + String nickname = distribDataListVo.getNickname(); + String decode = StringUtils.decode(nickname); + distribDataListVo.setNickname(decode); + String id = distribDataListVo.getId(); + String kg = accountMapper.selectOrderExportByHeadUserId(id,distribDataListDto); + distribDataListVo.setKg(kg); + String jdsl = accountMapper.selectJDSLExportByHeadUserId(id,distribDataListDto); + distribDataListVo.setJdsl(jdsl); + } + } + } + PageInfo<DistribDataListVo> pageInfo = new PageInfo<>(distribDataListVos); + Map<String, Object> data = new HashMap<>(); + int count = Convert.toInt(pageInfo.getTotal()); + data.put("data", distribDataListVos); + data.put("count", count); + data.put("code", 0); + return data; + } + + public ViewScoreSettingVo viewScoreSetting(String ruleStr) { + ViewScoreSettingVo viewScoreSettingVo = new ViewScoreSettingVo(); + RedPaperRule redPaperRule = redPaperRuleMapper.selectByRuleName(ruleStr); + if(ObjectUtil.isEmpty(redPaperRule)){ + viewScoreSettingVo.setRegisterScore(0); + viewScoreSettingVo.setShareScore(0); + viewScoreSettingVo.setShareScoreTime(0); + viewScoreSettingVo.setFirstScore(0); + viewScoreSettingVo.setStatus((short) 0); + }else{ + String shareRatio = redPaperRule.getShareRatio(); + if(StrUtil.isNotEmpty(shareRatio)){ + List<String> shareRatios = StrUtil.split(shareRatio,',',false,false); + if(ObjectUtil.isNotEmpty(shareRatios)){ + viewScoreSettingVo.setId(redPaperRule.getId()); + viewScoreSettingVo.setRegisterScore(StrUtil.isEmpty(shareRatios.get(0))?0:Integer.parseInt(shareRatios.get(0))); + viewScoreSettingVo.setShareScore(StrUtil.isEmpty(shareRatios.get(1))?0:Integer.parseInt(shareRatios.get(1))); + viewScoreSettingVo.setShareScoreTime(StrUtil.isEmpty(shareRatios.get(2))?0:Integer.parseInt(shareRatios.get(2))); + viewScoreSettingVo.setFirstScore(StrUtil.isEmpty(shareRatios.get(3))?0:Integer.parseInt(shareRatios.get(3))); + viewScoreSettingVo.setStatus(redPaperRule.getStatus()); + } + }else{ + viewScoreSettingVo.setId(redPaperRule.getId()); + viewScoreSettingVo.setRegisterScore(0); + viewScoreSettingVo.setShareScore(0); + viewScoreSettingVo.setShareScoreTime(0); + viewScoreSettingVo.setFirstScore(0); + viewScoreSettingVo.setStatus(redPaperRule.getStatus()); + } + } + return viewScoreSettingVo; + } + + public void addScoreSetting(UpdateScoreSetting model) { + RedPaperRule redPaperRule = new RedPaperRule(); + StringBuffer stringBuffer = new StringBuffer(); + int registerScore = ObjectUtil.isEmpty(model.getRegisterScore()) ? 0 : model.getRegisterScore(); + stringBuffer.append(registerScore+","); + int shareScore = ObjectUtil.isEmpty(model.getShareScore()) ? 0 : model.getShareScore(); + stringBuffer.append(shareScore+","); + int shareScoreTime = ObjectUtil.isEmpty(model.getShareScoreTime()) ? 0 : model.getShareScoreTime(); + stringBuffer.append(shareScoreTime+","); + int firstScore = ObjectUtil.isEmpty(model.getFirstScore()) ? 0 : model.getFirstScore(); + stringBuffer.append(firstScore); + redPaperRule.setStatus((short) 0); + redPaperRule.setRuleName("积分运行设置"); + redPaperRule.setRuleType("10"); + redPaperRule.setSharingProfitType("register_score,share_score,share_score_time,first_score"); + redPaperRule.setShareRatio(stringBuffer.toString()); + redPaperRuleMapper.insert(redPaperRule); + } + + public void updateScoreSetting(UpdateScoreSetting model) { + RedPaperRule redPaperRule = redPaperRuleMapper.selectByPrimaryKey(model.getId()); + if(ObjectUtil.isNotEmpty(redPaperRule)){ + StringBuffer stringBuffer = new StringBuffer(); + int registerScore = ObjectUtil.isEmpty(model.getRegisterScore()) ? 0 : model.getRegisterScore(); + stringBuffer.append(registerScore+","); + int shareScore = ObjectUtil.isEmpty(model.getShareScore()) ? 0 : model.getShareScore(); + stringBuffer.append(shareScore+","); + int shareScoreTime = ObjectUtil.isEmpty(model.getShareScoreTime()) ? 0 : model.getShareScoreTime(); + stringBuffer.append(shareScoreTime+","); + int firstScore = ObjectUtil.isEmpty(model.getFirstScore()) ? 0 : model.getFirstScore(); + stringBuffer.append(firstScore); + redPaperRule.setStatus(model.getStatus()); + redPaperRule.setSharingProfitType("register_score,share_score,share_score_time,first_score"); + redPaperRule.setShareRatio(stringBuffer.toString()); + redPaperRuleMapper.updateByPrimaryKey(redPaperRule); + } + } + + public void shareToMoments(String userId) { + List<RedPaperRule> redPaperRules = redPaperRuleMapper.selectByRuleType("10"); + if (CollUtil.isEmpty(redPaperRules)) { + return; + } + + RedPaperRule rule = redPaperRules.get(0); + if (rule.getStatus() == 0) { + log.info("规则被禁用, 不执行返利"); + return; + } + + String shareTimes = getRuleValue(rule, CommonEnum.朋友圈分享限次.getValue()); + + String shareScore = getRuleValue(rule, CommonEnum.朋友圈分享奖励.getValue()); + String key = "moments:times:" + userId; + Integer times = redisUtil.getAsInt("moments:times:" + userId); + times = times == null ? 1 : times + 1; + + if (StrUtil.isNotBlank(shareTimes)) { + if (times > Integer.parseInt(shareTimes)) { + throw new RestException("达到24小时内最大分享次数"); + } + + if (StrUtil.isBlank(shareScore)) { + return; + } + + AccountInfo accountInfo = accountMapper.selectOneByUserId(userId); + BigDecimal returnScore = new BigDecimal(shareScore); + BigDecimal collectScore = StrUtil.isNotBlank(accountInfo.getCollectScore()) ? new BigDecimal(accountInfo.getCollectScore()) : BigDecimal.ZERO; + accountInfo.setCollectScore(collectScore.add(returnScore).setScale(0, RoundingMode.DOWN).toString()); + accountMapper.updateByPrimaryKey(accountInfo); + + ScoreDetails scoreDetails = new ScoreDetails(); + scoreDetails.setCurrentScore(new BigDecimal(accountInfo.getCollectScore())); + scoreDetails.setOriginalScore(collectScore); + scoreDetails.setChangeScore(returnScore); + scoreDetails.setCreatedTime(new Date()); + scoreDetails.setType(ScoreDetails.SCORE_TYPE_SHARE_MOMENTS); + scoreDetails.setUserId(accountInfo.getUserId()); + scoreDetailsMapper.insert(scoreDetails); + + SysMessage sysMessage = new SysMessage(); + sysMessage.setCreateTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); + sysMessage.setCreateUserId(accountInfo.getUserId()); + sysMessage.setUserId(accountInfo.getUserId()); + sysMessage.setMessageType("4"); + sysMessage.setMessageSubTypeName("朋友圈分享"); + sysMessage.setMessage("朋友圈分享, 积分:" + returnScore); + sysMessage.setFlag("2"); + sysMessageMapper.insert(sysMessage); + + Date tomorrow = DateUtil.parse(DateUtil.tomorrow().toString("yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss"); + long time = DateUtil.between(new Date(), tomorrow, DateUnit.SECOND, false); + redisUtil.setex(key, times.toString(), (int) time); + } + } + + public void inviteAward(String phone) { + AccountInfo accountInfo = accountMapper.selectAccountInfoByPhone(phone); + + List<RedPaperRule> redPaperRules = redPaperRuleMapper.selectByRuleType("10"); + if (CollUtil.isEmpty(redPaperRules)) { + return; + } + + RedPaperRule rule = redPaperRules.get(0); + String invite = getRuleValue(rule, CommonEnum.邀请奖励.getValue()); + + if (StrUtil.isBlank(invite)) { + return; + } + + BigDecimal returnScore = new BigDecimal(invite); + BigDecimal collectScore = StrUtil.isNotBlank(accountInfo.getCollectScore()) ? new BigDecimal(accountInfo.getCollectScore()) : BigDecimal.ZERO; + accountInfo.setCollectScore(collectScore.add(returnScore).setScale(0, RoundingMode.DOWN).toString()); + accountMapper.updateByPrimaryKey(accountInfo); + + ScoreDetails scoreDetails = new ScoreDetails(); + scoreDetails.setCurrentScore(new BigDecimal(accountInfo.getCollectScore())); + scoreDetails.setOriginalScore(collectScore); + scoreDetails.setChangeScore(returnScore); + scoreDetails.setCreatedTime(new Date()); + scoreDetails.setType(ScoreDetails.SCORE_TYPE_INVITE); + scoreDetails.setUserId(accountInfo.getUserId()); + scoreDetailsMapper.insert(scoreDetails); + + SysMessage sysMessage = new SysMessage(); + sysMessage.setCreateTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); + sysMessage.setCreateUserId(accountInfo.getUserId()); + sysMessage.setUserId(accountInfo.getUserId()); + sysMessage.setMessageType("4"); + sysMessage.setMessageSubTypeName("邀请奖励"); + sysMessage.setMessage("邀请奖励, 积分:" + returnScore); + sysMessage.setFlag("2"); + sysMessageMapper.insert(sysMessage); + } + + private String getRuleValue(RedPaperRule redPaperRule, String key) { + List<String> rules = StrUtil.split(redPaperRule.getSharingProfitType(), ','); + List<String> values = StrUtil.split(redPaperRule.getShareRatio(), ','); + + int i = rules.indexOf(key); + return values.get(i); + } } -- Gitblit v1.9.1