Helius
2022-08-17 94e644443a660b39521f08805b66c27ced736e40
src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallOrderService.java
@@ -4,6 +4,7 @@
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.enumerates.FlowTypeEnum;
import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum;
import cc.mrbird.febs.common.utils.RedisUtils;
import cc.mrbird.febs.mall.dto.*;
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.*;
@@ -42,6 +43,8 @@
    private final MallOrderRefundOperationMapper mallOrderRefundOperationMapper;
    private final MallOrderRefundAddressMapper mallOrderRefundAddressMapper;
    private final MallGoodsCommentMapper mallGoodsCommentMapper;
    private final MallMoneyFlowMapper mallMoneyFlowMapper;
@@ -160,6 +163,19 @@
            iApiMallMemberWalletService.addBalance(amount, mallOrderInfo.getMemberId());
            mallMoneyFlowService.addMoneyFlow(mallOrderRefund.getMemberId(), amount, MoneyFlowTypeEnum.REFUND.getValue(), mallOrderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue());
            //积分池减少对应的数值
            String redisKey = "scorePool";
            String scorePoolRedis = redisUtils.getString(redisKey);
            if(StrUtil.isBlank(scorePoolRedis)){
                redisUtils.set(redisKey,0,0L);
            }
            BigDecimal scorePoolOld = new BigDecimal(redisUtils.getString(redisKey));
            if(scorePoolOld.compareTo(amount) < 0){
                redisUtils.set(redisKey,0,0L);
            }else{
                redisUtils.set(redisKey,scorePoolOld.subtract(amount).intValue(),0L);
            }
        }
        MallOrderRefundOperation mallOrderRefundOperation = new MallOrderRefundOperation();
@@ -197,6 +213,7 @@
        return new FebsResponse().success();
    }
    private final RedisUtils redisUtils;
    @Override
    public FebsResponse refundConfirm(Long id) {
        MallOrderRefund mallOrderRefund = mallOrderRefundMapper.selectById(id);
@@ -226,6 +243,18 @@
        BigDecimal refundAmount = mallOrderRefund.getAmount();
        //用户钱包增加对应的余额
        iApiMallMemberWalletService.addBalance(refundAmount, mallOrderInfo.getMemberId());
        //积分池减少对应的数值
        String redisKey = "scorePool";
        String scorePoolRedis = redisUtils.getString(redisKey);
        if(StrUtil.isBlank(scorePoolRedis)){
            redisUtils.set(redisKey,0,0L);
        }
        BigDecimal scorePoolOld = new BigDecimal(redisUtils.getString(redisKey));
        if(scorePoolOld.compareTo(refundAmount) < 0){
            redisUtils.set(redisKey,0,0L);
        }else{
            redisUtils.set(redisKey,scorePoolOld.subtract(refundAmount).intValue(),0L);
        }
        //新增一条资金流水
        mallMoneyFlowService.addMoneyFlow(mallOrderRefund.getMemberId(), refundAmount, MoneyFlowTypeEnum.REFUND.getValue(), mallOrderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue());
@@ -363,6 +392,35 @@
    }
    @Override
    public IPage<AdminMallGoodsCommentVo> getCommentListInPage(AdminMallGoodsCommentDto adminMallGoodsCommentDto, QueryRequest request) {
        Page<AdminMallGoodsCommentVo> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<AdminMallGoodsCommentVo> adminMallGoodsCommentVos = mallGoodsCommentMapper.getCommentListInPage(page, adminMallGoodsCommentDto);
        return adminMallGoodsCommentVos;
    }
    @Override
    public FebsResponse showStateSwitchOn(Long id) {
        MallGoodsComment mallGoodsComment = mallGoodsCommentMapper.selectById(id);
        if (ObjectUtil.isEmpty(mallGoodsComment)) {
            return new FebsResponse().fail().message("评论不存在,请刷新当前页面");
        }
        mallGoodsComment.setShowState(MallGoodsComment.SHOW_STATE_ENABLE);
        mallGoodsCommentMapper.updateById(mallGoodsComment);
        return new FebsResponse().success();
    }
    @Override
    public FebsResponse showStateSwitchOff(Long id) {
        MallGoodsComment mallGoodsComment = mallGoodsCommentMapper.selectById(id);
        if (ObjectUtil.isEmpty(mallGoodsComment)) {
            return new FebsResponse().fail().message("评论不存在,请刷新当前页面");
        }
        mallGoodsComment.setShowState(MallGoodsComment.SHOW_STATE_DISABLED);
        mallGoodsCommentMapper.updateById(mallGoodsComment);
        return new FebsResponse().success();
    }
    @Override
    public void deliverGoodsByOrderNo(DeliverGoodsDto deliverGoodsDto) {
        MallOrderInfo mallOrderInfo = mallOrderInfoMapper.selectByOrderNo(deliverGoodsDto.getOrderNo());
        if (mallOrderInfo == null) {