| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.GreenScoreEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.AppContants; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.mall.dto.ScoreSettingDto; |
| | | import cc.mrbird.febs.mall.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallMemberWallet; |
| | | import cc.mrbird.febs.mall.entity.MallScoreSignRecord; |
| | | import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallMemberWalletMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallScoreSignRecordMapper; |
| | | import cc.mrbird.febs.common.utils.MallUtils; |
| | | import cc.mrbird.febs.mall.conversion.MallOrderInfoConversion; |
| | | import cc.mrbird.febs.mall.dto.*; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberService; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.service.IMallMoneyFlowService; |
| | | import cc.mrbird.febs.mall.service.IScoreService; |
| | | import cc.mrbird.febs.mall.vo.ScoreSignVo; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | | import cn.hutool.core.date.DateField; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | private final MallScoreSignRecordMapper mallScoreSignRecordMapper; |
| | | private final IMallMoneyFlowService mallMoneyFlowService; |
| | | private final IApiMallMemberWalletService walletService; |
| | | private final MallMemberMapper mallMemberMapper; |
| | | private final MallScoreVoucherMapper mallScoreVoucherMapper; |
| | | private final IApiMallMemberWalletService memberWalletService; |
| | | private final MallMemberBankMapper mallMemberBankMapper; |
| | | private final MallMemberWithdrawMapper mallMemberWithdrawMapper; |
| | | private final IApiMallMemberService mallMemberService; |
| | | private final MallScoreRecordMapper mallScoreRecordMapper; |
| | | |
| | | @Override |
| | | public ScoreSignVo scoreSign() { |
| | |
| | | |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(member.getId()); |
| | | |
| | | MallScoreSignRecord mallScoreSignRecord = mallScoreSignRecordMapper.selectRecentSignRecord(member.getId()); |
| | | |
| | | ScoreSignVo scoreSign = new ScoreSignVo(); |
| | | scoreSign.setMineScore(wallet.getPrizeScore().intValue()); |
| | | scoreSign.setHasSignDays(mallScoreSignRecord == null ? 0 : mallScoreSignRecord.getTotalCnt()); |
| | | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SCORE_SIGN_SETTING.getType(), DataDictionaryEnum.SCORE_SIGN_SETTING.getCode()); |
| | | if (dic != null) { |
| | | scoreSign.setSetting(JSONObject.parseObject(dic.getValue(), ScoreSettingDto.class)); |
| | | DataDictionaryCustom signScpreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.SIGN_SCORE.getType(), DataDictionaryEnum.SIGN_SCORE.getCode()); |
| | | if (signScpreDic != null) { |
| | | scoreSign.setSetting(Integer.parseInt(signScpreDic.getValue())); |
| | | } |
| | | return scoreSign; |
| | | } |
| | | |
| | | @Override |
| | | public MallScoreSignRecord judgeScoreIsContinuity(MallScoreSignRecord mallScoreSignRecord) { |
| | | if (mallScoreSignRecord.getSignTime() == null) { |
| | | return mallScoreSignRecord; |
| | | } |
| | | |
| | | // 若最新签到日期,与当天相差大于一天,则更新数据库(避免定时器更新失败) |
| | | if (DateUtil.betweenDay(mallScoreSignRecord.getSignTime(), new Date(), true) > 1 || mallScoreSignRecord.getTotalCnt() == 7) { |
| | | mallScoreSignRecord.setTotalCnt(0); |
| | | mallScoreSignRecordMapper.updateById(mallScoreSignRecord); |
| | | } |
| | | return mallScoreSignRecord; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiMallScoreSignRecordVo> findMallScoreSignRecordList(ApiMallScoreSignRecordDto apiMallScoreSignRecordDto) { |
| | | |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | IPage<ApiMallScoreSignRecordVo> page = new Page<>(apiMallScoreSignRecordDto.getPageNum(), apiMallScoreSignRecordDto.getPageSize()); |
| | | apiMallScoreSignRecordDto.setMemberId(member.getId()); |
| | | IPage<ApiMallScoreSignRecordVo> apiMallScoreSignRecordVos = mallScoreSignRecordMapper.selectApiOrderListInPage(page, apiMallScoreSignRecordDto); |
| | | return apiMallScoreSignRecordVos.getRecords(); |
| | | } |
| | | |
| | | @Override |
| | | public ApiScoreVoucherInfoVo memberScoreVoucher() { |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | ApiScoreVoucherInfoVo apiScoreVoucherInfoVo = new ApiScoreVoucherInfoVo(); |
| | | |
| | | 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()); |
| | | apiScoreVoucherInfoVo.setScorePrice(new BigDecimal(scorePriceDic.getValue()).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | DataDictionaryCustom scorePoolCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | GreenScoreEnum.SCORE_POOL_CNT.getType(), |
| | | GreenScoreEnum.SCORE_POOL_CNT.getCode()); |
| | | apiScoreVoucherInfoVo.setScorePoolCnt(new BigDecimal(scorePoolCntDic.getValue()).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | |
| | | BigDecimal voucherCntSurplus = mallScoreRecordMapper.selectSurplusCntByMemberId(member.getId()); |
| | | apiScoreVoucherInfoVo.setVoucherCntSurplus(voucherCntSurplus); |
| | | return apiScoreVoucherInfoVo; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiScoreVoucherRecordVo> findMallScoreVoucherList(ApiScoreVoucherRecordDto apiScoreVoucherRecordDto) { |
| | | IPage<ApiScoreVoucherRecordVo> page = new Page<>(apiScoreVoucherRecordDto.getPageNum(), apiScoreVoucherRecordDto.getPageSize()); |
| | | IPage<ApiScoreVoucherRecordVo> apiScoreVoucherRecordVoIPage = mallScoreVoucherMapper.findMallScoreVoucherListInPage(page, apiScoreVoucherRecordDto); |
| | | return apiScoreVoucherRecordVoIPage.getRecords(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public FebsResponse voucherBusinessBuy(ApiVoucherBusinessDto apiVoucherBusinessDto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | BigDecimal voucherCnt = apiVoucherBusinessDto.getVoucherCnt(); |
| | | if(voucherCnt.compareTo(BigDecimal.ZERO) <= 0){ |
| | | throw new FebsException("请输入合理的数量"); |
| | | } |
| | | DataDictionaryCustom scorePoolCntDic = dataDictionaryCustomMapper.selectScorePoolCntForUpdate( |
| | | GreenScoreEnum.SCORE_POOL_CNT.getType(), |
| | | GreenScoreEnum.SCORE_POOL_CNT.getCode()); |
| | | BigDecimal scorePoolCnt = new BigDecimal(scorePoolCntDic.getValue() == null ? "0" : scorePoolCntDic.getValue()); |
| | | if(scorePoolCnt.compareTo(voucherCnt) < 0){ |
| | | throw new FebsException("可购买总量不足"); |
| | | } |
| | | String tradePassword = apiVoucherBusinessDto.getTradePassword(); |
| | | if (StrUtil.isBlank(tradePassword)) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | MallMember mallMember = mallMemberMapper.selectById(memberId); |
| | | if (StrUtil.isBlank(mallMember.getTradePassword())) { |
| | | throw new FebsException("未设置支付密码"); |
| | | } |
| | | |
| | | if (!SecureUtil.md5(tradePassword).equals(mallMember.getTradePassword())) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | DataDictionaryCustom scorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | GreenScoreEnum.SCORE_PRICE.getType(), |
| | | GreenScoreEnum.SCORE_PRICE.getCode()); |
| | | BigDecimal scorePrice = new BigDecimal(scorePriceDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal voucherAmount = voucherCnt.multiply(scorePrice); |
| | | |
| | | MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | BigDecimal balance = mallMemberWallet.getBalance(); |
| | | if(voucherAmount.compareTo(balance) > 0){ |
| | | throw new FebsException("余额不足"); |
| | | } |
| | | //减少余额 |
| | | memberWalletService.reduceBalance(voucherAmount,memberId); |
| | | //减少绿色积分池 |
| | | scorePoolCnt = scorePoolCnt.subtract(voucherCnt); |
| | | scorePoolCntDic.setValue(scorePoolCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(scorePoolCntDic); |
| | | //增加凭证数量 |
| | | // mallMemberWalletMapper.addVorCherCntByMemberId(voucherCnt,memberId); |
| | | //增加凭证燃烧值数量 |
| | | mallMemberWalletMapper.addVorCherFireCntByMemberId(voucherCnt,memberId); |
| | | //增加购买记录 |
| | | String voucherNo = MallUtils.getOrderNum("VB"); |
| | | MallScoreVoucher mallScoreVoucher = new MallScoreVoucher(); |
| | | mallScoreVoucher.setVoucherNo(voucherNo); |
| | | mallScoreVoucher.setMemberId(memberId); |
| | | mallScoreVoucher.setVoucherCnt(voucherCnt); |
| | | mallScoreVoucher.setPrice(scorePrice); |
| | | mallScoreVoucher.setVoucherAmount(voucherAmount); |
| | | mallScoreVoucher.setType("B"); |
| | | mallScoreVoucherMapper.insert(mallScoreVoucher); |
| | | |
| | | //产生一条流水记录 |
| | | mallMoneyFlowService.addMoneyFlow( |
| | | mallMemberWallet.getMemberId(), |
| | | voucherCnt, |
| | | MoneyFlowTypeEnum.VOUCHER_BUY.getValue(), |
| | | voucherNo, |
| | | FlowTypeEnum.VOUCHER_CNT.getValue()); |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public FebsResponse voucherBusinessSale(ApiVoucherBusinessDto apiVoucherBusinessDto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | BigDecimal voucherCnt = apiVoucherBusinessDto.getVoucherCnt(); |
| | | if(voucherCnt.compareTo(BigDecimal.ZERO) <= 0){ |
| | | throw new FebsException("请输入合理的数量"); |
| | | } |
| | | String tradePassword = apiVoucherBusinessDto.getTradePassword(); |
| | | if (StrUtil.isBlank(tradePassword)) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | MallMember mallMember = mallMemberMapper.selectById(memberId); |
| | | if (StrUtil.isBlank(mallMember.getTradePassword())) { |
| | | throw new FebsException("未设置支付密码"); |
| | | } |
| | | |
| | | if (!SecureUtil.md5(tradePassword).equals(mallMember.getTradePassword())) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | BigDecimal voucherCntMember = mallMemberWallet.getVoucherCnt(); |
| | | if(voucherCntMember.compareTo(voucherCnt) < 0){ |
| | | throw new FebsException("数量不足"); |
| | | } |
| | | |
| | | DataDictionaryCustom scorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | GreenScoreEnum.SCORE_PRICE.getType(), |
| | | GreenScoreEnum.SCORE_PRICE.getCode()); |
| | | BigDecimal scorePrice = new BigDecimal(scorePriceDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal voucherAmount = voucherCnt.multiply(scorePrice); |
| | | //减少凭证积分 |
| | | //增加凭证现金 |
| | | mallMemberWalletMapper.addVorCherAmountAndCntById(voucherAmount,voucherCnt,mallMemberWallet.getId()); |
| | | //增加积分池 |
| | | DataDictionaryCustom scorePoolCntDic = dataDictionaryCustomMapper.selectScorePoolCntForUpdate( |
| | | GreenScoreEnum.SCORE_POOL_CNT.getType(), |
| | | GreenScoreEnum.SCORE_POOL_CNT.getCode()); |
| | | BigDecimal scorePoolCnt = new BigDecimal(scorePoolCntDic.getValue() == null ? "0" : scorePoolCntDic.getValue()); |
| | | scorePoolCnt = scorePoolCnt.add(voucherCnt).setScale(2,BigDecimal.ROUND_DOWN); |
| | | scorePoolCntDic.setValue(scorePoolCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(scorePoolCntDic); |
| | | |
| | | //增加购买记录 |
| | | String voucherNo = MallUtils.getOrderNum("VS"); |
| | | MallScoreVoucher mallScoreVoucher = new MallScoreVoucher(); |
| | | mallScoreVoucher.setVoucherNo(voucherNo); |
| | | mallScoreVoucher.setMemberId(memberId); |
| | | mallScoreVoucher.setVoucherCnt(voucherCnt); |
| | | mallScoreVoucher.setPrice(scorePrice); |
| | | mallScoreVoucher.setVoucherAmount(voucherAmount); |
| | | mallScoreVoucher.setType("S"); |
| | | mallScoreVoucherMapper.insert(mallScoreVoucher); |
| | | |
| | | //产生一条流水记录 |
| | | mallMoneyFlowService.addMoneyFlow( |
| | | mallMemberWallet.getMemberId(), |
| | | voucherAmount, |
| | | MoneyFlowTypeEnum.VOUCHER_SALE.getValue(), |
| | | voucherNo, |
| | | FlowTypeEnum.BALANCE.getValue()); |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void withdrawal(WithdrawalDto withdrawalDto) { |
| | | |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember mallMember = mallMemberMapper.selectById(memberId); |
| | | if (StrUtil.isBlank(mallMember.getTradePassword())) { |
| | | throw new FebsException("未设置支付密码"); |
| | | } |
| | | |
| | | if (!mallMember.getTradePassword().equals(SecureUtil.md5(withdrawalDto.getTradePwd()))) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | CashOutSettingVo cashOutSettingVo = new CashOutSettingVo(); |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.CASHOUT_SETTING.getType(), DataDictionaryEnum.CASHOUT_SETTING.getCode()); |
| | | if (dic != null) { |
| | | cashOutSettingVo = JSONObject.parseObject(dic.getValue(), CashOutSettingVo.class); |
| | | } |
| | | |
| | | if (withdrawalDto.getAmount().compareTo(cashOutSettingVo.getMinCashOut()) < 0) { |
| | | throw new FebsException("最小提现金额为"+cashOutSettingVo.getMinCashOut().setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | |
| | | MallMemberBank mallMemberBank = mallMemberBankMapper.selectById(withdrawalDto.getBankId()); |
| | | if(ObjectUtil.isEmpty(mallMemberBank)){ |
| | | throw new FebsException("未找到银行卡信息"); |
| | | } |
| | | |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | // 可提现 |
| | | BigDecimal canMoney = wallet.getVoucherAmount(); |
| | | |
| | | if(withdrawalDto.getAmount().compareTo(canMoney) > 0) { |
| | | throw new FebsException("金额不足"); |
| | | } |
| | | |
| | | walletService.reduce(withdrawalDto.getAmount(), memberId, "voucherAmount"); |
| | | String orderNo = MallUtils.getOrderNum("W"); |
| | | |
| | | MallMemberWithdraw withdraw = new MallMemberWithdraw(); |
| | | withdraw.setWithdrawNo(orderNo); |
| | | withdraw.setMemberId(memberId); |
| | | withdraw.setAmount(withdrawalDto.getAmount()); |
| | | withdraw.setStatus(1); |
| | | withdraw.setAmountFee(BigDecimal.ZERO); |
| | | withdraw.setRemark(AppContants.MEMBER_WITHDRAW_VOUCHER_AMOUNT); |
| | | withdraw.setWtihdrawTypeId(mallMemberBank.getId()); |
| | | mallMemberWithdrawMapper.insert(withdraw); |
| | | |
| | | mallMemberService.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.VOUCHER_AMOUNT.getValue()); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse findMallScoreVoucherListInPage(ApiScoreVoucherRecordDto apiScoreVoucherRecordDto) { |
| | | IPage<ApiScoreVoucherRecordVo> page = new Page<>(apiScoreVoucherRecordDto.getPageNum(), apiScoreVoucherRecordDto.getPageSize()); |
| | | Long id = LoginUserUtil.getLoginUser().getId(); |
| | | apiScoreVoucherRecordDto.setMemberId(id); |
| | | IPage<ApiScoreVoucherRecordVo> pages = mallScoreVoucherMapper.findMallScoreVoucherListInPage(page, apiScoreVoucherRecordDto); |
| | | return new FebsResponse().success().data(pages); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public void sign() { |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SCORE_SIGN_SETTING.getType(), DataDictionaryEnum.SCORE_SIGN_SETTING.getCode()); |
| | | if (dic == null) { |
| | | throw new FebsException("暂未设置积分"); |
| | | DataDictionaryCustom signScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.SIGN_SCORE.getType(), |
| | | DataDictionaryEnum.SIGN_SCORE.getCode()); |
| | | if (signScoreDic == null) { |
| | | throw new FebsException("签到活动未开启"); |
| | | } |
| | | Integer signScore = Integer.parseInt(signScoreDic.getValue()); |
| | | |
| | | MallScoreSignRecord mallScoreSignRecord = mallScoreSignRecordMapper.selectRecentSignRecord(member.getId()); |
| | | if (mallScoreSignRecord == null) { |
| | | mallScoreSignRecord = new MallScoreSignRecord(); |
| | | } |
| | | |
| | | String format = DateUtil.format(mallScoreSignRecord.getSignTime(), "yyyy-MM-dd"); |
| | | if (mallScoreSignRecord.getSignTime() != null && DateUtil.between(DateUtil.parse(format, "yyyy-MM-dd"), new Date(), DateUnit.DAY) == 0) { |
| | | throw new FebsException("今天已签到"); |
| | | if (mallScoreSignRecord.getSignTime() != null && DateUtil.betweenDay(mallScoreSignRecord.getSignTime(), new Date(), true) == 0) { |
| | | 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()); |
| | | |
| | | 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; |
| | | MallMember mallMember = mallMemberMapper.selectById(member.getId()); |
| | | Date createdTime = mallMember.getCreatedTime(); |
| | | |
| | | 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; |
| | | } |
| | | |
| | | mallScoreSignRecord.setMemberId(member.getId()); |
| | | mallScoreSignRecord.setTotalCnt(days); |
| | | mallScoreSignRecord.setTotalCnt(signScore); |
| | | 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()); |
| | | } |
| | | } |