| | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | ScoreSignVo scoreSign = new ScoreSignVo(); |
| | | scoreSign.setMineScore(wallet.getPrizeScore().intValue()); |
| | | |
| | | DataDictionaryCustom signScpreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.SIGN_SCORE.getType(), DataDictionaryEnum.SIGN_SCORE.getCode()); |
| | | MallScoreSignRecord mallScoreSignRecord = mallScoreSignRecordMapper.selectRecentSignRecord(member.getId()); |
| | | if (mallScoreSignRecord == null) { |
| | | scoreSign.setHasSignDays(0); |
| | | } else { |
| | | mallScoreSignRecord = judgeScoreIsContinuity(mallScoreSignRecord); |
| | | scoreSign.setHasSignDays(mallScoreSignRecord.getTotalCnt()); |
| | | } |
| | | |
| | | DataDictionaryCustom signScpreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SCORE_SIGN_SETTING.getType(), DataDictionaryEnum.SCORE_SIGN_SETTING.getCode()); |
| | | if (signScpreDic != null) { |
| | | scoreSign.setSetting(Integer.parseInt(signScpreDic.getValue())); |
| | | scoreSign.setSetting(JSONObject.parseObject(signScpreDic.getValue(), ScoreSettingDto.class)); |
| | | } |
| | | return scoreSign; |
| | | } |
| | |
| | | MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(member.getId()); |
| | | apiScoreVoucherInfoVo.setVoucherCnt(mallMemberWallet.getVoucherCnt().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : mallMemberWallet.getVoucherCnt()); |
| | | apiScoreVoucherInfoVo.setVoucherAmount(mallMemberWallet.getVoucherAmount().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : mallMemberWallet.getVoucherAmount()); |
| | | apiScoreVoucherInfoVo.setVoucherFireCnt(mallMemberWallet.getVoucherFireCnt().compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : mallMemberWallet.getVoucherFireCnt()); |
| | | DataDictionaryCustom scorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | GreenScoreEnum.SCORE_PRICE.getType(), |
| | | GreenScoreEnum.SCORE_PRICE.getCode()); |
| | |
| | | scorePoolCntDic.setValue(scorePoolCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(scorePoolCntDic); |
| | | //增加凭证数量 |
| | | mallMemberWalletMapper.addVorCherCntByMemberId(voucherCnt,memberId); |
| | | // mallMemberWalletMapper.addVorCherCntByMemberId(voucherCnt,memberId); |
| | | //增加凭证燃烧值数量 |
| | | mallMemberWalletMapper.addVorCherFireCntByMemberId(voucherCnt,memberId); |
| | | //增加购买记录 |
| | | String voucherNo = MallUtils.getOrderNum("VB"); |
| | | MallScoreVoucher mallScoreVoucher = new MallScoreVoucher(); |
| | |
| | | MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | BigDecimal voucherCntMember = mallMemberWallet.getVoucherCnt(); |
| | | if(voucherCntMember.compareTo(voucherCnt) < 0){ |
| | | throw new FebsException("绿色积分不足"); |
| | | throw new FebsException("数量不足"); |
| | | } |
| | | |
| | | DataDictionaryCustom scorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | |
| | | voucherAmount, |
| | | MoneyFlowTypeEnum.VOUCHER_SALE.getValue(), |
| | | voucherNo, |
| | | FlowTypeEnum.VOUCHER_AMOUNT.getValue()); |
| | | FlowTypeEnum.BALANCE.getValue()); |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | |
| | | public void sign() { |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | |
| | | DataDictionaryCustom signScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.SIGN_SCORE.getType(), |
| | | DataDictionaryEnum.SIGN_SCORE.getCode()); |
| | | if (signScoreDic == null) { |
| | | throw new FebsException("签到活动未开启"); |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SCORE_SIGN_SETTING.getType(), DataDictionaryEnum.SCORE_SIGN_SETTING.getCode()); |
| | | if (dic == null) { |
| | | throw new FebsException("暂未设置积分"); |
| | | } |
| | | Integer signScore = Integer.parseInt(signScoreDic.getValue()); |
| | | |
| | | MallScoreSignRecord mallScoreSignRecord = mallScoreSignRecordMapper.selectRecentSignRecord(member.getId()); |
| | | if (mallScoreSignRecord == null) { |
| | |
| | | } |
| | | |
| | | if (mallScoreSignRecord.getSignTime() != null && DateUtil.betweenDay(mallScoreSignRecord.getSignTime(), new Date(), true) == 0) { |
| | | throw new FebsException("今日已签到"); |
| | | throw new FebsException("今天已签到"); |
| | | } |
| | | /** |
| | | * 用户注册时间开始计算 |
| | | * 判断签到时间是否大于规定的signScoreDays,超出则获得的积分数为signScoreCnt |
| | | */ |
| | | // Integer count = mallScoreSignRecordMapper.selectCountByMemberId(member.getId()); |
| | | DataDictionaryCustom signScoreDaysDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.SIGN_SCORE_DAYS.getType(), |
| | | DataDictionaryEnum.SIGN_SCORE_DAYS.getCode()); |
| | | Integer signScoreDays = Integer.parseInt(signScoreDaysDic.getValue()); |
| | | |
| | | MallMember mallMember = mallMemberMapper.selectById(member.getId()); |
| | | Date createdTime = mallMember.getCreatedTime(); |
| | | mallScoreSignRecord = judgeScoreIsContinuity(mallScoreSignRecord); |
| | | |
| | | DateTime dateTime = DateUtil.offsetDay(createdTime, signScoreDays); |
| | | /** |
| | | * 签到时间不在系统设置的第一个阶段,则获取签到设置-签到积分后续获得积分数量 |
| | | */ |
| | | if(DateUtil.compare(dateTime, new Date()) < 0){ |
| | | DataDictionaryCustom signScoreCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.SIGN_SCORE_CNT.getType(), |
| | | DataDictionaryEnum.SIGN_SCORE_CNT.getCode()); |
| | | Integer signScoreCnt = Integer.parseInt(signScoreCntDic.getValue()); |
| | | signScore = signScoreCnt; |
| | | ScoreSettingDto scoreSetting = JSONObject.parseObject(dic.getValue(),ScoreSettingDto.class); |
| | | int days = mallScoreSignRecord.getTotalCnt() == null ? 1 : mallScoreSignRecord.getTotalCnt() + 1; |
| | | switch (days) { |
| | | case 1: |
| | | if (scoreSetting.getSignInOne() == null) { |
| | | throw new FebsException("积分未设置"); |
| | | } |
| | | mallScoreSignRecord.setScore(scoreSetting.getSignInOne()); |
| | | break; |
| | | case 2: |
| | | if (scoreSetting.getSignInTwo() == null) { |
| | | throw new FebsException("积分未设置"); |
| | | } |
| | | mallScoreSignRecord.setScore(scoreSetting.getSignInTwo()); |
| | | break; |
| | | case 3: |
| | | if (scoreSetting.getSignInThree() == null) { |
| | | throw new FebsException("积分未设置"); |
| | | } |
| | | mallScoreSignRecord.setScore(scoreSetting.getSignInThree()); |
| | | break; |
| | | case 4: |
| | | if (scoreSetting.getSignInFour() == null) { |
| | | throw new FebsException("积分未设置"); |
| | | } |
| | | mallScoreSignRecord.setScore(scoreSetting.getSignInFour()); |
| | | break; |
| | | case 5: |
| | | if (scoreSetting.getSignInFive() == null) { |
| | | throw new FebsException("积分未设置"); |
| | | } |
| | | mallScoreSignRecord.setScore(scoreSetting.getSignInFive()); |
| | | break; |
| | | case 6: |
| | | if (scoreSetting.getSignInSix() == null) { |
| | | throw new FebsException("积分未设置"); |
| | | } |
| | | mallScoreSignRecord.setScore(scoreSetting.getSignInSix()); |
| | | break; |
| | | case 7: |
| | | if (scoreSetting.getSignInSeven() == null) { |
| | | throw new FebsException("积分未设置"); |
| | | } |
| | | mallScoreSignRecord.setScore(scoreSetting.getSignInSeven()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | mallScoreSignRecord.setMemberId(member.getId()); |
| | | mallScoreSignRecord.setTotalCnt(signScore); |
| | | mallScoreSignRecord.setTotalCnt(days); |
| | | mallScoreSignRecord.setSignTime(new Date()); |
| | | mallScoreSignRecord.setScore(signScore); |
| | | mallScoreSignRecordMapper.insert(mallScoreSignRecord); |
| | | |
| | | BigDecimal amount = BigDecimal.valueOf(mallScoreSignRecord.getScore()); |
| | | walletService.add(amount, member.getId(), "prizeScore"); |
| | | mallMoneyFlowService.addMoneyFlow( |
| | | member.getId(), |
| | | amount, |
| | | MoneyFlowTypeEnum.SCORE_SIGN.getValue(), |
| | | null, |
| | | FlowTypeEnum.PRIZE_SCORE.getValue()); |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), amount, MoneyFlowTypeEnum.SCORE_SIGN.getValue(), null, FlowTypeEnum.PRIZE_SCORE.getValue()); |
| | | } |
| | | } |