xiaoyong931011
2023-08-31 c70e92bedb031f28648a0d6e358ac7a1ecdfefea
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
@@ -592,4 +592,23 @@
        mallMemberBankMapper.deleteById(id);
        return new FebsResponse().success();
    }
    @Override
    public FebsResponse redBag() {
        MallMember member = LoginUserUtil.getLoginUser();
        List<MallMoneyFlow> mallMoneyFlows = mallMoneyFlowMapper.selectByMemberIdAndTypeAndStatusAndDate(member.getId(), MoneyFlowTypeEnum.SCORE_POOL.getValue(), 1, new Date());
        if(CollUtil.isEmpty(mallMoneyFlows)){
            throw new FebsException("没有红包");
        }
        BigDecimal amount = BigDecimal.ZERO;
        for(MallMoneyFlow mallMoneyFlow : mallMoneyFlows){
            mallMoneyFlow.setStatus(2);
            mallMoneyFlowMapper.updateById(mallMoneyFlow);
            amount = mallMoneyFlow.getAmount().abs();
        }
        walletService.add(amount, member.getId(), "commission");
        walletService.reduce(amount.negate(), member.getId(), "score");
        return new FebsResponse().success().message("领取成功");
    }
}